コード例 #1
0
        public override void Behaviour(float fElapsedTime, DynamicGameObject player = null)
        {
            if (Health <= 0)
            {
                vx             = 0;
                vy             = 0;
                SolidVsDynamic = false;
                IsAttackable   = false;
                Patrol         = Enum.Actions.Left;
                return;
            }

            if (player != null)
            {
                // patrol (and fear of heights)

                StateTick -= fElapsedTime;

                if (StateTick <= 0.0f) // för att inte göra beslut så ofta.
                {
                    if (Patrol == Enum.Actions.Left)
                    {
                        vx = -1;
                    }
                    else if (Patrol == Enum.Actions.Right)
                    {
                        vx = 1;
                    }
                    else
                    {
                        vy = 0;
                        vx = 0;
                    }


                    StateTick += 1.0f;
                }
            }
        }
コード例 #2
0
 public override void Update(float elapsedTime, DynamicGameObject player = null)
 {
     //does nothing
 }
コード例 #3
0
 public virtual void OnInteract(DynamicGameObject player = null)
 {
 }
コード例 #4
0
 /// <summary>
 /// Elapsed time
 /// </summary>
 /// <param name="el"></param>
 public virtual void Update(float elapsedTime, DynamicGameObject player = null)
 {
 }
コード例 #5
0
        public override void Update(float elapsedTime, DynamicGameObject player)
        {
            if (KnockBackTimer > 0.0f)
            {
                // Flyttas till vänster eller höger, sätt hjälten till motsatt riktning

                if (vx < 0)
                {
                    TurnedTo = Enum.PlayerOrientation.Right;
                }
                else
                {
                    TurnedTo = Enum.PlayerOrientation.Left;
                }

                vx               = KnockBackDX * 3.0f;
                vy               = KnockBackDY * 2.0f;
                IsAttackable     = false;
                KnockBackTimer  -= elapsedTime;
                sprGraphicsState = Enum.GraphicsState.TakingDamage;

                if (KnockBackTimer <= 0.0f)
                {
                    StateTick    = 0.0f;
                    Controllable = true;
                    IsAttackable = true;
                }
            }
            else
            {
                //if (IsHero)
                //{


                // En bubbla av tid som förflyttar sig oberoende av resten av spelets state. Skapar ett slags pendel, gissar jag på.
                Timer += elapsedTime;
                if (Timer <= 0.1f)
                {
                    //GraphicCounter = 0;
                    GraphicCounter = 1;
                }
                else if (Timer <= 0.2f)
                {
                    //GraphicCounter = 1;
                    GraphicCounter = 2;
                }
                else if (Timer <= 0.3f)
                {
                    //GraphicCounter = 2;
                    GraphicCounter = 3;
                }
                //else if (Timer <= 0.4f)
                //{
                //    //GraphicCounter = 3;
                //    GraphicCounter = 4;

                //}
                //else if (Timer <= 0.5f)
                //{
                //    GraphicCounter = 4;
                //    Timer = 0.0f;
                //}
                else
                {
                    GraphicCounter = 4;
                    Timer          = 0.0f;
                }
                //Timer += elapsedTime;
                //if (Timer >= 0.2f)
                //{
                //    Timer -= 0.2f;

                //    // tänkt att "ocilera" (vad fan det nu är på svenska). ticka mellan 0 och 1
                //    GraphicCounter++;
                //    GraphicCounter %= 2;
                //}


                //   }


                if (Math.Abs(vy) > 0 && !IsIdle)
                {
                    if (vy < 0)
                    {
                        sprGraphicsState = Enum.GraphicsState.Jumping;
                    }
                    else
                    {
                        sprGraphicsState = Enum.GraphicsState.Falling;
                    }
                }
                else if (Math.Abs(vx) > 1.0f)
                {
                    sprGraphicsState = Enum.GraphicsState.Walking;
                }
                else
                {
                    sprGraphicsState = Enum.GraphicsState.Standing;
                }

                if (Health <= 0)
                {
                    sprGraphicsState = Enum.GraphicsState.Dead;
                }


                if (vx < -0.1f)
                {
                    FacingDirection = Enum.Direction.WEST;
                    TurnedTo        = Enum.PlayerOrientation.Left;
                }
                if (vx > 0.1f)
                {
                    FacingDirection = Enum.Direction.EAST;
                    TurnedTo        = Enum.PlayerOrientation.Right;
                }
                if (vy < -0.1f)
                {
                    FacingDirection = Enum.Direction.NORTH;
                }
                if (vy > 0.1f)
                {
                    FacingDirection = Enum.Direction.SOUTH;
                }

                Behaviour(elapsedTime, player);
            }
        }
