Exemple #1
0
    private GameObject InitializePlayer()
    {
        GameObject spawnPoint = spawnManager.PickRandomRespawn();
        GameObject aPlayer    = Instantiate(playerPrefab, spawnPoint.transform.position, Quaternion.identity) as GameObject;

        LocalPlayerController player = aPlayer.GetComponent <LocalPlayerController>();

        player.pIndex      = playerIndex;
        player.playerIndex = (int)playerIndex;

        GameData.players[player.playerIndex] = player;

        Vibration.VibrateForSeconds(0.3f, 0.5f, playerIndex);
        spawnManager.createParticleSystem(aPlayer);

        return(aPlayer);
    }
    private void SpawnPlayer(int playerIndex, Teams team, Transform spawnPoint)
    {
        GameObject player = null;

        switch (team)
        {
        case Teams.Blue:
            player = Instantiate(bluePlayer, spawnPoint.position, spawnPoint.rotation);
            break;

        case Teams.Red:
            player = Instantiate(redPlayer, spawnPoint.position, spawnPoint.rotation);
            break;
        }

        player.GetComponent <VehicleControls>().Initialize(playerIndex, team);

        Vibration.VibrateForSeconds(0.5f, 0.5f, playerIndex);
    }
Exemple #3
0
    public void Damage(float amount)
    {
        if (invulnerable)
        {
            return;
        }

        currentHealth -= amount;

        if (amount > maxHealth)
        {
            amount = maxHealth;
        }

        if (vibrateController)
        {
            Vibration.VibrateForSeconds(vibrationTime, amount / maxHealth * maxVibrateAmount, playerIndex);
        }

        CheckIfDead();

        UpdateHealthbar(currentHealth);
    }