Example #1
0
        // TODO: Ledges, waterfall, etc
        public virtual bool Move(FacingDirection facing, bool run, bool ignoreLegalCheck)
        {
            bool surfing = IsSurfing();

            IsMovingSelf  = true;
            MovementTimer = 0;
            Facing        = facing;
            PrevPos       = Pos;
            bool success = ignoreLegalCheck || IsMovementLegal(facing, CanSurf());

            if (success)
            {
                MovementSpeed = run ? RunningMovementSpeed : NormalMovementSpeed;
                ApplyMovement(facing);
                UpdateXYProgress();
                CameraObj.CopyMovementIfAttachedTo(this);
                if (surfing && !Overworld.IsSurfable(GetBlock().BlocksetBlock.Behavior))
                {
                    OnDismountFromWater();
                }
            }
            else
            {
                MovementSpeed = NormalMovementSpeed * BlockedMovementSpeedModifier;
            }
            return(success);
        }
Example #2
0
        public void Warp(IWarp warp)
        {
            var  map = Map.LoadOrGet(warp.DestMapId);
            int  x   = warp.DestX;
            int  y   = warp.DestY;
            byte e   = warp.DestElevation;

            Map.Layout.Block block = map.GetBlock_CrossMap(x, y, out map); // GetBlock_CrossMap in case our warp is actually in a connection for some reason
            // Facing is of the original direction unless the block behavior says otherwise
            // All QueuedScriptMovements will be run after the warp is complete
            switch (block.BlocksetBlock.Behavior)
            {
            case BlocksetBlockBehavior.Warp_WalkSouthOnExit:
            {
                Facing = FacingDirection.South;
                QueuedScriptMovements.Enqueue(ScriptMovement.Walk_S);
                break;
            }

            case BlocksetBlockBehavior.Warp_NoOccupancy_S:
            {
                Facing = FacingDirection.North;
                y--;
                break;
            }
            }
            UpdateMap(map);
            Pos.X         = x;
            Pos.Y         = y;
            Pos.Elevation = e;
            PrevPos       = Pos;
            if (CameraObj.CameraAttachedTo == this)
            {
                CameraObj.CameraCopyMovement();
            }
        }
Example #3
0
        // TODO: Ledges, waterfall, etc
        public virtual bool Move(FacingDirection facing, bool run, bool ignoreLegalCheck)
        {
            CanMove        = false;
            _movementTimer = 0;
            _movementSpeed = run ? RunningMovementSpeed : NormalMovementSpeed;
            Facing         = facing;
            PrevPos        = Pos;
            bool success = ignoreLegalCheck || IsMovementLegal(facing);

            if (success)
            {
                ApplyMovement(facing);
                UpdateXYProgress();
                if (CameraObj.CameraAttachedTo == this)
                {
                    CameraObj.CameraCopyMovement();
                }
            }
            else
            {
                _movementSpeed *= BlockedMovementSpeedModifier;
            }
            return(success);
        }
Example #4
0
        public static unsafe void Render(uint *bmpAddress, int bmpWidth, int bmpHeight)
        {
            // Gather variables we need to draw everything at the right coordinates
            CameraObj  camera       = Camera;
            Position   cameraPos    = camera.Pos;
            int        cameraPixelX = (cameraPos.X * Overworld.Block_NumPixelsX) - (bmpWidth / 2) + (Overworld.Block_NumPixelsX / 2) + camera._progressX + CameraOfsX;
            int        cameraPixelY = (cameraPos.Y * Overworld.Block_NumPixelsY) - (bmpHeight / 2) + (Overworld.Block_NumPixelsY / 2) + camera._progressY + CameraOfsY;
            Map        cameraMap    = camera.Map;
            List <Obj> objs         = cameraMap.Objs;
            int        numObjs      = objs.Count;
            int        xpBX         = cameraPixelX % Overworld.Block_NumPixelsX;
            int        ypBY         = cameraPixelY % Overworld.Block_NumPixelsY;
            int        startBlockX  = (cameraPixelX / Overworld.Block_NumPixelsX) - (xpBX >= 0 ? 0 : 1);
            int        startBlockY  = (cameraPixelY / Overworld.Block_NumPixelsY) - (ypBY >= 0 ? 0 : 1);
            int        numBlocksX   = (bmpWidth / Overworld.Block_NumPixelsX) + (bmpWidth % Overworld.Block_NumPixelsX == 0 ? 0 : 1);
            int        numBlocksY   = (bmpHeight / Overworld.Block_NumPixelsY) + (bmpHeight % Overworld.Block_NumPixelsY == 0 ? 0 : 1);
            int        endBlockX    = startBlockX + numBlocksX + (xpBX == 0 ? 0 : 1);
            int        endBlockY    = startBlockY + numBlocksY + (ypBY == 0 ? 0 : 1);
            int        startPixelX  = xpBX >= 0 ? -xpBX : -xpBX - Overworld.Block_NumPixelsX;
            int        startPixelY  = ypBY >= 0 ? -ypBY : -ypBY - Overworld.Block_NumPixelsY;

            // Loop each elevation
            for (byte e = 0; e < Overworld.NumElevations; e++)
            {
                // Draw blocks
                int curPixelX = startPixelX;
                int curPixelY = startPixelY;
                for (int blockY = startBlockY; blockY < endBlockY; blockY++)
                {
                    for (int blockX = startBlockX; blockX < endBlockX; blockX++)
                    {
                        Map.Layout.Block block = cameraMap.GetBlock_CrossMap(blockX, blockY, out _);
                        if (block != null)
                        {
                            Blockset.Block b = block.BlocksetBlock;
                            void Draw(Blockset.Block.Tile[] subLayers, int tx, int ty)
                            {
                                int numSubLayers = subLayers.Length;

                                for (int t = 0; t < numSubLayers; t++)
                                {
                                    Blockset.Block.Tile tile  = subLayers[t];
                                    Tileset.Tile        ttile = tile.TilesetTile;
                                    RenderUtils.DrawBitmap(bmpAddress, bmpWidth, bmpHeight, tx, ty, ttile.AnimBitmap ?? ttile.Bitmap, Overworld.Tile_NumPixelsX, Overworld.Tile_NumPixelsY, xFlip: tile.XFlip, yFlip: tile.YFlip);
                                }
                            }

                            for (int by = 0; by < Overworld.Block_NumTilesY; by++)
                            {
                                Blockset.Block.Tile[][][] arrY = b.Tiles[by];
                                int ty = curPixelY + (by * Overworld.Tile_NumPixelsY);
                                for (int bx = 0; bx < Overworld.Block_NumTilesX; bx++)
                                {
                                    Draw(arrY[bx][e], curPixelX + (bx * Overworld.Tile_NumPixelsX), ty);
                                }
                            }
                        }
                        curPixelX += Overworld.Block_NumPixelsX;
                    }
                    curPixelX  = startPixelX;
                    curPixelY += Overworld.Block_NumPixelsY;
                }

                // Draw VisualObjs
                // TODO: They will overlap each other regardless of y coordinate because of the order of the list
                // TODO: Objs from other maps
                for (int i = 0; i < numObjs; i++)
                {
                    Obj o = objs[i];
                    if (o.Pos.Elevation == e && o is VisualObj v)
                    {
                        v.Draw(bmpAddress, bmpWidth, bmpHeight, startBlockX, startBlockY, startPixelX, startPixelY);
                    }
                }
            }
        }