예제 #1
0
    // ----- Engine funktioner ----- \\

    private void OnCollisionEnter(Collision collision)
    {
        if (networkMaster == true)
        {
            IShip ship = collision.gameObject.GetComponent <IShip>();

            if (ship != null)
            {
                if (ship != firedFromShip)
                {
                    ship.ApplyDamage(firedFromShip.GetCannonDamage());

                    firedFromShip.GetGameManager().OnCannonBallDestroyed(this);
                }
            }
            else
            {
                Mine mine = collision.gameObject.GetComponent <Mine>();

                if (mine != null)
                {
                    mine.MineDestroyed();
                }

                firedFromShip.GetGameManager().OnCannonBallDestroyed(this);
            }
        }
    }
예제 #2
0
    ///<summary>Bliver kaldt når vi rammer sammen med et andet objekt</summary>
    private void ShipCollisionHandler(Collision collision)
    {
        OnShipCollision();

        IShip ship = collision.gameObject.GetComponent <IShip>();

        if (ship != null)
        {
            ship.ApplyDamage(10 * (int)rigid.velocity.magnitude);
        }
    }
예제 #3
0
    ///<summary>Bliver kaldt når vi rammer sammen med et andet objekt</summary>
    private void MineCollisionHandler(Collision collision)
    {
        IShip ship = collision.gameObject.GetComponent <IShip>();

        if (ship != null)
        {
            ship.ApplyDamage(mineDamage);

            MineDestroyed();
        }
    }