Esempio n. 1
0
            protected override MovePart OnComplete(Actor self, Mobile mobile, Move parent)
            {
                var fromSubcellOffset = self.World.Map.OffsetOfSubCell(mobile.fromSubCell);
                var toSubcellOffset   = self.World.Map.OffsetOfSubCell(mobile.toSubCell);

                var nextCell = parent.PopPath(self, mobile);

                if (nextCell != null)
                {
                    if (IsTurn(mobile, nextCell.Value.First))
                    {
                        var nextSubcellOffset = self.World.Map.OffsetOfSubCell(nextCell.Value.Second);
                        var ret = new MoveFirstHalf(
                            move,
                            Util.BetweenCells(self.World, mobile.fromCell, mobile.toCell) + (fromSubcellOffset + toSubcellOffset) / 2,
                            Util.BetweenCells(self.World, mobile.toCell, nextCell.Value.First) + (toSubcellOffset + nextSubcellOffset) / 2,
                            mobile.Facing,
                            Util.GetNearestFacing(mobile.Facing, self.World.Map.FacingBetween(mobile.toCell, nextCell.Value.First, mobile.Facing)),
                            moveFraction - moveFractionTotal);

                        mobile.FinishedMoving(self);
                        mobile.SetLocation(mobile.toCell, mobile.toSubCell, nextCell.Value.First, nextCell.Value.Second);
                        return(ret);
                    }

                    parent.path.Add(nextCell.Value.First);
                }

                var ret2 = new MoveSecondHalf(
                    move,
                    Util.BetweenCells(self.World, mobile.fromCell, mobile.toCell) + (fromSubcellOffset + toSubcellOffset) / 2,
                    self.World.Map.CenterOfCell(mobile.toCell) + toSubcellOffset,
                    mobile.Facing,
                    mobile.Facing,
                    moveFraction - moveFractionTotal);

                mobile.EnteringCell(self);
                mobile.SetLocation(mobile.toCell, mobile.toSubCell, mobile.toCell, mobile.toSubCell);
                return(ret2);
            }
Esempio n. 2
0
            protected override MovePart OnComplete(Actor self, Mobile mobile, Move parent)
            {
                var fromSubcellOffset = MobileInfo.SubCellOffsets[mobile.fromSubCell];
                var toSubcellOffset   = MobileInfo.SubCellOffsets[mobile.toSubCell];

                var nextCell = parent.PopPath(self, mobile);

                if (nextCell != null)
                {
                    if (IsTurn(mobile, nextCell.Value.First))
                    {
                        var nextSubcellOffset = MobileInfo.SubCellOffsets[nextCell.Value.Second];
                        var ret = new MoveFirstHalf(
                            move,
                            Util.BetweenCells(mobile.fromCell, mobile.toCell) + (fromSubcellOffset + toSubcellOffset) / 2,
                            Util.BetweenCells(mobile.toCell, nextCell.Value.First) + (toSubcellOffset + nextSubcellOffset) / 2,
                            mobile.Facing,
                            Util.GetNearestFacing(mobile.Facing, Util.GetFacing(nextCell.Value.First - mobile.toCell, mobile.Facing)),
                            moveFraction - moveFractionTotal);

                        mobile.SetLocation(mobile.toCell, mobile.toSubCell, nextCell.Value.First, nextCell.Value.Second);
                        return(ret);
                    }

                    parent.path.Add(nextCell.Value.First);
                }

                var ret2 = new MoveSecondHalf(
                    move,
                    Util.BetweenCells(mobile.fromCell, mobile.toCell) + (fromSubcellOffset + toSubcellOffset) / 2,
                    mobile.toCell.CenterPosition + toSubcellOffset,
                    mobile.Facing,
                    mobile.Facing,
                    moveFraction - moveFractionTotal);

                mobile.EnteringCell(self);
                mobile.SetLocation(mobile.toCell, mobile.toSubCell, mobile.toCell, mobile.toSubCell);
                return(ret2);
            }