public void LocationTurnTo(PredefinedDirection dir) { if (!location.IsSittingDown) { if (dir == PredefinedDirection.NO_DIRECTION) return; PredefinedActorCommand command = PredefinedActorCommand.turn_n; short rotation = 0; switch (dir) { case(PredefinedDirection.N): command = PredefinedActorCommand.turn_n; rotation = 0; break; case(PredefinedDirection.NE): command = PredefinedActorCommand.turn_ne; rotation = 45; break; case (PredefinedDirection.E): command = PredefinedActorCommand.turn_e; rotation = 90; break; case (PredefinedDirection.SE): command = PredefinedActorCommand.turn_se; rotation = 135; break; case (PredefinedDirection.S): command = PredefinedActorCommand.turn_s; rotation = 180; break; case (PredefinedDirection.SW): command = PredefinedActorCommand.turn_sw; rotation = 225; break; case (PredefinedDirection.W): command = PredefinedActorCommand.turn_w; rotation = 270; break; case (PredefinedDirection.NW): command = PredefinedActorCommand.turn_nw; rotation = 315; break; } if (location.Rotation != rotation) { // Rotate only if new rotation different location.Rotation = rotation; SendAnimationCommand(command); } } }
public void LocationTakeStep(PredefinedDirection dir) { if (!location.IsSittingDown) { if (dir == PredefinedDirection.NO_DIRECTION) return; AddActorCommandOutgoingMessage msgAddActorCommand = (AddActorCommandOutgoingMessage)OutgoingMessagesFactory.Create(OutgoingMessageType.ADD_ACTOR_COMMAND); msgAddActorCommand.EntityID = EntityID; switch (dir) { case(PredefinedDirection.N): msgAddActorCommand.Command = PredefinedActorCommand.move_n; location.Rotation = 0; location.Y++; break; case(PredefinedDirection.NE): msgAddActorCommand.Command = PredefinedActorCommand.move_ne; location.Rotation = 45; location.Y++; location.X++; break; case (PredefinedDirection.E): msgAddActorCommand.Command = PredefinedActorCommand.move_e; location.Rotation = 90; location.X++; break; case (PredefinedDirection.SE): msgAddActorCommand.Command = PredefinedActorCommand.move_se; location.Rotation = 135; location.Y--; location.X++; break; case (PredefinedDirection.S): msgAddActorCommand.Command = PredefinedActorCommand.move_s; location.Rotation = 180; location.Y--; break; case (PredefinedDirection.SW): msgAddActorCommand.Command = PredefinedActorCommand.move_sw; location.Rotation = 225; location.Y--; location.X--; break; case (PredefinedDirection.W): msgAddActorCommand.Command = PredefinedActorCommand.move_w; location.Rotation = 270; location.X--; break; case (PredefinedDirection.NW): msgAddActorCommand.Command = PredefinedActorCommand.move_nw; location.Rotation = 315; location.Y++; location.X--; break; } PutMessageIntoMyAndObserversQueue(msgAddActorCommand); } }