Ejemplo n.º 1
0
    void Overcharge(string shooterId)
    {
        ResetColor();
        Destroy(Instantiate(shockwavePrefab, Vector3.zero, Quaternion.identity), 5f);

        // Damage and knock back relative to distance from sun
        GameObject playerObj = NetworkCharacter.GetPlayerGameObject(PhotonNetwork.LocalPlayer);
        float      dist      = playerObj.transform.position.magnitude;
        float      damage    = UserDefinedConstants.sunDamage * (1 - dist / UserDefinedConstants.sphereRadius);

        dmgCtrl.BroadcastInflictDamage(shooterId, damage, PhotonNetwork.LocalPlayer.UserId);
        playerObj.GetComponent <Rigidbody>().AddForce(playerObj.transform.position.normalized * damage, ForceMode.Impulse);
    }
    public void RemoteExplosion(Vector3 position, Vector3 explosionForce, float dist, string shooterId)
    {
        // Instantiate explosion graphic and sound
        Explosion(position);

        // Apply force (disable root motion for a bit):
        Player     player    = PhotonNetwork.LocalPlayer;
        GameObject playerObj = NetworkCharacter.GetPlayerGameObject(player);

        playerObj.GetComponent <PlayerMovementController>().DisableRootMotionFor(UserDefinedConstants.explosionParalysisTime);
        playerObj.GetComponent <Rigidbody>().AddForce(explosionForce, ForceMode.Impulse);
        // Do damage (to self):
        float damage = UserDefinedConstants.projectileHitDamage * (1 - Mathf.Clamp01(dist / UserDefinedConstants.explosionRadius));

        dmgCtrl.BroadcastInflictDamage(shooterId, damage, player.UserId);
    }