コード例 #1
0
 public void ResetPos()
 {
     while (GamePlay.Collided(this, 0, LastDir))
     {
         int rand = Globals.gen.Next(0, 5);
         if (rand == 0)
         {
             OffSet.X += 1;
         }
         else if (rand == 1)
         {
             OffSet.X -= 1;
         }
         else if (rand == 2)
         {
             OffSet.Y += 1;
         }
         else
         {
             OffSet.Y -= 1;
         }
         SetPos();
     }
     Game.SetScreenByPlayerPos();
 }
コード例 #2
0
        public void Move()
        {
            if (IsCasting || GamePlay.Collided(this, Speed, MoveDir))
            {
                return;
            }

            if (MoveDir == Dir.Up)
            {
                OffSet.Y -= Speed;
                if (OffSet.Y <= -Globals.TileSize)
                {
                    CurPos.Y -= 1;
                    OffSet.Y  = 0;
                    if (this == Game.Player && Game.World.TileList[CurPos.X, CurPos.Y].StepTrigger)
                    {
                        TriggerHandler.HandleTriggers(Game.World.TileList[CurPos.X, CurPos.Y].Script);
                    }
                }
            }
            else if (MoveDir == Dir.Down)
            {
                OffSet.Y += Speed;
                if (OffSet.Y >= Globals.TileSize)
                {
                    CurPos.Y += 1;
                    OffSet.Y  = 0;
                    if (this == Game.Player && Game.World.TileList[CurPos.X, CurPos.Y].StepTrigger)
                    {
                        TriggerHandler.HandleTriggers(Game.World.TileList[CurPos.X, CurPos.Y].Script);
                    }
                }
            }
            else if (MoveDir == Dir.Left)
            {
                OffSet.X -= Speed;
                if (OffSet.X <= -Globals.TileSize)
                {
                    CurPos.X -= 1;
                    OffSet.X  = 0;
                    if (this == Game.Player && Game.World.TileList[CurPos.X, CurPos.Y].StepTrigger)
                    {
                        TriggerHandler.HandleTriggers(Game.World.TileList[CurPos.X, CurPos.Y].Script);
                    }
                }
            }
            else if (MoveDir == Dir.Right)
            {
                OffSet.X += Speed;
                if (OffSet.X >= Globals.TileSize)
                {
                    CurPos.X += 1;
                    OffSet.X  = 0;
                    if (this == Game.Player && Game.World.TileList[CurPos.X, CurPos.Y].StepTrigger)
                    {
                        TriggerHandler.HandleTriggers(Game.World.TileList[CurPos.X, CurPos.Y].Script);
                    }
                }
            }
        }