public void activateSelection() { ColorChanger pallete = currentSelection.GetComponent <ColorChanger>(); if (pallete.state != SelectionState.ACTIVE) { pallete.setActive(color); } else { pallete.setDefault(color); } }
void Update() { float h = 0f; float v = 0f; bool action = false; switch (inputType) { case InputType.GAMEPAD: h = Input.GetAxis(Utils.getControlForPlayer(Control.LeftStickX, gamepadNumber)); v = Input.GetAxis(Utils.getControlForPlayer(Control.LeftStickY, gamepadNumber)); action = Input.GetButtonDown(Utils.getControlForPlayer(Control.A, gamepadNumber)); break; case InputType.KEYBOARD: h = Input.GetAxis(Control.Horizontal); v = Input.GetAxis(Control.Vertical); action = Input.GetButtonDown(Control.Space); break; default: break; } if (h < 0f && timer >= threshold) { // Go to left selection timer = 0f; moveSelection(SelectionDirection.LEFT); } else if (h > 0f && timer >= threshold) { // Go to right selection timer = 0f; moveSelection(SelectionDirection.RIGHT); } if (v > 0f && timer >= threshold) { // Go to up selection timer = 0f; moveSelection(SelectionDirection.UP); } else if (v < 0f && timer >= threshold) { // Go to down selection timer = 0f; moveSelection(SelectionDirection.DOWN); } if (action) { if (currentSelection == colorButton) { Debug.Log("Change color for " + this); colorButton.onClick.Invoke(); } else if (currentSelection == readyButton) { Debug.Log(this + " is ready"); activateSelection(); readyButton.onClick.Invoke(); } else if (currentSelection == maleButton) { Debug.Log(this + " is male"); ColorChanger pallete = currentSelection.GetComponent <ColorChanger>(); if (pallete.state != SelectionState.ACTIVE) { activateSelection(); gender = Gender.MALE; femaleButton.GetComponent <ColorChanger> ().setDefault(color); } else { pallete.setDefault(color); gender = Gender.FEMALE; femaleButton.GetComponent <ColorChanger> ().setActive(color); } } else if (currentSelection == femaleButton) { Debug.Log(this + " is female"); ColorChanger pallete = currentSelection.GetComponent <ColorChanger>(); if (pallete.state != SelectionState.ACTIVE) { activateSelection(); gender = Gender.FEMALE; maleButton.GetComponent <ColorChanger> ().setDefault(color); } else { pallete.setDefault(color); gender = Gender.MALE; maleButton.GetComponent <ColorChanger> ().setActive(color); } } } // Increase wait time if (timer <= threshold) { timer += Time.deltaTime; } }