Beispiel #1
0
    private void ClearActionButtons()
    {
        SpritedStringUI buttonText     = null;
        ButtonAnimator  buttonAnimator = null;
        GameObject      buttonObject   = null;

        if (actionTexts != null)
        {
            for (int i = 0; i < actionTexts.Length; i++)
            {
                buttonText = actionTexts[i];
                if (buttonText != null)
                {
                    buttonText.Clear();
                    actionTexts[i] = null;
                }
            }
            actionTexts = null;
        }
        if (actionTextObjects != null)
        {
            for (int i = 0; i < actionTextObjects.Length; i++)
            {
                buttonObject = actionTextObjects[i];
                if (buttonObject != null)
                {
                    Destroy(buttonObject);
                    actionTextObjects[i] = null;
                }
            }
            actionTextObjects = null;
        }
        if (actionButtons != null)
        {
            for (int i = 0; i < actionButtons.Length; i++)
            {
                buttonAnimator = actionButtons[i];
                if (buttonAnimator != null)
                {
                    buttonAnimator.Clear();
                    actionButtons[i] = null;
                }
            }
            actionButtons = null;
        }
        actionButtonTransforms = null;
        if (actionButtonObjects != null)
        {
            for (int i = 0; i < actionButtonObjects.Length; i++)
            {
                buttonObject = actionButtonObjects[i];
                if (buttonObject != null)
                {
                    Destroy(buttonObject);
                    actionButtonObjects[i] = null;
                }
            }
            actionButtonObjects = null;
        }
    }
Beispiel #2
0
 private void CreateCurrentNodeMarker()
 {
     if ((optionsParentTransform != null) && (markerButtonObject == null) && (markerButtonModel != null))
     {
         markerButtonObject = Instantiate(markerButtonModel) as GameObject;
         markerButtonTrans  = markerButtonObject.GetComponent <RectTransform>();
         markerButton       = markerButtonObject.GetComponent <ButtonAnimator>();
         if ((markerButtonTrans == null) || (markerButton == null))
         {
             if (markerButton != null)
             {
                 markerButton.Clear();
                 markerButton = null;
             }
             markerButtonTrans = null;
             Destroy(markerButtonObject);
             markerButtonObject = null;
         }
         else
         {
             markerButtonTrans.SetParent(optionsParentTransform, false);
             markerButtonTrans.anchoredPosition = markerAnchoredPos;
         }
     }
 }
Beispiel #3
0
 public virtual void DeselectOptionComponent()
 {
     if (selectedOptionComponent != null)
     {
         selectedOptionComponent.SetPressed(false);
         selectedOptionComponent = null;
     }
 }
Beispiel #4
0
        private async void UpdateSuccess_Load(object sender, EventArgs e)
        {
            okay_button.Visible = false;
            icon.Visible        = false;
            LogoAnimator.Show(icon);
            await Task.Delay(700);

            ButtonAnimator.Show(okay_button);
        }
Beispiel #5
0
        public MenuButton(Vector2 location, string text, ButtonStyles style, MenuPageEventArgs args, ButtonType type)
        {
            _location = location;
            _text     = text;
            _style    = style;
            _args     = args;
            _type     = type;

            _state    = ButtonStates.Enabled;
            _animator = new Animator(ButtonAnimator.GetAnimationsFromStyle(_style), (int)ButtonStates.Enabled, ButtonAnimator.GetImageSizeFromStyle(_style));
        }
Beispiel #6
0
    protected virtual bool CheckOptionsHit(Vector2 canvasPoint)
    {
        RectTransform  optionTransform = null;
        ButtonAnimator optionComponent = null;
        float          realWidth       = 0f;
        float          realHeight      = 0f;
        float          xMin            = 0f;
        float          yMax            = 0f;

        if (optionTransforms != null)
        {
            for (int i = 0; i < optionTransforms.Length; i++)
            {
                optionTransform = optionTransforms[i];
                realWidth       = optionTransform.rect.width * optionTransform.localScale.x;
                realHeight      = optionTransform.rect.height * optionTransform.localScale.y;
                xMin            = optionTransform.anchoredPosition.x - realWidth / 2f;
                yMax            = optionTransform.anchoredPosition.y + realHeight / 2f;
                if (optionsParentTransform != null)
                {
                    xMin += optionsParentTransform.anchoredPosition.x;
                    yMax += optionsParentTransform.anchoredPosition.y;
                }
                if (UsefulFunctions.AreaContainsPoint(xMin, yMax, realWidth, realHeight, canvasPoint.x, canvasPoint.y))
                {
                    selectedOptionComponent = null;
                    if (optionComponents != null)
                    {
                        if (optionComponents.Length > i)
                        {
                            optionComponent = optionComponents[i];
                            if (optionComponent != null)
                            {
                                selectedOptionComponent = optionComponent;
                                selectedOptionComponent.SetPressed(true);
                            }
                        }
                    }
                    selectedChoiceEffect = ChoiceEffect.None;
                    if (optionEffects != null)
                    {
                        if (optionEffects.Length > i)
                        {
                            selectedChoiceEffect = optionEffects[i];
                        }
                    }
                    return(true);
                }
            }
        }
        return(false);
    }
