public override void GetKnockedDown(DirectionTarget cameFrom, int damage)
        {
            // Set state and texture
            IsAttackable     = false;
            this.IsAttacking = false;
            state            = AdonCloseState.KnockedDown;
            texture          = Game1.SprAdonWalkIdle;
            frameX           = 0;
            frameY           = 4;
            drawWidth        = DRAW_WIDTH_KNOCKDOWN;
            drawHeight       = DRAW_HEIGHT_TAKEHIT;
            originCharacters = new Vector2((drawWidth / 2), drawHeight);
            SetDrawArea();

            // Play Sound
            SoundManager.PlaySound("GetHit03");

            // Face the man who beat you
            if (cameFrom == DirectionTarget.Right)
            {
                FacingDir = DirectionTarget.Left;
            }
            else
            {
                FacingDir = DirectionTarget.Right;
            }

            this.Health -= damage;
        }
        private void AnimateKnockDown(GameTime gT)
        {
            currentFrameTime += (float)gT.ElapsedGameTime.TotalSeconds;
            if (currentFrameTime >= Actor.FrameRate * 1.2f)
            {
                currentFrameTime = 0f;
                frameX++;
                if (frameX == 1 && CheckForDeath() && frameY == 4)
                {
                    SoundManager.PlaySound("GetHit-Died");
                }
                if (frameX > 4 && frameY == 5)
                {
                    if (CheckForDeath())
                    {
                        state     = AdonCloseState.Dying;
                        stateTime = 1f;
                        frameX    = 4;
                        return;
                    }
                    // Set state and texture
                    state  = AdonCloseState.Down;
                    frameX = 4;

                    stateTime = 0f;
                    return;
                }
                if (frameX > 4 && frameY == 4)
                {
                    frameX = 0;
                    frameY++;
                }
                SetDrawArea();
            }
        }
예제 #3
0
        public override void GetKnockedDown(DirectionTarget cameFrom, int damage)
        {
            // Set state and texture
            this.IsAttackable = false;
            this.IsAttacking  = false;
            this.state        = AdonCloseState.KnockedDown;

            this.Sprite = Texture_Walk_Idle;
            this.InitSpriteFrames(DRAW_WIDTH_KNOCKDOWN, DRAW_HEIGHT_TAKEHIT, 0, 4);
            this.SetOriginPosition("bottom");
            this.SetDrawArea();

            // Play Sound
            SoundManager.PlaySound("GetHit03");

            // Face the man who beat you
            if (cameFrom == DirectionTarget.Right)
            {
                FacingDir = DirectionTarget.Left;
            }
            else
            {
                FacingDir = DirectionTarget.Right;
            }

            this.Health -= damage;
        }
        public override void GetHitKick(DirectionTarget cameFrom, int damage)
        {
            this.IsAttacking = false;

            this.Health -= damage;
            if (CheckForDeath())
            {
                SoundManager.PlaySound("GetHit-Died");
                GetKnockedDown(cameFrom, 0);
                return;
            }

            // Set state and tetxture
            state      = AdonCloseState.TakeHitLowKick;
            texture    = Game1.SprAdonWalkIdle;
            frameX     = 0;
            frameY     = 4;
            drawWidth  = DRAW_WIDTH_TAKEHITLOW;
            drawHeight = DRAW_HEIGHT_TAKEHITLOW;
            SetDrawArea();

            // Play Sound
            SoundManager.PlaySound("GetHit02");

            // Face the man who beat you
            if (cameFrom == DirectionTarget.Left)
            {
                FacingDir = DirectionTarget.Right;
            }
            else
            {
                FacingDir = DirectionTarget.Left;
            }
        }
        private void DecideWhatToDo()
        {
            if (Game1.Random.NextDouble() < 0.5d)
            {
                // Decide to retreat
                GetRetreatTarget();

                // Set time to be in Retreat STate
                stateTime = (float)(Game1.Random.NextDouble() + 1.8);
            }
            else
            {
                // ATTACK
                if (NoOtherEnemiesAttacking())
                {
                    this.IsAttacking = true;
                    this.state       = AdonCloseState.MoveTo;
                    frameX           = 0;
                    drawWidth        = DRAW_WIDTH_WALK;
                }
                //else // ???????????????????????? - They wont wait until other enemy is done fighting with player
                //{
                //   GetRetreatTarget();
                //}
            }
        }
