示例#1
0
    // will work on later after doing energy meter
    void OnTriggerEnter2D(Collider2D col)
    {
        // If enemy bullets hit this, player's energy reduced

        if (col.CompareTag("Bullet"))
        {
            if ((col.gameObject.GetComponent <bullet>()) != null)
            {
                bullet _bullet = col.gameObject.GetComponent <bullet>();

                if ((_bullet.getPlayerID()) != getPlayerID())
                {
                    driver.subtractEnergy(_bullet.energy_val);
                    Destroy(col.gameObject);
                }
            }
            Destroy(col.gameObject);
        }
    }
示例#2
0
    // for protoype test, we will have a classic spread shot as weapon
    //

    void produceBullets(float chargeVal)
    {
        float chargeStrength = 5 * chargeVal;
        int   weaponLevel    = (int)chargeStrength;    // truncating on purpose for level range

        if (weaponLevel == 1)
        {
            makeShot(0);
        }
        else if (weaponLevel == 2)
        {
            makeShot(-5f);
            makeShot(5f);
        }
        else if (weaponLevel == 3)
        {
            makeShot(0);
            makeShot(-7.5f);
            makeShot(7.5f);
        }
        else if (weaponLevel == 4)
        {
            makeShot(-2.5f);
            makeShot(2.5f);
            makeShot(-7.5f);
            makeShot(7.5f);
        }
        else if (weaponLevel == 5)
        {
            makeShot(0);
            makeShot(-5f);
            makeShot(5f);
            makeShot(-10f);
            makeShot(10f);
        }

        float chargeCost = ((float)weaponLevel) / 5;

        driver.subtractEnergy(chargeCost);
    }