public void RegisterColorParam(string paramater, ColorSelectionButton colorSelectionScript) { this.ColorParamaters.Add(new ParameterNameWithColorButtonScript { ParamaterName = paramater, colorScript = colorSelectionScript, }); }
public void InitColorPicker() { selectedColor = ColorPalette[0]; foreach (Color32 c in ColorPalette) { ColorSelectionButton obj = Instantiate(ColorButtonPrefab, CrayonsContainerContent); obj.Init(this, c); } CrayonsContainerContent.GetComponent <RectTransform>().sizeDelta = new Vector2(100, ColorPalette.Count * 110); }
ColorSelectionButton GetAvailableDown(ColorSelectionButton current) { ColorSelectionButton tempFocus = current.down; while (tempFocus.focusedUponTheNightWhenTheHorsesAreFree && tempFocus.down != tempFocus) { tempFocus = tempFocus.down; } if (!tempFocus.focusedUponTheNightWhenTheHorsesAreFree) { tempFocus.focusedUponTheNightWhenTheHorsesAreFree = true; current.focusedUponTheNightWhenTheHorsesAreFree = false; return tempFocus; } return current; }
ColorSelectionButton GetAvailableLeft(ColorSelectionButton current) { ColorSelectionButton tempFocus = current.left; while (tempFocus.focusedUponTheNightWhenTheHorsesAreFree && tempFocus.left != tempFocus) { tempFocus = tempFocus.left; } if (!tempFocus.focusedUponTheNightWhenTheHorsesAreFree) { tempFocus.focusedUponTheNightWhenTheHorsesAreFree = true; //if(!colorButtonNames.Contains(tempFocus.name)) //{ current.focusedUponTheNightWhenTheHorsesAreFree = false; //} return tempFocus; } return current; }
void Start() { confirmedButton = GameObject.Find ("ColorsConfirmed"); colorsConfirmedButton = confirmedButton.GetComponent<Button> (); colorsConfirmedSelectionButton = confirmedButton.GetComponent<ColorSelectionButton> (); InputManager.OnDeviceDetached += OnDeviceDetached; spawnPoints = new List<Vector3> (); try{ int sizeOfBtns = colorStarts.Count; } catch { Debug.Log("You didn't set the Respawns prefab, dingus."); } foreach (ColorSelectionButton c in colorStarts) { spawnPoints.Add(c.transform.position); } layla = GameObject.Find("Layla"); Debug.Log("Layla: " + layla); }
void Update() { foreach (ColorSelectionButton btn in colorsThatHaveBeenSelected) { btn.focusedUponTheNightWhenTheHorsesAreFree = true; } // Use last device which provided input. //var inputDevice = InputManager.ActiveDevice; filteredDirection.Filter( device.Direction, Time.deltaTime ); // filteredDirection = inputDevice.Direction; // if (layla.AllPlayersActive()) // { // focusedButton = confirmColors; // } if (filteredDirection.Left.WasRepeated) { Debug.Log( "!!!" ); } string previousButtonName = focusedButton.name; // Move focus with directional inputs. if (filteredDirection.Up.WasPressed) { focusedButton = GetAvailableUp(focusedButton); Debug.Log ("prev: " + previousButtonName); if(focusedButton.name == previousButtonName && (focusedButton.name == "Back" || focusedButton.name == "ColorsConfirmed")) { focusedButton.focusedUponTheNightWhenTheHorsesAreFree = false; ColorInputManager manager = GameObject.Find ("ColorInputManager").GetComponent<ColorInputManager>(); foreach(ColorSelectionButton btn in manager.colorStarts) { if(!btn.focusedUponTheNightWhenTheHorsesAreFree) { focusedButton = btn; focusedButton.focusedUponTheNightWhenTheHorsesAreFree = true; break; } } } } if (filteredDirection.Down.WasPressed) { focusedButton = GetAvailableDown(focusedButton); } if (filteredDirection.Left.WasPressed) { focusedButton = GetAvailableLeft(focusedButton); } if (filteredDirection.Right.WasPressed) { focusedButton = GetAvailableRight(focusedButton); } if (device.Action1.WasPressed) { if (focusedButton.isColor) { // Debug.Log("Focused button: " + focusedButton.name); Color c = focusedButton.GetComponent<ColorSelectionButton>().GetColor(); c.a = 1; handImage.color = c; labelImage.color = c; layla.SetPlayerColor(device,c); if(colorsThatHaveBeenSelected.Count > 0) { ColorSelectionButton btn = colorsThatHaveBeenSelected[0]; btn.focusedUponTheNightWhenTheHorsesAreFree = false; colorsThatHaveBeenSelected.Clear(); } colorsThatHaveBeenSelected.Add(focusedButton); } else { LoadScene(); } } if (device.Action2.WasPressed) { //Application.LoadLevel("PlayerSelectionWithController"); layla.ErasePlayerColor(device); handImage.color = Color.white; labelImage.color = Color.white; if(colorsThatHaveBeenSelected.Count > 0) { foreach(ColorSelectionButton btn in colorsThatHaveBeenSelected) { btn.focusedUponTheNightWhenTheHorsesAreFree = false; } colorsThatHaveBeenSelected.Clear(); } } }
void Start() { confirmedButton = GameObject.Find ("ColorsConfirmed"); colorsConfirmed = confirmedButton.GetComponent<Button> (); GameObject playerInputManager = GameObject.Find ("ColorInputManager"); GameObject selectionChild = transform.GetChild (0).gameObject; GameObject cursor = selectionChild.transform.GetChild(0).gameObject; handImage = cursor.GetComponent<Image> (); GameObject label = selectionChild.transform.GetChild(1).gameObject; labelImage = label.GetComponent<Image> (); ColorInputManager colorInputManagerScript = playerInputManager.GetComponent<ColorInputManager> (); int i = 0; while (colorInputManagerScript.colorStarts[i].focusedUponTheNightWhenTheHorsesAreFree) { i++; } focusedButton = colorInputManagerScript.colorStarts[i]; focusedButton.focusedUponTheNightWhenTheHorsesAreFree = true; layla = liaison.GetComponent<GameControlLiaison>(); }
ColorSelectionButton GetAvailableUp(ColorSelectionButton current) { ColorSelectionButton tempFocus = current.up; while (tempFocus.focusedUponTheNightWhenTheHorsesAreFree && tempFocus.up != tempFocus) { tempFocus = tempFocus.up; Debug.Log ("Green is covered up: " + tempFocus.name); } if (!tempFocus.focusedUponTheNightWhenTheHorsesAreFree) { tempFocus.focusedUponTheNightWhenTheHorsesAreFree = true; current.focusedUponTheNightWhenTheHorsesAreFree = false; Debug.Log ("Returning tempFocus " + tempFocus.name); return tempFocus; } return current; }