Beispiel #7
0
    protected override void Awake()
    {
        int[] IDRow = null;

        base.Awake();
        mapSize          = slotsPerMapSide;
        mapSize          = (mapSize > 0) ? mapSize : 1;
        slotToCanvasRate = (slotToCanvasRate > 0f) ? slotToCanvasRate : 0.1f;
        wallToSlotRate   = (wallToSlotRate > 0f) ? wallToSlotRate : 0.2f;

        /*halmeida - why should the slotNodeIDs matrix be static instead of dynamic?
         * If it was dynamic, the allocation of a slot with a very high value of row and column would be much more
         * expensive than the allocation of a slot with small values, because high row and column values demand the
         * allocation of a much longer array, which still has to be entirely initialized with invalid ID values
         * before receiving the proper ID value at specific indexes.
         * We could imagine that if the matrix was sparse instead of filled, dynamic allocation would not be a problem,
         * but that isn't true because the filled matrix of integers is equivalent to a sparse matrix of pointers. When
         * pointing unused pointers to null, integers are being set with a specific value, as the integers that receive
         * the invalid ID values in the filled static matrix.*/
        slotNodeIDs = new int[mapSize][];
        for (int i = 0; i < mapSize; i++)
        {
            IDRow = new int[mapSize];
            for (int j = 0; j < mapSize; j++)
            {
                IDRow[j] = GraphNode.NODE_ID_INVALID;
            }
            slotNodeIDs[i] = IDRow;
        }
        loadedNodeIDs      = null;
        nodeFirstRows      = null;
        nodeFirstColumns   = null;
        nodeLastRows       = null;
        nodeLastColumns    = null;
        nodePassages       = null;
        nodeSlotObjects    = null;
        nodeSlotImages     = null;
        nodeWallObjects    = null;
        nodeWallImages     = null;
        canvasSlotSize     = 0f;
        canvasWallSize     = 0f;
        mapVisible         = false;
        currentNodeID      = GraphNode.NODE_ID_INVALID;
        markerButtonObject = null;
        markerButtonTrans  = null;
        markerButton       = null;
        markerAnchoredPos  = Vector2.zero;
        minVisibleRow      = -1;
        minVisibleColumn   = -1;
        maxVisibleRow      = -1;
        maxVisibleColumn   = -1;
    }
    public void Start()
    {
        mButton         = GetComponent <Button>();
        mButtonAnimator = GetComponent <ButtonAnimator>();

        mButton.onClick.AddListener(ButtonActivation);

        Transform Child = transform.GetChild(0);

        if (Child != null)
        {
            Icon = Child.GetComponent <Image>();
        }
    }
Beispiel #9
0
    private GameObject CheckButtonValidity(GameObject testObject)
    {
        ButtonAnimator testAnimator  = null;
        RectTransform  testTransform = null;

        if (testObject != null)
        {
            testAnimator  = testObject.GetComponent <ButtonAnimator>();
            testTransform = testObject.GetComponent <RectTransform>();
            if ((testAnimator != null) && (testTransform != null))
            {
                return(testObject);
            }
        }
        return(null);
    }
Beispiel #10
0
    protected virtual void ProgressOptionComponents(float timeStep)
    {
        ButtonAnimator optionComponent = null;

        if (optionComponents != null)
        {
            for (int i = 0; i < optionComponents.Length; i++)
            {
                optionComponent = optionComponents[i];
                if (optionComponent != null)
                {
                    optionComponent.Progress(timeStep);
                }
            }
        }
    }
Beispiel #11
0
    protected override void ProgressOptionComponents(float timeStep)
    {
        ButtonAnimator optionButton = null;

        if (sectionButtons != null)
        {
            for (int i = 0; i < sectionButtons.Length; i++)
            {
                optionButton = sectionButtons[i];
                if (optionButton != null)
                {
                    optionButton.Progress(timeStep);
                }
            }
        }
        if (itemButtons != null)
        {
            for (int i = firstItemIndex; i <= lastItemIndex; i++)
            {
                optionButton = itemButtons[i];
                if (optionButton != null)
                {
                    optionButton.Progress(timeStep);
                }
            }
        }
        if (itemReturnButton != null)
        {
            itemReturnButton.Progress(timeStep);
        }
        if (itemAdvanceButton != null)
        {
            itemAdvanceButton.Progress(timeStep);
        }
        if (actionButtons != null)
        {
            for (int i = 0; i < actionButtons.Length; i++)
            {
                optionButton = actionButtons[i];
                if (optionButton != null)
                {
                    optionButton.Progress(timeStep);
                }
            }
        }
        base.ProgressOptionComponents(timeStep);
    }
Beispiel #12
0
 public virtual bool ReactToQuitRequest(bool ignoreQuitAvailability)
 {
     if (!ignoreQuitAvailability)
     {
         if (quitComponent != null)
         {
             selectedQuitComponent = quitComponent;
             selectedQuitComponent.SetPressed(true);
         }
         else
         {
             return(false);
         }
     }
     selectedChoiceEffect = ChoiceEffect.CloseMenu;
     return(true);
 }
Beispiel #13
0
    private void ChangeButtonState(bool pressedState, ButtonAnimator buttonAnimator, SpritedStringUI buttonName,
                                   SpritedStringUI buttonAmount)
    {
        if (buttonAnimator != null)
        {
            buttonAnimator.SetPressed(pressedState);
        }
        Color textColor = pressedState ? equippedTextColor : Color.white;

        if (buttonName != null)
        {
            buttonName.SetColor(textColor, Vector4.zero);
        }
        if (buttonAmount != null)
        {
            buttonAmount.SetColor(textColor, Vector4.zero);
        }
    }
Beispiel #14
0
 private bool CheckQuitHit(Vector2 canvasPoint)
 {
     if (quitTransform != null)
     {
         float realWidth  = quitTransform.rect.width * quitTransform.localScale.x;
         float realHeight = quitTransform.rect.height * quitTransform.localScale.y;
         float xMin       = quitTransform.anchoredPosition.x - realWidth / 2f;
         float yMax       = quitTransform.anchoredPosition.y + realHeight / 2f;
         if (UsefulFunctions.AreaContainsPoint(xMin, yMax, realWidth, realHeight, canvasPoint.x, canvasPoint.y))
         {
             selectedQuitComponent = quitComponent;
             selectedQuitComponent.SetPressed(true);
             ReactToQuitRequest(true);
             return(true);
         }
     }
     return(false);
 }
