public bool InterceptActionPress() { TransactionBox boxComponent = null; bool intercepted = false; ITransactionListener listener = null; if (boxComponents != null) { for (int i = 0; i < boxComponents.Length; i++) { boxComponent = boxComponents[i]; if (boxComponent != null) { if (boxComponent.ReactToActionPress()) { intercepted = true; listener = boxSourceListeners[i]; if (listener != null) { listener.AdvanceTransaction(); } } } } } return(intercepted); }
public void UpdateTransaction(GameObject sourceObject, int newMaxValue, int newCurrentValue, int newCurrentValueStep, bool investing, GameObject wsGaugeModel) { GameObject boxSourceObject = null; TransactionBox boxComponent = null; if ((sourceObject != null) && (boxSourceObjects != null)) { for (int i = 0; i < boxSourceObjects.Length; i++) { boxSourceObject = boxSourceObjects[i]; if (boxSourceObject == sourceObject) { boxComponent = boxComponents[i]; boxComponent.ResetForReconstruction(); boxComponent.SetBoxLimits(boxLimits.x, boxLimits.y); boxComponent.SetEssentials(symbolDatabase, bodySprite, "TO REPLACE", 0f, TextBox.TextAlignment.AlignMiddle, false, BOX_OPENING_SPEED); boxComponent.SetOrnamentGauge(wsGaugeModel); boxComponent.SetParameters(newMaxValue, newCurrentValue, newCurrentValueStep, investing); boxComponent.Build(); return; } } } }
public TransactionBox TBoxFull() { TransactionBox TBox = new TransactionBox(); //TBox.NUSID = button; //TBox.TransactionID = button; //TBox.BookingDateTime = button; //TBox.FacilityID = button; //TBox.TimeSlot = button; //TBox.TransactionType = button; //TBox.TransDateTime = button; return(TBox); }
public void AdvanceBoxAppearance() { int newIndex = -1; TransactionBox boxComponent = null; SpriteRenderer tailRenderer = null; if ((boxDatabase != null) && (boxAppearanceIndex > -1)) { newIndex = boxAppearanceIndex++; if (!boxDatabase.GetBoxAppearance(BoxAppearanceDatabase.BoxPurpose.System, newIndex, ref bodySprite, ref tailSprite)) { newIndex = 0; boxDatabase.GetBoxAppearance(BoxAppearanceDatabase.BoxPurpose.System, newIndex, ref bodySprite, ref tailSprite); } boxAppearanceIndex = newIndex; ExtractTailDimensions(); if (boxComponents != null) { for (int i = 0; i < boxComponents.Length; i++) { boxComponent = boxComponents[i]; if (boxComponent != null) { boxComponent.ChangeBoxBody(bodySprite); } } } if (boxTailRenderers != null) { for (int i = 0; i < boxTailRenderers.Length; i++) { tailRenderer = boxTailRenderers[i]; if (tailRenderer != null) { tailRenderer.sprite = tailSprite; } } } } }
public void CloseTransaction(GameObject sourceObject) { GameObject boxSourceObject = null; TransactionBox boxComponent = null; if ((sourceObject != null) && (boxSourceObjects != null)) { for (int i = 0; i < boxSourceObjects.Length; i++) { boxSourceObject = boxSourceObjects[i]; if (boxSourceObject == sourceObject) { boxComponent = boxComponents[i]; if (boxComponent != null) { boxComponent.Close(); } return; } } } }
public void Progress(float timeStep) { TransactionBox boxComponent = null; GameObject boxSourceObject = null; GameObject boxObject = null; GameObject boxTailObject = null; float boxSourceDistance = 0f; Vector2 boxDimensions = Vector2.zero; bool boxTryAbove = false; Vector2 tailOffset = Vector2.zero; Vector3 boxPosition = Vector3.zero; bool positionValid = false; Vector3 tailLocalPosition = Vector3.zero; if (boxComponents != null) { for (int i = 0; i < boxComponents.Length; i++) { boxComponent = boxComponents[i]; if (boxComponent != null) { boxComponent.Progress(timeStep); if (boxComponent.IsCleared()) { RemoveTransactionByIndex(i); if (boxComponents == null) { break; } else { i--; } } else { /*halmeida - relying on the coherence of all box related arrays.*/ boxSourceObject = boxSourceObjects[i]; boxSourceDistance = boxSourceDistances[i]; boxObject = boxObjects[i]; boxDimensions = boxComponent.GetBoxWorldDimensions(); boxTryAbove = boxTryAboves[i]; boxPosition = GetBoxPositionForSource(boxSourceObject, boxSourceDistance, boxDimensions, boxTryAbove, ref positionValid, ref tailOffset); if (!positionValid) { RemoveTransactionByIndex(i); if (boxComponents == null) { break; } else { i--; } } else { boxObject.transform.localPosition = boxPosition; boxTailObject = boxTailObjects[i]; if (boxTailObject != null) { tailLocalPosition = boxTailObject.transform.localPosition; tailLocalPosition.x = tailOffset.x; tailLocalPosition.y = tailOffset.y; boxTailObject.transform.localPosition = tailLocalPosition; if (tailOffset.y > 0f) { boxTailObject.transform.rotation = Quaternion.Euler(0f, 0f, 180f); } else { boxTailObject.transform.rotation = Quaternion.Euler(0f, 0f, 0f); } } } } } } } }
public bool CreateTransaction(GameObject sourceObject, ITransactionListener sourceListener, float sourceDistance, int maxValue, int currentValue, int currentValueStep, bool investing, bool tryAbove, GameObject wsGaugeModel) { GameObject boxObject = null; TransactionBox boxComponent = null; Vector2 boxDimensions = Vector2.zero; Vector2 boxOffset = Vector2.zero; Vector3 boxPosition = Vector3.zero; bool boxPositionValid = false; GameObject boxTailObject = null; SpriteRenderer boxTailRenderer = null; Vector2 tailOffset = Vector2.zero; /*halmeida - if there is already a transaction with the sourceObject, we remove it immediately, before * creating a new one with the specified values.*/ RemoveTransaction(sourceObject); if ((transactionBoxParent != null) && (symbolDatabase != null) && (sourceObject != null) && (sourceListener != null)) { boxObject = new GameObject("TransactionBox"); boxComponent = boxObject.AddComponent <TransactionBox>(); boxComponent.SetBoxLimits(boxLimits.x, boxLimits.y); boxComponent.SetEssentials(symbolDatabase, bodySprite, "TO REPLACE", 0f, TextBox.TextAlignment.AlignMiddle, false, BOX_OPENING_SPEED); boxComponent.SetOrnamentGauge(wsGaugeModel); boxComponent.SetParameters(maxValue, currentValue, currentValueStep, investing); boxTailObject = new GameObject("TransactionBoxTail"); boxTailRenderer = boxTailObject.AddComponent <SpriteRenderer>(); boxTailRenderer.sprite = tailSprite; boxComponent.Build(); boxDimensions = boxComponent.GetBoxWorldDimensions(); boxPosition = GetBoxPositionForSource(sourceObject, sourceDistance, boxDimensions, tryAbove, ref boxPositionValid, ref tailOffset); if (boxPositionValid) { boxObject.transform.SetParent(transactionBoxParent.transform, false); /*halmeida - since the transactionBoxParent is at x = 0 and y = 0, I can use the local position of its * children as if it was their position. Changing just the local position is faster.*/ boxObject.transform.localPosition = boxPosition; boxTailObject.transform.SetParent(boxObject.transform, false); boxTailObject.transform.localPosition = new Vector3(tailOffset.x, tailOffset.y, boxComponent.GetBoxToTextDepth()); if (tailOffset.y > 0f) { boxTailObject.transform.rotation = Quaternion.Euler(0f, 0f, 180f); } boxComponent.Open(); UsefulFunctions.IncreaseArray <GameObject>(ref boxObjects, boxObject); UsefulFunctions.IncreaseArray <TransactionBox>(ref boxComponents, boxComponent); UsefulFunctions.IncreaseArray <GameObject>(ref boxSourceObjects, sourceObject); UsefulFunctions.IncreaseArray <ITransactionListener>(ref boxSourceListeners, sourceListener); UsefulFunctions.IncreaseArray <float>(ref boxSourceDistances, sourceDistance); UsefulFunctions.IncreaseArray <bool>(ref boxTryAboves, tryAbove); UsefulFunctions.IncreaseArray <GameObject>(ref boxTailObjects, boxTailObject); UsefulFunctions.IncreaseArray <SpriteRenderer>(ref boxTailRenderers, boxTailRenderer); return(true); } boxComponent.Clear(); GameObject.Destroy(boxObject); GameObject.Destroy(boxTailObject); } return(false); }