Пример #1
0
        public virtual void Update(Vector2 a_offset, SquareGrid a_grid)
        {
            if (HSpeed > 0)
            {
                Ori = GameGlobals.Orientation.RIGHT;
            }
            else if (HSpeed < 0)
            {
                Ori = GameGlobals.Orientation.LEFT;
            }

            Vector4 boundingBox = BoundingBox;

            List <GridLocation> botSlots = a_grid.GetBotSlots(boundingBox);

            OnGround = IsOnGround(a_grid, boundingBox, botSlots);

            if (VSpeed < 0)
            {
                List <GridLocation> topSlots = a_grid.GetTopSlots(boundingBox);
                Jump(a_grid, boundingBox, topSlots);
            }
            if (!IgnoringPhysics)
            {
                GravityEffect(a_grid, boundingBox, botSlots);
            }

            Position = new Vector2(Position.X, Position.Y + VSpeed);

            boundingBox.Z = Position.Y - (Dimension.Y / 2) * BoundingBoxOffset.Z;
            boundingBox.W = Position.Y + (Dimension.Y / 2) * BoundingBoxOffset.W;
            if (HSpeed < 0)
            {
                List <GridLocation> leftSlots = a_grid.GetLeftSlots(boundingBox);
                MoveLeft(a_grid, boundingBox, leftSlots);
            }
            else if (HSpeed > 0)
            {
                List <GridLocation> rightSlots = a_grid.GetRightSlots(boundingBox);
                MoveRight(a_grid, boundingBox, rightSlots);
            }

            if (Position.X + HSpeed < a_grid.TotalPhysicalDims.X && Position.X + HSpeed > a_grid.StartingPhysicalPos.X)
            {
                Position = new Vector2(Position.X + HSpeed, Position.Y);
            }

            if (Position.Y >= a_grid.TotalPhysicalDims.Y)
            {
                Dead = true;
            }

            base.Update(a_offset);
        }