コード例 #1
0
        public void RemoveOldestPartOfWorld()
        {
            IPartOfWorldView oldestPart = GameWorldModel.Instance.PartsOfWorld.Dequeue();

            partsOfWorldManagerWorker.RemovePart(oldestPart as PartOfWorldView);
            ChangedPartsOfWorldAmountSignal.Dispatch();
        }
コード例 #2
0
        void CreateObstaclesOnLine(IPartOfWorldView targetPart, Vector3 startPosition, Vector3 endPosition)
        {
            float   totalLength    = Vector3.Distance(startPosition, endPosition);
            float   counter        = 0f;
            byte    attempsCounter = 0;
            float   currentSegment = 0f;
            Vector3 currentPosition;

            while (counter <= 1f)
            {
                attempsCounter = 0;

                while (attempsCounter < 3)
                {
                    currentSegment  = Random.Range(GameWorldModel.Instance.MinDistanceBetweenObstacles, GameWorldModel.Instance.MaxDistanceBetweenObstacles) / totalLength;
                    currentPosition = Vector3.Lerp(startPosition, endPosition, counter + currentSegment);
                    if (obstaclesManagerWorker.FindFirstNearObstacle(currentPosition, GameWorldModel.Instance.SideCheckDistance) == null)
                    {
                        Transform newObstacle = obstaclesManagerWorker.CreateObjectFromPool().transform;
                        newObstacle.position = currentPosition + new Vector3(0f, obstaclesYOffset, 0f);
                        AddObstacleToPartOfWorld(targetPart, newObstacle.gameObject);
                        break;
                    }

                    attempsCounter++;
                }

                counter += currentSegment; //Attemp create next obstacle from previous position in any case
            }
        }
コード例 #3
0
 public void CreateObstaclesOnPartOfWorld(IPartOfWorldView targetPart)
 {
     foreach (PartOfWorldView.LineInfo nowLine in targetPart.LinesInfo)
     {
         CreateObstaclesOnLine(targetPart, nowLine.WayPoints[0].position, nowLine.WayPoints[nowLine.WayPoints.Length - 1].position);
     }
 }
コード例 #4
0
 void AddObstacleToPartOfWorld(IPartOfWorldView targetPart, GameObject obstacle)
 {
     if (!obstaclesByPart.ContainsKey(targetPart))
     {
         obstaclesByPart.Add(targetPart, new List <GameObject>());
     }
     obstaclesByPart[targetPart].Add(obstacle);
 }
コード例 #5
0
 public void RemoveAllObstaclesFromPartOfWorld(IPartOfWorldView targetPart)
 {
     if (obstaclesByPart.ContainsKey(targetPart))
     {
         foreach (GameObject nowObstacle in obstaclesByPart[targetPart])
         {
             obstaclesManagerWorker.RemoveObstacle(nowObstacle);
         }
         obstaclesByPart[targetPart].Clear();
     }
 }