Beispiel #15
0
 protected override void ClearOptions()
 {
     if (markerButtonObject != null)
     {
         if (markerButton != null)
         {
             markerButton.Clear();
             markerButton = null;
         }
         markerButtonTrans = null;
         Destroy(markerButtonObject);
         markerButtonObject = null;
     }
     if (nodeSlotObjects != null)
     {
         for (int i = 0; i < nodeSlotObjects.Length; i++)
         {
             ClearNodeVisual(i);
         }
     }
     mapVisible = false;
 }
        /// <summary>
        /// Creates an instance of the Zeroit drop down button
        /// </summary>
        /// <param name="startLocation">Sets the start location</param>
        public ZeroitButtonDropDown(Point startLocation)
        {
            InitializeComponent();

            //Set the style--------------------------------------

            //Remove title bar and set edge-style
            this.Text            = string.Empty;
            this.FormBorderStyle = FormBorderStyle.None;

            BackColor = Color.Snow;


            //Disable normal window functions
            this.MinimizeBox   = false;
            this.MaximizeBox   = false;
            this.ControlBox    = false;
            this.ShowInTaskbar = false;
            this.TopMost       = true; //make it appear on the very top
            //----------------------------------------------------

            this.Capture = true; //allows mouse events to be triggered no matter where the mouse clicks

            //Match the position to the parent control
            this.Left = startLocation.X;
            this.Top  = startLocation.Y;

            ButtonAnimator animate = new ButtonAnimator();

            animate.Target        = this;
            animate.AnimationType = ButtonAnimator.GetAnimationType.TopAnchoredHeightEffect;
            animate.EasingType    = ButtonAnimator.EasingFunctionTypes.BounceEaseOut;
            animate.Duration      = 500;
            animate.ValueToReach  = 120;
            animate.Activate();
        }
Beispiel #17
0
 private void CreateItemButtons()
 {
     chosenItemIndex   = -1;
     checkingItemIndex = -1;
     if ((validItems != null) && (itemButtonModel != null) && (itemButtons == null))
     {
         if (validItems.Count > 0)
         {
             itemButtonObjects    = new GameObject[validItems.Count];
             itemButtonTransforms = new RectTransform[validItems.Count];
             itemButtons          = new ButtonAnimator[validItems.Count];
             itemTextObjects      = new GameObject[validItems.Count];
             itemTextTransforms   = new RectTransform[validItems.Count];
             itemTexts            = new SpritedStringUI[validItems.Count];
             itemAmountObjects    = new GameObject[validItems.Count];
             itemAmountTransforms = new RectTransform[validItems.Count];
             itemAmountComponents = new SpritedStringUI[validItems.Count];
             Vector2          buttonScale         = itemDisplayScheme.buttonElementScale;
             Vector2[]        allPositionRates    = itemDisplayScheme.elementPositionRates;
             Vector2          buttonPositionRates = Vector2.zero;
             Vector2          textPositionRates   = Vector2.zero;
             GameTextDatabase gameTextDatabase    = GameTextDatabase.Instance;
             ItemData         itemData            = null;
             string           itemName            = null;
             bool             itemHidden          = false;
             GameObject       itemButtonObject    = null;
             RectTransform    itemButtonTrans     = null;
             ButtonAnimator   itemButton          = null;
             GameObject       itemTextObject      = null;
             RectTransform    itemTextTrans       = null;
             SpritedStringUI  itemText            = null;
             GameObject       itemAmountObject    = null;
             RectTransform    itemAmountTransform = null;
             SpritedStringUI  itemAmountComponent = null;
             bool             needsScroll         = false;
             for (int i = 0; i < validItems.Count; i++)
             {
                 itemData            = validItems[i];
                 itemHidden          = true;
                 buttonPositionRates = new Vector2(0.5f, 0.5f);
                 gameTextDatabase.GetItemDescription(itemData.itemID, ref itemName);
                 if (allPositionRates != null)
                 {
                     if (i < allPositionRates.Length)
                     {
                         itemHidden          = false;
                         buttonPositionRates = allPositionRates[i];
                     }
                     else
                     {
                         needsScroll = true;
                     }
                 }
                 CreateButtonObject(itemButtonModel, buttonScale, buttonPositionRates, TextAlignment.Center, ref itemButtonObject,
                                    ref itemButtonTrans, ref itemButton);
                 textPositionRates = buttonPositionRates + itemTextOffsetRates;
                 CreateTextDisplayObject("ItemName", itemName, Vector2.one, textPositionRates, TextAlignment.Left,
                                         ref itemTextObject, ref itemTextTrans, ref itemText);
                 textPositionRates = buttonPositionRates + itemAmountOffsetRates;
                 CreateTextDisplayObject("ItemUnits", validItemUnits[i].ToString(), Vector2.one, textPositionRates,
                                         TextAlignment.Right, ref itemAmountObject, ref itemAmountTransform, ref itemAmountComponent);
                 if (itemHidden)
                 {
                     lastItemIndex = i - 1;
                     itemButtonObject.SetActive(false);
                     itemTextObject.SetActive(false);
                     itemAmountObject.SetActive(false);
                 }
                 else
                 {
                     if (firstItemIndex == -1)
                     {
                         firstItemIndex = i;
                         lastItemIndex  = i;
                     }
                 }
                 itemButtonObjects[i]    = itemButtonObject;
                 itemButtonTransforms[i] = itemButtonTrans;
                 itemButtons[i]          = itemButton;
                 itemTextObjects[i]      = itemTextObject;
                 itemTextTransforms[i]   = itemTextTrans;
                 itemTexts[i]            = itemText;
                 itemAmountObjects[i]    = itemAmountObject;
                 itemAmountTransforms[i] = itemAmountTransform;
                 itemAmountComponents[i] = itemAmountComponent;
                 if ((chosenItemIndex == -1) && (itemButton != null))
                 {
                     if (player.IsEquippedWith(itemData.itemID))
                     {
                         chosenItemIndex = i;
                         ChangeButtonState(true, itemButton, itemText, itemAmountComponent);
                     }
                 }
             }
             if (needsScroll)
             {
                 buttonScale         = itemDisplayScheme.buttonReturnScale;
                 buttonPositionRates = itemDisplayScheme.returnPositionRates;
                 CreateButtonObject(itemReturnButtonModel, buttonScale, buttonPositionRates, TextAlignment.Center,
                                    ref itemReturnButtonObject, ref itemReturnButtonTransform, ref itemReturnButton);
                 buttonScale         = itemDisplayScheme.buttonAdvanceScale;
                 buttonPositionRates = itemDisplayScheme.advancePositionRates;
                 CreateButtonObject(itemAdvanceButtonModel, buttonScale, buttonPositionRates, TextAlignment.Center,
                                    ref itemAdvanceButtonObject, ref itemAdvanceButtonTransform, ref itemAdvanceButton);
                 if (itemReturnButton != null)
                 {
                     itemReturnButton.SetPressed(true);
                 }
             }
         }
         else
         {
             Debug.Log("Debug : MenuInventory : no items to show in section " + chosenSectionIndex + ".");
         }
     }
 }