コード例 #6
0
 public virtual void Behaviour(float fElapsedTime, DynamicGameObject player = null)
 {
 }
コード例 #7
0
        public override void Behaviour(float fElapsedTime, DynamicGameObject player = null)
        {
            if (Health <= 0)
            {
                vx             = 0;
                vy             = 0;
                SolidVsDynamic = false;
                IsAttackable   = false;
                // Patrol = Enum.Actions.Left;
                return;
            }



            if (player != null)
            {
                Ticker++;

                StateTick -= fElapsedTime;



                if (StateTick <= 0.0f) // för att inte göra beslut så ofta.
                {
                    StateTick += 1.0f;
                }



                //if (!IsAttackable)
                //{
                //    Ticker = 0;
                //}

                //
                //if (State == Enum.LastStage.StayUp && Ticker < 120)
                //{
                //    State = Enum.LastStage.MovingDown;
                //}
                //else if (State == Enum.LastStage.MovingDown && Ticker > 120)
                //{
                //    State = Enum.LastStage.StayDown;
                //}
                //else if (State == Enum.LastStage.StayDown && Ticker > 150)
                //{
                //    State = Enum.LastStage.MovingUp;
                //}
                //else if (State == Enum.LastStage.MovingUp && Ticker > 270)
                //{
                //    State = Enum.LastStage.StayUp;
                //}
                //else if (Ticker >= 300)
                //{
                //    Ticker = 0;
                //}
                if (Ticker < 60)
                {
                    State = Enum.LastStage.MovingDown;
                }
                else if (Ticker < 120)
                {
                    State = Enum.LastStage.MovingUp;

                    if (Ticker < 118)
                    {
                        TurnedTo = Enum.PlayerOrientation.Left;
                    }
                }
                else if (Ticker < 160)
                {
                    TurnedTo = Enum.PlayerOrientation.Right;
                }
                else if (Ticker >= 180)
                {
                    Ticker = 0;
                }



                //



                if (py < 12 || py > 13)
                {
                    if (py < 12)
                    {
                        py = 12;
                    }
                    if (py > 13)
                    {
                        py = 13;
                    }
                }

                if (State == Enum.LastStage.MovingDown)
                {
                    if (vy <= 0)
                    {
                    }
                    vy = 2;

                    //if (py != 13)
                    //{
                    //    //py = py + 0.20f;
                    //    py = 13;
                    //}
                }
                else if (State == Enum.LastStage.MovingUp)
                {
                    if (vy >= 0)
                    {
                    }
                    vy = -2;
                }



                vx = 0;
                if (py <= FromCor)
                {
                    vy = 0;
                    py = 12;
                }
                if (py >= ToCor)
                {
                    vy = 0;
                    py = 13;
                }


                //reset IsAttackable
                if (!IsAttackable && py == 13)
                {
                    IsAttackable = true;
                }


                // Switch X
                if (py == 13.0f)
                {
                    Core.Aggregate.Instance.IsUnderGround = true;
                    Core.Aggregate.Instance.IsMoving      = false;
                }
                else if (py == 12.0f)
                {
                    Core.Aggregate.Instance.IsAboveGround = true;
                    Core.Aggregate.Instance.IsMoving      = false;
                }
                else
                {
                    Core.Aggregate.Instance.IsMoving      = true;
                    Core.Aggregate.Instance.IsUnderGround = false;
                    Core.Aggregate.Instance.IsAboveGround = false;
                }



                //if (State == Enum.LastStage.StayUp)
                //{
                //    py = 12.0f;
                //}
                //else if (State == Enum.LastStage.MovingUp)
                //{
                //    if (py > 12.0f)
                //    {
                //        py = py - 0.025f;
                //    }
                //    else
                //    {
                //        py = 12.0f;
                //    }
                //}
                //else if (State == Enum.LastStage.StayDown)
                //{
                //    py = 13.0f;
                //}
                //else if (State == Enum.LastStage.MovingDown)
                //{
                //    if (py < 13.0f)
                //    {
                //        py = py + 0.025f;
                //    }
                //    else
                //    {
                //        py = 13.0f;
                //    }
                //}
            }
        }
