示例#1
0
 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));
             }
         }
     }
 }
示例#2
0
    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);
                            }
                        }
                    }
                }
            }
        }
示例#4
0
 void OnTriggerEnter(Collider collisionInfo)
 {
     if (checkCollisions)
     {
         GameManagerScript Game = GameObject.Find("GameManager").GetComponent <GameManagerScript>();
         if (collisionInfo.tag == "Asteroid")
         {
             GenericObstacle obstacle = ObstaclesManager.GetObstacleByTransform(collisionInfo.transform);
             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));
                 }
             }
         }
     }
 }