Beispiel #1
0
    public void SetOwner(int newPlayerNumber, PlayerController newPlayerController)
    {
        if (Owner.PlayerController != null)
        {
            if (Owner.PlayerController.Planets.Contains(this))
            {
                Owner.PlayerController.Planets.Remove(this);
            }
        }

        Owner.PlayerNumber     = newPlayerNumber;
        Owner.PlayerController = newPlayerController;

        Owner.PlayerController.Planets.Add(this);
//		Debug.Log("bases count of player " + owner.playerNumber + " is " + owner.playerController.bases.Count);

        if (Health.Percent < 1)
        {
            Reset();
        }

        if (AssignedHpBarSlider != null)
        {
            Destroy(AssignedHpBarSlider.gameObject);
        }
        // if player is new owner
        if (Owner.PlayerNumber != -1)
        {
            //AddUIHPBar();
            Spawner.StartSpawn(Trans.position);
        }
        // else it's neutral
        else
        {
            Spawner.StopSpawn();
            Spawner.StopAllCoroutines();
        }
        Spawner.AddBonusInitial();
        Spawner.UpdateLabel();
        AssignMaterial();
    }