Beispiel #18
0
    private bool CreateHeader()
    {
        string        buttonCaption    = null;
        RectTransform toDiscard        = null;
        Vector2       anchoredPosition = Vector2.zero;

        if (interfaceCanvasObject != null)
        {
            GameTextDatabase gameTextDatabase = GameTextDatabase.Instance;
            if ((titleModel != null) && (titleObject == null))
            {
                titleObject    = Instantiate(titleModel) as GameObject;
                titleTransform = titleObject.GetComponent <RectTransform>();
                titleComponent = titleObject.GetComponent <ButtonAnimator>();
                if ((titleTransform != null) && (titleComponent != null))
                {
                    titleTransform.SetParent(interfaceCanvasTrans, false);
                    anchoredPosition.x = (titlePositionRates.x - 0.5f) * interfaceCanvasRect.width;
                    anchoredPosition.y = (titlePositionRates.y - 0.5f) * interfaceCanvasRect.height;
                    titleTransform.anchoredPosition = anchoredPosition;
                    titleTransform.localScale       = new Vector3(titleScale.x, titleScale.y, 1f);
                    if (gameTextDatabase != null)
                    {
                        buttonCaption = gameTextDatabase.GetMenuOptionText(titleTextEffect);
                        CreateButtonText(titleTransform, buttonCaption, ref titleTextObject, ref toDiscard, ref titleText, true);
                    }
                    titleComponent.SetPressed(true);
                }
                else
                {
                    titleTransform = null;
                    if (titleComponent != null)
                    {
                        titleComponent.Clear();
                        titleComponent = null;
                    }
                    Destroy(titleObject);
                    titleObject = null;
                }
            }
            if (allowQuitOption && (quitModel != null) && (quitObject == null))
            {
                quitObject    = Instantiate(quitModel) as GameObject;
                quitTransform = quitObject.GetComponent <RectTransform>();
                quitComponent = quitObject.GetComponent <ButtonAnimator>();
                if ((quitTransform != null) && (quitComponent != null))
                {
                    quitTransform.SetParent(interfaceCanvasTrans, false);
                    anchoredPosition.x             = (quitPositionRates.x - 0.5f) * interfaceCanvasRect.width;
                    anchoredPosition.y             = (quitPositionRates.y - 0.5f) * interfaceCanvasRect.height;
                    quitTransform.anchoredPosition = anchoredPosition;
                    quitTransform.localScale       = new Vector3(quitScale.x, quitScale.y, 1f);
                    if (gameTextDatabase != null)
                    {
                        buttonCaption = gameTextDatabase.GetMenuOptionText(quitTextEffect);
                        CreateButtonText(quitTransform, buttonCaption, ref quitTextObject, ref toDiscard, ref quitText, true);
                    }
                }
                else
                {
                    quitTransform = null;
                    if (quitComponent != null)
                    {
                        quitComponent.Clear();
                        quitComponent = null;
                    }
                    Destroy(quitObject);
                    quitObject = null;
                }
            }
            return((quitObject != null) || (titleObject != null));
        }
        return(false);
    }
Beispiel #19
0
    protected virtual void BuildOptions()
    {
        if ((interfaceCanvasComponent == null) || (optionsParentTransform == null))
        {
            return;
        }
        SeparateCurrentlyValidOptions();
        if ((currentValidOptionModels == null) || (currentValidOptionChoiceEffects == null))
        {
            return;
        }
        optionObjects     = new GameObject[currentValidModels];
        optionTransforms  = new RectTransform[currentValidModels];
        optionComponents  = new ButtonAnimator[currentValidModels];
        optionEffects     = new ChoiceEffect[currentValidModels];
        optionTextObjects = new GameObject[currentValidModels];
        optionTexts       = new SpritedStringUI[currentValidModels];
        GameObject      optionModel         = null;
        GameObject      newOptionObject     = null;
        RectTransform   newOptionTrans      = null;
        ButtonAnimator  newOptionComponent  = null;
        Vector2         newOptionScale      = Vector2.one;
        ChoiceEffect    newOptionEffect     = ChoiceEffect.None;
        GameObject      newOptionTextObject = null;
        RectTransform   toDiscard           = null;
        SpritedStringUI newOptionText       = null;
        /*halmeida - discover the canvas X coordinate where all options should be placed.*/
        float newAnchoredX = (optionCenterXRate - 0.5f) * interfaceCanvasRect.width;

        /*halmeida - discover the canvas Y coordinate where the top of the first option should be placed.*/
        highestOptionTopY = (highestOptionTopRate - 0.5f) * interfaceCanvasRect.height;
        float newAnchoredY = highestOptionTopY;
        /*halmeida - discover the vertical distance from one option to the next.*/
        float            optionDistance   = optionDistanceRate * interfaceCanvasRect.height;
        float            halfOptionHeight = 0f;
        GameTextDatabase gameTextDatabase = GameTextDatabase.Instance;
        string           buttonCaption    = null;

        for (int i = 0; i < currentValidModels; i++)
        {
            optionModel        = currentValidOptionModels[i];
            newOptionObject    = Instantiate(optionModel) as GameObject;
            newOptionTrans     = newOptionObject.GetComponent <RectTransform>();
            newOptionComponent = newOptionObject.GetComponent <ButtonAnimator>();
            newOptionScale     = currentValidOptionScales[i];
            newOptionEffect    = currentValidOptionChoiceEffects[i];
            newOptionTrans.SetParent(optionsParentTransform, false);
            newOptionTrans.localScale = new Vector3(newOptionScale.x, newOptionScale.y, 1f);
            halfOptionHeight          = (newOptionTrans.rect.height / 2f) * newOptionScale.y;
            newAnchoredY -= halfOptionHeight;
            newOptionTrans.anchoredPosition = new Vector2(newAnchoredX, newAnchoredY);
            newAnchoredY       -= halfOptionHeight + optionDistance;
            newOptionTextObject = null;
            newOptionText       = null;
            if (useOptionEffectAsText && (gameTextDatabase != null))
            {
                buttonCaption = gameTextDatabase.GetMenuOptionText(newOptionEffect);
                CreateButtonText(newOptionTrans, buttonCaption, ref newOptionTextObject, ref toDiscard, ref newOptionText, false);
            }
            optionObjects[i]     = newOptionObject;
            optionTransforms[i]  = newOptionTrans;
            optionComponents[i]  = newOptionComponent;
            optionEffects[i]     = newOptionEffect;
            optionTextObjects[i] = newOptionTextObject;
            optionTexts[i]       = newOptionText;
        }
        hiddenOptionHeight = 0f;
        if (newAnchoredY < -interfaceCanvasRect.height / 2f)
        {
            hiddenOptionHeight = -newAnchoredY - interfaceCanvasRect.height / 2f;
        }
    }
