public PlayerCreator(PlayerConstructSettings settings) { _numHeightBlocks = settings.NumHeightBlocks; _numWidthBlock = settings.NumWidthBlocks; _numDoubleBranches = settings.NumDoubleBranches; _blockPrefab = settings.BlockPrefab; _playerFactory = new MonoBehaviourFactory <PlayerController>("Player"); }
public void CreateGatePools() { for (int i = 0; i < 4; i++) // I hardcoded it cos we we will rotate player 4 times for 90 degrees. That covers exactly 360 degrees { CreateNewTypeOfGate(); } Gate gate = new MonoBehaviourFactory <Gate>("Gate").Create(); gate.StartCoroutine(ExcludeBlocksFromGates()); //I needed any Monobehaviour to start coroutine }
void CreateNewTypeOfGate() //Creation of "prefabs" of gates { Gate gate = new MonoBehaviourFactory <Gate>("Gate").Create(); GameObject futureBottom = GameObject.CreatePrimitive(PrimitiveType.Cube); futureBottom.name = "GateBottom"; futureBottom.transform.localScale = new Vector3(_gaps, 0.01f, 1); futureBottom.transform.parent = gate.transform; _gateBottom = futureBottom.GetComponent <Renderer>(); GameObject outerGate = GameObject.Instantiate(_outerGate); outerGate.name = "DecorGate"; outerGate.transform.parent = gate.transform; GateSpeedUpPlayer speedUpcollider = new MonoBehaviourFactory <GateSpeedUpPlayer>("Speed up Col").Create(); speedUpcollider.transform.position += Vector3.right * _gaps; //We need to place it just behind the gate speedUpcollider.transform.parent = gate.transform; speedUpcollider.transform.eulerAngles = Vector3.zero; float yGaps = 0.1f; //we need to already add some height/ Can't be changed int numInRow = Mathf.RoundToInt((_gateBottom.bounds.size.z / _gaps)) - 1; // so we can skip last element. We don't need a cubes to be spawned in gate panels for (int i = 0; i < _numInColumn; i++) { float xGaps = 0; for (int k = 1; k < numInRow; k++) //We start from 2 element, for the same reason { xGaps += _gaps; GateBlock block = GameObject.Instantiate(_gateBlock); block.transform.position = new Vector3(_gateBottom.bounds.max.x - 0.05f, yGaps, _gateBottom.bounds.max.z - 0.05f - xGaps); block.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f); block.transform.parent = _gateBottom.transform; gate.Blocks.Add(block); } yGaps += _gaps; } _gates.Add(gate); gate.gameObject.SetActive(false); }