private void Awake()
 {
     if (inst)
     {
         Destroy(this);
     }
     else
     {
         inst = this;
     }
 }
Exemple #2
0
    //Whenever ship collides with an interactable object
    void OnCollisionEnter(Collision collision)
    {
        InteractiveObject interaction = collision.transform.GetComponent <InteractiveObject>();

        if (interaction == null)
        {
            return;
        }

        //allow the interaction only if the object isn't owned by player it is touching
        if (interaction.owner != GetComponent <NetworkIdentity>().netId)
        {
            GameObject otherPlayerBoat = ClientScene.FindLocalObject(interaction.owner);

            StatusEffectsManager ourEffectsManager = GetComponent <StatusEffectsManager>();

            int teamOfObject = otherPlayerBoat == null ? -1 : otherPlayerBoat.GetComponent <Health>().team;

            //allow the interaction only if the object touching us is owned by an enemy and the object is allowed to interact with enemies
            //or if the object touching us is owned by a teammate and the object is allowed to interact with teammates
            //or if the interaction object isn't owned by any particular player
            if (teamOfObject == -1 || (teamOfObject == team && interaction.DoesEffectTeammates()) || (teamOfObject != team && interaction.DoesEffectEnemies()))
            {
                //tell the interactive object about the interaction
                //giving them this health, the boat this health is attached to, this boats status effect manager, and the collision that caused the interaction
                //if(isServer)
                interaction.OnInteractWithPlayer(this, gameObject, ourEffectsManager, collision);

                //if we are the server, destroy the interactive object after the interaction
                //if it says it is destroy after interactions
                if (interaction.DoesDestroyInInteract())
                {
                    Destroy(collision.gameObject);
                }
            }
        }
    }
Exemple #3
0
    public override void OnInteractWithPlayer(Health playerHealth, GameObject playerBoat, StatusEffectsManager manager, Collision collision)
    {
        base.OnInteractWithPlayer(playerHealth, playerBoat, manager, collision);

        int healthChange = -damageDealt;

        //if this object is on the side of the player who owns this object
        //send out the command to change the players health
        //setting the source of the health change to be the owner of this cannonball
        playerHealth.ChangeHealth(healthChange, owner);
    }
Exemple #4
0
    public override void OnInteractWithPlayer(Health playerHealth, GameObject playerBoat, StatusEffectsManager manager, Collision collision)
    {
        base.OnInteractWithPlayer(playerHealth, playerBoat, manager, collision);

        int healthChange = -damageDealt;

        //if this object is on the side of the player who owns this object
        //send out the command to change the players health
        //setting the source of the health change to be the owner of this cannonball
        if (isServer && playerHealth.team != NetworkServer.FindLocalObject(owner).GetComponent <Health>().team)
        {
            playerHealth.ChangeHealth(healthChange, owner);
        }
        DestroyPreserveParticles();
    }
Exemple #5
0
 /// <summary>
 /// Called when this object successfully interacts (collides) with an appropriate enemy or teammate of the player who owns this object.
 /// Or any boat if the object is owned by no-one.
 /// </summary>
 /// <param name="playerHealth">The health script of the player collided with.</param>
 /// <param name="playerBoat">The GameObject boat of the player collided with.</param>
 /// <param name="manager">The player boat's status effect manager.</param>
 /// <param name="collision">Information about the collision that caused the interaction.</param>
 public override void OnInteractWithPlayer(Health playerHealth, GameObject playerBoat, StatusEffectsManager manager, Collision collision)
 {
     return;
 }
Exemple #6
0
    public override void OnInteractWithPlayerTrigger(Health playerHealth, GameObject playerBoat, StatusEffectsManager manager, Collider collider)
    {
        base.OnInteractWithPlayerTrigger(playerHealth, playerBoat, manager, collider);

        int healthChange = -damageDealt;

        playerHealth.ChangeHealth(healthChange, owner);
        DestroyPreserveParticles();
    }
Exemple #7
0
    public override void OnInteractWithPlayer(Health playerHealth, GameObject playerBoat, StatusEffectsManager manager, Collision collision)
    {
        //notifies the player events system that the player who interacted with this object picked up a health pack (this object)
        //also sets isHealthPack to true, since this is a health pack
        Player.ActivateEventPlayerPickup(MultiplayerManager.FindPlayer(playerBoat.GetComponent <NetworkIdentity>().netId), true);

        //send out the command to change the players health
        //setting the source of the healthpack to nothing, since no player is responsible
        if (isServer)
        {
            playerHealth.ChangeHealth(ammoAmmount, NetworkInstanceId.Invalid);
            Destroy(gameObject);
        }
    }
Exemple #8
0
 public virtual void OnInteractWithPlayerTrigger(Health playerHealth, GameObject playerBoat, StatusEffectsManager manager, Collider collider)
 {
     return;
 }
Exemple #9
0
    public override void OnInteractWithPlayerTrigger(Health playerHealth, GameObject playerBoat, StatusEffectsManager manager, Collider collider)
    {
        //notifies the player events system that the player who interacted with this object picked up a health pack (this object)
        //also sets isHealthPack to true, since this is a health pack

        if (isServer)
        {
            if (playerBoat.GetComponent <HeavyWeapon>().AmmoCount >= playerBoat.GetComponent <HeavyWeapon>().ammoCapacity)
            {
                return;
            }
            playerBoat.GetComponent <HeavyWeapon>().AddAmmo(ammoAmmount);
            Player.ActivateEventPlayerPickup(MultiplayerManager.FindPlayer(playerBoat.GetComponent <NetworkIdentity>().netId), true);
            RpcConsumePack(playerBoat.GetComponent <NetworkIdentity>().netId);
        }
    }
Exemple #10
0
    public override void OnInteractWithPlayer(Health playerHealth, GameObject playerBoat, StatusEffectsManager manager, Collision collision)
    {
        base.OnInteractWithPlayer(playerHealth, playerBoat, manager, collision);
        int healthChange = -damageDealt;

        playerHealth.ChangeHealth(healthChange / 2, owner);
    }
Exemple #11
0
    public override void OnInteractWithPlayer(Health playerHealth, GameObject playerBoat, StatusEffectsManager manager, Collision collision)
    {
        int healthChange = -damageDealt;

        //if this object is on the side of the player who owns this object
        //send out the command to change the players health
        //setting the source of the health change to be the owner of this cannonball
        if (isServer)
        {
            playerHealth.ChangeHealth(healthChange, owner);
        }

        //locally instantiates an explosion prefab at the site of the interaction for graphics
        GameObject explode = (GameObject)Instantiate(explosion, collision.contacts[0].point, Quaternion.identity);

        explode.GetComponent <ParticleSystem>().Emit(100);
    }