Beispiel #1
0
        public void Hammer(Animation animation, attackMethod attackHandle)
        {
            if (!canAttack())
            {
                return;
            }
            doAttack("bomb");

            this.attackHandle = attackHandle;
        }
Beispiel #2
0
        // Attack commands take two inputs, a sprite and an Attack handel
        // All other information for the attack (damage, damageType, etc.) is handled in the AttackList class
        // Eventually these methods should be unified to a single method
        public void Slash(Animation animation, attackMethod attackHandle)
        {
            if (!canAttack())
            {
                return;
            }
            doAttack("sword");
            isSlashing = true;

            this.attackHandle = attackHandle;
        }
Beispiel #3
0
        public void Shoot(Animation animation, attackMethod attackHandle)
        {
            if (!canGuard())
            {
                return;
            }
            gunSprite = animation;
            gunSprite.Reset();
            doAttack("shoot");
            isShooting = true;

            this.attackHandle = attackHandle;
        }
Beispiel #4
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (moveStart)
            {
                if (!moveSprite.active)
                {
                    moveStart = false;
                    moveFin   = true;
                    moveSprite.currentFrame = moveSprite.frameCount - 1;
                    moveSprite.active       = true;
                    moveSprite.forward      = false;
                    doMove();
                }
            }

            if (moveFin)
            {
                if (!moveSprite.active)
                {
                    isSliding    = false;
                    moveFin      = false;
                    activeSprite = staticSprite;

                    string panel = stage.getPanelType(position);
                    onStep(this, panel);
                }
            }

            if (isAttacking)
            {
                int Frame  = activeSprite.currentFrame;
                int Target = attackFrame[attackName];

                if ((Frame >= Target) && (Target > 0) && (attackHandle != null))
                {
                    attackHandle(info);
                    attackHandle = null;
                }

                if (!activeSprite.active && !isShooting)
                {
                    isAttacking  = false;
                    activeSprite = staticSprite;
                    //Shooting and slashing have special conditions for attacking
                    attackHandle?.Invoke(info);
                }
            }

            //Sets guard when sprite animation finishes
            if (isGuarding)
            {
                if (!guardSprite.active)
                {
                    isGuarding = false;
                    Guard      = true;
                }
            }

            //Advance the guard timer, break guard if over
            if (Guard)
            {
                guardElapsed += (int)gameTime.ElapsedGameTime.TotalMilliseconds;
                if ((guardElapsed > guardTime) && (guardTime > 0))
                {
                    breakGuard();
                }
            }
        }