protected override void Update() { _legs.Walking = true; //Move: if (KeyboardManager.KeysDown.Contains(Keys.A)) { TryStep(Directions.Left, _speed); ChangeDirectionAndImage(MobDirection.Left); } else if (KeyboardManager.KeysDown.Contains(Keys.D)) { TryStep(Directions.Right, _speed); ChangeDirectionAndImage(MobDirection.Right); } else if (KeyboardManager.KeysDown.Contains(Keys.W)) { TryStep(Directions.Up, _speed); ChangeDirectionAndImage(MobDirection.Up); } else if (KeyboardManager.KeysDown.Contains(Keys.S)) { TryStep(Directions.Down, _speed); ChangeDirectionAndImage(MobDirection.Down); } else { _legs.Walking = false; } //Update camera: Camera.Position = Sprite.Position - new Vector2(WindowChecks.Width() / 2, WindowChecks.Height() / 2); //Pull out sword: if (MouseManager.Click() && _canSword != false) { Vector2 mousePosNormal = new Vector2(MouseManager.CurrentMouseState.X, MouseManager.CurrentMouseState.Y); mousePosNormal -= Sprite.Position - Camera.Position; ObjectHolder.Create(new PlayerSword(this, (float)Math.Atan2(mousePosNormal.X, -mousePosNormal.Y))); _canSword = false; _restart_canSword.Restart(30); } //Restart _canSword: if (_restart_canSword.IsDone()) { _canSword = true; } }
private static void StoreTestData(IObjectContainer container) { for (int i = 0; i < NumberOfItems; i++) { Item item = new Item(i); container.Store(ObjectHolder.Create(item)); container.Store( CollectionHolder.Create( item, new Item(NumberOfItems + i), new Item(2 * NumberOfItems + i))); } }
protected override void LoadContent() { //Initialize the GameInfo: GameInfo.RefSpriteBatch = spriteBatch; GameInfo.RefDevice = Device; GameInfo.RefDeviceManager = graphics; GameInfo.RefContent = Content; //Initialize some more static classes: TextureHolder.Initialize(); SoundHolder.Initialize(); MouseManager.Initialize(); //Initalize the grid: Grid grid = new Grid(new Vector2(0, 0), 100, 40); Grid gridFloor = new Grid(new Vector2(0, 0), 100, 40); ObjectHolder.Create(grid); ObjectHolder.Create(gridFloor); //Initialize the camera: Camera.Initialize(new Vector2(0, 0)); //Initialize default sprites: TextureHolder.DefaultTextures[typeof(DungeonWall)] = TextureHolder.AddTexture("DungeonWall"); TextureHolder.DefaultTextures[typeof(DungeonFloor)] = TextureHolder.AddTexture("DungeonFloor"); TextureHolder.DefaultTextures[typeof(DungeonFloor2)] = TextureHolder.AddTexture("DungeonFloor2"); TextureHolder.DefaultTextures[typeof(Player)] = TextureHolder.AddTexture("Player"); TextureHolder.DefaultTextures[typeof(PlayerLegs)] = TextureHolder.AddTexture("PlayerLegs"); TextureHolder.DefaultTextures[typeof(PlayerSword)] = TextureHolder.AddTexture("PlayerSword"); TextureHolder.DefaultTextures[typeof(CannonBot)] = TextureHolder.AddTexture("CannonBot"); TextureHolder.DefaultTextures[typeof(Sink)] = TextureHolder.AddTexture("Sink"); //Load sounds: //Create game objects: gridFloor.CreateFromString( //Make the floor new Dictionary <char, Type>() { { 'f', typeof(DungeonFloor) }, { 's', typeof(DungeonFloor2) }, { '.', null } }, new Dictionary <char, GameObject>() { }, new string[] { "..............", ".sfffffffffff.", ".ffffffffffff.", ".ffffffffffff..........", ".fffffffffffffffsfffff.", ".fffffffsfffffffffffff.", ".fffffffffffffffffffff.", ".fffffffffffffffffffff.", ".ffffffffffff..........", ".fffsffffffff.", ".ffffffffffff.", ".............." }); grid.CreateFromString( new Dictionary <char, Type>() { { 'w', typeof(DungeonWall) }, { 'p', typeof(Player) }, { 'c', typeof(CannonBot) }, { 's', typeof(Sink) }, { '.', null } }, new Dictionary <char, GameObject>() { { '1', new Sink(new Vector2(0, 0), MazeGameEngine.FurnitureDirection.Up) } }, new string[] { "wwwwwwwwwwwwww", "w............w", "w............w", "w............wwwwwwwwww", "w.....................w", "w.....p...............w", "w.....................w", "w.....................w", "w............wwwwwwwwww", "w............w", "w.....1......w", "wwwwwwwwwwwwww" }); //Make a reference to the UI objects: (so that other objects can interact with them) }
public Player(Vector2 position) : base(position) { _legs = new PlayerLegs(this); ObjectHolder.Create(_legs); }
public Player() : base() { _legs = new PlayerLegs(this); ObjectHolder.Create(_legs); }