예제 #1
0
        public override void Draw(SpriteBatch spriteBatch)
        {
            if (!enabled || dead)
            {
                return;
            }
            if (!isWizard)
            {
                if (animations.ContainsKey(currentAnimation))
                {
                    SpriteEffects effect = SpriteEffects.None;
                    if (flipped)
                    {
                        effect = SpriteEffects.FlipHorizontally;
                    }
                    spriteBatch.Draw(animations[currentAnimation].Texture, Camera.WorldToScreen(WorldRectangle), animations[currentAnimation].FrameRectangle, Color.White, 0.0f, Vector2.Zero, effect, drawDepth);
                }
                else
                {
                    Console.WriteLine("Animation key {0} is not contained in animations.", currentAnimation);
                }
                if (StupidClass.CurrentTurn < 5)
                {
                    if (gameState == GameState.playing && StupidClass.players[StupidClass.CurrentTurn] == this)
                    {
                        drawArrows(spriteBatch);
                        ui.Draw(spriteBatch);
                    }
                }
            }
            else
            {
                foreach (Monster item in Wizard.units)
                {
                    if (TileMap.mCells[(int)item.pos.X, (int)item.pos.Y].visible)
                    {
                        spriteBatch.Draw(item.texture, Camera.WorldToScreen(new Rectangle(item.WorldRectangle.X, item.WorldRectangle.Y, 64, 64)), null,
                                         Color.White, 0f, new Vector2(0, 0), SpriteEffects.None, 0.6f);

                        spriteBatch.Draw(StupidClass.redBox,
                                         Camera.WorldToScreen(new Rectangle(item.WorldRectangle.X + 5, item.WorldRectangle.Y - 5, item.hpRed.Width, item.hpRed.Height))
                                         , null, Color.White, 0f, new Vector2(0, 0), SpriteEffects.None, 0.5f);
                        spriteBatch.Draw(StupidClass.greenBox,
                                         Camera.WorldToScreen(new Rectangle(item.WorldRectangle.X + 5, item.WorldRectangle.Y - 5, item.hpGreen.Width, item.hpGreen.Height)),
                                         null, Color.White, 0f, new Vector2(0, 0), SpriteEffects.None, 0.4f);
                    }
                }
                if (StupidClass.CurrentTurn < 5 && StupidClass.players[StupidClass.CurrentTurn] == this)
                {
                    //ADD WIZARD UI HERE
                    //spriteBatch.Draw(StupidClass.greenBox, new Rectangle(550, 440, 200, 32), null, Color.White, 0.0f, Vector2.Zero, SpriteEffects.None, 0.4f);

                    // for (int i = 0; i < Wizard.spells.Count-1; i++)
                    // {
                    //      spriteBatch.Draw(Wizard.spells[i].tex, new Rectangle(10+(i*70), 425, 64, 64), new Rectangle(0, 0, 64, 64), Color.White, 0.0f, Vector2.Zero, SpriteEffects.None, 0.4f);
                    // }

                    foreach (Monster item in Wizard.units)
                    {
                        item.drawArrows(spriteBatch);
                    }
                    WizardUI.Draw(spriteBatch);
                }
            }
            #region HpBar
            spriteBatch.Draw(StupidClass.redBox,
                             Camera.WorldToScreen(new Rectangle(WorldRectangle.X + 5, WorldRectangle.Y - 5, hero.hpRed.Width, hero.hpRed.Height))
                             , null, Color.White, 0f, new Vector2(0, 0), SpriteEffects.None, 0.5f);
            spriteBatch.Draw(StupidClass.greenBox,
                             Camera.WorldToScreen(new Rectangle(WorldRectangle.X + 5, WorldRectangle.Y - 5, hero.hpGreen.Width, hero.hpGreen.Height)),
                             null,
                             Color.White, 0f, new Vector2(0, 0), SpriteEffects.None, 0.4f);
            #endregion
        }
