using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using Sprint2_actual.Commands; using Sprint2_actual.SpriteFactories; using Sprint2_actual.StateFiles; using Sprint2_actual.Items; using System.Collections.Generic; using Sprint2_actual.ActiveItems; using System.Linq; namespace Sprint2_actual { public class Game1 : Game { private GraphicsDeviceManager graphics; //public SpriteBatch spriteBatch; public Vector2 spritePos; private static ISprite blockSprites; private static ISprite npcSprites; public Texture2D PlayerTexture; public Texture2D ItemTexture; private List controllerList; private ILink player; //make private, create a property with get method private NPC npc; //make private, create a property with get method private Block block; public DisplayItemStateMachine itemMachine { get; set; } public IItem DisplayItem { get; set; } //public List ProjectileList { get; set; } public static ISprite BlockSprites { get { return blockSprites; } set { blockSprites = value; } } public Block Block { get { return block; } } public NPC Npc { get { return npc; } } public ILink Player { get { return player; } set { player = value; } } public static ISprite NPCSprites { get { return npcSprites; } set { npcSprites = value; } } public Game1() { //Sbubby Eef freef graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; IsMouseVisible = true; } protected override void Initialize() { ICommand LinkMoveDown = new LinkMoveDownCommand(this); ICommand LinkMoveUp = new LinkMoveUpCommand(this); ICommand LinkMoveLeft = new LinkMoveLeftCommand(this); ICommand LinkMoveRight = new LinkMoveRightCommand(this); ICommand TakeDamage = new DamagedLinkCommand(this); ICommand Idle = new LinkMoveIdleCommand(this); ICommand Attack = new LinkAttackCommand(this); ICommand UseArrow = new LinkItemArrowCommand(this); ICommand UseBoomerangA = new LinkItemBoomerangACommand(this); ICommand UseBomb = new LinkItemBombCommand(this); ICommand UseFire = new LinkItemFireCommand(this); ICommand UseBoomerangB = new LinkItemBoomerangBCommand(this); ICommand UseFlamingArrow = new LinkItemFlamingArrowCommand(this); ICommand Quit = new QuitCommand(this); ICommand setNextBlockSprite = new NextBlockCommand(this); ICommand setPrevBlockSprite = new PreviousBlockCommand(this); ICommand setNextNPCSprite = new NextNPCCommand(this); ICommand setPrevNPCSprite = new PreviousNPCCommand(this); ICommand setNextItemSprite = new NextItemCommand(this); ICommand setPrevItemSprite = new PreviousItemCommand(this); KeyboardController k = new KeyboardController(); k.RegisterCommand(Keys.D0, Quit); k.RegisterCommand(Keys.W, LinkMoveUp); k.RegisterCommand(Keys.S, LinkMoveDown); k.RegisterCommand(Keys.A, LinkMoveLeft); k.RegisterCommand(Keys.D, LinkMoveRight); k.RegisterCommand(Keys.Z, Attack); k.RegisterCommand(Keys.N, Attack); k.RegisterCommand(Keys.E, TakeDamage); k.RegisterIdleCommand(Idle); k.RegisterCommand(Keys.D1, UseArrow); k.RegisterCommand(Keys.D2, UseBoomerangA); k.RegisterCommand(Keys.D3, UseBomb); k.RegisterCommand(Keys.D4, UseFire); k.RegisterCommand(Keys.D5, UseBoomerangB); k.RegisterCommand(Keys.D6, UseFlamingArrow); k.RegisterCommand(Keys.Y, setNextBlockSprite); k.RegisterCommand(Keys.T, setPrevBlockSprite); k.RegisterCommand(Keys.O, setPrevNPCSprite); k.RegisterCommand(Keys.P, setNextNPCSprite); k.RegisterCommand(Keys.I, setNextItemSprite); k.RegisterCommand(Keys.U, setPrevItemSprite); controllerList = new List(); controllerList.Add(k); npc = new NPC(); block = new Block(); itemMachine = new DisplayItemStateMachine(this); //ProjectileList = new List(); base.Initialize(); } protected override void LoadContent() { GlobalVars.spriteBatch = new SpriteBatch(GraphicsDevice); GlobalVars.ProjectileList = new List(); //SpriteFont font = Content.Load("File"); PlayerTexture = Content.Load("NES - The Legend Of Zelda - Link"); Player = new Link(this, PlayerTexture); ItemTexture = Content.Load("Items&Weapons"); //SpriteFont font = Content.Load("File"); BlockSpriteFactory.Instance.LoadAllTextures(Content); ItemSpriteFactory.Instance.LoadAllTextures(Content); NPCSpriteFactory.Instance.LoadAllTextures(Content); blockSprites = BlockSpriteFactory.Instance.CreateBlock1(); npcSprites = NPCSpriteFactory.Instance.CreateOldMan(); DisplayItem = new WoodenSwordItem(this, 600, 250); } protected override void Update(GameTime gameTime) { GlobalVars.gameTime = gameTime; foreach (IController controller in controllerList) { controller.Update(); } foreach (AItemSprites projectile in GlobalVars.ProjectileList) { projectile.update(gameTime); } for (int i = 0; i < GlobalVars.ProjectileList.Count; i++) { if (GlobalVars.ProjectileList.ElementAt(i).IsRemoved) { GlobalVars.ProjectileList.RemoveAt(i); } } Player.Update(); base.Update(gameTime); NPCSprites.update(gameTime); DisplayItem.UpdateItem(gameTime); } protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.DimGray); GlobalVars.spriteBatch.Begin(); block.Draw(); // for this draw method, I get the ISprite dungeonSprites inside of the Block class and call on it for draw() npc.Draw(); DisplayItem.DrawItem(); Player.Draw(); foreach (AItemSprites projectile in GlobalVars.ProjectileList) { projectile.draw(); } GlobalVars.spriteBatch.End(); base.Draw(gameTime); } } }