private void ResawnHelper(CountdownTimer t) { // Find the dead player again Controller deadPlayer = controllers.Find(x => x.ID.Equals(System.Enum.Parse(typeof(PlayerID), t.ID))); //RespawnNode playerNode = respawnNodes.Find(x => x.ID.Equals(System.Enum.Parse(typeof(PlayerID), t.ID))); RespawnNode playerNode = respawnNodes[Random.Range(0, respawnNodes.Count)]; if (deadPlayer != null) { deadPlayer.transform.position = playerNode.transform.position; // Let the player revive itself if (currentGame.GetType().Equals(typeof(MeleeMinigame))) { deadPlayer.LifeComponent.Respawn(false); } else if (currentGame.GetType().Equals(typeof(CaymanGame))) { deadPlayer.LifeComponent.Respawn(false); } else { deadPlayer.LifeComponent.Respawn(); } } }
public void StartGame() { if (currentGame) { currentGame.ForceEnd(); } inGame = true; gameWon = false; playerScores = new int[4]; transitionStarted = false; scoreAdded = false; respawnNodes = new List <RespawnNode>(); goblets = new List <Goblet>(); gamesQueue = new List <Minigame>(); RespawnNode[] findNodes = FindObjectsOfType <RespawnNode>(); for (int i = 0; i < findNodes.Length; i++) { respawnNodes.Add(findNodes[i]); } Goblet[] findGoblets = FindObjectsOfType <Goblet>(); for (int i = 0; i < findGoblets.Length; i++) { goblets.Add(findGoblets[i]); } dialogHolder = GameObject.Find("DialogHolder"); field = GameObject.Find("Field"); RefillGames(); currentGame = gamesQueue[0]; gamesQueue.RemoveAt(0); for (int i = 0; i < controllers.Count; i++) { controllers[i].Enable(); RespawnNode playerNode = respawnNodes.Find(x => x.ID.Equals(controllers[i].ID)); controllers[i].transform.position = playerNode.transform.position; controllers[i].SetInitAttributes(); controllers[i].RespawnAt(playerNode.transform.position); } currentGame.Init(); veryFirstTimer = 4f; Camera.main.GetComponent <Animator>().SetTrigger("GodDemands"); dialogHolder.GetComponent <SpriteRenderer>().sprite = currentGame.instructions; winningCharacterSprite = GameObject.Find("WinningCharacterSprite"); winText = GameObject.Find("WinText"); }
void Enabled() { if (networkView.isMine) { mc = GetComponent <MotionControl>(); inv = GetComponent <Inventory>(); //melee = GetComponent<MeleeAttack>(); bomb = GetComponent <Bomb>(); health = GetComponent <Health>(); current = GameObject.Find(FirstNavNode).GetComponent <RespawnNode>(); current = current.nextNodes[0]; Debug.Log("AI Current Target: " + current.name); StartCoroutine(AITick()); } }
public void ResetGame() { Camera.main.GetComponent <Animator>().SetTrigger("RestartGame"); for (int i = 0; i < 4; i++) { playerScores[i] = 0; } foreach (PlayerID id in characterToPlayer.Values) { Enums.Characters c = characterToPlayer.FirstOrDefault(x => x.Value == id).Key; Goblet g = goblets.Find(x => x.character.Equals(c)); g.UpdateScale(Mathf.Clamp01(((float)playerScores[((int)id) - 1]) / (float)MAX_SCORE)); } inGame = true; for (int i = 0; i < controllers.Count; i++) { controllers[i].Enable(); RespawnNode playerNode = respawnNodes.Find(x => x.ID.Equals(controllers[i].ID)); controllers[i].transform.position = playerNode.transform.position; } }
IEnumerator AITick() { while (true) { if (Vector3.Distance(transform.position, current.transform.position) < TriggerRadius) { current = current.nextNodes[Random.Range(0, current.nextNodes.Count)]; } //Debug.Log("AI Current Target: " + current.name); if (inv.Count(PickUpTypes.Weapon) > 1) { // Use bomb if (this.name == "Hesp(Clone)") { HespBomb(); } if (this.name == "Diloph(Clone)") { DilophBomb(); } if (this.name == "TRex(Clone)") { TRexBomb(); } if (this.name == "Spino(Clone)") { SpinoBomb(); } if (this.name == "Troodon(Clone)") { TroodonBomb(); } } if (inv.Count(PickUpTypes.Weapon) > 0) { // Use melee if (this.name == "Hesp(Clone)") { HespMelee(); } if (this.name == "Diloph(Clone)") { DilophMelee(); } if (this.name == "TRex(Clone)") { TRexMelee(); } if (this.name == "Spino(Clone)") { SpinoMelee(); } if (this.name == "Troodon(Clone)") { TroodonMelee(); } } if (health.Current <= 30.0f && inv.Count(PickUpTypes.Health) > 0) { inv.UsePickUp(PickUpTypes.Health); } if (inv.Count(PickUpTypes.Turbo) > 0) { inv.UsePickUp(PickUpTypes.Turbo); } yield return(new WaitForSeconds(NavTick)); } }