Exemplo n.º 1
0
        internal IEnemyModel getEnemyModel(string type)
        {
            if (!enemyModelList.ContainsKey(type))
            {
                EnemyModel enemyModel;
                switch (type)
                {
                case "Spear":
                    enemyModel = new EnemyModel("Spear Man", 10, 50, 75);     // str, spd, hth
                    break;

                case "Axe":
                    enemyModel = new EnemyModel("Axe Man", 12, 40, 85);
                    break;

                case "Sword":
                    enemyModel = new EnemyModel("Sword Man", 11, 45, 80);
                    break;

                case "Bow":
                    enemyModel = new EnemyModel("Bow Man", 8, 80, 50);
                    break;

                case "Boss":
                    enemyModel = new EnemyModel("Boss", 20, 100, 150);
                    break;

                default:
                    enemyModel = null;
                    break;
                }
                enemyModelList[type] = enemyModel; // add type to dictionary for use later
            }
            return(enemyModelList[type]);          // return type if already created
        }
Exemplo n.º 2
0
        internal IEnemyModel getEnemyModel(string type)
        {
            if (!enemyModelList.ContainsKey(type))
            {
                EnemyModel enemyModel; // Flywieght incorporated into our factory method
                switch (type)
                {
                case "Spear":
                    enemyModel = new EnemyModel("Spear Man", 10, 50, 45);     // str, spd, hth
                    break;

                case "Axe":
                    enemyModel = new EnemyModel("Axe Man", 12, 40, 55);     // flyweight
                    break;

                case "Sword":
                    enemyModel = new EnemyModel("Sword Man", 11, 45, 40);     // flyweight
                    break;

                case "Bow":
                    enemyModel = new EnemyModel("Bow Man", 8, 80, 30);     // flyweight
                    break;

                case "Boss":
                    enemyModel = new EnemyModel("Boss", 20, 75, 100);     // flyweight
                    break;

                default:
                    enemyModel = null;
                    break;
                }
                enemyModelList[type] = enemyModel; // add type to dictionary for use later
            }
            return(enemyModelList[type]);          // return type if already created
        }