private void ResetAllObject() { PlayerListController.RemoveAllChild(); // destroy all attackers GameObject attackers = GameObject.Find("BattleMode/Attackers"); attackers.GetComponent <PlayerListController>().resetAttackerCount(); Debug.Log(attackers.transform.childCount); for (int i = 0; i < attackers.transform.childCount; i++) { GameObject attacker = GameObject.Find("BattleMode/Attackers/AttackerWrapper_" + (i + 1)); if (attacker != null) { Destroy(attacker); } } // Destroy all defenders GameObject defenders = GameObject.Find("BattleMode/Defenders"); defenders.GetComponent <DefenderListController>().resetDefenderCount(); Debug.Log(defenders.transform.childCount); for (int i = 0; i < defenders.transform.childCount; i++) { GameObject defender = GameObject.Find("BattleMode/Defenders/DefenderWrapper_" + (i + 1)); if (defender != null) { Destroy(defender); } } }
// Use this for initialization void Start() { if (PLC == null) { PLC = this; } _photonView = PhotonView.Get(this); }
private void OnTriggerEnter(Collider other) { if (other.gameObject.CompareTag("Ball")) { if (status == FIND_THE_BALL) { Debug.Log("Ball was catched"); status = FOUND_THE_BALL; //other.gameObject.transform.parent.SetParent(transform.parent); //other.gameObject.GetComponent<BallController>().IsCatched(); if (!GameController.isRushTime) { speed = CARRYING_SPEED * Time.fixedDeltaTime; } else { speed = ATTACKER_SPEED * Time.fixedDeltaTime; } //other.gameObject.SetActive(false); GameController.ballInstance.IsCatched(); GameController.s_attackerParticle.gameObject.SetActive(true); // GetComponentInParent<PlayerList>(); } } else if (other.gameObject.CompareTag("DefenderRange")) { //defender found attackter if (isAttacker && status == FOUND_THE_BALL) { PlayerController defender = other.gameObject.transform.parent.GetComponentInParent <PlayerController>(); if (defender.status != INACTIVATED) { defender.target = this.gameObject; defender.status = FOUND_ACTTACKER; Debug.Log("Found Attacker"); } } } else if (other.gameObject.CompareTag("Goal") && status == FOUND_THE_BALL) { if (transform.parent.position.z > 0) { GameController.activeGoalText("YOU WIN"); } else { GameController.activeGoalText("YOU LOSE"); } GameController.s_attackerParticle.gameObject.SetActive(false); GameController.ballInstance.ResetPos(); Destroy(this.gameObject); } if (other.gameObject.CompareTag("Attacker") && !isAttacker && status == FOUND_ACTTACKER) { PlayerController attacker = other.gameObject.GetComponentInChildren <PlayerController>(); if (attacker.status == FOUND_THE_BALL) { GetComponent <Animator>().SetBool("isCollision", true); attacker.gameObject.GetComponent <Animator>().SetBool("isCollision", true); Debug.Log("Col with attacker"); status = INACTIVATED; attacker.status = INACTIVATED; attacker.deactivedTime = ATTACKER_REACTIVE_TIME; attacker.inactivedTime = Time.realtimeSinceStartup; PlayerListController playerList = attacker.GetComponentInParent <PlayerListController>(); GameController.ballInstance.setNextAttackerToMove(playerList.findNextAttacker(this.transform.parent.position)); deactivedTime = DEFENDER_REACTIVE_TIME; inactivedTime = Time.realtimeSinceStartup; } // speed = RETURN_SPEED*Time.deltaTime; } else if (other.gameObject.CompareTag("TopWall") || other.gameObject.CompareTag("BottomWall")) { //destroy attackers/defender Destroy(this.gameObject); } }