예제 #1
0
    // Return an instance of the type's archetypal class.
    public static Item FromType(Types type)
    {
        Item ret = null;

        switch (type)
        {
        case Types.Hand: ret = new MeleeWeapon() as Item; break;

        case Types.Rifle: ret = new ProjectileWeapon() as Item; break;

        case Types.Bullet:
            ret           = new Projectile() as Item;
            ret.stackable = true;
            break;

        case Types.HealthPack:  ret = new HealthPowerUp() as Item; break;

        case Types.AmmoPack: ret = new AmmoPowerUp() as Item; break;

        case Types.Ammo:
            ret           = new Item();
            ret.stackable = true;
            break;

        case Types.AidHealthPack: ret = new HealthAid() as Item; break;
        }

        return(ret);
    }
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.P))
     {
         HealthPowerUp newHealthPowerUp = new HealthPowerUp();
     }
 }
예제 #3
0
파일: Helper.cs 프로젝트: Remmery/Pong
        /// <summary>
        /// Choose a random powerup.
        /// </summary>
        /// <returns>A random powerup</returns>
        public static PowerUp ChooseRandomPowerUp(int width, int height, Data.Setup s)
        {
            PowerUp powerUp;
            Random  random = new Random();
            double  x      = random.Next(width / 4, width / 4 * 3);
            double  y      = random.Next(height / 5, height / 5 * 4);

            switch (random.Next(5))
            {
            case 0:
                powerUp = new HealthPowerUp(x, y, 40, s.HealingShield);
                break;

            case 1:
                powerUp = new SpeedPowerUp(x, y, 40, s.SpeedBallPercent);
                break;

            case 2:
                powerUp = new ReversePowerUp(x, y, 40, s.ReverseTime);
                break;

            case 3:
                powerUp = new MultiBallPowerUp(x, y, 40);
                break;

            default:
                powerUp = new BombPowerUp(x, y, 40, s.DamageBomb);
                break;
            }
            return(powerUp);
        }
예제 #4
0
    private void SpawnPowerUp(PowerUpType type)
    {
        MinionSpawner ms = GameObject.Find("MinionSpawner").GetComponent <MinionSpawner>();

        switch (type)
        {
        case PowerUpType.BOOST_MINION_HEALTH:
            HealthPowerUp P1 = Instantiate(healthPU).GetComponent <HealthPowerUp>();
            P1.target             = ms;
            P1.transform.position = this.transform.position;
            break;

        case PowerUpType.BOOST_MINION_SPAWN:
            MinionSpawnPowerUp P2 = Instantiate(spawnPU).GetComponent <MinionSpawnPowerUp>();
            P2.target             = ms;
            P2.transform.position = this.transform.position;
            break;

        case PowerUpType.BOOST_MINION_ATK_SPEED:
            GameObject P3 = Instantiate(AtkSpeedPU);
            P3.transform.position = this.transform.position;
            break;
        }
    }
