using System.Collections; using System.Collections.Generic; using UnityEngine; public class CharacterMovement : MonoBehaviour { public float Speed; GameObject localPlayer; public List Players = new List(); public List Nearby = new List(); public float DistanceToWin; Camera cam; private void Start() { localPlayer = Multiplayer.PlayersManager.Instance.LocalPlayer; Players.Add(localPlayer); foreach (GameObject curPlayer in Multiplayer.PlayersManager.Instance.RemotePlayers.Values) { Players.Add(curPlayer); } cam = localPlayer.GetComponentInChildren(); } //Public movement functions :) private void Update() { if (Input.GetMouseButton(0)) { Vector3 mousePos = new Vector3(Input.mousePosition.x, 0.0f, Input.mousePosition.y); Vector3 screenCentre = new Vector3(Screen.width / 2, 0.0F, Screen.height / 2); Vector3 movePos = mousePos - screenCentre; movePos.x = movePos.x / Screen.width; movePos.z = movePos.z / Screen.height; localPlayer.GetComponent().Move(movePos * Speed * Time.deltaTime); Debug.Log("Movepos" + movePos + " speed " + Speed); } } public bool CheckNearby() { for (int i = 0; i < Players.Count; i++) { if ((localPlayer.transform.position - Players[i].transform.position).magnitude < DistanceToWin) { Greet(); } else { Player playerScript = Players[i].GetComponent(); foreach (GameObject dummy in playerScript.dummies) { if ((localPlayer.transform.position - dummy.transform.position).magnitude < DistanceToWin) { Greet(); } } } } return CheckWin(); } bool CheckWin() { for (int i = 0; i < Nearby.Count; i++) { if (Nearby[i] == false) { return false; } } return true; } public void Greet() { //Play audio //Trigger animation } }