예제 #2
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            TileMap.Initialize(Content.Load <Texture2D>(@"Textures\PlatformTiles"));
            Camera.WorldRectangle = new Rectangle(0, 0, 200 * 64, 200 * 64);
            Camera.Position       = Vector2.Zero;
            Camera.ViewPortWidth  = 800;
            Camera.ViewPortHeight = 600;

            players[0]      = new Player(Content);
            players[0].xPos = 1;
            players[0].animations["afk"] = new AnitmaionLines(Content.Load <Texture2D>(@"Textures\Sprites\Player\Wizard"), 64, "afk");
            //make wizard
            players[1]      = new Player(Content);
            players[1].xPos = 2;
            players[1].hero = new Swordsman();
            players[1].animations["afk"] = new AnitmaionLines(Content.Load <Texture2D>(@"Textures\Sprites\Player\Knight"), 64, "afk");


            players[2]      = new Player(Content);
            players[2].xPos = 3;
            players[2].hero = new Monk();
            players[2].animations["afk"] = new AnitmaionLines(Content.Load <Texture2D>(@"Textures\Sprites\Player\Monk"), 64, "afk");

            HeroUIButton[] ui1 = new HeroUIButton[2];
            ui1[0] = new HeroUIButton(new Rectangle(10, 425, 64, 64), new Heal(Content.Load <Texture2D>(@"Textures\UInHUD\HeroSpells\heal")));
            ui1[1] = new HeroUIButton(new Rectangle(84, 425, 64, 64), new Sacrifice(Content.Load <Texture2D>(@"Textures\UInHUD\HeroSpells\heal")));

            players[2].ui.init(ui1);

            players[3]      = new Player(Content);
            players[3].xPos = 4;
            players[3].hero = new Bandit();
            players[3].animations["afk"] = new AnitmaionLines(Content.Load <Texture2D>(@"Textures\Sprites\Player\Thief"), 64, "afk");
            players[4]      = new Player(Content);
            players[4].xPos = 5;
            players[4].hero = new MiniWizard();
            players[4].animations["afk"] = new AnitmaionLines(Content.Load <Texture2D>(@"Textures\Sprites\Player\MiniWizard"), 64, "afk");

            players[0].isWizard = true;
            players[0].xPos     = 0;
            players[0].yPos     = 0;
            foreach (Player item in players)
            {
                item.hero.UpdateStats(item);
                item.hero.Init();
                if (item.hero.agility == 3 || item.hero.intelligence == 3)
                {
                    item.hero.equipment[0].range = 3;
                }
            }


            players[4].hero.ap = 0;
            currentTurn        = 4;

            LvlManager.Initialize(Content, players[0]);
            LvlManager.LLevel(0);
            font             = Content.Load <SpriteFont>(@"Fonts\Font");
            StupidClass.font = font;

            StupidClass.greenBox = Content.Load <Texture2D>(@"Textures\UInHUD\greenbox");
            StupidClass.redBox   = Content.Load <Texture2D>(@"Textures\UInHUD\redbox");

            TileMap.effectTextures.Add(Content.Load <Texture2D>(@"Textures\Sprites\Lines\invisLine"));
            TileMap.effectTextures.Add(Content.Load <Texture2D>(@"Textures\Sprites\TileEffects\fire"));

            Wizard.initialize(Content);
            Wizard.spells[0].tex = Content.Load <Texture2D>(@"Textures\UInHUD\WizardSpells\darkness");
            Wizard.spells[1].tex = Content.Load <Texture2D>(@"Textures\UInHUD\WizardSpells\fire");
            Wizard.spells[2].tex = Content.Load <Texture2D>(@"Textures\UInHUD\WizardSpells\glue");
            Wizard.spells[3].tex = Content.Load <Texture2D>(@"Textures\UInHUD\WizardSpells\teleport");
            Wizard.spells[4].tex = Content.Load <Texture2D>(@"Textures\UInHUD\WizardSpells\iceage");
            Wizard.spells[5].tex = Content.Load <Texture2D>(@"Textures\Sprites\Monsters\Ogre");
            Wizard.spells[6].tex = Content.Load <Texture2D>(@"Textures\Sprites\Monsters\Skeleton");
            Wizard.spells[7].tex = Content.Load <Texture2D>(@"Textures\Sprites\Monsters\Imp");

            TileMap.te.Add(Content.Load <Texture2D>(@"Textures\Sprites\TileEffects\fire"));
            TileMap.te.Add(Content.Load <Texture2D>(@"Textures\Sprites\TileEffects\glue"));
            TileMap.te.Add(Content.Load <Texture2D>(@"Textures\Sprites\TIleEffects\ice"));

            WizardUI.init(Content.Load <Texture2D>(@"Textures\UInHUD\mana"), Content.Load <Texture2D>(@"Textures\UInHUD\manabar"),
                          Content.Load <Texture2D>(@"Textures\UInHUD\warrows"), Content.Load <Texture2D>(@"Textures\UInHUD\WUI"));
        }