コード例 #8
0
        public override void Behaviour(float fElapsedTime, DynamicGameObject player = null)
        {
            if (Health <= 0)
            {
                vx             = 0;
                vy             = 0;
                SolidVsDynamic = false;
                IsAttackable   = false;
                return;
            }

            //Temp, för test i demo endast. Byt ut när boss är bra först

            if (player != null)
            {
                Ticker++;

                StateTick -= fElapsedTime;

                if (StateTick <= 0.0f) // för att inte göra beslut så ofta.
                {
                    StateTick += 1.0f;
                }



                if (Ticker < 60)
                {
                    State = Enum.LastStage.MovingDown;
                }
                else if (Ticker < 120)
                {
                    State = Enum.LastStage.MovingUp;
                }
                else if (Ticker >= 180)
                {
                    Ticker = 0;
                }



                if (py < 12 || py > 13)
                {
                    if (py < 12)
                    {
                        py = 12;
                    }
                    if (py > 13)
                    {
                        py = 13;
                    }
                }

                if (State == Enum.LastStage.MovingDown)
                {
                    if (vy <= 0)
                    {
                    }
                    vy = 2;

                    //if (py != 13)
                    //{

                    //    py = 13;
                    //}
                }
                else if (State == Enum.LastStage.MovingUp)
                {
                    if (vy >= 0)
                    {
                    }
                    vy = -2;
                }



                vx = 0;
                if (py <= FromCor)
                {
                    vy = 0;
                    py = 12;
                }
                if (py >= ToCor)
                {
                    vy = 0;
                    py = 13;
                }
            }
            //end temp
        }
コード例 #9
0
        public override void Behaviour(float fElapsedTime, DynamicGameObject player = null)
        {
            if (Health <= 0)
            {
                vx             = 0;
                vy             = 0;
                SolidVsDynamic = false;
                IsAttackable   = false;
                return;
            }

            if (player != null)
            {
                // För att jaga player.

                // no default behaviour
                // Check if player is nearby
                float fTargetX  = player.px - px;
                float fTargetY  = player.py - py;
                float fDistance = (float)Math.Sqrt(fTargetX * fTargetX + fTargetY * fTargetY);

                StateTick -= fElapsedTime;

                if (StateTick <= 0.0f) // för att inte göra beslut så ofta.
                {
                    if (fDistance < 6.0f)
                    {
                        Ticker = 0;

                        vx = (fTargetX / fDistance) * 2.0f;
                        // vy = (fTargetY / fDistance) * 2.0f;

                        //if (fDistance < 1.5f) // för att attakera med projektil
                        //    PerformAttack();
                    }
                    else
                    {
                        vx = 0;
                        vy = 0;
                        Ticker++;
                    }

                    StateTick += 1.0f;


                    // enkel hantera om idle
                    if (Ticker > 7)
                    {
                        var vändåt = GetFacingDirection();
                        //FacingDirection = Enum.Direction.EAST;

                        if (vändåt == 1)
                        {
                            //vänster Enum.Direction.WEST
                            vx = 0.12f;
                        }
                        else if (vändåt == 3)
                        {
                            // höger Enum.Direction.EAST
                            vx = -0.12f;
                        }

                        Ticker = 0;
                    }
                }
            }
        }