Ejemplo n.º 1
0
    private IEnumerator Respawn(Herbivore player)
    {
        player.EnablePlayer(false);
        // - Change camera to fixed camera
        yield return(new WaitForSeconds(deathPenaltyTime));

        Carnivore carnivore = GameObject.FindObjectOfType <Carnivore>();

        player.transform.GetComponent <NetworkPlayerCaveFog>().useFog = false;

        if (carnivore)  //  If carnivore in game
        {
            Vector3 carnivoreLocation = carnivore.transform.position;

            distanceList.Clear();

            foreach (Transform startPos in NetworkGameManager.Instance.herbivoreStartPoints)    //  Check starting positions if  is empty
            {
                if (startPos.GetComponent <StartPositionCheck>().isEmpty == true)
                {
                    //  Debugging Distances >>     float dist = Vector3.Distance(startPos.position, carnivore.transform.position); Debug.Log("" + startPos.transform.name + " - matka: " + dist);
                    distanceList.Add(startPos);
                }
            }

            distanceList.Sort(delegate(Transform c, Transform s)    //  Sort list by: smallest distance >>  biggest distance. Between starting positions and carnivore
            {
                return(Vector3.Distance(carnivore.transform.position, c.transform.position).CompareTo((Vector3.Distance(carnivore.transform.position, s.transform.position))));
            }
                              );

            player.transform.position = distanceList.ElementAt(distanceList.Count - 1).position;    //  Last in list is most far from carnivore and is herbivores starting position.
            //  Debugging Herbivore Starting Position >>    Debug.Log("Herbivore started at: " + distanceList.ElementAt(distanceList.Count - 1));
        }
        else  //  If NOT carnivore in game then random spawn
        {
            //  Debugging   If Not Carnivore >>     Debug.Lornivore not found.");
            player.transform.position = NetworkGameManager.Instance.herbivoreStartPoints[Random.Range(0, NetworkGameManager.Instance.herbivoreStartPoints.Count)].position;
        }

        // - Reset values
        player.Experience -= experiencePenalty;
        player.EnablePlayer(true);
        player.gameObject.SetActive(true);
        yield return(null);
    }
Ejemplo n.º 2
0
 public void EndMatchForPlayer(Herbivore player)
 {
     herbivoresWon += 1;
     player.EnablePlayer(false);
     player.EnablePlayerCamera(false);
     if (herbivoresWon == NetworkGameManager.Instance.InGamePlayerList.Count - 1)
     {
         EndMatch();
     }
 }
Ejemplo n.º 3
0
 public void KillPlayer(Herbivore player)
 {
     player.EnablePlayer(false);
     player.EnablePlayerCamera(false);
 }