Beispiel #20
0
 public void ClearVisualRepresentation(bool immediately)
 {
     if (!graphicsCleared)
     {
         if (overlayDark || immediately)
         {
             if (titleText != null)
             {
                 titleText.Clear();
                 titleText = null;
             }
             if (titleTextObject != null)
             {
                 Destroy(titleTextObject);
                 titleTextObject = null;
             }
             if (titleComponent != null)
             {
                 titleComponent.Clear();
                 titleComponent = null;
             }
             titleTransform = null;
             if (titleObject != null)
             {
                 Destroy(titleObject);
                 titleObject = null;
             }
             selectedQuitComponent = null;
             if (quitText != null)
             {
                 quitText.Clear();
                 quitText = null;
             }
             if (quitTextObject != null)
             {
                 Destroy(quitTextObject);
                 quitTextObject = null;
             }
             if (quitComponent != null)
             {
                 quitComponent.Clear();
                 quitComponent = null;
             }
             quitTransform = null;
             if (quitObject != null)
             {
                 Destroy(quitObject);
                 quitObject = null;
             }
             ClearOptions();
             if (optionsParent != null)
             {
                 optionsParentTransform = null;
                 Destroy(optionsParent);
                 optionsParent = null;
             }
             if (!immediately && (imageOverlayComponent != null))
             {
                 overlayFadeSpeed = -overlayFadeSpeedRef;
             }
             else
             {
                 overlayDark  = false;
                 overlayClear = true;
             }
         }
         if (overlayClear)
         {
             if (imageOverlayObject != null)
             {
                 imageOverlayComponent = null;
                 Destroy(imageOverlayObject);
                 imageOverlayObject = null;
             }
             graphicsCleared = true;
             if (immediately)
             {
                 requiringProgress    = false;
                 selectedChoiceEffect = ChoiceEffect.None;
             }
         }
     }
 }
Beispiel #21
0
    protected virtual void ClearOptions()
    {
        ButtonAnimator  optionComponent = null;
        GameObject      optionObject    = null;
        SpritedStringUI optionText      = null;

        selectedOptionComponent = null;
        optionEffects           = null;
        if (optionComponents != null)
        {
            for (int i = 0; i < optionComponents.Length; i++)
            {
                optionComponent = optionComponents[i];
                if (optionComponent != null)
                {
                    optionComponent.Clear();
                    optionComponents[i] = null;
                }
            }
            optionComponents = null;
        }
        if (optionTransforms != null)
        {
            for (int i = 0; i < optionTransforms.Length; i++)
            {
                optionTransforms[i] = null;
            }
            optionTransforms = null;
        }
        if (optionObjects != null)
        {
            for (int i = 0; i < optionObjects.Length; i++)
            {
                optionObject = optionObjects[i];
                if (optionObject != null)
                {
                    Destroy(optionObject);
                    optionObjects[i] = null;
                }
            }
            optionObjects = null;
        }
        if (optionTexts != null)
        {
            for (int i = 0; i < optionTexts.Length; i++)
            {
                optionText = optionTexts[i];
                if (optionText != null)
                {
                    optionText.Clear();
                    optionTexts[i] = null;
                }
            }
            optionTexts = null;
        }
        if (optionTextObjects != null)
        {
            for (int i = 0; i < optionTextObjects.Length; i++)
            {
                optionObject = optionTextObjects[i];
                if (optionObject != null)
                {
                    Destroy(optionObject);
                    optionTextObjects[i] = null;
                }
            }
            optionTextObjects = null;
        }
        currentValidModels              = 0;
        currentValidOptionModels        = null;
        currentValidOptionScales        = null;
        currentValidOptionChoiceEffects = null;
        currentValidOptionEventIDs      = null;
    }
Beispiel #22
0
 private void Awake()
 {
     _buttonAnimator = GetComponent <ButtonAnimator>();
     _buttonSpeaker  = GetComponent <ButtonSpeaker>();
 }
