Exemplo n.º 1
0
        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 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();
            }
        }
 void OnTriggerEnter(Collider collisionInfo)
 {
     if (collisionInfo.tag == "Obstacle")
     {
         ObstaclesObstructed.Add(ObstaclesManager.GetChosenObstacle(collisionInfo.transform.name));
     }
     else if (collisionInfo.tag == "Mine" || collisionInfo.tag == "TimedBomb")
     {
         IsObstructedByBombToken = true;
     }
 }
Exemplo n.º 4
0
 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);
                 }
             }
         }
     }
 }
Exemplo n.º 5
0
 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;
             }
         }
     }
 }
Exemplo n.º 7
0
    void OnTriggerEnter(Collider collisionInfo)
    {
        if (checkCollisions)
        {
            if (collisionInfo.tag == "Obstacle")
            {
                GenericObstacle obstacle = ObstaclesManager.GetChosenObstacle(collisionInfo.transform.name);
                if (!OverlapedAsteroids.Contains(obstacle))
                {
                    OverlapedAsteroids.Add(obstacle);
                }
            }

            if (collisionInfo.tag == "Mine")
            {
                if (!OverlapedMines.Contains(collisionInfo))
                {
                    OverlapedMines.Add(collisionInfo);
                }
            }
        }
    }
Exemplo n.º 8
0
        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);
                            }
                        }
                    }
                }
            }
        }
        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);
                        }
                    }
                }
            }
        }
Exemplo n.º 10
0
 public static void ConfirmSelectionOfObstacle(string obstacleName)
 {
     TargetLocked = ObstaclesManager.GetChosenObstacle(obstacleName);
     (Phases.CurrentSubPhase as SelectTargetLockableSubPhase).InvokeFinish();
 }
Exemplo n.º 11
0
        public static void ConfirmSelectionOfObstacle(string obstacleName)
        {
            GenericObstacle obstacle = ObstaclesManager.GetChosenObstacle(obstacleName);

            SelectTargetAction(obstacle);
        }