protected override GameObject[] GenerateUI(out Vector2 offsets) { this.tl = tl; ActionKeyPersistance.ActionKeyPersistanceData[] mappings = ActionKeyPersistance.GetKeyCubeMapping(); for (int yy = 0; yy < 3; yy++) { for (int xx = 0; xx < 3; xx++) { GameObject mapButton = this.generator.DrawButton("", new Vector2(tl.x + this.procUI.xOffset + xx * (this.procUI.xOffset + this.procUI.buttonPixelsX), tl.y - (yy * (this.procUI.yOffset + this.procUI.buttonPixelsY)))); this.Elements.Add(mapButton); int keyId = yy * 3 + xx + 1; ActionButtonMap node = new ActionButtonMap(keyId, mapButton, this.actionButtonData); ActionKeyPersistance.ActionKeyPersistanceData mapping = mappings.FirstOrDefault(y => y.KeyId == keyId); if (mapping != null) { node.SetName(mapping.CubeName); } this.actionButtonData.Add(node); mapButton.GetComponent <Button>().onClick.AddListener(() => node.Select()); } } offsets = new Vector2((this.procUI.xOffset + this.procUI.buttonPixelsX) * 3, (this.procUI.yOffset + this.procUI.buttonPixelsY) * 3); return(this.Elements.ToArray()); }
private void OnClickDeleteCube(string nameText) { CubePersistance.DeleteCube(nameText); ActionKeyPersistance.Delete(nameText); this.procUI.drawActionButtonMapping.Refresh(); this.Refresh(); }
public void RedoMappingConnections() { var existingMappings = ActionKeyPersistance.GetKeyCubeMapping(); for (int i = 0; i < 9; i++) { var btnInfo = buttons[i]; int index = i; Button button = btnInfo.Button.GetComponent <Button>(); button.onClick.RemoveAllListeners(); btnInfo.Button.GetComponent <Button>().onClick.AddListener(() => ActionButtonOnClick(index + 1)); btnInfo.Button.SetActive(false); var mappings = existingMappings.Where(x => x.KeyId == i + 1).ToArray(); if (mappings.Length == 1) { btnInfo.CubeName = mappings[0].CubeName; btnInfo.Button.transform.Find("Text").GetComponent <Text>().text = mappings[0].CubeName; } } }
private void OnClickLoadCube(string cubeName) { DrawActionButtonMapping.ActionButtonMap selected = this.procUI.drawActionButtonMapping.actionButtonData.SingleOrDefault(x => x.Selected); // if we are loading a Cube to work on... if (selected == null) { ReferenceBuffer.Instance.worldSpaceUI.connTracker.AddBundle(cubeName); ReferenceBuffer.Instance.worldSpaceUI.connTracker.LoadPersistedData(cubeName, true); } // if we are mapping key to a Cube... else { ActionKeyPersistance.ActionKeyPersistanceData[] mappings = ActionKeyPersistance.GetKeyCubeMapping(); if (mappings.Any(x => x.CubeName == cubeName)) { Debug.Log("There is already key with that cube name!!!"); return; } if (selected == null) { return; } selected.SetName(cubeName); selected.Deselect(); ActionKeyPersistance.Persist(new ActionKeyPersistance.ActionKeyPersistanceData { CubeName = cubeName, KeyId = selected.Id, }); ReferenceBuffer.Instance.ShowPresetBehaviour.RedoMappingConnections(); } }
public void MapConnections() { var existingMappings = ActionKeyPersistance.GetKeyCubeMapping(); this.buttons = new List <ActionButton>(); for (int i = 1; i <= 9; i++) { ActionButton btnInfo = new ActionButton(); this.buttons.Add(btnInfo); btnInfo.Button = GameObject.Find("ActionButton" + i); int index = i; btnInfo.Button.GetComponent <Button>().onClick.AddListener(() => ActionButtonOnClick(index)); btnInfo.Button.SetActive(false); var mappings = existingMappings.Where(x => x.KeyId == i).ToArray(); if (mappings.Length == 1) { btnInfo.CubeName = mappings[0].CubeName; btnInfo.Button.transform.Find("Text").GetComponent <Text>().text = mappings[0].CubeName; } btnInfo.ID = i; } }
private void ActionButtonOnClick(int id) { ActionButton btnInfo = this.buttons.Single(x => x.ID == id); if (btnInfo.CubeName != null) { Debug.Log($"WORKS=> {btnInfo.CubeName}"); GameObject player = ReferenceBuffer.Instance.PlayerObject; Vector3?droneMarker = null; if (ReferenceBuffer.Instance.DroneIntersection != null) { droneMarker = ReferenceBuffer.Instance.DroneIntersection.GetIntersectionPosition; } ReferenceBuffer.Instance.worldSpaceUI.connTracker.RunCube(btnInfo.CubeName, new Variable[] { new Variable { Name = ResultCanvas.PlayerForwardVarName, Value = ReferenceBuffer.Instance.PlayerObject.transform.forward, }, new Variable { Name = ResultCanvas.PlayerPositionVarName, Value = ReferenceBuffer.Instance.PlayerObject.transform.position, }, new Variable { Name = ResultCanvas.PlayerMarkerVarName, Value = ReferenceBuffer.Instance.PlayerIntersection.GetIntersectionPosition, }, new Variable { Name = ResultCanvas.DroneMarkerVarName, Value = droneMarker, }, }); return; } CubeInfo[] infos = CubePersistance.GetAllSavedCubes(); if (infos.Length == 0) { Debug.Log("There are no saved QUBES!!!"); return; } string lastName = infos.Last().Name; var persistedKeys = ActionKeyPersistance.GetKeyCubeMapping(); if (persistedKeys.Select(x => x.CubeName).Contains(lastName)) { Debug.Log("That spell name already keyd!"); return; } ActionKeyPersistance.Persist(new ActionKeyPersistance.ActionKeyPersistanceData { CubeName = lastName, KeyId = id, }); btnInfo.Button.transform.Find("Text").GetComponent <Text>().text = lastName; }