public SpaceStateManager( MessageHandlerID messageHandlerId, IClientPlayerInfoManager clientPlayerInfoManager, IGlobalGameUISingleton globalGameUiSingleton, CollisionManager collisionManager, INetworkingService networkingService, PhysicsManager physicsManager, PlayerShipManager playerShipManager, ProjectileManager projectileManager, SelectionManager selectionManager, SimulationManager simulationManager, ClientShipManager clientShipManager, SpaceManager spaceManager, StructureFactoryManager structureFactoryManager, TargetingService targetingService, TeamManager teamManager, WarpHoleManager warpHoleManager, MessageService_ToServer messageService, FloatyAreaObjectManager floatyAreaObjectManager) : base(messageHandlerId, clientPlayerInfoManager, collisionManager, globalGameUiSingleton, networkingService, physicsManager, playerShipManager, projectileManager, selectionManager, clientShipManager, simulationManager, structureFactoryManager, warpHoleManager, teamManager, targetingService, floatyAreaObjectManager, messageService, GameStateType.Space, new SpaceViewModel(clientShipManager) ) { _spaceManager = spaceManager; _synchronousUpdateList.Add(_playerShipManager); }
bool ScreenElementsContains(Vector2 point) { if (gameSpeedButton.Contains(point)) { return(true); } else if (miniMap.Contains(point)) { return(true); } else if (SetupPhase && ShipSelectionRect.Contains(point)) { return(true); } else if (PlayerShipManager.HasSomethingSelected() && shipInfoPanel.ContainsMouse(point)) { return(true); } else if (fleetCombatInfoPanel.Contains(point)) { return(true); } return(false); }
public PlayableGameState(MessageHandlerID messageHandlerId, IClientPlayerInfoManager clientPlayerInfoManager, INetworkingService networkingService, CollisionManager collisionManager, PhysicsManager physicsManager, PlayerShipManager playerShipManager, ProjectileManager projectileManager, SelectionManager selectionManager, ClientShipManager clientShipManager, SimulationManager simulationManager, StructureFactoryManager structureFactoryManager, WarpHoleManager warpholeManager, TeamManager teamManager, TargetingService targetingService, FloatyAreaObjectManager floatyAreaObjectManager, MessageService_ToServer messageService, IStructureManager structureManager, GameStateType stateType ) : base(messageHandlerId, clientPlayerInfoManager, networkingService, messageService, playerShipManager, stateType) { _collisionManager = collisionManager; _physicsManager = physicsManager; _projectileManager = projectileManager; _selectionManager = selectionManager; _clientShipManager = clientShipManager; _simulationManager = simulationManager; _structureFactory = structureFactoryManager; _warpholeManager = warpholeManager; _teamManager = teamManager; _targetingService = targetingService; _floatyAreaObjectManager = floatyAreaObjectManager; StructureManager = structureManager; _networkingService.RegisterMessageHandler(this, _playableStateManager_MessageReceived); }
public RadarSpaceManager(ContentManager Content, SpriteBatch spriteBatch, GraphicsDevice graphics, BorderManager borderManager, PlayerShipManager playerShipManager, ProjectileManager projectileManager, SpaceObjectManager spaceObjectManager, ClientShipManager clientShipManager, WarpHoleManager warpholeManager, GameWindow gameWindow) { textFont = Content.Load <SpriteFont>(@"GUI/drawFont"); tex_Radar = Content.Load <Texture2D>(@"GUI/radar"); tex_DotW = Content.Load <Texture2D>(@"GUI/dot_w"); tex_OrbitalRing = Content.Load <Texture2D>(@"GUI/planetrings"); tex_Ship = Content.Load <Texture2D>(@"GUI/Minimap/Hud_ShipRadar"); tex_NetworkShip = Content.Load <Texture2D>(@"GUI/Minimap/otherShips"); tex_EdgeOfRadar = Content.Load <Texture2D>(@"GUI/Minimap/edgeofradar"); tex_Sun = Content.Load <Texture2D>(@"GUI/Minimap/sunMinimap"); tex_Warp = Content.Load <Texture2D>(@"GUI/Minimap/warp3"); _graphics = graphics; _content = Content; _borderManager = borderManager; _playerShipManager = playerShipManager; _projectileManager = projectileManager; _clientShipManager = clientShipManager; _radarCamera = new Camera2D(gameWindow); _spaceObjectManager = spaceObjectManager; _spriteBatch = spriteBatch; _warpholeManager = warpholeManager; radarWidth = 300; radarHeight = 300; radarTarget = new RenderTarget2D(spriteBatch.GraphicsDevice, radarWidth, radarHeight, false, SurfaceFormat.Color, DepthFormat.Depth24); // Adds all of the dynamically sized rings for Minimap. planetRings = new List <Texture2D>(); planetRings.Add(Content.Load <Texture2D>(@"GUI/Minimap/BaseRing_50px")); planetRings.Add(Content.Load <Texture2D>(@"GUI/Minimap/BaseRing_68px")); planetRings.Add(Content.Load <Texture2D>(@"GUI/Minimap/BaseRing_80px")); planetRings.Add(Content.Load <Texture2D>(@"GUI/Minimap/BaseRing_100px")); planetRings.Add(Content.Load <Texture2D>(@"GUI/Minimap/BaseRing_120px")); planetRings.Add(Content.Load <Texture2D>(@"GUI/Minimap/BaseRing_150px")); planetRings.Add(Content.Load <Texture2D>(@"GUI/Minimap/BaseRing_200px")); planetRings.Add(Content.Load <Texture2D>(@"GUI/Minimap/BaseRing_250px")); planetRings.Add(Content.Load <Texture2D>(@"GUI/Minimap/BaseRing_300px")); moonRings = new List <Texture2D>(); moonRings.Add(Content.Load <Texture2D>(@"GUI/Minimap/BaseMoonRing_30px")); moonRings.Add(Content.Load <Texture2D>(@"GUI/Minimap/BaseMoonRing_40px")); moonRings.Add(Content.Load <Texture2D>(@"GUI/Minimap/BaseMoonRing_50px")); moonRings.Add(Content.Load <Texture2D>(@"GUI/Minimap/BaseMoonRing_80px")); moonRings.Add(Content.Load <Texture2D>(@"GUI/Minimap/BaseMoonRing_100px")); moonRings.Add(Content.Load <Texture2D>(@"GUI/Minimap/BaseMoonRing_120px")); moonRings.Add(Content.Load <Texture2D>(@"GUI/Minimap/BaseMoonRing_150px")); _radarCamera._zoom = 1.2f; }
public PlayableGameStateClient(MessageHandlerID messageHandlerId, IClientPlayerInfoManager clientPlayerInfoManager, CollisionManager collisionManager, IGlobalGameUISingleton globalGameUiSingleton, INetworkingService networkingService, PhysicsManager physicsManager, PlayerShipManager playerShipManager, ProjectileManager projectileManager, SelectionManager selectionManager, ClientShipManager clientShipManager, SimulationManager simulationManager, StructureFactoryManager structureFactoryManager, WarpHoleManager warpholeManager, TeamManager teamManager, TargetingService targetingService, FloatyAreaObjectManager floatyAreaObjectManager, MessageService_ToServer messageService, GameStateType stateType, TViewModel viewModel ) : base(messageHandlerId, clientPlayerInfoManager, networkingService, collisionManager, physicsManager, playerShipManager, projectileManager, selectionManager, clientShipManager, simulationManager, structureFactoryManager, warpholeManager, teamManager, targetingService, floatyAreaObjectManager, messageService, viewModel, stateType) { ViewModel = viewModel; WebView = (TWebView)Activator.CreateInstance(typeof(TWebView), globalGameUiSingleton, ViewModel); SetupUpdateList(_synchronousUpdateList); }
public static SpaceStateManager BuildSpaceStateManager(int?areaID, IMessenger messenger, INetworkingService _networkingService) { //Null references, unused by the Simulator TextureManager textureManager = null; SpriteBatch spriteBatch = null; ParticleManager particleManager = null; Texture2D warpholeTexture = null; Texture2D borderTexture = null; SelectionManager selectionManager = null; IGlobalGameUISingleton globalGameUISingleton = null; MessageService_ToServer messageService = new MessageService_ToServer(messenger); SimulationManager simulationManager = new SimulationManager(); CollisionManager collisionManager = new CollisionManager(messageService); PlayerShipManager playerShipManager = new PlayerShipManager(messageService); IClientPlayerInfoManager clientPlayerInfoManager = new PlayablePlayerInfoManager(playerShipManager); TargetingService targetingService = new TargetingService(); TeamManager teamManager = new TeamManager(targetingService); PhysicsManager physicsManager = new PhysicsManager(); BorderManager borderManager = new BorderManager(borderTexture, spriteBatch, physicsManager); ProjectileManager projectileManager = new ProjectileManager(particleManager, physicsManager.World, spriteBatch, targetingService, simulationManager, messageService, collisionManager); ClientShipManager clientShipManager = new ClientShipManager(particleManager, playerShipManager, spriteBatch, textureManager, simulationManager, targetingService, teamManager, projectileManager, messageService, clientPlayerInfoManager, true); clientShipManager.SendPositionUpdates = true; StructureFactoryManager structureFactoryManager = new StructureFactoryManager(messageService, physicsManager.World, projectileManager, targetingService, teamManager, null, clientShipManager, null, true); WarpHoleManager warpholeManager = new WarpHoleManager(messageService, particleManager, physicsManager, clientShipManager, warpholeTexture); GravityManager gravityManager = new GravityManager(physicsManager); SpaceObjectManager spaceObjectManager = new SpaceObjectManager(textureManager, messageService, spriteBatch, particleManager, physicsManager); SpaceManager spaceManager = new SpaceManager(spriteBatch, borderManager, gravityManager, physicsManager, spaceObjectManager, warpholeManager); FloatyAreaObjectManager floatyAreaObjectManager = new FloatyAreaObjectManager(physicsManager.World, textureManager, messageService, spriteBatch, particleManager); var mhi = areaID == null ? new MessageHandlerID() : new MessageHandlerID((int)areaID); SpaceStateManager spaceStateManager = new SpaceStateManager(mhi, clientPlayerInfoManager, globalGameUISingleton, collisionManager, _networkingService, physicsManager, playerShipManager, projectileManager, selectionManager, simulationManager, clientShipManager, spaceManager, structureFactoryManager, targetingService, teamManager, warpholeManager, messageService, floatyAreaObjectManager); spaceStateManager.SetAreaId(areaID); return(spaceStateManager); }
public UIConversionService( CameraService cameraService, PlayerShipManager playerShipManager, SpriteBatch spriteBatch) { _cameraService = cameraService; _playerShipManager = playerShipManager; _spriteBatch = spriteBatch; }
public ActivePlayerGameState(MessageHandlerID messageHandlerId, IClientPlayerInfoManager clientPlayerInfoManager, INetworkingService networkingService, MessageService_ToServer messageService, PlayerShipManager playerShipManager, GameStateType stateType) : base(messageHandlerId, clientPlayerInfoManager, networkingService, messageService, stateType) { _playerShipManager = playerShipManager; }
void EndCombat() { PlayerShipManager.SetPause(true); EnemyShipManager.SetPause(true); AlliedShipManager.SetPause(true); NeutralShipManager.SetPause(true); screenState = ScreenState.Summary; BuildSummaryShipList(); }
void PlaceShip() { CommandUsed += selectedDesign.CommandPoints; MoneyUsed += selectedDesign.GetTotalValue(); ShipData shipData = new ShipData(selectedDesign); Ship newShip = ResourceManager.instance.CreateCombatShip(shipData, DummyUnit.transform.position, DummyUnit.transform.rotation); PlayerPlacedObjects.Add(newShip.gameObject); PlayerShipManager.AddSpaceUnit(newShip); PlayerFleet.AddShip(newShip.GetShipData()); }
public static PlanetStateManager BuildPlanetStateManager(int?areaID, IMessenger messenger, INetworkingService _networkingService, PhysicsConfig _physicsConfig) { //Null references, unused by the Simulator TextureManager textureManager = null; SpriteBatch spriteBatch = null; ParticleManager particleManager = null; Texture2D warpholeTexture = null; SelectionManager selectionManager = null; MessageService_ToServer messageService = new MessageService_ToServer(messenger); SimulationManager simulationManager = new SimulationManager(); CollisionManager collisionManager = new CollisionManager(messageService); PlayerShipManager playerShipManager = new PlayerShipManager(messageService); IClientPlayerInfoManager clientPlayerInfoManager = new PlayablePlayerInfoManager(playerShipManager); TargetingService targetingService = new TargetingService(); TeamManager teamManager = new TeamManager(targetingService); PhysicsManager physicsManager = new PhysicsManager(); ProjectileManager projectileManager = new ProjectileManager(particleManager, physicsManager.World, spriteBatch, targetingService, simulationManager, messageService, collisionManager); ClientShipManager clientShipManager = new ClientShipManager(particleManager, playerShipManager, spriteBatch, textureManager, simulationManager, targetingService, teamManager, projectileManager, messageService, clientPlayerInfoManager, true); clientShipManager.SendPositionUpdates = true; StructureFactoryManager structureFactoryManager = new StructureFactoryManager(messageService, physicsManager.World, projectileManager, targetingService, teamManager, null, clientShipManager, null, true); WarpHoleManager warpholeManager = new WarpHoleManager(messageService, particleManager, physicsManager, clientShipManager, warpholeTexture); FloatyAreaObjectManager floatyAreaObjectManager = new FloatyAreaObjectManager(physicsManager.World, textureManager, messageService, spriteBatch, particleManager); var mhi = areaID == null ? new MessageHandlerID() : new MessageHandlerID((int)areaID); PlanetStateManager planetStateManager = new PlanetStateManager( mhi, clientPlayerInfoManager, null, collisionManager, physicsManager, playerShipManager, projectileManager, clientShipManager, structureFactoryManager, warpholeManager, _networkingService, selectionManager, simulationManager, targetingService, teamManager, GameStateType.Planet, floatyAreaObjectManager, messageService, _physicsConfig.PlanetTileWidth, _physicsConfig.PlanetTileHeight); planetStateManager.SetAreaId(areaID); return(planetStateManager); }
void LoadScenario(Scenario scenario) { ResetCamera(); Camera.main.transform.position = new Vector3(scenario.DeploymentAreaPosition.x, Camera.main.transform.position.y, scenario.DeploymentAreaPosition.z); deploymentArea = ResourceManager.CreateDeploymentArea(scenario.DeploymentAreaPosition); deploymentArea.transform.localScale = new Vector3(2.5f, 1f, 2.5f); CommandLimit = scenario.CommandLimit; MoneyLimit = scenario.MoneyLimit; combatTimer.SetTime(scenario.TimeLimit); foreach (Scenario.ShipEntry ship in scenario.PlayerShips) { Ship newShip = ResourceManager.CreateCombatShip(new ShipData(ResourceManager.GetShipDesignData(ResourceManager.shipDesigns[ship.Hull][ship.Design])), ship.Position, ship.Rotation); newShip.GetShipData().DisplayName = ship.Name; PlayerShipManager.AddSpaceUnit(newShip); PlayerFleet.AddShip(newShip.GetShipData()); } foreach (Scenario.ShipEntry ship in scenario.EnemyShips) { Ship newShip = ResourceManager.CreateCombatShip(new ShipData(ResourceManager.GetShipDesignData(ResourceManager.shipDesigns[ship.Hull][ship.Design])), ship.Position, ship.Rotation); newShip.GetShipData().DisplayName = ship.Name; EnemyShipManager.AddSpaceUnit(newShip); EnemyFleet.AddShip(newShip.GetShipData()); } foreach (Scenario.ShipEntry ship in scenario.AlliedShips) { Ship newShip = ResourceManager.CreateCombatShip(new ShipData(ResourceManager.GetShipDesignData(ResourceManager.shipDesigns[ship.Hull][ship.Design])), ship.Position, ship.Rotation); newShip.GetShipData().DisplayName = ship.Name; AlliedShipManager.AddSpaceUnit(newShip); AlliedFleet.AddShip(newShip.GetShipData()); } foreach (Scenario.ShipEntry ship in scenario.NeutralShips) { Ship newShip = ResourceManager.CreateCombatShip(new ShipData(ResourceManager.GetShipDesignData(ResourceManager.shipDesigns[ship.Hull][ship.Design])), ship.Position, ship.Rotation); newShip.GetShipData().DisplayName = ship.Name; NeutralShipManager.AddSpaceUnit(newShip); NeutralFleet.AddShip(newShip.GetShipData()); } EnemyShipManager.HighLightAllShips(true); AlliedShipManager.HighLightAllShips(true); NeutralShipManager.HighLightAllShips(true); }
/// <summary> /// Manages all aspects of Planetary Invasion. /// </summary> /// <param name="Content">Content Manager</param> /// <param name="planetLevel">Level to play on.</param> public PlanetStateManager(MessageHandlerID messageHandlerId, IClientPlayerInfoManager clientPlayerInfoManager, IGlobalGameUISingleton globalGameUiSingleton, CollisionManager collisionManager, PhysicsManager physicsManager, PlayerShipManager playerShipManager, ProjectileManager projectileManager, ClientShipManager clientShipManager, StructureFactoryManager structureFactoryManager, WarpHoleManager warpholeManager, INetworkingService networkingService, SelectionManager selectionManager, SimulationManager simulationManager, TargetingService targetService, TeamManager teamManager, GameStateType stateType,//Should be moon or planet FloatyAreaObjectManager floatyAreaObjectManager, MessageService_ToServer messageService, int wallTexWidth, int wallTexHeight) : base(messageHandlerId, clientPlayerInfoManager, collisionManager, globalGameUiSingleton, networkingService, physicsManager, playerShipManager, projectileManager, selectionManager, clientShipManager, simulationManager, structureFactoryManager, warpholeManager, teamManager, targetService, floatyAreaObjectManager, messageService, stateType, new PlanetViewModel(clientShipManager) ) { _wallWidth = wallTexWidth; _wallHeight = wallTexHeight; _synchronousUpdateList.Add(_playerShipManager); _messageService = messageService; }
public DrawableSpaceStateManager( MessageService_ToServer messageService, IClientPlayerInfoManager clientPlayerInfoManager, BackgroundManager backgroundManager, BloomComponent bloom, CollisionManager collisionManager, Game game, GameWindow window, GlobalGameUISingleton globalGameUiSingleton, LidgrenNetworkingService networkingService, SpriteBatch spriteBatch, ParticleManager particleManager, PhysicsManager physicsManager, PlayerShipManager playerShipManager, ProjectileManager projectileManager, SelectionManager selectionManager, SimulationManager simulationManager, ClientShipManager clientShipManager, SpaceManager spaceManager, StructureFactoryManager structureFactoryManager, TextureManager textureManager, TargetingService targetingService, TeamManager teamManager, WarpHoleManager warpHoleManager, SpaceObjectManager spaceObjectManager, UIConversionService uiConversionService, FloatyAreaObjectManager floatyAreaObjectManager) : base(null, clientPlayerInfoManager, globalGameUiSingleton, collisionManager, networkingService, physicsManager, playerShipManager, projectileManager, selectionManager, simulationManager, clientShipManager, spaceManager, structureFactoryManager, targetingService, teamManager, warpHoleManager, messageService, floatyAreaObjectManager) { _bloom = bloom; _spriteBatch = spriteBatch; _textureManager = textureManager; _uiConversionService = uiConversionService; _spriteBatch = spriteBatch; _particleManager = particleManager; Camera = new Camera2D(window); Camera.Zoom = 1f; //ViewModel = new SpaceViewModel(ClientShipManager); _spaceGameView = new SpaceGameView( messageService, backgroundManager, bloom, Camera, particleManager, projectileManager, clientShipManager, spaceManager, spaceObjectManager, spriteBatch, uiConversionService, floatyAreaObjectManager, ViewModel, globalGameUiSingleton.GameUI); _viewUpdateList.Add(_spaceGameView); _drawList = new HashSet <IDraw>(); _drawList.Add(_spaceGameView); _synchronousUpdateList.Add(_particleManager); }
public override void Draw() { miniMap.Draw(); shipInfoPanel.Draw(mousePosition); fleetCombatInfoPanel.Draw(); gameSpeedButton.Draw(); if (SetupPhase) { GUI.Box(ShipSelectionRect, "", GameManager.instance.standardBackGround); shipHullList.Draw(); DesignScrollPostion = GUI.BeginScrollView(DesignScrollWindowRect, DesignScrollPostion, DesignScrollViewRect); foreach (DesignDataListEntry entry in DesignDataList) { entry.Draw(selectedDesign); } GUI.EndScrollView(); //Owner Toggles if (GUI.Toggle(OwnerPlayerButtonRect, PlayerSelected, "Player")) { if (!PlayerSelected) { PlayerSelected = true; EnemySelected = false; AllySelected = false; NeutralSelected = false; if (DummyUnit != null) { DummyUnit.transform.GetChild(0).gameObject.layer = 9; } PlayMainButtonClick(); } } if (GUI.Toggle(OwnerEnemyButtonRect, EnemySelected, "Enemy")) { if (!EnemySelected) { PlayerSelected = false; EnemySelected = true; AllySelected = false; NeutralSelected = false; if (DummyUnit != null) { DummyUnit.transform.GetChild(0).gameObject.layer = 10; } PlayMainButtonClick(); } } if (GUI.Toggle(OwnerAlliedButtonRect, AllySelected, "Ally")) { if (!AllySelected) { PlayerSelected = false; EnemySelected = false; AllySelected = true; NeutralSelected = false; if (DummyUnit != null) { DummyUnit.transform.GetChild(0).gameObject.layer = 11; } PlayMainButtonClick(); } } if (GUI.Toggle(OwnerNeutralButtonRect, NeutralSelected, "Neutral")) { if (!NeutralSelected) { PlayerSelected = false; EnemySelected = false; AllySelected = false; NeutralSelected = true; if (DummyUnit != null) { DummyUnit.transform.GetChild(0).gameObject.layer = 13; } PlayMainButtonClick(); } } //Button to start Combat if (GUI.Button(StartButtonRect, "Start", GameManager.instance.standardButtonStyle)) { DeselectDesignData(); PlayerShipManager.SetPause(false); EnemyShipManager.SetPause(false); AlliedShipManager.SetPause(false); SetupPhase = false; PlayMainButtonClick(); } } else { if (shipDragSelectionBox.isActive()) { shipDragSelectionBox.Draw(); } } }
// Update is called once per frame public override void Update() { base.Update(); SetMousePosition(); if (SetupPhase) { if (Input.GetKeyDown(KeyCode.Escape)) { CloseScreen(); } if (Input.GetMouseButtonDown(1)) { DeselectDesignData(); if (PickedUpObject != null) { PickedUpObject.transform.position = PickedUpOrigin; PickedUpObject = null; } } if (Input.GetMouseButton(1)) { Ray ray; RaycastHit hit; ray = Camera.main.ScreenPointToRay(Input.mousePosition); //If we hit... if (Physics.Raycast(ray, out hit, Mathf.Infinity)) { if (hit.collider.transform.root.tag == "Ship") { Ship ship = hit.collider.transform.root.GetComponent <Ship> (); ship.GetShipData().RemoveFromFleet(); ship.DestroyAllFighters(); ship.DestroyWeaponEffects(); ship.DeleteSelf(); } else if (hit.collider.transform.root.tag == "Fighter") { Fighter fighter = hit.collider.transform.root.GetComponent <Fighter> (); fighter.GetParentWing().DestroySelf(); } else if (hit.collider.transform.root.tag == "FighterWing") { hit.collider.transform.root.GetComponent <FighterWing>().DestroySelf(); } } } else if (DummyUnit != null && !ScreenElementsContains(mousePosition)) { Ray ray; RaycastHit hit; ray = Camera.main.ScreenPointToRay(Input.mousePosition); //If we hit... if (Physics.Raycast(ray, out hit, Mathf.Infinity)) { if (!PivotSet) { DummyUnit.transform.position = new Vector3(hit.point.x, 1f, hit.point.z); } if (Input.GetMouseButtonDown(0)) { PivotPoint = DummyUnit.transform.position; PivotSet = true; } else if (Input.GetMouseButton(0)) { Vector3 Direction = (new Vector3(hit.point.x, 1f, hit.point.z) - PivotPoint); if (Direction.magnitude > DummyUnitRadius) { Quaternion Rotation = Quaternion.LookRotation(Direction); DummyUnit.transform.rotation = Rotation; } } else if (Input.GetMouseButtonUp(0)) { ShipData shipData = new ShipData(selectedDesign); Ship newShip = ResourceManager.CreateCombatShip(shipData, DummyUnit.transform.position, DummyUnit.transform.rotation); if (newShip != null) { if (PlayerSelected) { PlayerShipManager.AddSpaceUnit(newShip); PlayerFleet.AddShip(newShip.GetShipData()); } else if (EnemySelected) { EnemyShipManager.AddSpaceUnit(newShip); EnemyFleet.AddShip(newShip.GetShipData()); } else if (AllySelected) { AlliedShipManager.AddSpaceUnit(newShip); AlliedFleet.AddShip(newShip.GetShipData()); } else if (NeutralSelected) { NeutralShipManager.AddSpaceUnit(newShip); NeutralFleet.AddShip(newShip.GetShipData()); } } PivotSet = false; } } } else if (PickedUpObject != null && !ScreenElementsContains(mousePosition)) { Ray ray; RaycastHit hit; ray = Camera.main.ScreenPointToRay(Input.mousePosition); //If we hit... if (Physics.Raycast(ray, out hit, Mathf.Infinity)) { if (!PivotSet) { PickedUpObject.transform.position = new Vector3(hit.point.x, 1f, hit.point.z); } if (Input.GetMouseButtonDown(0)) { PivotPoint = PickedUpObject.transform.position; PivotSet = true; } else if (Input.GetMouseButton(0)) { Vector3 Direction = (new Vector3(hit.point.x, 1f, hit.point.z) - PivotPoint); if (Direction.magnitude > DummyUnitRadius) { Quaternion Rotation = Quaternion.LookRotation(Direction); PickedUpObject.transform.rotation = Rotation; } } else if (Input.GetMouseButtonUp(0)) { PickedUpObject = null; PivotSet = false; } } } else if (miniMap.Contains(mousePosition)) { if (Input.GetMouseButton(0)) { miniMap.GetWorldPosition(mousePosition); } } else if (DummyUnit == null) { if (Input.GetMouseButtonUp(0)) { Ray ray; RaycastHit hit; ray = Camera.main.ScreenPointToRay(Input.mousePosition); //If we hit... if (Physics.Raycast(ray, out hit, Mathf.Infinity)) { if (hit.collider.transform.root.tag == "Ship") { PickedUpObject = hit.collider.transform.root.gameObject; PickedUpOrigin = hit.collider.transform.root.transform.position; } } } } } else { //Update the ships managers UpdateShipManagers(); Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto); if (Input.GetKeyDown(KeyCode.Escape)) { SetPauseShipManagers(true); SetupPhase = true; } if (!ScreenElementsContains(mousePosition)) { Ray ray; RaycastHit hit; ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit, Mathf.Infinity)) { //Highlight hovered units if (hit.collider.transform.root.tag == "Ship") { hit.collider.transform.root.GetComponent <SpaceUnit> ().Hovered(); } else if (hit.collider.transform.root.tag == "Fighter") { hit.collider.transform.root.GetComponent <Fighter> ().GetParentWing().Hovered(); } else if (hit.collider.transform.root.tag == "FighterWing") { hit.collider.transform.root.GetComponent <FighterWing> ().Hovered(); } //Process abilities if (PlayerShipManager.AbilityActivite()) { if (hit.collider.transform.root.tag == "Ship") { Ship hoveredShip = hit.collider.transform.root.GetComponent <Ship>(); if (hoveredShip.ValidTransporterTarget(PlayerShipManager)) { if (PlayerShipManager.TransporterTargetingTroop) { Cursor.SetCursor(ResourceManager.GetIconTexture("Icon_TransportTroop"), Vector2.zero, CursorMode.Auto); if (Input.GetMouseButtonDown(0)) { PlayerShipManager.CastActiveAbility(hoveredShip); } } else if (PlayerShipManager.TransporterTargetingCrew) { Cursor.SetCursor(ResourceManager.GetIconTexture("Icon_TransportCrew"), Vector2.zero, CursorMode.Auto); if (Input.GetMouseButtonDown(0)) { PlayerShipManager.CastActiveAbility(hoveredShip); } } } } if (Input.GetMouseButtonDown(1)) { PlayerShipManager.ResetAbilities(); } } else //Normal movement and commands { if (Input.GetMouseButtonDown(0)) { //Cancel movement order if (PivotSet) { PivotSet = false; Object.Destroy(PivotObject); foreach (GameObject marker in DirectionMarkers) { Object.Destroy(marker); } DirectionMarkers.Clear(); } //Check if clicked a ship if (hit.collider.transform.root.tag == "Ship") { Ship ship = hit.collider.transform.root.GetComponent <Ship>(); if (ship.GetShipManager() == PlayerShipManager) { if (!Input.GetKey(KeyCode.LeftShift)) { PlayerShipManager.DeselectShips(); } PlayerShipManager.AddToSelection(ship); } else { PlayerShipManager.SelectUnownedShip(ship); } } else if (hit.collider.transform.root.tag == "FighterWing") { FighterWing fighterWing = hit.collider.transform.root.GetComponent <FighterWing>(); if (fighterWing.GetShipManager() == PlayerShipManager) { if (!Input.GetKey(KeyCode.LeftShift)) { PlayerShipManager.DeselectShips(); } PlayerShipManager.AddToSelection(fighterWing); } else { PlayerShipManager.SelectUnownedFighter(fighterWing); } } else if (hit.collider.transform.root.tag == "Fighter") { Fighter fighter = hit.collider.transform.root.GetComponent <Fighter>(); if (fighter.GetShipManager() == PlayerShipManager) { if (!Input.GetKey(KeyCode.LeftShift)) { PlayerShipManager.DeselectShips(); } PlayerShipManager.AddToSelection(fighter); } else { PlayerShipManager.SelectUnownedFighter(fighter); } } else if (hit.collider.gameObject.tag == "PlayArea") { if (!Input.GetKey(KeyCode.LeftShift)) { PlayerShipManager.DeselectShips(); } shipDragSelectionBox.SetStart(Input.mousePosition); } } else if (Input.GetMouseButtonDown(1) && PlayerShipManager.HasSomethingSelected()) { if (hit.collider.gameObject.tag == "PlayArea") { PivotSet = true; PivotObject = new GameObject(); PivotObject.transform.position = hit.point; Vector3 shipGroupCenter; Vector3 sum = Vector3.zero; foreach (Ship ship in PlayerShipManager.GetSelectedShips()) { sum += ship.transform.position; } foreach (FighterWing fighterWing in PlayerShipManager.GetSelectedFighters()) { sum += fighterWing.transform.position; } shipGroupCenter = sum / PlayerShipManager.GetSelectedMobileUnitsCount(); Vector3 Direction = PivotObject.transform.position - shipGroupCenter; Quaternion rotation = Quaternion.LookRotation(Direction, Vector3.up); PivotObject.transform.rotation = rotation; foreach (Ship ship in PlayerShipManager.GetSelectedShips()) { GameObject marker = ResourceManager.CreateDirectionMarker(ship.transform.position + Direction); marker.transform.rotation = rotation; DirectionMarkers.Add(marker); marker.transform.parent = PivotObject.transform; } foreach (FighterWing fighterWing in PlayerShipManager.GetSelectedFighters()) { GameObject marker = ResourceManager.CreateDirectionMarker(fighterWing.transform.position + Direction); marker.transform.rotation = rotation; DirectionMarkers.Add(marker); marker.transform.parent = PivotObject.transform; } } else if (hit.collider.transform.root.tag == "Ship") { Ship ship = hit.collider.transform.root.GetComponent <Ship>(); PlayerShipManager.SetTargetForSelectedShips(ship); } else if (hit.collider.transform.root.tag == "FighterWing") { FighterWing fighterWing = hit.collider.transform.root.GetComponent <FighterWing>(); PlayerShipManager.SetTargetForSelectedShips(fighterWing.GetFirstFighter()); } else if (hit.collider.transform.root.tag == "Fighter") { Fighter fighter = hit.collider.transform.root.GetComponent <Fighter>(); PlayerShipManager.SetTargetForSelectedShips(fighter); } } else if (Input.GetMouseButton(1) && PivotSet) { if (hit.collider.gameObject.tag == "PlayArea") { Vector3 Direction = hit.point - PivotObject.transform.position; if (Direction.sqrMagnitude > 0) { Quaternion rotation = Quaternion.LookRotation(Direction, Vector3.up); PivotObject.transform.rotation = rotation; foreach (GameObject marker in DirectionMarkers) { marker.transform.rotation = rotation; } } } } else if (PivotSet) { if (hit.collider.gameObject.tag == "PlayArea") { List <Vector3> points = new List <Vector3>(); foreach (GameObject marker in DirectionMarkers) { points.Add(marker.transform.position); } PlayerShipManager.SetGoalPositionsForShips(points, PivotObject.transform.rotation); PivotSet = false; Object.Destroy(PivotObject); foreach (GameObject marker in DirectionMarkers) { Object.Destroy(marker); } DirectionMarkers.Clear(); } } } } //Drag left click if (Input.GetMouseButton(0)) { shipDragSelectionBox.SetEnd(Input.mousePosition); } else if (shipDragSelectionBox.isActive()) { //Deselect ships from before if (!Input.GetKey(KeyCode.LeftShift)) { PlayerShipManager.DeselectShips(); } shipDragSelectionBox.SetActive(false); shipDragSelectionBox.SelectShips(PlayerShipManager); } } else if (miniMap.Contains(mousePosition)) { if (Input.GetMouseButton(0)) { miniMap.GetWorldPosition(mousePosition); } } } }
bool ScreenElementsContains(Vector2 point) { if (miniMap.Contains(point) || gameSpeedButton.Contains(point)) { return(true); } else if (screenState == ScreenState.setup && SetupPanel.Contains(point)) { return(true); } else if (screenState == ScreenState.play && shipInfoPanel.ContainsMouse(point) && PlayerShipManager.HasSomethingSelected()) { return(true); } return(false); }
DrawablePlanetStateManager _buildPlanetStateManager(GlobalGameUISingleton globalGameUiSingleton, CameraService cameraService, TextureManager textureManager, ParticleManager particleManager, TextDrawingService textDrawingService, MessageService_ToServer messageService, LidgrenNetworkingService networkingService) { CollisionManager instance_collisionManager; ParticleManager instance_particleManager = null; SimulationManager instance_simulationManager; TargetingService instance_targetingService; TeamManager instance_teamManager; UIConversionService instance_uiConversionService; ClientShipManager instance_clientShipManager; PhysicsManager instance_physicsManager; ProjectileManager instance_projectileManager; StructureFactoryManager instance_structureFactoryManager; WarpHoleManager instance_warpholeManager; SelectionManager instance_selectionManager; FloatyAreaObjectManager instance_floatyAreaObjectManager; instance_collisionManager = new CollisionManager(messageService); if (_loadGraphics) { instance_particleManager = new ParticleManager(_graphics, _spriteBatch, Content, textureManager); } instance_simulationManager = new SimulationManager(); instance_targetingService = new TargetingService(); instance_teamManager = new TeamManager(instance_targetingService); PlayerShipManager instance_playerShipManager = new PlayerShipManager(messageService); IClientPlayerInfoManager instance_clientPlayerInfoManager = new PlayablePlayerInfoManager(instance_playerShipManager); instance_uiConversionService = new UIConversionService(cameraService, instance_playerShipManager, _spriteBatch); instance_physicsManager = new PhysicsManager(); instance_projectileManager = new ProjectileManager(instance_particleManager, instance_physicsManager.World, _spriteBatch, instance_targetingService, instance_simulationManager, messageService, instance_collisionManager); instance_clientShipManager = new ClientShipManager(instance_particleManager, instance_playerShipManager, _spriteBatch, textureManager, instance_simulationManager, instance_targetingService, instance_teamManager, instance_projectileManager, messageService, instance_clientPlayerInfoManager, false); instance_structureFactoryManager = new StructureFactoryManager(messageService, instance_physicsManager.World, instance_projectileManager, instance_targetingService, instance_teamManager, textureManager, instance_clientShipManager, _spriteBatch, false); instance_warpholeManager = new WarpHoleManager(messageService, instance_particleManager, instance_physicsManager, instance_clientShipManager, _loadGraphics?textureManager.Warphole:null); instance_selectionManager = new SelectionManager(textDrawingService, _spriteBatch, instance_clientShipManager, messageService, instance_physicsManager, instance_playerShipManager, instance_targetingService, instance_uiConversionService); instance_floatyAreaObjectManager = new FloatyAreaObjectManager(instance_physicsManager.World, textureManager, messageService, _spriteBatch, particleManager); PhysicsConfig physicsConfig = new PhysicsConfig(); return(new DrawablePlanetStateManager( _spriteBatch, instance_clientPlayerInfoManager, instance_collisionManager, globalGameUiSingleton, instance_particleManager, instance_physicsManager, instance_playerShipManager, instance_projectileManager, instance_clientShipManager, instance_structureFactoryManager, textureManager, networkingService, instance_selectionManager, instance_simulationManager, instance_targetingService, instance_teamManager, GameStateType.Planet, instance_uiConversionService, instance_warpholeManager, Window, instance_floatyAreaObjectManager, messageService, physicsConfig.PlanetTileWidth, physicsConfig.PlanetTileHeight)); }
public PlayableUIStateManagerContainer(GameStateType currentAreaType, PlayerShipManager playerShipManager, IClientPlayerInfoManager clientPlayerInfoManager) : base(currentAreaType) { PlayerShipManager = playerShipManager; ClientPlayerInfoManager = clientPlayerInfoManager; }
// Update is called once per frame public override void Update() { combatCameraMover.Update(); SetMousePosition(); if (Input.GetKeyDown(KeyCode.Escape)) { if (SummaryScrollList.isOpen()) { SummaryScrollList.SetOpen(false); } else if (designDisplayWindow.isOpen()) { designDisplayWindow.SetOpen(false); } else { if (SetupPhase) { if (quitResumeSubScreen.isOpen()) { quitResumeSubScreen.SetOpen(false); } else { quitResumeSubScreen.SetOpen(true); } } else { SetPauseShipManagers(true); SetupPhase = true; } } } if (SetupPhase) { if (Input.GetMouseButtonDown(1)) { DeselectDesignData(); if (PickedUpObject != null) { PickedUpObject.transform.position = PickedUpOrigin; PickedUpObject = null; } } if (Input.GetMouseButton(1)) { Ray ray; RaycastHit hit; ray = Camera.main.ScreenPointToRay(Input.mousePosition); //If we hit... if (Physics.Raycast(ray, out hit, Mathf.Infinity)) { if (hit.collider.transform.root.tag == "Ship") { Ship ship = hit.collider.transform.root.GetComponent <Ship>(); ship.GetShipData().RemoveFromFleet(); ship.DestroyAllFighters(); ship.DestroyWeaponEffects(); ship.DeleteSelf(); } if (hit.collider.transform.root.tag == "Station") { Station station = hit.collider.transform.root.GetComponent <Station>(); station.stationData.RemoveFromFleet(); station.DestroyAllFighters(); station.DeleteSelf(); } else if (hit.collider.transform.root.tag == "Fighter") { Fighter fighter = hit.collider.transform.root.GetComponent <Fighter>(); fighter.GetParentWing().DestroySelf(); } else if (hit.collider.transform.root.tag == "FighterWing") { hit.collider.transform.root.GetComponent <FighterWing>().DestroySelf(); } } } else if (DummyUnit != null && !ScreenElementsContains(mousePosition)) { Ray ray; RaycastHit hit; ray = Camera.main.ScreenPointToRay(Input.mousePosition); //If we hit... if (Physics.Raycast(ray, out hit, Mathf.Infinity)) { if (isPositionInPlayArea(hit.point)) { if (!PivotSet) { DummyUnit.transform.position = new Vector3(hit.point.x, 1f, hit.point.z); } if (Input.GetMouseButtonDown(0)) { PivotPoint = DummyUnit.transform.position; PivotSet = true; } else if (Input.GetMouseButton(0)) { Vector3 Direction = (new Vector3(hit.point.x, 1f, hit.point.z) - PivotPoint); if (Direction.magnitude > DummyUnitRadius) { Quaternion Rotation = Quaternion.LookRotation(Direction); DummyUnit.transform.rotation = Rotation; } } else if (Input.GetMouseButtonUp(0)) { if (SelectedUnityCategory == UnitCategory.Ships && selectedDesign != null) { ShipData shipData = new ShipData(selectedDesign); Ship newShip = ResourceManager.instance.CreateCombatShip(shipData, DummyUnit.transform.position, DummyUnit.transform.rotation); if (newShip != null) { if (PlayerSelected) { PlayerShipManager.AddSpaceUnit(newShip); PlayerFleet.AddShip(newShip.GetShipData()); } else if (EnemySelected) { EnemyShipManager.AddSpaceUnit(newShip); EnemyFleet.AddShip(newShip.GetShipData()); } else if (AllySelected) { AlliedShipManager.AddSpaceUnit(newShip); AlliedFleet.AddShip(newShip.GetShipData()); } else if (NeutralSelected) { NeutralShipManager.AddSpaceUnit(newShip); NeutralFleet.AddShip(newShip.GetShipData()); } } } else if (SelectedUnityCategory == UnitCategory.Stations && selectedStationDesign != null) { StationData stationData = new StationData(selectedStationDesign); Station newStation = ResourceManager.instance.CreateCombatStation(stationData, DummyUnit.transform.position, DummyUnit.transform.rotation); if (PlayerSelected) { PlayerShipManager.AddSpaceUnit(newStation); PlayerFleet.AddStation(newStation.stationData); } else if (EnemySelected) { EnemyShipManager.AddSpaceUnit(newStation); EnemyFleet.AddStation(newStation.stationData); } else if (AllySelected) { AlliedShipManager.AddSpaceUnit(newStation); AlliedFleet.AddStation(newStation.stationData); } else if (NeutralSelected) { NeutralShipManager.AddSpaceUnit(newStation); NeutralFleet.AddStation(newStation.stationData); } } else if (SelectedUnityCategory == UnitCategory.Fighters && selectedFighter != null) { FighterWing wing = ResourceManager.CreateFighterWing(); Fighter newFighter = ResourceManager.instance.CreateCombatFighter(selectedFighter, DummyUnit.transform.position, DummyUnit.transform.rotation); wing.addFighter(newFighter); List <Fighter> createdFighters = new List <Fighter>(); createdFighters.Add(newFighter); for (int i = 1; i < selectedFighter.MaxSquadronSize; i++) { Vector3 randomOffect = new Vector3(DummyUnit.transform.position.x + Random.Range(-0.5f, 0.5f), DummyUnit.transform.position.y + Random.Range(0.1f, 0.6f), DummyUnit.transform.position.z + Random.Range(-0.5f, 0.5f)); newFighter = ResourceManager.instance.CreateCombatFighter(selectedFighter, randomOffect, DummyUnit.transform.rotation); wing.addFighter(newFighter); createdFighters.Add(newFighter); } if (PlayerSelected) { PlayerShipManager.AddFighterWing(wing); foreach (Fighter fighter in createdFighters) { PlayerShipManager.AddSpaceUnit(fighter); } } else if (EnemySelected) { EnemyShipManager.AddFighterWing(wing); foreach (Fighter fighter in createdFighters) { EnemyShipManager.AddSpaceUnit(fighter); } } else if (AllySelected) { AlliedShipManager.AddFighterWing(wing); foreach (Fighter fighter in createdFighters) { AlliedShipManager.AddSpaceUnit(fighter); } } else if (NeutralSelected) { NeutralShipManager.AddFighterWing(wing); foreach (Fighter fighter in createdFighters) { NeutralShipManager.AddSpaceUnit(fighter); } } wing.SetNewGoalPosition(DummyUnit.transform.position); } PivotSet = false; } } } } else if (PickedUpObject != null && !ScreenElementsContains(mousePosition)) { Ray ray; RaycastHit hit; ray = Camera.main.ScreenPointToRay(Input.mousePosition); //If we hit... if (Physics.Raycast(ray, out hit, Mathf.Infinity)) { if (isPositionInPlayArea(hit.point)) { if (!PivotSet) { PickedUpObject.transform.position = new Vector3(hit.point.x, 1f, hit.point.z); } if (Input.GetMouseButtonDown(0)) { PivotPoint = PickedUpObject.transform.position; PivotSet = true; } else if (Input.GetMouseButton(0)) { Vector3 Direction = (new Vector3(hit.point.x, 1f, hit.point.z) - PivotPoint); if (Direction.magnitude > DummyUnitRadius) { Quaternion Rotation = Quaternion.LookRotation(Direction); PickedUpObject.transform.rotation = Rotation; } } else if (Input.GetMouseButtonUp(0)) { PickedUpObject = null; PivotSet = false; } } } } else if (miniMap.Contains(mousePosition)) { if (Input.GetMouseButton(0)) { combatCameraMover.GoTo(miniMap.GetWorldPosition(mousePosition)); } } else if (DummyUnit == null) { if (Input.GetMouseButtonUp(0)) { Ray ray; RaycastHit hit; ray = Camera.main.ScreenPointToRay(Input.mousePosition); //If we hit... if (Physics.Raycast(ray, out hit, Mathf.Infinity)) { if (hit.collider.transform.root.tag == "Ship" || hit.collider.transform.root.tag == "Station") { PickedUpObject = hit.collider.transform.root.gameObject; PickedUpOrigin = hit.collider.transform.root.transform.position; } } } } } else if (!designDisplayWindow.isOpen()) { //Update the ships managers UpdateShipManagers(); combatTimer.CountUp(); doubleClickDetector.Update(); Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto); storedUnitPanel.Update(); if (!ScreenElementsContains(mousePosition)) { Ray ray; RaycastHit hit; ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit, Mathf.Infinity)) { //Highlight hovered units if (hit.collider.transform.root.tag == "Ship" || hit.collider.transform.root.tag == "Station") { hit.collider.transform.root.GetComponent <SpaceUnit>().Hovered(); } else if (hit.collider.transform.root.tag == "Fighter") { hit.collider.transform.root.GetComponent <Fighter>().GetParentWing().Hovered(); } else if (hit.collider.transform.root.tag == "FighterWing") { hit.collider.transform.root.GetComponent <FighterWing>().Hovered(); } //Process abilities if (PlayerShipManager.AbilityActivite()) { if (hit.collider.transform.root.tag == "Ship") { Ship hoveredShip = hit.collider.transform.root.GetComponent <Ship>(); if (hoveredShip.ValidTransporterTarget(PlayerShipManager)) { if (PlayerShipManager.TransporterTargetingTroop) { //Cursor.SetCursor(ResourceManager.instance.GetIconTexture("Icon_TransportTroop"), Vector2.zero, CursorMode.Auto); if (Input.GetMouseButtonDown(0)) { PlayerShipManager.CastActiveAbility(hoveredShip); } } else if (PlayerShipManager.TransporterTargetingCrew) { //Cursor.SetCursor(ResourceManager.instance.GetIconTexture("Icon_TransportCrew"), Vector2.zero, CursorMode.Auto); if (Input.GetMouseButtonDown(0)) { PlayerShipManager.CastActiveAbility(hoveredShip); } } } } if (Input.GetMouseButtonDown(1)) { PlayerShipManager.ResetAbilities(); } } else //Normal movement and commands { if (Input.GetMouseButtonDown(0)) { //Cancel movement order if (PivotSet) { PivotSet = false; Object.Destroy(PivotObject); foreach (GameObject marker in DirectionMarkers) { Object.Destroy(marker); } DirectionMarkers.Clear(); } //Check if clicked a ship if (hit.collider.transform.root.tag == "Ship") { Ship ship = hit.collider.transform.root.GetComponent <Ship>(); if (ship.GetShipManager() == PlayerShipManager) { if (!Input.GetKey(KeyCode.LeftShift)) { PlayerShipManager.DeselectShips(); } if (doubleClickDetector.GetClicks() > 1) { PlayerShipManager.AddToSelection(ship.GetHull()); } else { PlayerShipManager.AddToSelection(ship); } combatCameraMover.SetFollowTarget(ship.gameObject); } else { PlayerShipManager.SelectUnownedShip(ship); } } else if (hit.collider.transform.root.tag == "Station") { Station station = hit.collider.transform.root.GetComponent <Station>(); if (station.GetShipManager() == PlayerShipManager) { if (!Input.GetKey(KeyCode.LeftShift)) { PlayerShipManager.DeselectShips(); } PlayerShipManager.AddToSelection(station); } else { PlayerShipManager.SelectUnownedStation(station); } } else if (hit.collider.transform.root.tag == "FighterWing") { FighterWing fighterWing = hit.collider.transform.root.GetComponent <FighterWing>(); if (fighterWing.GetShipManager() == PlayerShipManager) { if (!Input.GetKey(KeyCode.LeftShift)) { PlayerShipManager.DeselectShips(); } PlayerShipManager.AddToSelection(fighterWing); } else { PlayerShipManager.SelectUnownedFighter(fighterWing); } } else if (hit.collider.transform.root.tag == "Fighter") { Fighter fighter = hit.collider.transform.root.GetComponent <Fighter>(); if (fighter.GetShipManager() == PlayerShipManager) { if (!Input.GetKey(KeyCode.LeftShift)) { PlayerShipManager.DeselectShips(); } PlayerShipManager.AddToSelection(fighter); } else { PlayerShipManager.SelectUnownedFighter(fighter); } } else if (hit.collider.gameObject.tag == "PlayArea") { if (!Input.GetKey(KeyCode.LeftShift)) { PlayerShipManager.DeselectShips(); } shipDragSelectionBox.SetStart(Input.mousePosition); shipDragSelectionBox.SetActive(true); } } else if (Input.GetMouseButtonDown(1) && PlayerShipManager.HasSomethingSelected()) { if (hit.collider.gameObject.tag == "PlayArea") { if (isPositionInPlayArea(hit.point)) { PivotSet = true; PivotObject = new GameObject(); PivotObject.transform.position = hit.point; Vector3 shipGroupCenter; Vector3 sumVector = Vector3.zero; foreach (Ship ship in PlayerShipManager.GetSelectedShips()) { sumVector += ship.transform.position; } foreach (FighterWing fighterWing in PlayerShipManager.GetSelectedFighters()) { sumVector += fighterWing.transform.position; } shipGroupCenter = sumVector / PlayerShipManager.GetSelectedMobileUnitsCount(); Vector3 Direction = PivotObject.transform.position - shipGroupCenter; if (Direction != Vector3.zero) { Quaternion rotation = Quaternion.LookRotation(Direction, Vector3.up); PivotObject.transform.rotation = rotation; foreach (Ship ship in PlayerShipManager.GetSelectedShips()) { Vector3 markerPosition = ship.transform.position + Direction; //Try to keep ships 2 units apart foreach (GameObject markers in DirectionMarkers) { Vector3 otherMarkerDirection = markerPosition - markers.transform.position; if (otherMarkerDirection.sqrMagnitude < 4f) { markerPosition = markers.transform.position + otherMarkerDirection.normalized * 2f; } } GameObject marker = ResourceManager.CreateDirectionMarker(markerPosition); marker.transform.rotation = rotation; DirectionMarkers.Add(marker); //marker.transform.parent = PivotObject.transform; } foreach (FighterWing fighterWing in PlayerShipManager.GetSelectedFighters()) { GameObject marker = ResourceManager.CreateDirectionMarker(fighterWing.transform.position + Direction); marker.transform.rotation = rotation; DirectionMarkers.Add(marker); //marker.transform.parent = PivotObject.transform; } } } } else if (hit.collider.transform.root.tag == "Ship") { Ship ship = hit.collider.transform.root.GetComponent <Ship>(); PlayerShipManager.SetTargetForSelectedShips(ship); } else if (hit.collider.transform.root.tag == "Station") { Station station = hit.collider.transform.root.GetComponent <Station>(); PlayerShipManager.SetTargetForSelectedShips(station); } else if (hit.collider.transform.root.tag == "FighterWing") { FighterWing fighterWing = hit.collider.transform.root.GetComponent <FighterWing>(); PlayerShipManager.SetTargetForSelectedShips(fighterWing.GetFirstFighter()); } else if (hit.collider.transform.root.tag == "Fighter") { Fighter fighter = hit.collider.transform.root.GetComponent <Fighter>(); PlayerShipManager.SetTargetForSelectedShips(fighter); } } else if (Input.GetMouseButton(1) && PivotSet) { if (hit.collider.gameObject.tag == "PlayArea") { Vector3 Direction = hit.point - PivotObject.transform.position; if (Direction.sqrMagnitude > 1f) { Quaternion rotation = Quaternion.LookRotation(Direction, Vector3.up); PivotObject.transform.rotation = rotation; foreach (GameObject marker in DirectionMarkers) { marker.transform.rotation = rotation; } } } } else if (PivotSet) { if (hit.collider.gameObject.tag == "PlayArea") { List <Vector3> points = new List <Vector3>(); foreach (GameObject marker in DirectionMarkers) { points.Add(marker.transform.position); } PlayerShipManager.SetGoalPositionsForShips(points, PivotObject.transform.rotation); PivotSet = false; Object.Destroy(PivotObject); foreach (GameObject marker in DirectionMarkers) { Object.Destroy(marker); } DirectionMarkers.Clear(); } } } } //Drag left click if (Input.GetMouseButton(0)) { shipDragSelectionBox.SetEnd(Input.mousePosition); } else if (shipDragSelectionBox.isActive()) { //Deselect ships from before if (!Input.GetKey(KeyCode.LeftShift)) { PlayerShipManager.DeselectShips(); } shipDragSelectionBox.SetActive(false); shipDragSelectionBox.SelectShips(PlayerShipManager); } } else if (miniMap.Contains(mousePosition)) { if (Input.GetMouseButton(0)) { combatCameraMover.GoTo(miniMap.GetWorldPosition(mousePosition)); } } } }
public DrawablePlanetStateManager( SpriteBatch spriteBatch, IClientPlayerInfoManager clientPlayerInfoManager, CollisionManager collisionManager, GlobalGameUISingleton globalGameUiSingleton, ParticleManager particleManager, PhysicsManager physicsManager, PlayerShipManager playerShipManager, ProjectileManager projectileManager, ClientShipManager clientShipManager, StructureFactoryManager structureFactoryManager, TextureManager textureManager, INetworkingService networkingService, SelectionManager selectionManager, SimulationManager simulationManager, TargetingService targetService, TeamManager teamManager, GameStateType stateType,//Should be planet or moon UIConversionService uiConversionService, WarpHoleManager warpholeManager, GameWindow window, FloatyAreaObjectManager floatyAreaObjectManager, MessageService_ToServer messageService, int tileWidth, int tileHeight) : base(null, clientPlayerInfoManager, globalGameUiSingleton, collisionManager, physicsManager, playerShipManager, projectileManager, clientShipManager, structureFactoryManager, warpholeManager, networkingService, selectionManager, simulationManager, targetService, teamManager, stateType, floatyAreaObjectManager, messageService, tileWidth, tileHeight) { _spriteBatch = spriteBatch; _textureManager = textureManager; _particleManager = particleManager; Camera = new Camera2D(window); Camera.Zoom = 1f; //ViewModel = new PlanetViewModel(clientShipManager); _planetGameView = new PlanetGameView( Camera, uiConversionService, particleManager, ViewModel, projectileManager, clientShipManager, spriteBatch, textureManager, floatyAreaObjectManager, globalGameUiSingleton.GameUI, SendStructurePlacementRequest); _spriteBatch = spriteBatch; globalGameUiSingleton.GameUI.RegisterCallbackVoid("SendStructurePlacementRequest", SendStructurePlacementRequest); _viewUpdateList.Add(_planetGameView); _drawList = new HashSet <IDraw>(); _drawList.Add(_planetGameView); _synchronousUpdateList.Add(_particleManager); }
public override void OnStartLocalPlayer() { localPlayer = this; CmdSetPlayerID(Network.player.ipAddress); inventory = GetComponent <PlayerInventory> (); animationController = GetComponent <PlayerAnimationController> (); shipManager = GetComponent <PlayerShipManager> (); uiManager = GameObject.FindObjectOfType <UIManager> (); if (!uiManager) { Debug.LogException(new System.Exception("No UIManager object found in scene")); } playerMesh = transform.Find("Player Model/Mesh").gameObject; // Set mesh to "Local Player Mesh" layer, which is culled by player's camera playerMesh.layer = 8; // ...so the player doesn't see his own body playerHands = transform.Find("Camera/Player Hands").gameObject; playerHands.SetActive(true); foreach (Transform child in transform.Find("Player Model").GetComponentsInChildren <Transform>()) { if (child.tag == "Right Hand Third Person") { thirdPersonRightHand = child.gameObject; break; } } foreach (Transform child in thirdPersonRightHand.GetComponentsInChildren <Transform>()) { child.gameObject.layer = 8; } // Enable camera and controller components for just the local instance camera = GetComponentInChildren <Camera> (); camera.enabled = true; Debug.Log(camera); audioListener = GetComponentInChildren <AudioListener> (); audioListener.enabled = true; firstPersonController = GetComponent <CustomFirstPersonController> (); firstPersonController.enabled = true; uiManager.UpdateInventoryPanelsAfterSync(); uiManager.EnableCursorLock(); GameObject.FindObjectOfType <Canvas> ().worldCamera = camera; GameObject.FindObjectOfType <Canvas> ().planeDistance = 0.1f; DebugID(); CmdUpdateServerManagerPlayerList(); }
DrawableSpaceStateManager _buildSpaceStateManager(GlobalGameUISingleton globalGameUiSingleton, CameraService cameraService, TextureManager textureManager, ParticleManager particleManager, TextDrawingService textDrawingService, MessageService_ToServer messageService, IClientWebViewConfig clientWebviewConfig, LidgrenNetworkingService networkingService, BloomComponent bloom) { CollisionManager instance_collisionManager; ParticleManager instance_particleManager = null; SimulationManager instance_simulationManager; TargetingService instance_targetingService; TeamManager instance_teamManager; UIConversionService instance_uiConversionService; ClientShipManager instance_clientShipManager; PhysicsManager instance_physicsManager; ProjectileManager instance_projectileManager; StructureFactoryManager instance_structureFactoryManager; WarpHoleManager instance_warpholeManager; SelectionManager instance_selectionManager; FloatyAreaObjectManager instance_floatyAreaObjectManager; //Space unique BackgroundManager instance_backgroundManager = null; SpaceManager instance_spaceManager; BorderManager instance_borderManager = null; GravityManager instance_gravityManager; SpaceObjectManager instance_spaceObjectManager; instance_collisionManager = new CollisionManager(messageService); if (_loadGraphics) { instance_particleManager = new ParticleManager(_graphics, _spriteBatch, Content, textureManager); } instance_simulationManager = new SimulationManager(); instance_targetingService = new TargetingService(); instance_teamManager = new TeamManager(instance_targetingService); PlayerShipManager instance_playerShipManager = new PlayerShipManager(messageService); IClientPlayerInfoManager instance_clientPlayerInfoManager = new PlayablePlayerInfoManager(instance_playerShipManager); instance_uiConversionService = new UIConversionService(cameraService, instance_playerShipManager, _spriteBatch); instance_physicsManager = new PhysicsManager(); instance_projectileManager = new ProjectileManager(instance_particleManager, instance_physicsManager.World, _spriteBatch, instance_targetingService, instance_simulationManager, messageService, instance_collisionManager); instance_clientShipManager = new ClientShipManager(instance_particleManager, instance_playerShipManager, _spriteBatch, textureManager, instance_simulationManager, instance_targetingService, instance_teamManager, instance_projectileManager, messageService, instance_clientPlayerInfoManager, false); instance_structureFactoryManager = new StructureFactoryManager(messageService, instance_physicsManager.World, instance_projectileManager, instance_targetingService, instance_teamManager, textureManager, instance_clientShipManager, _spriteBatch, false); instance_warpholeManager = new WarpHoleManager(messageService, instance_particleManager, instance_physicsManager, instance_clientShipManager, _loadGraphics ? textureManager.Warphole : null); instance_selectionManager = new SelectionManager(textDrawingService, _spriteBatch, instance_clientShipManager, messageService, instance_physicsManager, instance_playerShipManager, instance_targetingService, instance_uiConversionService); if (_loadGraphics) { instance_backgroundManager = new BackgroundManager(Content, instance_particleManager, _spriteBatch, cameraService, new Random(8)); } instance_borderManager = new BorderManager(_loadGraphics?textureManager.tex_DotW:null, _spriteBatch, instance_physicsManager); instance_gravityManager = new GravityManager(instance_physicsManager); instance_spaceObjectManager = new SpaceObjectManager(textureManager, messageService, _spriteBatch, instance_particleManager, instance_physicsManager); instance_spaceManager = new SpaceManager(_spriteBatch, instance_borderManager, instance_gravityManager, instance_physicsManager, instance_spaceObjectManager, instance_warpholeManager); instance_floatyAreaObjectManager = new FloatyAreaObjectManager(instance_physicsManager.World, textureManager, messageService, _spriteBatch, particleManager); return(new DrawableSpaceStateManager( messageService, instance_clientPlayerInfoManager, instance_backgroundManager, bloom, instance_collisionManager, this, Window, globalGameUiSingleton, networkingService, _spriteBatch, instance_particleManager, instance_physicsManager, instance_playerShipManager, instance_projectileManager, instance_selectionManager, instance_simulationManager, instance_clientShipManager, instance_spaceManager, instance_structureFactoryManager, textureManager, instance_targetingService, instance_teamManager, instance_warpholeManager, instance_spaceObjectManager, instance_uiConversionService, instance_floatyAreaObjectManager)); }