Example #1
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 #2
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);
        }