Esempio n. 1
0
 public void StartEndGame(PlayerSpaceshipController survivor, List <PlayerInDiscController> inDiscControllers, Vector3 endGameSpawnpoint)
 {
     _survivor          = survivor;
     _inDiscControllers = inDiscControllers;
     _endGameSpawnpoint = endGameSpawnpoint;
     StartCoroutine(_endGameStartAnimation);
 }
Esempio n. 2
0
    // Use this for initialization
    void Awake()
    {
        firePoint = gameObject.transform.Find("Firepoint");
        rand      = new System.Random();

        // to ensure ammunition flies faster than players
        PlayerSpaceshipController shipController = GetComponent <PlayerSpaceshipController>();

        if (shipController != null)
        {
            //Speed += shipController.AccelerationForce;
            playerId = shipController.PlayerId;
        }

        if (firePoint == null)
        {
            Debug.LogError("Firepoint was null. Is child missing or named wrong?");
        }


        ProjectileLogic projectileLogic = null;

        foreach (GameObject ammuType in Ammunition)
        {
            projectileLogic = ammuType.GetComponent <ProjectileLogic>();

            if (projectileLogic == null)
            {
                Debug.LogError("Ammunition \"" + ammuType.name + "\" does not have ProjectileLogic component.");
            }
        }
    }
Esempio n. 3
0
    public void PlayerDeath(PlayerSpaceshipController player)
    {
        if (!_isEndGame)
        {
            alivePlayers.Remove(player);
            Debug.Log($"[PlayerManager] Player died: {player.PlayerId}");
            deadPlayers.Add(SpawnPlayerInDisc(player.PlayerId, player.color));

            if (alivePlayers.Count == 1)
            {
                EndGameManager.StartEndGame(alivePlayers.SingleOrDefault(), deadPlayers, spawnpoints[4]);
                _isEndGame = true;
            }
        }
        else
        {
            EndGameManager.DiscWin();
        }
    }
    IEnumerator HealthPenalty()
    {
        while (true)
        {
            float playTotalHP = 0;
            for (int k = 0; k < maxPlayers; k++)
            {
                if (gameplayerControllers[k] != null)
                {
                    PlayerController pc = (PlayerController)gameplayerControllers[k];
                    float hp = pc.GetComponent<PlayerInfo>().getHealth();
                    playTotalHP += (hp / pc.GetComponent<PlayerInfo>().max_health)*10;
                    if (hp == 0)
                    {
                        int pernalty = (int)(pc.score * ScoreParameter.Personal_Health_Penalty_Persent);
                        pc.score -= pernalty;
                    }
                }
                //else if (disconnectedPlayerControllers[k] != null)
                //{

                //}
            }
            //Debug.Log("playTotalHP "+playTotalHP);
            if (cizitenshipHealth <= 0)
            {
                citizenshipZeroTime++;
            }
            if (spaceshipCon != null)
            {

                spaceshipCon.SetCitizenShipDamage(cizitenshipHealth);
                spaceshipCon.SetPlayerSpaceshipDamage(playTotalHP);
            }
            else
            {
                GameObject goo = GameObject.Find("playerSpaceshipWithEffect(Clone)");
                if(goo != null)
                    spaceshipCon = goo.GetComponent<PlayerSpaceshipController>();
            }
            yield return new WaitForSeconds(1);
        }
    }