Beispiel #23
0
    private void CreateActionButtons()
    {
        if ((validItems != null) && (actionButtonModel != null) && (interfaceCanvasTrans != null) && (actionButtons == null))
        {
            GameTextDatabase gameTextDatabase = GameTextDatabase.Instance;
            int totalActions = 0;
            if (itemActions != null)
            {
                totalActions = itemActions.Length;
            }
            if ((totalActions > 0) && (checkingItemIndex > -1) && (checkingItemIndex < validItems.Count))
            {
                ItemData itemData     = validItems[checkingItemIndex];
                bool     isEquippable = (itemData.equipment != null);
                bool     isEquipped   = player.IsEquippedWith(itemData.itemID);
                bool     isExpendable = itemData.expendable;
                actionButtonObjects    = new GameObject[totalActions];
                actionButtonTransforms = new RectTransform[totalActions];
                actionButtons          = new ButtonAnimator[totalActions];

                /*halmeida - the button objects and the text objects have to be separate objects so that they
                 * can have different scaling.*/
                actionTextObjects = new GameObject[totalActions];
                actionTexts       = new SpritedStringUI[totalActions];
                Vector2         buttonScale         = actionDisplayScheme.buttonElementScale;
                Vector2         buttonPositionRates = Vector2.zero;
                string          actionName          = null;
                Vector2[]       allPositionRates    = actionDisplayScheme.elementPositionRates;
                GameObject      buttonObject        = null;
                RectTransform   buttonTransform     = null;
                ButtonAnimator  buttonAnimator      = null;
                GameObject      buttonTextObject    = null;
                RectTransform   buttonTextTrans     = null;
                SpritedStringUI buttonText          = null;
                for (int i = 0; i < totalActions; i++)
                {
                    if (gameTextDatabase != null)
                    {
                        actionName = gameTextDatabase.GetMenuOptionText(itemActions[i]);
                    }
                    if (allPositionRates != null)
                    {
                        buttonPositionRates = (allPositionRates.Length > i) ? allPositionRates[i] : new Vector2(0.5f, 0.5f);
                    }
                    CreateButtonObject(actionButtonModel, buttonScale, buttonPositionRates, TextAlignment.Center,
                                       ref buttonObject, ref buttonTransform, ref buttonAnimator);
                    actionButtonObjects[i]    = buttonObject;
                    actionButtonTransforms[i] = buttonTransform;
                    actionButtons[i]          = buttonAnimator;
                    CreateTextDisplayObject("ActionName", actionName, Vector2.one, buttonPositionRates, TextAlignment.Center,
                                            ref buttonTextObject, ref buttonTextTrans, ref buttonText);
                    actionTextObjects[i] = buttonTextObject;
                    actionTexts[i]       = buttonText;
                    switch (itemActions[i])
                    {
                    case ChoiceEffect.Equip:
                        if (!isEquippable || isEquipped)
                        {
                            ChangeButtonState(true, buttonAnimator, buttonText, null);
                        }
                        break;

                    case ChoiceEffect.Unequip:
                        if (!isEquipped)
                        {
                            ChangeButtonState(true, buttonAnimator, buttonText, null);
                        }
                        break;

                    case ChoiceEffect.Use:
                        if (!isExpendable)
                        {
                            ChangeButtonState(true, buttonAnimator, buttonText, null);
                        }
                        break;
                    }
                }
            }
        }
    }
Beispiel #24
0
 protected override void Awake()
 {
     base.Awake();
     itemDatabase           = null;
     textBoxUIManager       = null;
     sectionButtonModel     = null;
     itemButtonModel        = null;
     itemReturnButtonModel  = null;
     itemAdvanceButtonModel = null;
     actionButtonModel      = null;
     if (sectionDisplayScheme != null)
     {
         sectionButtonModel = CheckButtonValidity(sectionDisplayScheme.buttonElementModel);
     }
     Vector2[] itemContentOffsets = null;
     if (itemDisplayScheme != null)
     {
         itemButtonModel        = CheckButtonValidity(itemDisplayScheme.buttonElementModel);
         itemReturnButtonModel  = CheckButtonValidity(itemDisplayScheme.buttonReturnModel);
         itemAdvanceButtonModel = CheckButtonValidity(itemDisplayScheme.buttonAdvanceModel);
         itemContentOffsets     = itemDisplayScheme.elementContentOffsetRates;
     }
     if (actionDisplayScheme != null)
     {
         actionButtonModel = CheckButtonValidity(actionDisplayScheme.buttonElementModel);
     }
     sectionButtonObjects    = null;
     sectionButtonTransforms = null;
     sectionButtons          = null;
     sectionTextObjects      = null;
     sectionTexts            = null;
     chosenSectionIndex      = -1;
     itemButtonObjects       = null;
     itemButtonTransforms    = null;
     itemButtons             = null;
     itemTextObjects         = null;
     itemTextTransforms      = null;
     itemTexts             = null;
     itemTextOffsetRates   = Vector2.zero;
     itemAmountObjects     = null;
     itemAmountTransforms  = null;
     itemAmountComponents  = null;
     itemAmountOffsetRates = Vector2.zero;
     if (itemContentOffsets != null)
     {
         if (itemContentOffsets.Length > 0)
         {
             itemTextOffsetRates = itemContentOffsets[0];
             if (itemContentOffsets.Length > 1)
             {
                 itemAmountOffsetRates = itemContentOffsets[1];
             }
         }
     }
     itemReturnButtonObject     = null;
     itemReturnButtonTransform  = null;
     itemReturnButton           = null;
     itemAdvanceButtonObject    = null;
     itemAdvanceButtonTransform = null;
     itemAdvanceButton          = null;
     chosenItemIndex            = -1;
     checkingItemIndex          = -1;
     firstItemIndex             = -1;
     lastItemIndex          = -1;
     validItems             = new List <ItemData>();
     validItemUnits         = new List <int>();
     secondOverlayObject    = null;
     secondOverlayImage     = null;
     thirdOverlayObject     = null;
     thirdOverlayImage      = null;
     hypotheticObjects      = null;
     hypotheticTexts        = null;
     actionButtonObjects    = null;
     actionButtonTransforms = null;
     actionButtons          = null;
     actionTextObjects      = null;
     actionTexts            = null;
 }
