Esempio n. 1
0
    public int TryDestroyHazard(PlayerID player)
    {
        if (player == hazardOwner)
        {
            return(-1);
        }

        bool generatePowerUp = UnityEngine.Random.Range(0f, 1f) > 0.95f;
        int  powerUp         = UnityEngine.Random.Range(0, powerUps.Count);

        if (DataUtility.gameData.isNetworkedGame)
        {
            PunTools.PhotonRPC(view, "RPC_TryDestroyHazard", RpcTarget.AllBuffered, player, generatePowerUp, powerUp);
            return(HazardLevel);
        }
        else
        {
            if (generatePowerUp)
            {
                Instantiate(powerUps[powerUp], transform.position, Quaternion.identity);
            }
            gameObject.SetActive(false);
            spawner.HazardDestroyed(HazardLevel, transform.position, player, this);
            spawner.Return(this);
            return(HazardLevel);
        }
    }
Esempio n. 2
0
    protected void RPC_TryDestroyHazard(PlayerID player, bool generatePowerUp, int powerUp)
    {
        spawner?.HazardDestroyed(HazardLevel, transform.position, player, this);

        if (generatePowerUp)
        {
            Instantiate(powerUps[powerUp], transform.position, Quaternion.identity);
        }

        Destroy(gameObject);
    }