protected Vector3 GetRandomTargetCloseToPc(PCBehavior pc) { if (pc == null) { Debug.Log(AIcontext.Get <Team>("SelfTeam")); } Vector2 randV2 = UnityEngine.Random.insideUnitCircle * pc.PCRange; // just another security check if (AIcontext.Get <NavMeshAgent>("agent").isOnNavMesh) { AIcontext.Set <PCBehavior>("PcTarget", pc); if (pc == null) { return(AIcontext.Get <Transform>("self").position + new Vector3(randV2.x, 1f, randV2.y)); } else { // We set target to some place around the pc (but still inside) return(pc.transform.position + new Vector3(randV2.x, 1f, randV2.y)); } } return(pc.trans.position); }
public void DispatchPlayer(PCBehavior pc) { IsAlive = true; gd.Set <bool>("Alive", true); SetupSpawnPosition(pc); ResetOwnStat(); }
// Get the closest which is not from this team public PCBehavior GetClosestNextPC(Vector3 pos, Team team) { PCBehavior behavior = GetClosestPC(pos, team); PCBehavior[] availablePC = PCs.Where(x => x.ControlledBy != team).ToArray(); if (availablePC.Length == 0) { return(null); } return(availablePC[Random.Range(0, availablePC.Length)]); }
/// <summary> /// This function respawn a single player after it died and waited /// for a certain amount of time. /// </summary> /// <param name="player">The player we have to respawn.</param> public void ReassingSinglePlayer(PlayerAI player) { PCBehavior spawnPC = PCManager.Instance.GetRandomPC(player.selfTeam); // if no other pc are available if (spawnPC == null) { return; } player.gameObject.SetActive(true); //player.SetNewPosition(PCManager.Instance.GetRandomPC(player.selfTeam).trans.position); player.DispatchPlayer(spawnPC); //tickets[(int)player.selfTeam] -= 1; Teams[(int)player.selfTeam].Add(player); DeadPlayers.Remove(DeadPlayers.Where(x => x.player == player).First()); //TeamsDeads[(int)player.selfTeam].Remove(player); }
public void NotifyPCChanged(PCBehavior behavior) { //Spawner.Instance.NotifyPcCaptured(behavior); }
void SetupSpawnPosition(PCBehavior pc) { Vector2 randV2 = Random.insideUnitCircle * pc.PCRange; SetNewPosition(pc.trans.position + new Vector3(randV2.x, 1f, randV2.y)); }