void OnTriggerStay(Collider collisionInfo) { if (checkCollisionsNow) { if (collisionInfo.tag == "Asteroid") { GenericObstacle obstacle = ObstaclesManager.GetObstacleByTransform(collisionInfo.transform); if (!OverlappedAsteroidsNow.Contains(obstacle)) { OverlappedAsteroidsNow.Add(obstacle); } } else if (collisionInfo.tag == "Mine") { if (!OverlapedMinesNow.Contains(collisionInfo)) { OverlapedMinesNow.Add(collisionInfo); } } else if (collisionInfo.name == "OffTheBoard") { OffTheBoardNow = true; } else if (collisionInfo.name == "ObstaclesStayDetector") { if (collisionInfo.tag != "Untagged" && collisionInfo.tag != TheShip.GetTag()) { OverlappedShipsNow.Add(Roster.GetShipById(collisionInfo.tag)); } } } }
private void StartSelectObstacle(object sender, System.EventArgs e) { ChosenObstacle = null; BombsManager.ToggleReadyToDetonateHighLight(true); SelectObstacleSubPhase subphase = Phases.StartTemporarySubPhaseNew <SelectObstacleSubPhase>( Name, delegate { BombsManager.ToggleReadyToDetonateHighLight(false); Triggers.FinishTrigger(); } ); subphase.PrepareByParameters( SelectObstacle, TrySelectObstacle, Host.Owner.PlayerNo, true, Name, "Select obstacle to destroy", ImageUrl ); subphase.Start(); }
public void ShowChosenObstaclesPanel() { string prefabPath = "Prefabs/SquadBuilder/ObstacleViewPanel"; GameObject prefab = (GameObject)Resources.Load(prefabPath, typeof(GameObject)); GameObject contentGO = GameObject.Find("UI/Panels/ChosenObstaclesPanel/Content/ObstaclesPanel").gameObject; SquadBuilderView.DestroyChildren(contentGO.transform); SquadBuilderView.DestroyChildren(GameObject.Find("PreviewsHolder").transform); for (int i = 0; i < 3; i++) { GameObject newObstacleViewPanel = GameObject.Instantiate(prefab, contentGO.transform); GenericObstacle obstacle = Global.SquadBuilder.CurrentSquad.ChosenObstacles[i]; newObstacleViewPanel.GetComponent <ObstacleViewPanelScript>().Initialize( obstacle, i + 1, delegate { CurrentObstacle = obstacle; MainMenu.CurrentMainMenu.ChangePanel("BrowseObstaclesPanel"); } ); } MainMenu.ScalePanel(contentGO.transform); }
private void SelectObstacle(GenericObstacle obstacle) { Messages.ShowInfo("Obstacle was selected"); ChosenObstacle = obstacle; SelectObstacleSubPhase.SelectObstacle(); }
private void CheckObstructionRecursive(Vector3 point1, Vector3 point2, GenericShip targetShip) { RaycastHit hitInfo = new RaycastHit(); if (Physics.Raycast(point1 + new Vector3(0, 0.003f, 0), point2 - point1 + new Vector3(0, 0.003f, 0), out hitInfo)) { if (hitInfo.collider.tag == "Obstacle") { GenericObstacle obstructedObstacle = ObstaclesManager.GetChosenObstacle(hitInfo.collider.name); if (!ObstructedByObstacles.Contains(obstructedObstacle)) { ObstructedByObstacles.Add(obstructedObstacle); } IgnoreCollider(hitInfo); CheckObstructionRecursive(point1, point2, targetShip); } else if (hitInfo.collider.tag.StartsWith("ShipId:")) { if (hitInfo.collider.tag != "ShipId:" + targetShip.ShipId) { GenericShip obstructedShip = Roster.GetShipById(hitInfo.collider.tag); if (!ObstructedByShips.Contains(obstructedShip)) { ObstructedByShips.Add(obstructedShip); } IgnoreCollider(hitInfo); CheckObstructionRecursive(point1, point2, targetShip); } } else if (hitInfo.collider.tag == "Mine" || hitInfo.collider.tag == "TimedBomb") { IsObstructedByBombToken = true; } } }
public void ShowBrowseObstaclesPanel() { string prefabPath = "Prefabs/SquadBuilder/ObstacleViewPanelSmall"; GameObject prefab = (GameObject)Resources.Load(prefabPath, typeof(GameObject)); GameObject contentGO = GameObject.Find("UI/Panels/BrowseObstaclesPanel/Content").gameObject; SquadBuilderView.DestroyChildren(contentGO.transform); SquadBuilderView.DestroyChildren(GameObject.Find("PreviewsHolder").transform); for (int i = 0; i < ObstaclesManager.Instance.AllPossibleObstacles.Count; i++) { GameObject newObstacleViewPanel = GameObject.Instantiate(prefab, contentGO.transform); GenericObstacle obstacle = ObstaclesManager.Instance.AllPossibleObstacles[i]; newObstacleViewPanel.GetComponent <ObstacleViewPanelScript>().Initialize( obstacle, i, delegate { int index = Global.SquadBuilder.CurrentSquad.ChosenObstacles.IndexOf(CurrentObstacle); Global.SquadBuilder.CurrentSquad.ChosenObstacles[index] = obstacle; MainMenu.CurrentMainMenu.ChangePanel("ChosenObstaclesPanel"); } ); if (Global.SquadBuilder.CurrentSquad.ChosenObstacles.Contains(obstacle) && obstacle != CurrentObstacle) { newObstacleViewPanel.GetComponent <Button>().interactable = false; } } }
public static void PlaceObstacle(string obstacleName, Vector3 position, Vector3 angles) { Phases.CurrentSubPhase.IsReadyForCommands = false; ChosenObstacle = ObstaclesManager.GetChosenObstacle(obstacleName); ChosenObstacle.ObstacleGO.transform.position = position; ChosenObstacle.ObstacleGO.transform.eulerAngles = angles; Board.ToggleOffTheBoardHolder(false); ChosenObstacle.ObstacleGO.transform.parent = Board.BoardTransform; ChosenObstacle.IsPlaced = true; ChosenObstacle = null; IsEnteredPlacementZone = false; IsEnteredPlaymat = false; MovementTemplates.ReturnRangeRulerR1(); MovementTemplates.ReturnRangeRulerR2(); if (ObstaclesManager.GetPlacedObstaclesCount() < 6) { Phases.CurrentSubPhase.Next(); } else { FinishSubPhase(); } }
public void SetShip(Ship.GenericShip ship) { this.ChosenShip = ship; this.ChosenObstacle = null; newPosition = Vector3.zero; newRotation = 0f; }
public void SetObstacle(GenericObstacle obstacle) { // TODO: may be better to operate on the GameObject for the ship and obtacles, since that's the commonality? Then we couldn't get things like ship base size, but the GameObject renderer / colider size is probably just as good for this purpose this.ChosenShip = null; this.ChosenObstacle = obstacle; newPosition = Vector3.zero; newRotation = 0f; }
private void SelectObstacle(GenericObstacle obstacle) { SelectObstacleSubPhase.SelectObstacleNoCallback(); Messages.ShowInfo("An obstacle was selected"); ChosenObstacle = obstacle; StartMoveObstacleSubphase(); }
public ShipObstacleDistance(GenericShip ship, GenericObstacle obstacle) { Ship = ship; Obstacle = obstacle; if (!CheckDistanceSimple()) { CheckDistanceAdvanced(); } }
public BombObstacleDistance(GenericBomb bomb, GenericObstacle obstacle) { Bomb = bomb; Obstacle = obstacle; if (!CheckDistanceSimple()) { CheckDistanceAdvanced(); } }
private void SelectObstacle(GenericObstacle obstacle) { if (FilterTargets(obstacle)) { ConfirmSelectionOfObstacle(obstacle); } else { Messages.ShowError("This obstacle cannot be selected"); } }
public ShipObstacleDistance(GenericShip ship, GenericObstacle obstacle) { CollisionDetectionQuality currentQuality = ObstaclesManager.CollisionDetectionQuality; ObstaclesManager.SetObstaclesCollisionDetectionQuality(CollisionDetectionQuality.Low); Ship = ship; Obstacle = obstacle; if (!CheckDistanceSimple()) { CheckDistanceAdvanced(); } ObstaclesManager.SetObstaclesCollisionDetectionQuality(currentQuality); }
public void ObstacleDestroyed(GenericObstacle obstacle) { for (int i = 0; i < m_ObstaclesToDestroy.Length; i++) { if (obstacle.obstacleName == m_ObstaclesToDestroy[i].obstacleName) { m_Current++; } } if (m_Current >= m_Amount) { m_Completed = true; } }
void OnTriggerEnter(Collider collisionInfo) { if (checkCollisions) { GameManagerScript Game = GameObject.Find("GameManager").GetComponent <GameManagerScript>(); if (collisionInfo.tag == "Obstacle") { GenericObstacle obstacle = ObstaclesManager.GetChosenObstacle(collisionInfo.transform.name); if (!OverlapedAsteroids.Contains(obstacle)) { OverlapedAsteroids.Add(obstacle); } } else if (collisionInfo.tag == "Mine") { if (!OverlapedMines.Contains(collisionInfo)) { OverlapedMines.Add(collisionInfo); } } else if (collisionInfo.name == "OffTheBoard") { OffTheBoard = true; } else if (collisionInfo.name == "ObstaclesStayDetector") { if (collisionInfo.tag != this.tag) { Game.Movement.CollidedWith = collisionInfo; OverlapsShip = true; if (!OverlapedShips.Contains(Roster.GetShipById(collisionInfo.tag))) { OverlapedShips.Add(Roster.GetShipById(collisionInfo.tag)); } } } else if (collisionInfo.name == "RemoteCollider") { if (collisionInfo.tag != this.tag) { if (!OverlapedRemotes.Contains(Roster.GetShipById(collisionInfo.tag) as GenericRemote)) { OverlapedRemotes.Add(Roster.GetShipById(collisionInfo.tag) as GenericRemote); } } } } }
private void SelectObstacle(GenericObstacle obstacle) { Board.ToggleOffTheBoardHolder(true); ChosenObstacle = obstacle; UI.HideSkipButton(); if (CameraScript.InputTouchIsEnabled && !IsRandomSetupSelected[RequiredPlayer]) { // With touch controls, wait for confirmation before setting the position UI.ShowNextButton(); IsReadyForCommands = true; // Set up touch handler touchObjectPlacementHandler.SetObstacle(obstacle); } }
private void CheckRemoveAbility(GenericShip ship, GenericToken token, ref bool data) { BlueTargetLockToken lockToken = token as BlueTargetLockToken; if (lockToken != null) { GenericObstacle lockedObstacle = lockToken.OtherTargetLockTokenOwner as GenericObstacle; if (lockedObstacle != null) { if (HostShip.Tokens.GetTargetLockLetterPairsOn(lockedObstacle).Count == 1) { Messages.ShowInfo("Qi'Ra: You don't ignore obstacle anymore"); HostShip.IgnoreObstaclesList.Remove(lockedObstacle); } } } }
// Update is called once per frame void Update() { if (!m_Death) { if (m_ObjectsInUse.Count > 0) { for (int i = 0; i < m_ObjectsInUse.Count - 1; i++) { GameObject obstacle = m_ObjectsInUse[i].obstacle; GenericObstacle data = m_ObjectsInUse[i].data; m_ObjectsInUse[i].obstacle.transform.position = obstacle.transform.position + -Vector3.forward * (m_Level.speed + (data.additionalSpeed)) * Time.deltaTime; m_ObjectsInUse[i].RemoveTime(Time.deltaTime); if (m_ObjectsInUse[i].timeLeft <= 0) { ToObjectPool(m_ObjectsInUse[i]); m_ObjectsInUse.RemoveAt(i); } } } m_SpawnTimer -= Time.deltaTime; if (m_SpawnTimer < 0) { m_SpawnTimer = Mathf.Clamp(m_TimeForNextObstacle - ((m_Score.score / 30) / 10f), m_MinTime, m_MaxTime); m_Level.UpdateSpeed(Mathf.Clamp(10f + ((m_Score.score / 30f) * m_SpeedMultiplier), 10f, 40f)); int obstalces = Random.Range(1, 4); int lastX = -1; int lastY = -1; Stack <Vector2i> lastPositions = new Stack <Vector2i>(); for (int i = 0; i < obstalces; i++) { int x = Random.Range(0, 3); int y = Random.Range(0, 3); Vector2i position = new Vector2(x, y); if (!lastPositions.Contains(position)) { SpawnObstacle(m_Lanes.GetPosition(position), position); } lastPositions.Push(position); } } } }
private void SelectObstacle(GenericObstacle obstacle) { if (FilterTargetLockableTargets(obstacle)) { if (IsLocked) { return; } IsLocked = true; ConfirmSelectionOfObstacle(obstacle); } else { Messages.ShowError("This obstacle cannot be selected"); } }
public static void PlaceObstacle(string obstacleName, Vector3 position, Vector3 angles) { Phases.CurrentSubPhase.IsReadyForCommands = false; ChosenObstacle.ObstacleGO.transform.position = position; ChosenObstacle.ObstacleGO.transform.eulerAngles = angles; ChosenObstacle.ObstacleGO.transform.parent = Board.BoardTransform; ChosenObstacle.IsPlaced = true; ChosenObstacle = null; IsEnteredPlacementZone = false; IsEnteredPlaymat = false; MovementTemplates.ReturnRangeRulerR1(); MovementTemplates.ReturnRangeRulerR2(); FinishSubPhase(); }
public override void Initialize() { ShowObstaclesHolder(); MinBoardEdgeDistance = Board.BoardIntoWorld(2 * Board.RANGE_1); MinObstaclesDistance = Board.BoardIntoWorld(Board.RANGE_1); RequiredPlayer = Roster.AnotherPlayer(Phases.PlayerWithInitiative); // Will be changed in Next ChosenObstacle = null; foreach (GenericPlayer player in Roster.Players) { if (player.PlayerType == PlayerType.Ai) { IsRandomSetupSelected[player.PlayerNo] = true; } } Next(); }
void OnTriggerEnter(Collider collisionInfo) { if (checkCollisions) { if (collisionInfo.tag == "Obstacle") { GenericObstacle obstacle = ObstaclesManager.GetChosenObstacle(collisionInfo.transform.name); if (!OverlapedAsteroids.Contains(obstacle)) { OverlapedAsteroids.Add(obstacle); } } else if (collisionInfo.tag == "Mine") { if (!OverlapedMines.Contains(collisionInfo)) { OverlapedMines.Add(collisionInfo); } } else if (collisionInfo.name == "RemoteCollider") { if (collisionInfo.tag != this.tag) { if (!RemotesMovedThrough.Contains(Roster.GetShipById(collisionInfo.tag) as GenericRemote)) { RemotesMovedThrough.Add(Roster.GetShipById(collisionInfo.tag) as GenericRemote); } } } else if (collisionInfo.name == "ObstaclesStayDetector") { if (collisionInfo.tag != this.tag) { if (!ShipsMovedThrough.Contains(Roster.GetShipById(collisionInfo.tag))) { ShipsMovedThrough.Add(Roster.GetShipById(collisionInfo.tag)); } } } } }
void OnTriggerStay(Collider collisionInfo) { if (checkCollisionsNow) { if (collisionInfo.tag == "Obstacle") { GenericObstacle obstacle = ObstaclesManager.GetChosenObstacle(collisionInfo.transform.name); if (!OverlappedAsteroidsNow.Contains(obstacle)) { OverlappedAsteroidsNow.Add(obstacle); } } else if (collisionInfo.tag == "Mine") { if (!OverlapedMinesNow.Contains(collisionInfo)) { OverlapedMinesNow.Add(collisionInfo); } } else if (collisionInfo.name == "OffTheBoard") { OffTheBoardNow = true; } else if (collisionInfo.name == "ObstaclesStayDetector") { if (collisionInfo.tag != TheShip.GetTag()) { GenericShip ship = Roster.GetShipById(collisionInfo.tag); if (ship != null && !OverlappedShipsNow.Contains(ship)) { OverlappedShipsNow.Add(ship); } } else if (collisionInfo.tag == TheShip.GetTag()) { OverlapsCurrentShipNow = true; } } } }
void OnTriggerEnter(Collider collisionInfo) { if (checkCollisions) { if (collisionInfo.tag == "Asteroid") { GenericObstacle obstacle = ObstaclesManager.GetObstacleByTransform(collisionInfo.transform); if (!OverlapedAsteroids.Contains(obstacle)) { OverlapedAsteroids.Add(obstacle); } } if (collisionInfo.tag == "Mine") { if (!OverlapedMines.Contains(collisionInfo)) { OverlapedMines.Add(collisionInfo); } } } }
private void TryToSelectObstacle() { if (!EventSystem.current.IsPointerOverGameObject()) { if (Input.GetKeyUp(KeyCode.Mouse0)) { RaycastHit hitInfo = new RaycastHit(); if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hitInfo)) { if (hitInfo.transform.tag.StartsWith("Asteroid")) { GenericObstacle clickedObstacle = ObstaclesManager.GetObstacleByTransform(hitInfo.transform); if (clickedObstacle.IsPlaced) { SelectObstacle(clickedObstacle); } } } } } }
private void TryToSelectObstacle() { if (!EventSystem.current.IsPointerOverGameObject() && (Input.touchCount == 0 || !EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId))) { if (Input.GetKeyUp(KeyCode.Mouse0)) { RaycastHit hitInfo = new RaycastHit(); if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hitInfo)) { if (hitInfo.transform.tag.StartsWith("Obstacle")) { GenericObstacle clickedObstacle = ObstaclesManager.GetChosenObstacle(hitInfo.transform.name); if (clickedObstacle.IsPlaced) { SelectObstacle(clickedObstacle); } } } } } }
public override void Initialize() { Console.Write($"\nSetup Phase", isBold: true, color: "orange"); ShowObstaclesHolder(); MinBoardEdgeDistance = Board.BoardIntoWorld(2 * Board.RANGE_1); MinObstaclesDistance = Board.BoardIntoWorld(Board.RANGE_1); RequiredPlayer = Roster.AnotherPlayer(Phases.PlayerWithInitiative); // Will be changed in Next ChosenObstacle = null; foreach (GenericPlayer player in Roster.Players) { if (player.PlayerType == PlayerType.Ai) { IsRandomSetupSelected[player.PlayerNo] = true; } } ObstaclesManager.SetObstaclesCollisionDetectionQuality(CollisionDetectionQuality.Low); Next(); }
private void TryToSelectObstacle() { if (!EventSystem.current.IsPointerOverGameObject() && (Input.touchCount == 0 || !EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId))) { // On touch devices, select on down instead of up event so drag can begin immediately if (Input.GetKeyUp(KeyCode.Mouse0) || (Input.touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Began)) { RaycastHit hitInfo = new RaycastHit(); Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); bool castHit = Physics.Raycast(ray, out hitInfo); // If an asteroid wasn't found and we're on touch, see if the user tapped right next to an asteroid // Since the asteroid can be small, they can be hard to touch and this helps with that if (CameraScript.InputTouchIsEnabled && (!castHit || !hitInfo.transform.tag.StartsWith("Obstacle"))) { castHit = Physics.SphereCast(ray, 0.1f, out hitInfo, 10f); } // Select the obstacle found if it's valid if (castHit && hitInfo.transform.tag.StartsWith("Obstacle")) { GameObject obstacleGO = hitInfo.transform.parent.gameObject; GenericObstacle clickedObstacle = ObstaclesManager.GetChosenObstacle(obstacleGO.transform.name); if (!clickedObstacle.IsPlaced) { SelectObstacle(clickedObstacle); } } } } }
private void ConfirmSelectionOfObstacle(GenericObstacle obstacle) { GameMode.CurrentGameMode.ExecuteCommand(GenerateSelectObstacleCommand(obstacle.ObstacleGO.name)); }