예제 #3
0
        private void moveAndDirection(GameTime gameTime, ref MouseState mouseState, ref KeyboardState keyboardState, ref int currentTurn)
        {
            if (!dead)
            {
                if (hero.hp <= 0)
                {
                    dead = true;
                }

                if (keyboardState.IsKeyDown(Keys.Space))
                {
                    highlightTiles = true;
                }
                else
                {
                    highlightTiles = false;
                }

                #region Highlight & Select Tiles
                if (highlightTiles)
                {
                    short s = 10;
                    mouseState = Mouse.GetState();

                    for (int i = 0; i < TileMap.mCells.GetLength(0); i++)
                    {
                        for (int c = 0; c < TileMap.mCells.GetLength(1); c++)
                        {
                            try
                            {
                                //Crashes if mouse goes outside the map while still inside the window.
                                if (TileMap.mCells[Camera.ScreenToWorld(mouseRectangle).X / 64, Camera.ScreenToWorld(mouseRectangle).Y / 64] == TileMap.mCells[i, c])
                                {
                                    Console.WriteLine(TileMap.mCells[i, c].CodeValue);
                                    TileMap.mCells[i, c].Tcolor.R = 150;
                                    TileMap.mCells[i, c].Tcolor.G = 255;
                                    TileMap.mCells[i, c].Tcolor.B = 150;

                                    if (mouseState.LeftButton == ButtonState.Pressed)
                                    {
                                        if (TileMap.mCells[i, c] != tTile2)
                                        {
                                            tTile1 = TileMap.mCells[i, c];
                                        }
                                        else
                                        {
                                            tTile1 = TileMap.mCells[i, c];
                                            tTile2 = null;
                                        }
                                    }

                                    if (mouseState.RightButton == ButtonState.Pressed)
                                    {
                                        if (TileMap.mCells[i, c] != tTile1)
                                        {
                                            tTile2 = TileMap.mCells[i, c];
                                        }
                                        else
                                        {
                                            tTile2 = TileMap.mCells[i, c];
                                            tTile1 = null;
                                        }
                                    }
                                }
                                else
                                {
                                    TileMap.mCells[i, c].Tcolor = Color.White;
                                }
                            }
                            catch
                            {
                                break;
                            }
                        }
                    }
                }
                else
                {
                    foreach (MapSquare item in TileMap.mCells)
                    {
                        item.Tcolor = Color.White;
                    }
                }
                #endregion
                //Mark targeted tile 1
                if (tTile1 != null)
                {
                    tTile1.Tcolor.R = 150;
                    tTile1.Tcolor.G = 150;
                    tTile1.Tcolor.B = 255;
                }
                //mark Ttile 2
                if (tTile2 != null)
                {
                    tTile2.Tcolor.R = 255;
                    tTile2.Tcolor.G = 150;
                    tTile2.Tcolor.B = 150;
                }
                if (StupidClass.CurrentTurn < 5 && StupidClass.players[StupidClass.CurrentTurn] == this)
                {
                    if (keyboardState.IsKeyDown(Keys.Up))
                    {
                        Camera.Move(new Vector2(0, -8));
                    }
                    if (keyboardState.IsKeyDown(Keys.Down))
                    {
                        Camera.Move(new Vector2(0, 8));
                    }
                    if (keyboardState.IsKeyDown(Keys.Left))
                    {
                        Camera.Move(new Vector2(-8, 0));
                    }
                    if (keyboardState.IsKeyDown(Keys.Right))
                    {
                        Camera.Move(new Vector2(8, 0));
                    }

                    /*Console.Clear();
                     * Console.WriteLine(hero);
                     * Console.WriteLine("Level: " + hero.level + "\nExp: " + hero.experience + "/" + hero.maxExp);
                     * Console.WriteLine("Hp: " + hero.hp + "/" + hero.maxHp);
                     * Console.WriteLine("Ap: " + hero.ap + "/" + hero.maxAp);
                     * Console.WriteLine("Chance to dodge: " + hero.dodgeChance);
                     * Console.WriteLine("Damage: " + hero.damage);
                     * Console.WriteLine("Range: " + hero.equipment[0].range);*/
                }
                if (!isWizard)
                {
                    #region Make tiles visible
                    if (xPos > 0 && yPos > 0)
                    {
                        TileMap.mCells[xPos, yPos].visible         = true;
                        TileMap.mCells[xPos + 1, yPos].visible     = true;
                        TileMap.mCells[xPos - 1, yPos].visible     = true;
                        TileMap.mCells[xPos, yPos + 1].visible     = true;
                        TileMap.mCells[xPos, yPos - 1].visible     = true;
                        TileMap.mCells[xPos + 1, yPos + 1].visible = true;
                        TileMap.mCells[xPos - 1, yPos - 1].visible = true;
                        TileMap.mCells[xPos + 1, yPos - 1].visible = true;
                        TileMap.mCells[xPos - 1, yPos + 1].visible = true;
                    }
                    #endregion
                    //temp skip turn
                    if (StupidClass.CurrentTurn < 5)
                    {
                        if (keyboardState.IsKeyDown(Keys.Escape) && StupidClass.players[StupidClass.CurrentTurn] == this && StupidClass.inputTimer <= 0.0f)
                        {
                            hero.ap = 0;
                            StupidClass.inputTimer = 5000;
                        }

                        if (StupidClass.players[StupidClass.CurrentTurn] == this)
                        {
                            ui.Update(ref hero.ap, mouseState, ref hero);
                        }

                        if (mouseState.LeftButton == ButtonState.Pressed && StupidClass.players[StupidClass.CurrentTurn] == this)
                        {
                            moveY = 0;
                            moveX = 0;
                            if (StupidClass.inputTimer <= 0.0f)
                            {
                                if (directionMode)
                                {
                                    if (mouseRectangle.Intersects(Camera.WorldToScreen(new Rectangle(WorldRectangle.X, WorldRectangle.Y - 64, 64, 64))))
                                    {
                                        hero.dir = 0;
                                        hero.Attack(hero, 0);
                                        directionMode          = false;
                                        StupidClass.inputTimer = 4000;
                                        hero.ap--;
                                    }
                                    else if (mouseRectangle.Intersects(Camera.WorldToScreen(new Rectangle(WorldRectangle.X - 64, WorldRectangle.Y, 64, 64))))
                                    {
                                        hero.dir = 3;
                                        hero.Attack(hero, 0);
                                        directionMode = false;
                                        hero.ap--;
                                    }
                                    else if (mouseRectangle.Intersects(Camera.WorldToScreen(new Rectangle(WorldRectangle.X + 64, WorldRectangle.Y, 64, 64))))
                                    {
                                        hero.dir = 1;
                                        hero.Attack(hero, 0);
                                        directionMode = false;
                                        hero.ap--;
                                        StupidClass.inputTimer = 4000;
                                    }
                                    else if (mouseRectangle.Intersects(Camera.WorldToScreen(new Rectangle(WorldRectangle.X, WorldRectangle.Y + 64, 64, 64))))
                                    {
                                        hero.dir = 2;
                                        hero.Attack(hero, 0);
                                        directionMode = false;
                                        hero.ap--;
                                        StupidClass.inputTimer = 4000;
                                    }
                                }
                                else if (showArrows)
                                {
                                    if (mouseRectangle.Intersects(Camera.WorldToScreen(new Rectangle(WorldRectangle.X, WorldRectangle.Y - 64, 64, 64))))
                                    {
                                        --moveY;
                                        stopStuff = true;
                                        stuff(gameTime);
                                        StupidClass.inputTimer = 4000;
                                        showArrows             = false;
                                    }
                                    else if (mouseRectangle.Intersects(Camera.WorldToScreen(new Rectangle(WorldRectangle.X - 64, WorldRectangle.Y, 64, 64))))
                                    {
                                        --moveX;
                                        stopStuff = true;
                                        stuff(gameTime);
                                        StupidClass.inputTimer = 4000;
                                        showArrows             = false;
                                    }
                                    else if (mouseRectangle.Intersects(Camera.WorldToScreen(new Rectangle(WorldRectangle.X + 64, WorldRectangle.Y, 64, 64))))
                                    {
                                        ++moveX;
                                        stopStuff = true;
                                        stuff(gameTime);
                                        StupidClass.inputTimer = 4000;
                                        showArrows             = false;
                                    }
                                    else if (mouseRectangle.Intersects(Camera.WorldToScreen(new Rectangle(WorldRectangle.X, WorldRectangle.Y + 64, 64, 64))))
                                    {
                                        ++moveY;
                                        stopStuff = true;
                                        stuff(gameTime);
                                        StupidClass.inputTimer = 4000;
                                        showArrows             = false;
                                    }
                                }
                                else // Show move and attack buttons
                                {
                                    if (mouseRectangle.Intersects(Camera.WorldToScreen(new Rectangle(WorldRectangle.X, WorldRectangle.Y - 64, 64, 64))))
                                    {
                                        directionMode          = false;
                                        showArrows             = true;
                                        StupidClass.inputTimer = 3000;
                                    }
                                    else if (mouseRectangle.Intersects(Camera.WorldToScreen(new Rectangle(WorldRectangle.X + 64, WorldRectangle.Y, 64, 64))))
                                    {
                                        // ATTACK BUTTON ACTIVATED
                                        showArrows             = false;
                                        directionMode          = true;
                                        StupidClass.inputTimer = 3000;
                                    }
                                }
                            }
                        }
                        else
                        {
                            stopStuff = true;
                        }
                    }
                    if (StupidClass.inputTimer > 0 && StupidClass.CurrentTurn < 5 && StupidClass.players[StupidClass.CurrentTurn] == this)
                    {
                        StupidClass.inputTimer -= 150;
                    }
                    if (stopStuff)
                    {
                        moveX = 0;
                        moveY = 0;
                        updateAnimation(gameTime);
                        stopStuff = false;
                    }

                    if (hero.ap <= 0)
                    {
                        currentTurn++;

                        hero.UpdateStats();
                        hero.TurnUpdate();
                        StupidClass.changeVTiles();
                    }
                }
                else//ADD WIZARD UPDATE HERE
                {
                    foreach (Monster item in Wizard.units)
                    {
                        item.UpdateStats();
                        if (item.hp <= 0)
                        {
                            Wizard.units.Remove(item);
                            foreach (Player player in StupidClass.players)
                            {
                                player.hero.experience += (short)(item.level * 2);
                            }
                            break;
                        }
                    }
                    if (StupidClass.CurrentTurn < 5)
                    {
                        if (StupidClass.players[StupidClass.CurrentTurn] == this)
                        {
                            if (keyboardState.IsKeyDown(Keys.B))
                            {
                                Wizard.ap += 1;
                            }
                            foreach (Monster item in Wizard.units)
                            {
                                item.Move(gameTime, ref mouseState);
                            }
                        }
                        if (keyboardState.IsKeyDown(Keys.Escape) && StupidClass.players[StupidClass.CurrentTurn] == this && StupidClass.inputTimer <= 0.0f)
                        {
                            StupidClass.inputTimer = 5000;

                            foreach (Monster item in Wizard.units)
                            {
                                item.turnUpdate();
                            }
                            currentTurn++;
                            Wizard.endTurn();
                            StupidClass.changeVTiles();
                        }
                        if (StupidClass.players[StupidClass.CurrentTurn] == this && StupidClass.inputTimer <= 0)
                        {
                            MouseState ms = Mouse.GetState();
                            WizardUI.Update(ref Wizard.ap, ms, tTile1, tTile2, Content);
                        }
                        if (StupidClass.inputTimer > 0 && StupidClass.CurrentTurn < 5 && StupidClass.players[StupidClass.CurrentTurn] == this)
                        {
                            StupidClass.inputTimer -= 150;
                        }
                    }
                }
            }
            else if (StupidClass.CurrentTurn < 5 && StupidClass.players[StupidClass.CurrentTurn] == this)
            {
                currentTurn++;
                StupidClass.changeVTiles();
            }
            else
            {
                xPos = 0;
                yPos = 0;
            }
        }