Exemplo n.º 1
0
        public void updateAnimations(GameTime gameTime)
        {
            if (nextAnimation != null)
            {
                if (activeAnimation.animation.activeFrameNumber == activeAnimation.animation.Amount - 1 && !activeAnimation.animation.Looped)
                {
                    activeAnimation.isActive = false;
                    activeAnimation.animation.activeFrameNumber = 0;

                    activeAnimation.animation.PlayedOnce = false;
                    activeAnimation          = nextAnimation;
                    activeAnimation.isActive = true;
                    activeAnimation.animation.activeFrameNumber = 0;
                    activeAnimation.animation.start();
                    nextAnimation = null;
                }
            }



            HandFlat.Update(gameTime);
            attackSnip.Update(gameTime);
            attackFist.Update(gameTime);
            attackWave.Update(gameTime);
            idleState.Update(gameTime);
            HandRopeDown.Update(gameTime);
            HandRopeLetGo.Update(gameTime);
        }
Exemplo n.º 2
0
        public override void Update(GameTime gameTime)
        {
            UpdateAttackCooldown(gameTime);

            switch (currentBossState)
            {
            case State.AttackMoving:
            {
                UpdateAttackMovement(gameTime);

                //    if ((fixture.Body.GetLinearVelocityFromWorldPoint(new Vector2(0, 0)).X == 0) && (fixture.Body.GetLinearVelocityFromWorldPoint(new Vector2(0, 0)).Y == 0) && (fixture.Body.Position.Y > 6) && (mayAttack == true))
                if ((fixture.Body.Position.Y > 6.2f) && (mayAttack == true))
                {
                    fixture.Body.ResetDynamics();
                    nextAnimation    = attackWave;
                    currentBossState = State.Attacking;
                    mayAttack        = false;
                    Console.WriteLine("StateSwitch: " + currentBossState);
                }


                if (numberOfAttacks == 0)
                {
                    currentBossState = State.Rope1;
                }


                break;
            }

            case State.Attacking:
            {
                if (activeAnimation.animation.activeFrameNumber == activeAnimation.animation.Amount - 1 && !activeAnimation.animation.Looped)
                {
                    currentBossState = State.AttackMoving;
                    Console.WriteLine("StateSwitch: " + currentBossState);
                    nextAnimation = idleState;

                    activeAnimation.animation.PlayedOnce = false;
                    numberOfAttacks--;
                }



                break;
            }

            case State.Rope1:
            {
                if (!targetPositionReached && !HandInPosition)
                {
                    targetPosition = r1.lastBody.Position - new Vector2(1.0f, -6.0f);
                    this.UpdateScriptedEventPosition(gameTime);
                }
                else
                {
                    HandInPosition = true;
                    if (!animationStarted)
                    {
                        nextAnimation         = HandRopeDown;
                        animationStarted      = true;
                        RopeOffset            = r1.chainLinks[0].Position - activeAnimation.activeFixture.Body.Position;
                        targetPositionReached = false;
                    }

                    if (activeAnimation.animation.activeFrameNumber == activeAnimation.animation.Amount - 1)
                    {
                        if (!targetPositionReached)
                        {
                            targetPosition = new Vector2(this.fixture.Body.Position.X, 6);
                            this.UpdateScriptedEventPosition(gameTime);


                            foreach (Body bod in r1.chainLinks)
                            {
                                bod.Position = new Vector2(bod.Position.X, activeAnimation.activeFixture.Body.Position.Y - (RopeOffset.Y - (r1.chainLinks[0].Position.Y - bod.Position.Y)));
                            }

                            // r1.chainLinks[0].Position = activeAnimation.activeFixture.Body.Position;
                        }
                        else
                        {
                            //    r1.chainLinks[0].IsStatic = false;
                            currentBossState = State.Attacking;
                        }
                    }
                }


                break;
            }
            }


            updateAnimations(gameTime);



            // UpdateScriptedEventPosition(gameTime);
        }
