//TODO not able to spawn on start, needs to be reworked public IEnumerator SpawnPlayerCharacter() { yield return(new WaitForSeconds(spawnDelay)); if (BlockGridRenderer.Singleton != null && BlockGridRenderer.Singleton.entrance != null) { Vector3 characterSpawnPosition = BlockGridRenderer.Singleton.entrance.spawnPositions[activeCharacters.Count % 2].position; CharacterControl character = Instantiate(characterPrefab, characterSpawnPosition, Quaternion.Euler(Vector3.zero)) .GetComponent <CharacterControl>(); character.name = "Character" + (activeCharacters.Count + 1); activeCharacters.Add(character); GridCoordinates startPos = BlockGridController.Singleton.grid.startingPosition; GridCoordinates randomCoordinatesInsideRoom = new GridCoordinates( startPos.x + Random.Range(BlockGrid.startingRoomLeftRearCorner.x, BlockGrid.startingRoomFrontRightCorner.x), startPos.y + Random.Range(BlockGrid.startingRoomLeftRearCorner.y, BlockGrid.startingRoomFrontRightCorner.y) ); UnitToolbar.Singleton.AddUnitButton(character.name); yield return(new WaitForSeconds(0.1f)); //TODO rework and refactor target picker script. Need some kind of Move() method for CharacterControl to move him to given Vector3 PlaceTargetWithMouse targetPicker = character.targetPicker; targetPicker.transform.position = randomCoordinatesInsideRoom.GetPositionOffset(targetPicker.surfaceOffset); character.transform.SendMessage("SetTarget", targetPicker.transform); } yield return(null); }
private void Start() { toolbarStrings = editorBlockPrefabs.blockPrefabs.Select(x => x.prefab.name).ToArray(); GridCoordinates startingPosition = BlockGridController.Singleton.grid.startingPosition; CameraControllerOld.Singleton.freeRoamMovingPoint.position = startingPosition.GetPositionOffset(); }