void GenerateNext() { switch (this.MoveDirection) { case INFINITY_MOVE_DIRECTION.RIGHT: if (this.transform.position.x < this.infinityCamera.RightChecker.position.x) { GameObject _obj = this.stageController.GenerateNext(this.transform.position, this.DistanceOffset, this.MoveDirection); InfinityObjectController _controller = _obj.GetComponent <InfinityObjectController> (); _controller.Reset(); this.HasGeneratedNext = true; } break; case INFINITY_MOVE_DIRECTION.LEFT: if (this.transform.position.x > this.infinityCamera.LeftChecker.position.x) { GameObject _obj = this.stageController.GenerateNext(this.transform.position, this.DistanceOffset, this.MoveDirection); InfinityObjectController _controller = _obj.GetComponent <InfinityObjectController> (); _controller.Reset(); this.HasGeneratedNext = true; } break; } }
public GameObject GenerateNext(Vector3 currentPos, Vector3 currentDistanceOffset, INFINITY_MOVE_DIRECTION moveDirection) { int?_index = null; int _randomInt = Random.Range(0, this.ProbabilitySumMax); Debug.Log("_randomInt =" + _randomInt); int _probabilityStart = 0; int _probabilityEnd = 0; for (int i = 0; i < this.ProbabilityList.Length; i++) { _probabilityStart = _probabilityEnd; _probabilityEnd = _probabilityStart + this.ProbabilityList[i]; if (_randomInt >= _probabilityStart && _randomInt < _probabilityEnd) { _index = i; break; } } InfinityObjectController _infinityObj = this.PrefabList [_index.Value].GetComponent <InfinityObjectController>(); Vector3 _nextPos = Vector3.zero; switch (moveDirection) { case INFINITY_MOVE_DIRECTION.RIGHT: _nextPos = new Vector3(currentPos.x + currentDistanceOffset.x + _infinityObj.DistanceOffset.x, this.BaseY, currentPos.z); _nextPos.y += _infinityObj.DistanceOffset.y; break; case INFINITY_MOVE_DIRECTION.LEFT: _nextPos = new Vector3(currentPos.x - currentDistanceOffset.x - _infinityObj.DistanceOffset.x, this.BaseY, currentPos.z); _nextPos.y += _infinityObj.DistanceOffset.y; break; } return(this.Pool.FindGameObjectFromCache(this.PrefabList[_index.Value], _nextPos, Quaternion.identity, this.gameObject)); }