コード例 #1
0
        } // Registering entity

        public void RegisterEntity(PictureBox entity, EnemyEntityTag enemyTag)
        {
            moveObj.Add(entity);
            enemyEntity.Add(entity);
            entity.Tag       = enemyTag;
            entity.BackColor = Color.Transparent;
            entity.SizeMode  = PictureBoxSizeMode.StretchImage;
            switch (enemyTag)
            {
            case EnemyEntityTag.Ork:
                entity.Width  = 120;
                entity.Height = 120;
                break;

            case EnemyEntityTag.Skeleton:
                entity.Width  = 160;
                entity.Height = 160;
                break;

            case EnemyEntityTag.Dragon:
                entity.Width  = 260;
                entity.Height = 260;
                break;
            }
        } // Registering enemy entity
コード例 #2
0
        } // Tests to pickup an item, if it is better than one you have

        public void EnemyGotKilledGiveLoot(EnemyEntityTag enemy)
        {
            Random rnd        = new Random();
            int    randomLoot = rnd.Next(0, 101);

            switch (enemy)
            {
            case EnemyEntityTag.Ork:

                if (randomLoot >= 0 && randomLoot <= 60)
                {
                    coins += 5;
                }
                else if (randomLoot >= 61 && randomLoot <= 80)
                {
                    coins += 10; UpgradeItem(2, ItemsToUpgrade.Sword);
                }

                break;

            case EnemyEntityTag.Skeleton:
                if (randomLoot >= 0 && randomLoot <= 40)
                {
                    coins += 12;
                }
                else if (randomLoot >= 41 && randomLoot <= 70)
                {
                    coins += 17; magicFruit++;
                }
                else if (randomLoot >= 71 && randomLoot <= 95)
                {
                    coins += 20; UpgradeItem(2, ItemsToUpgrade.Armor);
                }
                else if (randomLoot >= 96 && randomLoot <= 100)
                {
                    coins += 25; UpgradeItem(3, ItemsToUpgrade.Sword);
                }

                break;

            case EnemyEntityTag.Dragon:

                if (randomLoot >= 0 && randomLoot <= 50)
                {
                    coins += 40; healPotion++;
                }
                if (randomLoot >= 51 && randomLoot <= 80)
                {
                    coins += 50; manaPotion++; magicFruit++;
                }
                if (randomLoot >= 81 && randomLoot <= 100)
                {
                    coins += 6; manaPotion++; healPotion++; magicFruit++; UpgradeItem(3, ItemsToUpgrade.Armor);
                }

                break;
            }
        } // Dropping random loot from enemies