// Use this for initialization void Start() { _img = GetComponent <Image>(); _builder = DataPipe.instance.BuildingInteraction; ActionGroup.transform.DOScale(0, 0); Action_1.Trigger = () => { Action_2.ResetVisualFuntionality(); _currentSelectedAction = Action_1; SelectAction(); }; Action_2.Trigger = () => { Action_1.ResetVisualFuntionality(); _currentSelectedAction = Action_2; SelectAction(); }; _resourceMan = DataPipe.instance.ResourceManager; _platformData = DataPipe.instance.PlatformData; BA_InputReceiverUI.Instance.ActionKey += BuildMenu; BA_InputReceiverUI.Instance.ActionKey2 += ReceiveBuildCommand; BA_InputReceiverUI.Instance.ActionDirectional += ReceiveDirectionalInput; InputMapper.MoveInputVector3 += ReceivePlatformCommand; _builder.RessourceCheck = () => RessourceCheck(); _arrowHandler = FindObjectOfType <DirectionalArrowHandler>(); }
public void RessourceCheck() { bool resetCurrentSelectedAction = false; if (_currentSelectedAction == Action_1 || _currentSelectedAction == null) { if (!_resourceMan.HasEnoughResource(_platformData.Platform1_Cost)) { Action_1.Hide(); //_currentSelectedAction = null; resetCurrentSelectedAction = true; Build(false); } } if (_currentSelectedAction == Action_2 || _currentSelectedAction == null) { if (!_resourceMan.HasEnoughResource(_platformData.Platform2_Cost)) { Action_2.Hide(); //_currentSelectedAction = null; resetCurrentSelectedAction = true; Build(false); } } if (resetCurrentSelectedAction) { _currentSelectedAction = null; } }
// Use this for initialization private void Awake() { if (instance == null) { instance = this; } myCam = Camera.main; graphicRay = GetComponent <GraphicRaycaster>(); }
public override IEnumerator Select(Unit unit, Board board, Timeline timeline, IEnumerator next) { ActionUI ui = Instantiate(actionUI.gameObject, gameObject.transform).GetComponent <ActionUI>(); ui.Initialize(unit, GetNewActionInstance(), board, timeline); while (ui.state != ActionSubmissionState.SUBMITTED && ui.state != ActionSubmissionState.CANCELLED) { yield return(new WaitForFixedUpdate()); } Destroy(ui.gameObject); StartCoroutine(next); yield return(null); }
private void ActivateUIFeedback(bool isActive) { if (isActive) { if (interactionUI == null) { interactionUI = Instantiate(Resources.Load <GameObject>("ToInstantiate/ActionCanvas")).GetComponent <ActionUI>(); interactionUI.Init(this); } interactionUI.gameObject.SetActive(true); } else { interactionUI?.gameObject.SetActive(false); } }
public void ReceiveDirectionalInput(Vector2 input) { if (!_active) { return; } float angle = Mathf.Atan2(input.x, input.y) * Mathf.Rad2Deg; if (angle < 45 && angle > -90) { _currentSelectedAction = Action_1; SelectAction(); } else if (angle < -90 || Mathf.Abs(angle) > 90) { _currentSelectedAction = Action_2; SelectAction(); } }
public void BuildMenu() { if (!_active) { Particles.Stop(true, ParticleSystemStopBehavior.StopEmitting); _arrowHandler.FadeOutAndBlock(); ContextRegulator.Building_Activated(); OnPointerDown(); //_currentSelectedAction = Action_1; //SelectAction(); _active = true; } else { Particles.Play(); _arrowHandler.Unblock(); _active = false; Build(false); ResetToNormal(); ContextRegulator.Building_Deactivated(); _currentSelectedAction = null; } }
private void OnEnable() { actionUI = (ActionUI)target; }
public void init() { ui = new ActionUI(); ui.ctrl = this; ui.init(); }