예제 #6
0
        public override void GetHitKick(DirectionTarget cameFrom, int damage)
        {
            this.IsAttacking = false;

            this.Health -= damage;
            if (CheckForDeath())
            {
                SoundManager.PlaySound("GetHit-Died");
                GetKnockedDown(cameFrom, 0);
                return;
            }

            // Set state and tetxture
            this.state = AdonCloseState.TakeHitLowKick;

            this.Sprite = Texture_Walk_Idle;
            this.InitSpriteFrames(DRAW_WIDTH_TAKEHITLOW, DRAW_HEIGHT_TAKEHITLOW, 0, 4);
            this.SetOriginPosition("bottom");
            this.SetDrawArea();

            // Play Sound
            SoundManager.PlaySound("GetHit02");

            // Face the man who beat you
            if (cameFrom == DirectionTarget.Left)
            {
                FacingDir = DirectionTarget.Right;
            }
            else
            {
                FacingDir = DirectionTarget.Left;
            }
        }
예제 #7
0
        private void DecideWhatToDo()
        {
            if (Game1.Random.NextDouble() < 0.5d)
            {
                // Decide to retreat
                GetRetreatTarget();

                // Set time to be in Retreat STate
                stateTime = (float)(Game1.Random.NextDouble() + 1.8);
            }
            else
            {
                // ATTACK
                if (NoOtherEnemiesAttacking())
                {
                    this.IsAttacking = true;
                    this.state       = AdonCloseState.MoveTo;

                    this.InitSpriteFrames(DRAW_WIDTH_WALK, this.DrawHeight, 0, this.FrameY);
                    this.SetOriginPosition("bottom");
                    this.SetDrawArea();
                }
                //else // ???????????????????????? - They wont wait until other enemy is done fighting with player
                //{
                //   GetRetreatTarget();
                //}
            }
        }
예제 #8
0
        public void SetIntro01TargetPosition(Vector2 targetPosition)
        {
            this.targetPosition = targetPosition;
            this.state          = AdonCloseState.Level01Intro;

            // Setup Walk Animation
            this.InitSpriteFrames(DRAW_WIDTH_WALK, DRAW_HEIGHT_NORMAL);
            this.Sprite = Texture_Walk_Idle;

            this.SetDrawArea();
        }
