using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; namespace ButtonTest { public class EnemyShip { protected Vector2 location; protected Texture2D image; protected bool attacking; protected int layer; protected int formationPosition; protected bool movingRight=true; public virtual void Draw(GameTime gameTime) { } public virtual void Update(GameTime gameTime) { if (!attacking) { if (movingRight) { location.X = location.X + 1; } else { location.X = location.X - 1; } } } } public class BlueShip : EnemyShip { public override void Update(GameTime gameTime) { // I fly straight down if (attacking) { location.Y = location.Y + 1; } base.Update(gameTime); } } public class RedShip : EnemyShip { public override void Update(GameTime gameTime) { // I fly down and right if (attacking) { location.Y = location.Y + 1; location.X = location.X + 1; } base.Update(gameTime); } } public class YellowShip : EnemyShip { public override void Update(GameTime gameTime) { // I fly straight down and to the left if (attacking) { location.Y = location.Y + 1; location.X = location.X - 1; } base.Update(gameTime); } } public class MyGame { // hypothetical game init EnemyShip[] ships = new EnemyShip[42]; private void GameInit() { ships[0] = new BlueShip(); ships[1] = new RedShip(); } private void Update(GameTime gameTime) { int i; for (i = 0; i < ships.Length; i++) { if (ships[i] != null) { ships[i].Update(gameTime); } } } } }