//This is our class for returning our cloned enemy. May be changed in the future //To return a hashmap or dictionairy of a group of cloned classes. public Dictionary<int, EnemySubclass> getClonedEnemy(int count, DifficultyState state) { //Declare our class for cloning Original = new EnemySubclass(WindowX, WindowY); //declare our return dictionairy Dictionary<int, EnemySubclass> returnDict = new Dictionary<int, EnemySubclass>(); //return a filled hash map //of the specified class (filled with 5 clones to start) for(int i = 0; i < count; i++) { //Set the attribs each time we add to the initial area Original.setDifficultyAttribs(state.EnemySpeed,state.EnemyKillWorth,state.EnemyScreenPts); //create our clone EnemySubclass EnemyClone = (EnemySubclass)getEnemy(Original); //add to dictionairy returnDict.Add(i, EnemyClone); } //return dictionairy full of 5 seperate enemies return returnDict; }
//This is our class for returning our cloned enemy. May be changed in the future //To return a hashmap or dictionairy of a group of cloned classes. public Dictionary <int, EnemySubclass> getClonedEnemy(int count, DifficultyState state) { //Declare our class for cloning Original = new EnemySubclass(WindowX, WindowY); //declare our return dictionairy Dictionary <int, EnemySubclass> returnDict = new Dictionary <int, EnemySubclass>(); //return a filled hash map //of the specified class (filled with 5 clones to start) for (int i = 0; i < count; i++) { //Set the attribs each time we add to the initial area Original.setDifficultyAttribs(state.EnemySpeed, state.EnemyKillWorth, state.EnemyScreenPts); //create our clone EnemySubclass EnemyClone = (EnemySubclass)getEnemy(Original); //add to dictionairy returnDict.Add(i, EnemyClone); } //return dictionairy full of 5 seperate enemies return(returnDict); }
//Overloaded method to return just basic EnemyClone public EnemySubclass spawnEnemy() { //create our clone EnemySubclass EnemyClone = (EnemySubclass)getEnemy(Original); return(EnemyClone); }
public EnemySubclass spawnEnemy(DifficultyState state) { //create our clone EnemySubclass EnemyClone = (EnemySubclass)getEnemy(Original); //Set the attribs each time we add to the initial area EnemyClone.setDifficultyAttribs(state.EnemySpeed, state.EnemyKillWorth, state.EnemyScreenPts); return(EnemyClone); }
//Impportant piece. This is the bit of code that calls the super (aka 'base' in C#) //Of the ICloneable to return the cloned object. public Enemy CloneCopy() { EnemySubclass EnemyObject = null; try { EnemyObject = (EnemySubclass)base.MemberwiseClone(); } catch { Console.Write("We have a problem"); } return(EnemyObject); }
/// <summary> /// method to add enemy /// </summary> public void spawnEnemy() { if (enemiesOnScreen.Count < maxEnemies) { //spawn enemy EnemySubclass enemy = spawner.spawnEnemy(diffContext.getState()); int[] Start = enemy.getStartPos(); //create vector for the enemy's start destination Vector2 CurrentEnemyVector = new Vector2(Start[0], Start[1]); //create destination for the enemy enemy.Destination = createDestination(Start[0], Start[1]); //add enemy position to enemies vector list enemiesVector.Add(CurrentEnemyVector); //add enemy to enemy list enemiesOnScreen.Add(enemy); } }
//constructor public SpawnerProto(int WindowX, int WindowY) { this.WindowX = WindowX; this.WindowY = WindowY; Original = new EnemySubclass(WindowX,WindowY); }
//constructor public SpawnerProto(int WindowX, int WindowY) { this.WindowX = WindowX; this.WindowY = WindowY; Original = new EnemySubclass(WindowX, WindowY); }