public AI_State(String m,KTYD.AI.Enemy e,KTYD.Model.Map mm) { myName = m; myEntity=e; myMap = mm; }
/// <summary> /// Monitor and Add enemies to the map /// </summary> /// <param name="gMap">Map</param> public void addEnemiesToMap(KTYD.Model.Map gMap) { int eCount = gMap.EnemiesEntities.Count; List<KTYD.Model.Character> player = gMap.PlayerEntities; int difficultyScore = eCount * GameConfig.DIFF_SCALE_FACTOR; int spawnCount = 0; Vector2 spawnPos; spawnPos.X = 2; spawnPos.Y = 2; int max_runner = 20; // need this just in case while loop is indefinite (if it ever happened) int max_run = 10; // need this just in case while loop is indefinite while (max_run !=0) { eCount++; spawnCount++; if(spawnCount>GameConfig.MAX_ENEMY_SPAWN) { return; } if (eCount > maxEnemies) { break; } if (difficultyScore > myScore) { break; } spawnPos = determineSpawnLocation(gMap.getPlayersList()); int tempRand = r.Next() % 4; Weapon eWeapon; // Spawn random items to be picked up if (tempRand == 1) { eWeapon = Weapon.createPistol(); } else if (tempRand == 2) { eWeapon = Weapon.createShotgun(); //itemTyper = Model.ItemType.HEALTH; } else if (tempRand == 3) { eWeapon = Weapon.createPistol(); } else { eWeapon = Weapon.createShotgun(); } difficultyScore = difficultyScore + GameConfig.DIFF_SCALE_FACTOR; Random r2 = new Random(); Random r3 = new Random(); double rot = (r2.Next()+r3.Next()+r.Next())/ (2 * Math.PI); KTYD.AI.Enemy e = new KTYD.AI.Enemy(spawnPos.X,spawnPos.Y,(float)(rot), GameConfig.IMG_BASE_GRAY, eWeapon, EntityState.SEARCH); gMap.loadEntity(e); --max_runner; }//while return; }