예제 #9
0
        public void SetToWait(DirectionTarget facingDir)
        {
            this.Sprite = Texture_Walk_Idle;

            this.InitSpriteFrames(DRAW_WIDTH_WAIT, DRAW_HEIGHT_WAIT, 0, 7);
            this.SetDrawArea();
            this.SetOriginPosition("bottom");

            this.state     = AdonCloseState.Wait;
            this.FacingDir = facingDir;
        }
 public void SetToWait(DirectionTarget facingDir)
 {
     texture    = Game1.SprAdonWalkIdle;
     drawWidth  = DRAW_WIDTH_WAIT;
     drawHeight = DRAW_HEIGHT_WAIT;
     frameX     = 0;
     frameY     = 7;
     SetDrawArea();
     state = AdonCloseState.Wait;
     this.originCharacters = new Vector2((drawWidth / 2), drawHeight);
     this.FacingDir        = facingDir;
 }
 public void SetIntro01TargetPosition(Vector2 targetPosition)
 {
     this.targetPosition = targetPosition;
     this.state          = AdonCloseState.Level01Intro;
     //this.InLevel.LevelState = LevelState.Intro;
     // Setup Walk Animation
     this.drawWidth  = DRAW_WIDTH_WALK;
     this.drawHeight = DRAW_HEIGHT_NORMAL;
     this.frameX     = 0;
     this.frameY     = 1;
     this.texture    = Game1.SprAdonWalkIdle;
     SetDrawArea();
 }
        private void GetRetreatTarget()
        {
            state = AdonCloseState.Retreat;

            // Retreat to which side of the player
            if (Game1.Random.NextDouble() < 0.5d)
            {
                // Go LEFT of the player
                retreatTarget.X = Game1.Random.Next((int)(InLevel.Player1.Position.X - 200),
                                                    (int)(InLevel.Player1.Position.X - 100));

                // Is this position off screen
                if (retreatTarget.X < Camera.Position.X - Game1.SCREEN_WIDTH / 2)
                {
                    // go to the Right Side of Player
                    retreatTarget.X = Game1.Random.Next((int)(InLevel.Player1.Position.X + 100),
                                                        (int)(InLevel.Player1.Position.X + 200));
                }
            }
            else
            {
                // go to the Right Side of Player
                retreatTarget.X = Game1.Random.Next((int)(InLevel.Player1.Position.X + 100),
                                                    (int)(InLevel.Player1.Position.X + 200));

                // Is this position off screen
                if (retreatTarget.X < Camera.Position.X - Game1.SCREEN_WIDTH / 2)
                {
                    // Go LEFT of the player
                    retreatTarget.X = Game1.Random.Next((int)(InLevel.Player1.Position.X - 200),
                                                        (int)(InLevel.Player1.Position.X - 100));
                }
            }

            // Get Y Retreat Target
            //int range = InLevel.PlayBounds.Bottom - InLevel.PlayBounds.Top;
            //float percent = (float)Game1.Random.NextDouble();
            //retreatTarget.Y = percent * range + InLevel.PlayBounds.Top;
            retreatTarget.Y = Game1.Random.Next(InLevel.PlayBounds.Top, InLevel.PlayBounds.Bottom);
        }
        public override void Update(GameTime gT)
        {
            switch (state)
            {
                #region Retreat State
            case AdonCloseState.Retreat:

                stateTime -= (float)gT.ElapsedGameTime.TotalSeconds;
                if (stateTime <= 0)
                {
                    // Run out of time
                    DecideWhatToDo();
                }
                else
                {
                    // Retreat to retreatTarget
                    // Move to X Target
                    if (Position.X < retreatTarget.X)     // target is to the RIGHT
                    {
                        this.Position.X += ACTOR_X_SPEED + ACTOR_X_RETREAT_SPEED;
                        if (Position.X > retreatTarget.X)     // Gone too far
                        {
                            Position.X = retreatTarget.X;
                        }
                    }
                    else     // Target to the LEFT
                    {
                        this.Position.X -= ACTOR_X_SPEED + ACTOR_X_RETREAT_SPEED;
                        if (Position.X < retreatTarget.X)     // Gone too far
                        {
                            Position.X = retreatTarget.X;
                        }
                    }
                    // Move to Y Location
                    if (Position.Y < retreatTarget.Y)     // target is Below US
                    {
                        this.Position.Y += ACTOR_Y_SPEED + ACTOR_Y_RETREAT_SPEED;
                        if (Position.Y > retreatTarget.Y)     // Gone too far
                        {
                            Position.Y = retreatTarget.Y;
                        }
                    }
                    else     // Target is above us
                    {
                        this.Position.Y -= ACTOR_Y_SPEED + ACTOR_Y_RETREAT_SPEED;
                        if (Position.Y < retreatTarget.Y)     // Gone too far
                        {
                            Position.Y = retreatTarget.Y;
                        }
                    }

                    // Make sure this enemy is always facing Player
                    if (Position.X < InLevel.Player1.Position.X)     // to the right of use
                    {
                        this.FacingDir = DirectionTarget.Right;
                    }
                    else     // to the left
                    {
                        this.FacingDir = DirectionTarget.Left;
                    }

                    // Which animation to use
                    if (this.Position == retreatTarget)
                    {
                        // At location IDLE
                        frameY    = 0;
                        drawWidth = DRAW_WIDTH_IDLE;
                        //drawHeight = DRAW_HEIGHT_NORMAL; ;
                        originCharacters = new Vector2(drawWidth / 2, drawHeight);
                        AnimateIdle(gT);
                    }
                    else
                    {
                        // Not at location
                        drawWidth = DRAW_WIDTH_WALK;
                        //drawHeight = DRAW_HEIGHT_NORMAL;
                        originCharacters = new Vector2(drawWidth / 2, drawHeight);
                        AnimateWalking(gT);
                    }
                }
                break;

                #endregion

                #region MoveTo
            case AdonCloseState.MoveTo:
                // Are we lined up with player
                bool linedUpX = LinedUpXWithPlayer();
                bool linedUpY = LinedUpYWithPlayer();

                if (linedUpX && linedUpY)
                {
                    // Set Pre-Attack State
                    frameX           = 0;
                    frameY           = 0;
                    state            = AdonCloseState.PreAttack;
                    drawWidth        = DRAW_WIDTH_IDLE;
                    originCharacters = new Vector2(drawWidth / 2, drawHeight);
                    SetDrawArea();

                    // How long do we stay in the pre-attack state
                    stateTime = 0.5f * (float)Game1.Random.NextDouble();

                    break;
                }
                AnimateWalking(gT);
                break;

                #endregion

                #region Pre Attack
            case AdonCloseState.PreAttack:
                // Am I still lined up with the player
                if (LinedUpXWithPlayer() && LinedUpYWithPlayer())
                {
                    // Have we been in this state long enough?
                    stateTime -= (float)gT.ElapsedGameTime.TotalSeconds;
                    if (stateTime < 0)
                    {
                        // Is Player Attackable
                        if (!InLevel.Player1.IsAttackable)
                        {
                            GetRetreatTarget();
                            break;
                        }

                        // if (NoOtherEnemiesAttacking())
                        //{

                        // Its time to attack
                        texture          = Game1.SprAdonAttacks;
                        frameX           = 0;
                        frameY           = D_ATTACK01_COMBO1_FRAME_Y;
                        drawWidth        = D_WIDTH_COMBO1_ATTACK01;
                        drawHeight       = D_HEIGHT_COMBO1_ATTACK01;
                        originCharacters = new Vector2(drawWidth / 2, drawHeight);
                        SetDrawArea();
                        state = AdonCloseState.Attack;
                        SoundManager.PlaySound("ThrowPunch");

                        attackNumber = 1;
                        //this.IsAttacking = true;
                        //}
                    }
                }
                else
                {
                    // Not lined up with the player
                    state            = AdonCloseState.MoveTo;
                    frameX           = 0;
                    drawWidth        = DRAW_WIDTH_WALK;
                    originCharacters = new Vector2(drawWidth / 2, drawHeight);
                    return;
                }
                AnimateIdle(gT);
                break;
                #endregion

                #region Attacks

            case AdonCloseState.Attack:
                // Do Nothing
                switch (attackNumber)
                {
                case 1:         // Animate
                    AnimateAttack1(gT);
                    break;

                case 2:         // Animate
                    AnimateAttack2(gT);
                    break;

                case 3:         // Animate
                    AnimateAttack3(gT);
                    break;
                }
                break;
                #endregion

                #region Take Hit and Die Cycle
            case AdonCloseState.TakeHit:
                originCharacters = new Vector2((drawWidth / 2), drawHeight);
                AnimateTakeHit(gT);
                break;

            case AdonCloseState.TakeHitLowKick:
                originCharacters = new Vector2((drawWidth / 2), drawHeight);
                AnimateTakeHitKick(gT);
                break;

            case AdonCloseState.KnockedDown:
                originCharacters = new Vector2((drawWidth / 2), drawHeight);
                AnimateKnockDown(gT);
                break;

            case AdonCloseState.Down:
                stateTime += (float)gT.ElapsedGameTime.TotalSeconds;
                if (stateTime >= Actor.DOWN_TIME)
                {
                    // Set up Gettign Up Animation
                    state            = AdonCloseState.GettingUp;
                    currentFrameTime = 0f;
                    frameX           = 0;
                    frameY           = 6;
                    drawWidth        = DRAW_WIDTH_GETTINGUP;
                    drawHeight       = DRAW_HEIGHT_NORMAL;
                    originCharacters = new Vector2(drawWidth / 2, drawHeight);
                    SetDrawArea();
                }
                break;

            case AdonCloseState.GettingUp:
                AnimateGettingUp(gT);
                break;

            case AdonCloseState.Dying:
                // Flash the Body a few times
                stateTime -= (float)gT.ElapsedGameTime.TotalSeconds;
                if (stateTime <= 0)
                {
                    stateTime = ENEMY_DEATH_FLASH_TIME;
                    IsVisible = !IsVisible;
                    DeathFlashes++;

                    if (DeathFlashes >= 8)
                    {
                        // Will I drop a item
                        if (Game1.Random.NextDouble() >= 0.9f)     // 0.9 = 10% chance of dropping item
                        {
                            this.InLevel.GameItems.Add(
                                new PickUpStone(this.InLevel, this.Position));
                        }
                        // Actor is Dead
                        RemoveActorFromLevel();
                    }
                }
                break;

                #endregion

                #region Waiting

            case AdonCloseState.Wait:

                AnimateWaiting(gT);

                break;

                #endregion

                #region CutScene Walking out
            case AdonCloseState.Level01Intro:
                if (this.Position != targetPosition)
                {
                    // Move to the destination
                    LineUpXTargetPos();
                    LineUpYTargetPos();
                    AnimateWalking(gT);
                }
                else
                {
                    RemoveActorFromLevel();
                }
                break;
                #endregion
            }
        }