// Start is called before the first frame update void Start() { foreach (GameObject obj in GameObject.FindGameObjectsWithTag("Player")) { players.Add(obj.gameObject); } foreach (GameObject obj in GameObject.FindGameObjectsWithTag("Enemy")) { enemies.Add(obj.gameObject); } //Always start from Blue Team if (isServer) { blueTeamBtn.gameObject.SetActive(true); blueCDPanel.gameObject.SetActive(false); blueTeamBtn.onClick.AddListener(BlueTeamReset); } else { redTeamBtn.gameObject.SetActive(true); redCDPanel.gameObject.SetActive(false); redTeamBtn.onClick.AddListener(RedTeamReset); } turnCounter = FindObjectOfType <TurnCounter>().GetComponent <TurnCounter>(); turnMenu = FindObjectOfType <TurnMenu>().GetComponent <TurnMenu>(); }
// Start is called before the first frame update void Start() { Init(); willMove = false; tM = GetComponent <TurnMenu>(); range = tM.move; willMove = tM.willMove; }
// Start is called before the first frame update void Start() { try { turnMenu = FindObjectOfType <TurnMenu>().GetComponent <TurnMenu>(); turnCounter = FindObjectOfType <TurnCounter>().GetComponent <TurnCounter>(); ballSpeed = FindObjectOfType <SoccerSpeedControl>().GetComponent <SoccerSpeedControl>(); } catch (Exception e) { //Avoid crash } }
protected void Init() { tiles = GameObject.FindGameObjectsWithTag("Tile"); halfHeight = GetComponent <Collider>().bounds.extents.y; TurnManager.AddUnit(this); if (gameObject.CompareTag("Player")) { tM = GetComponent <TurnMenu>(); move = tM.move; } else { move = 3; } }
private void Update() { if (turnCounter == null || turnMenu == null || ballSpeed == null) { try { turnCounter = FindObjectOfType <TurnCounter>().GetComponent <TurnCounter>(); turnMenu = FindObjectOfType <TurnMenu>().GetComponent <TurnMenu>(); ballSpeed = FindObjectOfType <SoccerSpeedControl>().GetComponent <SoccerSpeedControl>(); } catch (Exception e) { //Debug. } } if (turnCounter != null) { if (turnCounter.Shot == true) { updates(); } } }
public void Awake() { instance = this; }
// Update is called once per frame void Update() { if (players.Count == 0 || enemies.Count == 0) { if (players.Count == 0) { foreach (GameObject obj in GameObject.FindGameObjectsWithTag("Player")) { players.Add(obj.gameObject); } } else { foreach (GameObject obj in GameObject.FindGameObjectsWithTag("Enemy")) { enemies.Add(obj.gameObject); } } } else if (turnCounter == null) { turnCounter = FindObjectOfType <TurnCounter>().GetComponent <TurnCounter>(); } else if (turnMenu == null) { turnMenu = FindObjectOfType <TurnMenu>().GetComponent <TurnMenu>(); } //CD conditions //For Client-Side if (!isServer) { if (redCD > 0) { redCDPanel.gameObject.SetActive(true); redTeamBtn.interactable = false; redCDText.text = redCD.ToString(); redCDText.gameObject.SetActive(true); } else if (redCD == 0) { redCDPanel.gameObject.SetActive(false); redTeamBtn.interactable = true; } } //For Server-Side else { if (blueCD > 0) { blueCDPanel.gameObject.SetActive(true); blueTeamBtn.interactable = false; blueCDText.text = blueCD.ToString(); blueCDText.gameObject.SetActive(true); } else if (blueCD == 0) { blueCDPanel.gameObject.SetActive(false); blueTeamBtn.interactable = true; } } }