예제 #5
0
    // Return an instance of the type's archetypal class.
    public static Item FromType(Types type)
    {
        Item             ret = null;
        MeleeWeapon      mw;
        ProjectileWeapon pw;
        ThrownItem       ti;
        SpellCaster      sc;
        ItemData         dat;
        RestorationSpell rs;

        switch (type)
        {
        case Types.Hand: ret = new MeleeWeapon() as Item; break;

        case Types.Rifle: ret = new ProjectileWeapon() as Item; break;

        case Types.Bullet:
            ret           = new Projectile() as Item;
            ret.stackable = true;
            break;

        case Types.HealthPack:  ret = new HealthPowerUp() as Item; break;

        case Types.AmmoPack: ret = new AmmoPowerUp() as Item; break;

        case Types.Ammo:
            ret           = new Item();
            ret.stackable = true;
            break;

        case Types.AidHealthPack: ret = new HealthAid() as Item; break;

        case Types.Spear:
            ti = new ThrownItem();
            ti.healthDamage = 100;
            ti.staminaCost  = 25;
            ret             = ti as Item;
            ret.color       = new Vector3(0, 1, 0);
            break;

        case Types.Claws:
            mw = new MeleeWeapon();
            mw.healthDamage = 50;
            mw.swingSpeed   = 0.5f;
            mw.staminaCost  = 15;
            ret             = mw as Item;
            break;

        case Types.Staff:
            List <Types> spells = Session.session.career.GetAvailableSpells();
            sc  = new SpellCaster(spells);
            ret = sc as Item;
            break;

        case Types.Crossbow:
            pw = new ProjectileWeapon();
            pw.healthDamage    = 100;
            pw.maxAmmo         = 1;
            pw.ammoType        = "Bolt";
            pw.impulseStrength = 100f;
            dat      = new ItemData();
            dat.type = Types.Ammo;
            dat.name = pw.ammoType;
            pw.LoadInternalReserve(dat, 10);
            ret = pw as Item;
            break;

        case Types.RapidCrossbow:
            pw = new ProjectileWeapon();
            pw.healthDamage    = 100;
            pw.maxAmmo         = 1;
            pw.ammoType        = "Bolt";
            pw.impulseStrength = 100f;
            pw.reloadDelay     = 0.5f; // Four times faster
            dat      = new ItemData();
            dat.type = Types.Ammo;
            dat.name = pw.ammoType;
            pw.LoadInternalReserve(dat, 10);
            ret = pw as Item;
            break;

        case Types.DoubleCrossbow:
            pw = new ProjectileWeapon();
            pw.healthDamage    = 100;
            pw.maxAmmo         = 2;
            pw.ammoType        = "Bolt";
            pw.impulseStrength = 100f;
            dat      = new ItemData();
            dat.type = Types.Ammo;
            dat.name = pw.ammoType;
            pw.LoadInternalReserve(dat, 10);
            ret = pw as Item;
            break;

        case Types.FlintlockPistol:
            pw = new ProjectileWeapon();
            pw.healthDamage    = 100;
            pw.maxAmmo         = 1;
            pw.ammoType        = "MusketBall";
            pw.impulseStrength = 100f;
            dat      = new ItemData();
            dat.type = Types.Ammo;
            dat.name = pw.ammoType;
            pw.LoadInternalReserve(dat, 6);
            ret = pw as Item;
            break;

        case Types.Knife:
            mw = new MeleeWeapon();
            mw.healthDamage = 35;
            mw.swingSpeed   = 0.5f;
            mw.staminaCost  = 15;
            ret             = mw as Item;
            break;

        case Types.FireballSpell:
            pw = new ProjectileWeapon();
            pw.healthDamage      = 30;
            pw.requireAmmoToFire = false;
            pw.ammoType          = "Fireball";
            pw.manaCost          = 15;
            dat      = new ItemData();
            dat.type = Types.Ammo;
            dat.name = pw.ammoType;
            pw.LoadInternalReserve(dat, 1);
            ret = pw as Item;
            break;

        case Types.FireballIISpell:
            pw = new ProjectileWeapon();
            pw.healthDamage      = 60;
            pw.requireAmmoToFire = false;
            pw.ammoType          = "Fireball";
            pw.manaCost          = 20;
            dat      = new ItemData();
            dat.type = Types.Ammo;
            dat.name = pw.ammoType;
            pw.LoadInternalReserve(dat, 1);
            ret = pw as Item;
            break;

        case Types.FireballIIISpell:
            pw = new ProjectileWeapon();
            pw.healthDamage      = 100;
            pw.requireAmmoToFire = false;
            pw.ammoType          = "Fireball";
            pw.manaCost          = 50;
            dat      = new ItemData();
            dat.type = Types.Ammo;
            dat.name = pw.ammoType;
            pw.LoadInternalReserve(dat, 1);
            ret = pw as Item;
            break;

        case Types.HealSpell:
            rs          = new RestorationSpell();
            rs.health   = 15;
            rs.manaCost = 50;
            rs.coolDown = 1f;
            ret         = rs as Item;
            break;

        case Types.StaminaSpell:
            rs          = new RestorationSpell();
            rs.stamina  = 15;
            rs.manaCost = 15;
            rs.coolDown = 0.5f;
            ret         = rs as Item;
            break;

        case Types.ManaSpell:
            rs          = new RestorationSpell();
            rs.mana     = 25;
            rs.manaCost = 15;
            rs.coolDown = 0.5f;
            ret         = rs as Item;
            break;
        }
        return(ret);
    }