Beispiel #25
0
    private void ClearItemButtons()
    {
        SpritedStringUI buttonText     = null;
        ButtonAnimator  buttonAnimator = null;
        GameObject      buttonObject   = null;

        if (itemReturnButton != null)
        {
            itemReturnButton.Clear();
            itemReturnButton = null;
        }
        itemReturnButtonTransform = null;
        if (itemReturnButtonObject != null)
        {
            Destroy(itemReturnButtonObject);
            itemReturnButtonObject = null;
        }
        if (itemAdvanceButton != null)
        {
            itemAdvanceButton.Clear();
            itemAdvanceButton = null;
        }
        itemAdvanceButtonTransform = null;
        if (itemAdvanceButtonObject != null)
        {
            Destroy(itemAdvanceButtonObject);
            itemAdvanceButtonObject = null;
        }
        if (itemAmountComponents != null)
        {
            for (int i = 0; i < itemAmountComponents.Length; i++)
            {
                buttonText = itemAmountComponents[i];
                if (buttonText != null)
                {
                    buttonText.Clear();
                    itemAmountComponents[i] = null;
                }
            }
            itemAmountComponents = null;
        }
        itemAmountTransforms = null;
        if (itemAmountObjects != null)
        {
            for (int i = 0; i < itemAmountObjects.Length; i++)
            {
                buttonObject = itemAmountObjects[i];
                if (buttonObject != null)
                {
                    Destroy(buttonObject);
                    itemAmountObjects[i] = null;
                }
            }
            itemAmountObjects = null;
        }
        if (itemTexts != null)
        {
            for (int i = 0; i < itemTexts.Length; i++)
            {
                buttonText = itemTexts[i];
                if (buttonText != null)
                {
                    buttonText.Clear();
                    itemTexts[i] = null;
                }
            }
            itemTexts = null;
        }
        itemTextTransforms = null;
        if (itemTextObjects != null)
        {
            for (int i = 0; i < itemTextObjects.Length; i++)
            {
                buttonObject = itemTextObjects[i];
                if (buttonObject != null)
                {
                    Destroy(buttonObject);
                    itemTextObjects[i] = null;
                }
            }
            itemTextObjects = null;
        }
        if (itemButtons != null)
        {
            for (int i = 0; i < itemButtons.Length; i++)
            {
                buttonAnimator = itemButtons[i];
                if (buttonAnimator != null)
                {
                    buttonAnimator.Clear();
                    itemButtons[i] = null;
                }
            }
            itemButtons = null;
        }
        itemButtonTransforms = null;
        if (itemButtonObjects != null)
        {
            for (int i = 0; i < itemButtonObjects.Length; i++)
            {
                buttonObject = itemButtonObjects[i];
                if (buttonObject != null)
                {
                    Destroy(buttonObject);
                    itemButtonObjects[i] = null;
                }
            }
            itemButtonObjects = null;
        }
        chosenItemIndex   = -1;
        checkingItemIndex = -1;
        firstItemIndex    = -1;
        lastItemIndex     = -1;
    }
Beispiel #26
0
    private void ClearSectionButtons()
    {
        SpritedStringUI buttonText     = null;
        ButtonAnimator  buttonAnimator = null;
        GameObject      buttonObject   = null;

        if (sectionTexts != null)
        {
            for (int i = 0; i < sectionTexts.Length; i++)
            {
                buttonText = sectionTexts[i];
                if (buttonText != null)
                {
                    buttonText.Clear();
                    sectionTexts[i] = null;
                }
            }
            sectionTexts = null;
        }
        if (sectionTextObjects != null)
        {
            for (int i = 0; i < sectionTextObjects.Length; i++)
            {
                buttonObject = sectionTextObjects[i];
                if (buttonObject != null)
                {
                    Destroy(buttonObject);
                    sectionTextObjects[i] = null;
                }
            }
            sectionTextObjects = null;
        }
        if (sectionButtons != null)
        {
            for (int i = 0; i < sectionButtons.Length; i++)
            {
                buttonAnimator = sectionButtons[i];
                if (buttonAnimator != null)
                {
                    buttonAnimator.Clear();
                    sectionButtons[i] = null;
                }
            }
            sectionButtons = null;
        }
        sectionButtonTransforms = null;
        if (sectionButtonObjects != null)
        {
            for (int i = 0; i < sectionButtonObjects.Length; i++)
            {
                buttonObject = sectionButtonObjects[i];
                if (buttonObject != null)
                {
                    Destroy(buttonObject);
                    sectionButtonObjects[i] = null;
                }
            }
            sectionButtonObjects = null;
        }
        chosenSectionIndex = -1;
    }
Beispiel #27
0
    protected virtual void Awake()
    {
        GameObject     optionModel          = null;
        RectTransform  optionTrans          = null;
        ButtonAnimator optionComponent      = null;
        ChoiceEffect   optionChoiceEffect   = ChoiceEffect.None;
        GameObject     optionEventObject    = null;
        EventBase      optionEventComponent = null;
        int            optionEventID        = EventBase.INVALID_EVENT_ID;
        Vector2        optionScale          = Vector2.one;

        gameController                  = null;
        font                            = null;
        interfaceCanvasObject           = null;
        interfaceCanvasTrans            = null;
        interfaceCanvasComponent        = null;
        interfaceCanvasRect             = new Rect(0f, 0f, 0f, 0f);
        interfaceCanvasScreenRect       = new Rect(0f, 0f, 0f, 0f);
        imageOverlayModel               = null;
        imageOverlayObject              = null;
        imageOverlayComponent           = null;
        titleObject                     = null;
        titleTransform                  = null;
        titleComponent                  = null;
        titleTextObject                 = null;
        titleText                       = null;
        quitObject                      = null;
        quitTransform                   = null;
        quitComponent                   = null;
        quitTextObject                  = null;
        quitText                        = null;
        allowQuitOption                 = true;
        optionsParent                   = null;
        optionsParentTransform          = null;
        totalValidModels                = 0;
        totalValidOptionModels          = null;
        totalValidOptionScales          = null;
        totalValidOptionChoiceEffects   = null;
        totalValidOptionEventIDs        = null;
        currentValidModels              = 0;
        currentValidOptionModels        = null;
        currentValidOptionScales        = null;
        currentValidOptionChoiceEffects = null;
        currentValidOptionEventIDs      = null;
        optionObjects                   = null;
        optionTransforms                = null;
        optionComponents                = null;
        optionEffects                   = null;
        optionTextObjects               = null;
        optionTexts                     = null;
        selectedChoiceEffect            = ChoiceEffect.None;
        selectedQuitComponent           = null;
        selectedOptionComponent         = null;
        overlayFadeSpeed                = 0f;
        overlayFadeSpeedRef             = (backgroundAlphaSpeed > 0f) ? backgroundAlphaSpeed : 1f;
        overlayMaxAlpha                 = backgroundMaxAlpha;
        overlayDark                     = false;
        overlayClear                    = false;
        graphicsReady                   = false;
        graphicsCleared                 = false;
        touchingOverlay                 = false;
        draggingMenu                    = false;
        lastDragCanvasX                 = 0f;
        lastDragCanvasY                 = 0f;
        highestOptionTopY               = 0f;
        hiddenOptionHeight              = 0f;
        maxScreenOffsetLeft             = 0f;
        maxScreenOffsetRight            = 0f;
        maxScreenOffsetUp               = 0f;
        maxScreenOffsetDown             = 0f;
        requiringProgress               = false;
        clearBeforeEffect               = true;
        eventManager                    = null;
        previousMenu                    = null;
        if (optionModels != null)
        {
            for (int i = 0; i < optionModels.Length; i++)
            {
                optionModel = optionModels[i];
                if (optionModel != null)
                {
                    optionTrans     = optionModel.GetComponent <RectTransform>();
                    optionComponent = optionModel.GetComponent <ButtonAnimator>();
                    if ((optionTrans != null) && (optionComponent != null))
                    {
                        optionScale        = Vector2.one;
                        optionChoiceEffect = ChoiceEffect.None;
                        optionEventID      = EventBase.INVALID_EVENT_ID;
                        if (optionButtonScales != null)
                        {
                            if (optionButtonScales.Length > i)
                            {
                                optionScale = optionButtonScales[i];
                            }
                        }
                        if (optionChoiceEffects != null)
                        {
                            if (optionChoiceEffects.Length > i)
                            {
                                optionChoiceEffect = optionChoiceEffects[i];
                            }
                        }
                        if (optionEventRequirements != null)
                        {
                            if (optionEventRequirements.Length > i)
                            {
                                optionEventObject = optionEventRequirements[i];
                                if (optionEventObject != null)
                                {
                                    optionEventComponent = optionEventObject.GetComponent <EventBase>();
                                    if (optionEventComponent != null)
                                    {
                                        optionEventID = optionEventComponent.eventID;
                                    }
                                }
                            }
                        }
                        totalValidModels++;
                        UsefulFunctions.IncreaseArray <GameObject>(ref totalValidOptionModels, optionModel);
                        UsefulFunctions.IncreaseArray <Vector2>(ref totalValidOptionScales, optionScale);
                        UsefulFunctions.IncreaseArray <ChoiceEffect>(ref totalValidOptionChoiceEffects, optionChoiceEffect);
                        UsefulFunctions.IncreaseArray <int>(ref totalValidOptionEventIDs, optionEventID);
                    }
                }
            }
        }
    }
