Exemple #1
0
 private void CmdVehicleOptions(bool spaceKey, bool eKey)
 {
     if (spaceKey)
     {
         currentVehicle.CmdSwitchPlace(gameObject);
     }
     if (eKey)
     {
         currentVehicle.CmdQuitVehicle(gameObject);
     }
 }
Exemple #2
0
    public void TakeDamage(int amount, GameObject attacker)
    {
        if (!isServer)
        {
            return;
        }
        else
        {
            currentHealth -= amount;
            //if you died
            if (currentHealth <= 0)
            {
                if (destroyOnDeath)//You are a enemy
                {
                    if (attacker != null)
                    {
                        //if a player kill an enemy
                        HealthController playerController = attacker.GetComponent <HealthController>();
                        if (playerController != null)
                        {
                            playerController.Score += 10;
                        }
                    }
                    Destroy(gameObject);
                }
                else//You are a player
                {
                    player.CmdThrowItems();
                    // If the player was in the vehicle
                    if (player.State == PlayerStates.InVehicleDriving || player.State == PlayerStates.InVehicleTurret)
                    {
                        VehicleController vehicleController = player.CurrentVehicle;
                        vehicleController.CmdQuitVehicle(player.gameObject);
                    }

                    currentHealth = maxHealth;
                    //
                    RpcRespawn();

                    //if a player kill another player
                    if (attacker != null)
                    {
                        HealthController playerController = attacker.GetComponent <HealthController>();
                        if (playerController != null)
                        {
                            playerController.Score += 100;
                        }
                    }
                }
            }
        }
    }