Exemplo n.º 3
0
        public override void Initialise()
        {
            //The main fixture onto which all the forces will be applied
            fixture = FixtureFactory.CreateRectangle(Level.Physics, 700 / Level.PixelPerMeter, 300 / Level.PixelPerMeter, 1.0f);
            fixture.Body.BodyType       = BodyType.Dynamic;
            fixture.Body.FixedRotation  = true;
            fixture.Friction            = 0.0f;
            fixture.Body.Mass           = 0.0f;
            fixture.Body.IgnoreGravity  = true;
            fixture.CollisionCategories = CollisionCategory.Cat14;

            this.position         = new Vector2(5, 3);
            fixture.Body.Position = position;
            fixture.IsSensor      = false;



            //All the Animations
            idleState               = new ScalingAnimation(this, new Animation());
            idleState.scale         = new Vector2(2.85714286f, 2.85714286f);
            idleState.PolygonOffset = new Vector2(1.8f, 2.5f);
            idleState.TextureOffset = new Vector2(2.0f * Level.PixelPerMeter, -12 * Level.PixelPerMeter);



            attackFist               = new ScalingAnimation(this, new Animation());
            attackFist.scale         = new Vector2(2.85714286f, 2.85714286f);
            attackFist.PolygonOffset = new Vector2(7.2f, 3.7f);
            attackFist.TextureOffset = new Vector2(-8.0f * Level.PixelPerMeter, -13 * Level.PixelPerMeter);

            attackWave               = new ScalingAnimation(this, new Animation());
            attackWave.scale         = new Vector2(2.85714286f, 2.85714286f);
            attackWave.PolygonOffset = new Vector2(10f, 3.7f);
            attackWave.TextureOffset = new Vector2(-12 * Level.PixelPerMeter, -13 * Level.PixelPerMeter);

            attackSnip               = new ScalingAnimation(this, new Animation());
            attackSnip.scale         = new Vector2(2.85714286f, 2.85714286f);
            attackSnip.PolygonOffset = new Vector2(9.2f, 3.7f);
            attackSnip.TextureOffset = new Vector2(-8.0f * Level.PixelPerMeter, -13 * Level.PixelPerMeter);



            throughTheRoof = new ScalingAnimation(this, new Animation());

            HandFlat               = new ScalingAnimation(this, new Animation());
            HandFlat.scale         = new Vector2(2.85714286f, 2.85714286f);
            HandFlat.PolygonOffset = new Vector2(6, 3.7f);
            HandFlat.TextureOffset = new Vector2(1 * Level.PixelPerMeter, -13 * Level.PixelPerMeter);



            HandRopeDown               = new ScalingAnimation(this, new Animation());
            HandRopeDown.scale         = new Vector2(2.85714286f, 2.85714286f);
            HandRopeDown.PolygonOffset = new Vector2(4.3f, 3.7f);
            HandRopeDown.TextureOffset = new Vector2(2.0f * Level.PixelPerMeter, -13 * Level.PixelPerMeter);


            HandRopeLetGo               = new ScalingAnimation(this, new Animation());
            HandRopeLetGo.scale         = new Vector2(2.85714286f, 2.85714286f);
            HandRopeLetGo.PolygonOffset = new Vector2(7.2f, 3.7f);
            HandRopeLetGo.TextureOffset = new Vector2(-5.0f * Level.PixelPerMeter, -13 * Level.PixelPerMeter);



            //Place Ropes Correctly

            r1 = new Rope(new Vector2(2.9f, -9), new Vector2(2.9f, -2));

            /*  r2 = new Rope(new Vector2(1, -5), new Vector2(1, -2));
             * r3 = new Rope(new Vector2(2, -5), new Vector2(2, -2));
             * r4 = new Rope(new Vector2(3, -5), new Vector2(3, -2));
             * r5 = new Rope(new Vector2(4, -5), new Vector2(4, -2));
             * r6 = new Rope(new Vector2(5, -5), new Vector2(5, -2));
             * r7 = new Rope(new Vector2(6, -5), new Vector2(6, -2));
             * r8 = new Rope(new Vector2(7, -5), new Vector2(7, -2));
             * r9 = new Rope(new Vector2(8, -5), new Vector2(8, -2));
             */



            //camera settings
            Camera.Scale         = 0.35f;
            Camera.fixedOnPlayer = false;
            Camera.Position      = new Vector2(-0.2f * Level.PixelPerMeter, 0);



            //Backup Cooldown for the Attack-Movement
            backupCooldown = 0.2f;
            attackCooldown = 5.0f;

            //Inital BossState
            currentBossState         = State.AttackMoving;
            activeAnimation          = idleState;
            activeAnimation.isActive = true;
            numberOfAttacks          = 1;
        }