예제 #1
0
 public void UpdateAction(Player player)
 {
     for(int i = 0; i < enemies.Count; ++i)
     {
         enemies[i].UpdateAction(player);
         if (!enemies[i].unparriable)
             check_parry(enemies[i], player);
         if (enemies[i].health <= 0)
             enemies.Remove(enemies[i]);
     }
 }
예제 #2
0
 private void check_parry(Enemy enemy, Player player)
 {
     bool parry = false;
     bool misparry = false;
     if (player.pressedAttack1())
     {
         parry = (enemy.inAttack == "Attack1");
         misparry = !parry;
     }
     else if (player.pressedAttack2())
     {
         parry = (enemy.inAttack == "Attack2");
         misparry = !parry;
     }
     if (parry)
     {
         enemy.inAttack = "";
         player.parry();
         enemy.parried();
         Console.WriteLine(enemy.parryCount);
     }
     enemy.unparriable = misparry;
 }
예제 #3
0
        public void UpdateAction(Player player)
        {
            int direction;
            TimeSpan delta = (DateTime.Now - startAction);
            inAction = Math.Max(0.0, inAction - delta.TotalMilliseconds);

            Console.WriteLine(inAction);

            if(check_attack(player))
            {
                enemyStr = player.strength;
                damaged();
            }
            else if (inAction > 0.0)
                animations.PlayAnimation(animations.AnimationKey);
            else if (this.animations.Rect().Intersects(player.animations.Rect()))
            {
                if (parryCount >= parryMax)
                {
                    broke();
                    player.canAttack = true;
                }
                else if (inAttack == "")
                {
                    System.Random generator = new System.Random();
                    inAction = parryTime;
                    startAction = DateTime.Now;
                    if (generator.NextDouble() > 0.3)
                    {
                        inAttack = "Attack1";
                        this.animations.color = Color.Blue;
                    }
                    else
                    {
                        inAttack = "Attack2";
                        this.animations.color = Color.Yellow;
                    }
                    player.canAttack = true;
                    animations.PlayAnimation("Stoped" + getSense());
                }
                else if (inAction == 0.0)
                    successfullAttack(player);
                else
                    animations.PlayAnimation(animations.AnimationKey);
            }
            else
            {
                if (player.animations.position.X < this.animations.position.X)
                {
                    this.animations.PlayAnimation("WalkingLeft");
                    direction = -1;
                }
                else
                {
                    this.animations.PlayAnimation("WalkingRight");
                    direction = 1;
                }
                last_movement.X = direction;
                this.animations.position.X += direction * speed;

                if (this.animations.Rect().Intersects(player.animations.Rect()))
                    animations.PlayAnimation("Stoped" + getSense());
            }

            animations.old_position = animations.position;
            // Make sure that the player does not go out of bounds
        }
예제 #4
0
 public bool check_attack(Player player)
 {
     return this.animations.Rect().Intersects(player.animations.Rect()) &&
            isBroke() && player.pressedAttack();
 }
예제 #5
0
 private void successfullAttack(Player player)
 {
     player.inDamage = inAttack;
     player.enemyStr = strength;
     inAction = meleeTime;
     startAction = DateTime.Now;
     animations.PlayAnimation(inAttack + getSense());
     inAttack = "";
     unparriable = false;
     this.animations.color = color;
     parryCount = 0;
     player.canAttack = false;
 }
예제 #6
0
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            font = Content.Load<SpriteFont>("infoFont");
            background = Content.Load<Texture2D>("background");

            // Cria o personagem
            player = new Player(8.0f);
            // Posiciona o personagem na tela
            player.animations.position = new Vector2(100, GraphicsDevice.Viewport.Height-200);

            player.animations.AddAnimation("Stoped", Content.Load<Texture2D>("zero_walking"), 16, 1, 0, 1);
            player.animations.AddAnimation("Walking", Content.Load<Texture2D>("zero_walking"), 16, 1, 0, 16);
            player.animations.AddAnimation("Attack1", Content.Load<Texture2D>("zero_attack_1"), 1, 1, 0, 1, false);
            player.animations.AddAnimation("Attack2", Content.Load<Texture2D>("zero_attack_2"), 1, 1, 0, 1, false);
            player.animations.AddAnimation("Damage", Content.Load<Texture2D>("zero_damage"), 1, 1, 0, 1, false);
            player.animations.AddAnimation("Parry", Content.Load<Texture2D>("zero_parry"), 1, 1, 0, 1, false);
            player.animations.AddAnimation("Parried", Content.Load<Texture2D>("zero_parried"), 1, 1, 0, 1, false);
            player.animations.AddAnimation("Broke", Content.Load<Texture2D>("zero_broke"), 1, 1, 0, 1, false);

            enemiesManager.SpawnGenericEnemy(new Vector2(700, GraphicsDevice.Viewport.Height-200), Content);
        }