// TODO delete //public void CheckAllEnemies() //{ // Boolean test = false; // for (Byte index = 0; index < maxEnemySpawn; index++) // { // Enemy enemy = EnemyList[index]; // if (EnemyType.Test != enemy.EnemyType) // { // continue; // } // SByte slotID = enemy.SlotID; // if (EnemyDict.ContainsKey((Byte)slotID)) // { // EnemyDict.Remove((Byte)slotID); // } // enemy.Reset(); // //EnemyCount++; // //if (EnemyCount > EnemyTotal) // //{ // // test = true; // // enemy.None(); // //} // //SpawnOneEnemy(index); // } //// return test; //} public Boolean CheckThisEnemy(Byte index) { Boolean check = false; Enemy enemy = EnemyList[index]; if (EnemyType.Idle == enemy.EnemyType) { return(false); } SByte slotID = enemy.SlotID; if (EnemyDict.ContainsKey((Byte)slotID)) { EnemyDict.Remove((Byte)slotID); } enemy.Reset(); // Check this is last enemy!! if (EnemySpawn >= EnemyTotal) { enemy.None(); check = true; } return(check); }
public void Reset(LevelType theLevelType, Byte theEnemySpawn, UInt16 minDelay, UInt16 maxDelay, Byte enemyTotal) { levelType = theLevelType; maxEnemySpawn = theEnemySpawn; if (maxEnemySpawn > Constants.MAX_ENEMYS_SPAWN) { maxEnemySpawn = Constants.MAX_ENEMYS_SPAWN; } MinDelay = minDelay; MaxDelay = maxDelay; // Reset all enemies but not the list as will clear. for (Byte index = 0; index < maxEnemySpawn; index++) { EnemyList[index].Reset(); } EnemyTest.Clear(); EnemyDict.Clear(); // Ensure total at least the max. if (enemyTotal < maxEnemySpawn) { enemyTotal = maxEnemySpawn; } EnemyTotal = enemyTotal; EnemySpawn = 0; }
public Boolean CheckThisEnemy(Byte index) { Boolean check = false; Enemy enemy = EnemyList[index]; if (EnemyType.Idle == enemy.EnemyType) { return(false); } SByte testID = enemy.SlotID; if (testID >= 0 && testID < Constants.MAX_ENEMYS_SPAWN) { Byte slotID = (Byte)testID; if (EnemyDict.ContainsKey(slotID)) { EnemyDict.Remove(slotID); } } enemy.Reset(); // Check this is last enemy!! if (EnemySpawn >= EnemyTotal) { enemy.None(); check = true; } return(check); }
public override void Init() { EnemyDict.Clear(); foreach (EnemyBase enemy in EnemyList) { EnemyDict.Add(enemy.Id, enemy); CheckList(enemy.FearRaceList); CheckList(enemy.ResistRaceList); } }
public void SpawnOneEnemy(Byte index) { // TODO work out better the frame delay. UInt16 frameDelay = Constants.TestFrameDelay; //UInt16 frameDelay = MyGame.Manager.RandomManager.Next(MinDelay, MaxDelay); SByte slotID = Constants.INVALID_INDEX; while (true) { slotID = (SByte)MyGame.Manager.RandomManager.Next(Constants.MAX_ENEMYS_SPAWN); if (!EnemyDict.ContainsKey((Byte)slotID)) { break; } } // TODO delete //slotID = 0; // hard code slotID to test. MyGame.Manager.Logger.Info((slotID + 1).ToString()); Enemy enemy = EnemyList[index]; Vector2 position = enemy.Position; Byte randomX = (Byte)MyGame.Manager.RandomManager.Next(Constants.ENEMY_RANDOM_X); Byte randomY = (Byte)MyGame.Manager.RandomManager.Next(Constants.ENEMY_RANDOM_Y); UInt16 offsetX = EnemyOffsetX[(Byte)slotID]; UInt16 offsetY = EnemyOffsetY[(Byte)slotID]; position.X = randomX + offsetX; position.Y = randomY + offsetY; Rectangle bounds = EnemyBounds[(Byte)slotID]; enemy.Spawn((Byte)slotID, frameDelay, position, bounds); EnemyDict.Add((Byte)slotID, enemy); EnemySpawn++; }
public void SpawnOneEnemy(Byte index) { UInt16 frameDelay = enemyDelays[EnemySpawn]; Boolean enemyRotate = enemyRotates[EnemySpawn]; MoveType moveType = enemyMoves[EnemySpawn]; Byte theEnemySpeed = levelConfigData.EnemyVelocity; Byte slotID; while (true) { slotID = (Byte)MyGame.Manager.RandomManager.Next(Constants.MAX_ENEMYS_SPAWN); if (!EnemyDict.ContainsKey(slotID)) { break; } } // TODO delete //slotID = 0; // hard code slotID to test. //MyGame.Manager.Logger.Info((slotID+1).ToString()); // Retrieve the enemy from list. Enemy enemy = EnemyList[index]; Vector2 position = enemy.Position; Byte randomX = (Byte)MyGame.Manager.RandomManager.Next(Constants.ENEMY_RANDOM_X); Byte randomY = (Byte)MyGame.Manager.RandomManager.Next(Constants.ENEMY_RANDOM_Y); UInt16 offsetX = EnemyOffsetX[slotID]; UInt16 offsetY = EnemyOffsetY[slotID]; // This fits within [160,200] = [40,80] = [32,72] => [32 = 160-120-(2*4)] // [32,72] => [32 = 160-120-(2*4), 72 = 200-120-(2*4)] position.X = randomX + offsetX + Constants.BorderSize; position.Y = randomY + offsetY + Constants.BorderSize; // Implement bounds checking... Rectangle bounds = EnemyBounds[slotID]; if (position.X < bounds.Left) { position.X = bounds.Left; } if (position.X > bounds.Right) { position.X = bounds.Right; } if (position.Y < bounds.Top) { position.Y = bounds.Top; } if (position.Y > bounds.Bottom) { position.Y = bounds.Bottom; } enemy.Spawn(slotID, frameDelay, position, bounds, levelType, enemyRotate, moveType, theEnemySpeed); EnemyDict.Add(slotID, enemy); EnemySpawn++; }
public void Clear() { EnemyTest.Clear(); EnemyDict.Clear(); }