/// <summary> /// Places all players at initial starting locations /// </summary> /// <param name="settings"></param> /// <param name="playerPrefab"></param> public void InitPlaying(InitGameSettings settings, GameObject playerPrefab) { int playerCount = settings.playerControls.Count; float screenWidth = (Camera.main.orthographicSize * 2) * Camera.main.aspect; float screenHeight = Camera.main.orthographicSize * 2; float cameraX = Camera.main.transform.position.x; float cameraY = Camera.main.transform.position.y; float bottomLeftX = cameraX - (screenWidth / 2); float bottomLeftY = cameraY - (screenHeight / 2); float xDistBetweenWrenches = screenWidth / (playerCount); float sidePadding = xDistBetweenWrenches / 2; float bottomPadding = screenHeight * ratioFromFloor; print(playerCount); int offsetMult = 0; foreach (KeyCode controlKey in settings.playerControls) { //sidePadding = 0; float x = (bottomLeftX + sidePadding) + (xDistBetweenWrenches * offsetMult); float y = (bottomLeftY + bottomPadding); Vector3 startingPos = new Vector3(x, y, 1); PlacePlayer(startingPos, controlKey, playerPrefab); offsetMult++; } }
/// <summary> /// Given settings, moves game into playing scene. /// Requires that current scene is keyselect scene. /// </summary> /// <param name="settings">Settings to be used for Play scene</param> public void StartPlaying(InitGameSettings settings) { if (state != State.KeySelect) { throw new System.Exception("tried to start game from wrong position"); } state = State.Playing; GameState.settings = settings; playerCount = settings.playerControls.Count; SceneManager.LoadScene(StateToName(state)); }
void Start() { usedKeys = new List <KeyCode>(); currentPlayer = 0; gameSetting = new InitGameSettings(); }
// Start is called before the first frame update void Start() { gameSetting = new InitGameSettings(); InitAvailableKeys(); }