/// <summary> /// Creates this controller /// </summary> /// <param name="user">Command user that this controller listens to</param> /// <param name="actionTarget">Entity actions are sent to this object</param> public UserRtsController( CommandUser user, IMessageHandler actionTarget ) { m_Target = actionTarget; CommandList entityCommandList = CommandListManager.Instance.FindOrCreateFromEnum( typeof( EntityCommands ) ); user.AddActiveListener( entityCommandList, OnCommandActive ); }
/// <summary> /// Setup constructor /// </summary> /// <param name="camera">The camera to control</param> /// <param name="user">Control will respond to commands from this user</param> public FollowCameraControl( FollowCamera camera, CommandUser user ) { m_Camera = camera; // Create an input listener CommandInputListener listener = new CommandInputListener( ); listener.CommandListEnumType = typeof( Commands ); listener.User = user; AddChild( listener ); }
private ICommandUser CreateCommandUser(User item) { ICommandUser commandUser = new CommandUser(); commandUser.ID = item.ID.ToString(); commandUser.IsAuthenticated = true; commandUser.Username = item.Name; commandUser.UserData = item; commandUser.UserRoles.AddRange(item.Roles.Select(x => x.RoleName)); return(commandUser); }
public Sign(string login, string password, CommandUser command) { this.login = login; this.password = password; this.command = command; }
private void GameViewForm_Load( object sender, EventArgs e ) { // Add a performance display Scene.Objects.Add( new PerformanceDisplay( ) ); DebugInfo.ShowFps = true; DebugInfo.ShowMemoryWorkingSet = true; DebugInfo.ShowMemoryPeakWorkingSet = true; // Load in the game viewer LoadParameters loadArgs = new LoadParameters( ); loadArgs.Properties.Add( "Users", m_Users ); m_Viewer = ( Viewer )AssetManager.Instance.Load( m_Setup.ViewerSource, loadArgs ); gameDisplay.AddViewer( m_Viewer ); // Get start points IEnumerable< PlayerStart > startPoints = Scene.Objects.GetAllOfType<PlayerStart>( ); // Setup players InputContext inputContext = new InputContext( m_Viewer ); m_Users = new CommandUser[ m_Setup.NumberOfPlayers ]; for ( int playerIndex = 0; playerIndex < m_Setup.NumberOfPlayers; ++playerIndex ) { PlayerSetup player = m_Setup.Players[ playerIndex ]; // Find the start position for this player PlayerStart playerStart = null; foreach ( PlayerStart startPoint in startPoints ) { if ( startPoint.PlayerIndex == playerIndex ) { playerStart = startPoint; break; } } if ( playerStart == null ) { throw new InvalidOperationException( "No player start available for player " + playerIndex ); } // Load game inputs m_Users[ playerIndex ] = new CommandUser( ); CommandInputTemplateMap gameInputs = ( CommandInputTemplateMap )AssetManager.Instance.Load( player.CommandSource ); gameInputs.BindToInput( inputContext, m_Users[ playerIndex ] ); // Load the player's character object character = AssetManager.Instance.Load( player.CharacterSource ); Scene.Objects.Add( ( IUnique )character ); // Place the character at the start position IPlaceable placeable = Rb.Core.Components.Parent.GetType<IPlaceable>( character ); if ( placeable != null ) { placeable.Position = playerStart.Position; } // Hack... if the viewer camera is a follow camera, force it to look at the player if ( ( m_Setup.NumberOfPlayers == 1 ) && ( m_Viewer.Camera is FollowCamera ) ) { FollowCamera camera = ( FollowCamera )m_Viewer.Camera; // Follow the player camera.Target = ( IPlaceable )character; // Add a camera controller FollowCameraControl cameraControl = new FollowCameraControl( camera, m_Users[ 0 ] ); m_Viewer.Camera.AddChild( cameraControl ); } IParent characterParent = ( IParent )character; characterParent.AddChild( new UserController( m_Users[ playerIndex ], ( IMessageHandler )character ) ); } // Start rendering the scene m_Viewer.Renderable = Scene; // Kick off the update service... (TODO: AP: Not a very good hack) IUpdateService updater = Scene.GetService< IUpdateService >( ); if ( updater != null ) { updater.Start( ); } playButton.Enabled = false; }