/// <summary> /// Update method refactored from Map.cs /// </summary> public override void updateActions(KTYD.Model.Map gameMap) { gArray containers = gameMap.getContainers(); List<Entity> trashContainers = gameMap.getTrashContainers(); List<Entity> playersList = gameMap.getPlayersList(); List<Entity> bulletList = gameMap.getBulletList(); if (!this.isDead()) { //Writing a hack here to prevent the enemies from infinitely looking at edge did not work if (1 == 2) { } else { List<Entity> nearbyContainers = containers.getNearbycontainers(this); foreach (Entity u in nearbyContainers) { if (this != u) { if (this.isCollide(u)) { if (u.Type == EntityType.BULLET) { // If bullet is actually hitting entity if (u.isCollide(this)) { trashContainers.Add(u); ((KTYD.Model.Bullet)u).hitTarget(this); ((KTYD.Model.Bullet)u).setDie(); } } else if (u.Type == EntityType.ENEMY) { ((KTYD.AI.Enemy)u).resolveCollision(this); } else { this.restorePrevLocation(); } } else { if (u.Type == EntityType.PLAYER) { ((KTYD.AI.Enemy)this).determineActionForTarget(((KTYD.AI.Enemy)this).findClosestPlayer(playersList),gameMap); } } } }// for each }//offedge } if (!isDead()) { determineAction(trashContainers,playersList,bulletList,gameMap); // Runaway } base.update(); }
/// <summary> /// Determines what the bullet should do(taken from Map.cs) /// </summary> public override void updateActions(KTYD.Model.Map gameMap) { gArray gameEntities = gameMap.allEntities; List<Entity> trashContainers = gameMap.getTrashContainers(); DiffScaler AIDirector = gameMap.diffScaler(); List<Entity> nearbyEntities=gameEntities.getNearbycontainers(this); foreach (Entity u in nearbyEntities) { if (this != u) { if (this.isCollide(u)) { if (u.Type != EntityType.BULLET) { // if bullet is not already in the trash list if (!trashContainers.Contains(this)) { trashContainers.Add(this); ((KTYD.Model.Bullet)this).hitTarget(u); ((KTYD.Model.Bullet)this).setDie(); //SoundEffect[6].Play(); } if (u.Type == EntityType.ENEMY && ((KTYD.Model.Bullet)this).Owner == EntityType.PLAYER) { // add point AIDirector.addPoint(); } } } } }//for each }