Beispiel #1
0
    void OnCollisionEnter(Collision col)
    {
        BaseShip    bs = col.gameObject.GetComponent <BaseShip> ();
        Destroyable ds = col.gameObject.GetComponent <Destroyable> ();

        if (bs == whoFiredMe)
        {
            return;
        }
        if (bs != null)
        {
            if (col.collider.CompareTag("Turret"))
            {
                TurretAI ta = col.collider.GetComponent <TurretAI> ();
                if (ta != null)
                {
                    ta.Damage(damage, whoFiredMe);
                }
            }
            else if (col.collider.CompareTag("Weak"))
            {
                bs.Damage(damage * 2, whoFiredMe);
            }
            else
            {
                bs.Damage(damage, whoFiredMe);
            }
        }
        else if (ds != null)
        {
            ds.Damage(damage);
        }
    }
Beispiel #2
0
    public void Damage(float damage, BaseShip who)
    {
        BaseShip bs = GetComponentInParent <BaseShip> ();

        if (bs.GetShields() <= 0)
        {
            hp -= damage;
            bs.Damage(0, who);
            if (hp <= 0)
            {
                isDisabled = true;
            }
        }
        else
        {
            bs.Damage(damage, who);
        }

        hp = Mathf.Clamp(hp, 0, maxHp);
    }
Beispiel #3
0
    public void newRound(BaseShip ship)
    {
        int    randEvent;
        Random rng = new Random();

        randEvent = rng.Next(1, 4);


        switch (randEvent)
        {
        case 1:
            if (ship.didEvade())
            {
                eventLog.AddEvent("Evaded attack by hostile ship! No damage taken.");
            }
            else
            {
                if (ship.CurrentShieldCount() > 0)
                {
                    ship.DamageShield(1);
                    eventLog.AddEvent("Taking fire! Shields hit.");
                }
                else
                {
                    ship.Damage(5);
                    eventLog.AddEvent("Taking fire! Impacts on the hull, but she's holding.");
                }
            }
            break;

        case 2:
            this.ActivateShield(1);
            eventLog.AddEvent("Enemy ship powered their shields! They're at " + this.CurrentShieldCount() + " shields!");
            break;

        case 3:
            this.Heal(2);
            eventLog.AddEvent("Enemy ship repaired their hull! They're at " + this.CurrentHP() + " health!");
            break;
        }
    }
Beispiel #4
0
 public override void Fire1()
 {
     if (canFireP)
     {
         laserTimer = 0;
         int layermask = 1 << 8;
         layermask = ~layermask;
         if (Physics.Raycast(transform.position, transform.forward, out hit, primaryRange, layermask))
         {
             BaseShip    hitShip     = hit.collider.gameObject.GetComponent <BaseShip> ();
             Destroyable hitObstacle = hit.collider.gameObject.GetComponent <Destroyable> ();
             if (hitShip != null)
             {
                 hitShip.Damage(damage, GetComponentInParent <BaseShip> ());
             }
             else if (hitObstacle != null)
             {
                 hitObstacle.Damage(damage);
             }
         }
         primaryTimer = 0;
     }
 }