public void PlayAnimation(Animation animation)
        {
            if (Animation == animation)
            {
                return;
            }

            this.animation = animation;
            this.frameIndex = 0;
            this.time = 0.0f;
        }
예제 #2
0
        public void LoadContent()
        {
            if (dk== 0)

            {

                player = content.Load<Texture2D>("hero/dk-idle");
                idleAnimation = new Animation(player, 0.1f, true, 2);
                int positionX = (Level.windowWidth / 2) - (player.Width / 4)-30;
                int positionY = (Level.windowHeight / 2) - (player.Height / 4) + 80;
                playerPosition = new Vector2((float)positionX, (float)positionY);

                support = content.Load<Texture2D>("hero/link");
                supportAnimation = new Animation(support, 0.1f, true, 4);
                int support_positionX = (Level.windowWidth / 2) - (support.Width / 4) + 110;
                int support_positionY = (Level.windowHeight / 2) - (support.Height / 4) + 70;
                supportPosition = new Vector2((float)support_positionX, (float)support_positionY);

                boss = content.Load<Texture2D>("hero/boss2");
                bossAnimation = new Animation(boss, 0.1f, true, 7);
                int boss_positionX = (Level.windowWidth / 2) - (support.Width / 4) ;
                int boss_positionY = (Level.windowHeight / 2) - (support.Height / 4) + 30;
                bossPosition = new Vector2((float)boss_positionX, (float)boss_positionY);

             }

                finn = content.Load<Texture2D>("hero/at");
                finnAnimation = new Animation(finn, 0.1f, true, 8);
                int finn_positionX = (Level.windowWidth / 2) - (finn.Width / 4);
                int finn_positionY = (Level.windowHeight / 2) - (finn.Height / 4) +75;
                finnPosition = new Vector2((float)finn_positionX, (float)finn_positionY);

                damageStringFont = content.Load<SpriteFont>("Font");
                HpStringFont = content.Load<SpriteFont>("Font");
                spritePlayer.PlayAnimation(idleAnimation);
                supportPlayer.PlayAnimation(supportAnimation);
                bossPlayer.PlayAnimation(bossAnimation);
                finnPlayer.PlayAnimation(finnAnimation);
        }
예제 #3
0
        public void Update(GameTime gameTime)
        {
            if (level.mouseState.LeftButton == ButtonState.Pressed &&
                level.oldMouseState.LeftButton == ButtonState.Released)
            {
                        y1 = 0;

                        player = content.Load<Texture2D>("hero/dk-attack1");
                        attackAnimation = new Animation(player, 0.1f, false, 8);
                        int positionX = (Level.windowWidth / 2) - (player.Width / 4)+30 ;
                        int positionY = (Level.windowHeight / 2) - (player.Height / 4) + 80;
                        playerPosition = new Vector2((float)positionX, (float)positionY);

                        support = content.Load<Texture2D>("hero/linkAttack");

                        supportAttack = new Animation(support, 0.1f, false, 6);
                        int support_positionX = (Level.windowWidth / 2) - (support.Width / 4) + 140;
                        int support_positionY = (Level.windowHeight / 2) - (support.Height / 4) + 65;
                        supportPosition = new Vector2((float)support_positionX, (float)support_positionY);

                        boss = content.Load<Texture2D>("hero/bossHit");
                        bossHit = new Animation(boss, 0.1f, true, 7);
                        int boss_positionX = (Level.windowWidth / 2) - (support.Width / 4) + 80;
                        int boss_positionY = (Level.windowHeight / 2) - (support.Height / 4) + 30;
                        bossPosition = new Vector2((float)boss_positionX, (float)boss_positionY);

                        spritePlayer.PlayAnimation(attackAnimation);
                        supportPlayer.PlayAnimation(supportAttack);
                        bossPlayer.PlayAnimation(bossHit);

                        s1 = "attack";
                        enemyHp--;
                        if (enemyHp <= 0)
                        {
                            enemyHp = 10;
                        }

                        playerDamage = 1;

            }

            if (s1 == "Idle")
            {

            }
            else if (s1 == "attack")
            {
                //Trace.Write(supportPlayer.varStop + ",");
                if (supportPlayer.varStop == 5)
                {
                    int support_positionX = (Level.windowWidth / 2) - (support.Width / 4) + 180;
                    int support_positionY = (Level.windowHeight / 2) - (support.Height / 4) + 75;
                    supportPosition = new Vector2((float)support_positionX, (float)support_positionY);
                    supportPlayer.PlayAnimation(supportAnimation);

                    int positionX = (Level.windowWidth / 2) - (player.Width / 4) +30;
                    int positionY = (Level.windowHeight / 2) - (player.Height / 4) + 80;
                    playerPosition = new Vector2((float)positionX, (float)positionY);
                    spritePlayer.PlayAnimation(idleAnimation);

                    int boss_positionX = (Level.windowWidth / 2) - (support.Width / 4)+80;
                    int boss_positionY = (Level.windowHeight / 2) - (support.Height / 4) + 30;
                    bossPosition = new Vector2((float)boss_positionX, (float)boss_positionY);
                    bossPlayer.PlayAnimation(bossAnimation);
                    s1 = "idle";

                }

            }
        }