Beispiel #28
0
    private void CreateSectionButtons()
    {
        bool            toDiscard           = false;
        GameObject      buttonObject        = null;
        RectTransform   buttonTransform     = null;
        ButtonAnimator  buttonAnimator      = null;
        GameObject      buttonTextObject    = null;
        RectTransform   buttonTextTrans     = null;
        SpritedStringUI buttonText          = null;
        Vector2         buttonScale         = Vector2.one;
        Vector2         buttonPositionRates = Vector2.zero;

        if ((sectionButtonModel != null) && (interfaceCanvasTrans != null) && (sectionButtons == null))
        {
            GameTextDatabase gameTextDatabase = GameTextDatabase.Instance;
            int totalSections = 1;
            if (firstSections != null)
            {
                if (firstSections.Length > 0)
                {
                    totalSections += firstSections.Length;
                }
            }
            sectionButtonObjects    = new GameObject[totalSections];
            sectionButtonTransforms = new RectTransform[totalSections];
            sectionButtons          = new ButtonAnimator[totalSections];

            /*halmeida - the button objects and the text objects have to be separate objects so that they
             * can have different scaling.*/
            sectionTextObjects = new GameObject[totalSections];
            sectionTexts       = new SpritedStringUI[totalSections];
            buttonScale        = sectionDisplayScheme.buttonElementScale;
            string    sectionTitle     = null;
            Vector2[] allPositionRates = sectionDisplayScheme.elementPositionRates;
            for (int i = 0; i < totalSections; i++)
            {
                if (gameTextDatabase != null)
                {
                    if (i == (totalSections - 1))
                    {
                        sectionTitle = gameTextDatabase.GetSystemText(GameTextDatabase.TEXT_ID_NON_EQUIPPABLE_ITEMS, ref toDiscard);
                    }
                    else
                    {
                        sectionTitle = gameTextDatabase.GetEquipBodyPartName(firstSections[i]);
                    }
                }
                if (allPositionRates != null)
                {
                    buttonPositionRates = (allPositionRates.Length > i) ? allPositionRates[i] : new Vector2(0.5f, 0.5f);
                }
                CreateButtonObject(sectionButtonModel, buttonScale, buttonPositionRates, TextAlignment.Center,
                                   ref buttonObject, ref buttonTransform, ref buttonAnimator);
                sectionButtonObjects[i]    = buttonObject;
                sectionButtonTransforms[i] = buttonTransform;
                sectionButtons[i]          = buttonAnimator;
                CreateTextDisplayObject("SectionName", sectionTitle, Vector2.one, buttonPositionRates, TextAlignment.Center,
                                        ref buttonTextObject, ref buttonTextTrans, ref buttonText);
                sectionTextObjects[i] = buttonTextObject;
                sectionTexts[i]       = buttonText;
            }
        }
    }
Beispiel #29
0
 // Start is called before the first frame update
 void Start()
 {
     _audioSource    = GetComponent <AudioSource>();
     _buttonAnimator = GetComponent <ButtonAnimator>();
 }
Beispiel #30
0
 protected void CreateButtonObject(GameObject buttonModel, Vector2 scaleChange, Vector2 positionRates, TextAlignment anchorAlign,
                                   ref GameObject newButtonObject, ref RectTransform newButtonTransform, ref ButtonAnimator newButtonAnimator)
 {
     if (buttonModel != null)
     {
         newButtonObject    = Instantiate(buttonModel, interfaceCanvasTrans) as GameObject;
         newButtonAnimator  = newButtonObject.GetComponent <ButtonAnimator>();
         newButtonTransform = newButtonObject.GetComponent <RectTransform>();
         Vector2 originalUIDimensions = new Vector2(newButtonTransform.rect.width, newButtonTransform.rect.height);
         PlaceTransformProperly(newButtonTransform, originalUIDimensions, scaleChange, positionRates, anchorAlign);
     }
 }