示例#1
0
    void ActivateHireUnitButtonsIfNeeded()
    {
        // get city screen
        EditPartyScreen cityScreen = transform.root.GetComponentInChildren <UIManager>().GetComponentInChildren <EditPartyScreen>();

        // verify if we are in city view mode
        if (cityScreen != null)
        {
            // activate hire unit pnl button
            cityScreen.SetHireUnitPnlButtonActive(true);
        }
    }
示例#2
0
    void ShowCredits()
    {
        Debug.Log("Show credits");
        // I assume that we were at map before game end
        // Disable city screen if it was active
        EditPartyScreen cityScreen = UIRoot.Instance.GetComponentInChildren <UIManager>().GetComponentInChildren <EditPartyScreen>();

        if (cityScreen)
        {
            cityScreen.gameObject.SetActive(false);
        }
        // Disable map
        MapManager.Instance.gameObject.SetActive(false);
        MapMenuManager.Instance.gameObject.SetActive(false);
        // Enable credits
        GameObject credits = UIRoot.Instance.transform.Find("MiscUI/Credits").gameObject;

        credits.SetActive(true);
    }
示例#3
0
    public void OnDrop(PointerEventData eventData)
    {
        // verify if we are in city edit mode and not in hero edit mode
        EditPartyScreen cityScreen = transform.root.GetComponentInChildren <UIManager>().GetComponentInChildren <EditPartyScreen>();

        if (cityScreen != null)
        {
            // activate hire unit buttons again, after it was disabled
            cityScreen.SetHireUnitPnlButtonActive(true);
        }
        // verify if it is item being dragged
        if (InventoryItemDragHandler.itemBeingDragged != null)
        {
            // raise on item drop event (pass this slot as argument)
            itemHasBeenDroppedIntoTheUnitSlotEvent.Raise(this);
            //// verify if there is a unit in the slot
            //if (GetComponentInChildren<PartyUnitUI>() != null)
            //{
            //    // try to apply item to the unit
            //    GetComponentInChildren<PartyUnitUI>().ActOnItemDrop(InventoryItemDragHandler.itemBeingDragged);
            //}
            // reset cursor to normal
            // CursorController.Instance.SetNormalCursor();
        }
        // verify if it is party unit being dragged
        else if (UnitDragHandler.unitBeingDraggedUI != null)
        {
            // raise on unit drop event
            unitUIHasBeenDroppedIntoTheUnitSlotEvent.Raise(this);
            // act based on the previously set by OnDrag condition
            if (isDropAllowed)
            {
                // drop is allowed
                // act based on then draggable unit size
                // get actual unit, structure Cell-UnitCanvas(dragged->Unit link)
                PartyUnit draggedUnit = UnitDragHandler.unitBeingDraggedUI.GetComponent <PartyUnitUI>().LPartyUnit;
                Transform srcCellTr   = UnitDragHandler.unitBeingDraggedUI.transform.parent.parent;
                Transform dstCellTr   = transform.parent;
                if (draggedUnit.UnitSize == UnitSize.Single)
                {
                    // single unit
                    // possible states
                    // src  dst                                 result
                    // 1    free or occupied by single unit     swap single cells
                    // 1    occupied by double                  swap cells in horizontal panels
                    // act based on destination cell size
                    if (UnitSize.Single == cellSize)
                    {
                        // swap single cells
                        SwapTwoCellsContent(srcCellTr, dstCellTr);
                    }
                    else
                    {
                        // swap 2 single cells in src panel with double cell in dest panel
                        SwapSingleWithDouble(srcCellTr, dstCellTr, true);
                    }
                }
                else
                {
                    // double unit
                    if (UnitSize.Single == cellSize)
                    {
                        // swap single with double cells
                        SwapSingleWithDouble(srcCellTr, dstCellTr, false);
                    }
                    else
                    {
                        // swap 2 double cells
                        SwapTwoCellsContent(srcCellTr, dstCellTr);
                    }
                }
                // Instruct focus panels to be updated
                foreach (FocusPanel focusPanel in transform.root.GetComponentInChildren <UIManager>().GetComponentsInChildren <FocusPanel>())
                {
                    focusPanel.OnChange(FocusPanel.ChangeType.UnitsPositionChange);
                }
                //// drop unit if there is no other unit already present
                //if (!unit)
                //{
                //    PartyPanelMode panelMode = UnitDragHandler.unitBeingDragged.transform.parent.parent.parent.parent.GetComponent<PartyPanel>().GetPanelMode();
                //    if (PartyPanelMode.Garnizon == panelMode)
                //    {
                //        // enable hire unit button in the original parent cell and bring it to the front
                //        // and it is not wide
                //        // todo: add not wide condition check
                //    }
                //    // change parent of the dragged unit
                //    Debug.Log("Drop unit from " + UnitDragHandler.unitBeingDraggedParentTr.parent.gameObject.name);
                //    UnitDragHandler.unitBeingDragged.transform.SetParent(transform);
                //    // disable hire unit button in the destination (this) cell, if it is garnizon panel
                //    // structure 3PartyPanel-2Top/Middle/Bottom-1Front/Back/Wide-(this)UnitSlot
                //    panelMode = transform.parent.parent.parent.GetComponent<PartyPanel>().GetPanelMode();
                //    if (PartyPanelMode.Garnizon == panelMode)
                //    {
                //        // todo: add not wide condition check
                //    }
                //    // trigger event
                //    // ExecuteEvents.ExecuteHierarchy<IHasChanged>(gameObject, null, (x, y) => x.HasChanged());
                //}
            }
            else
            {
                // drop is not allowed
                // display error message
                NotificationPopUp.Instance().DisplayMessage(errorMessage);
            }
        }
        else
        {
            Debug.LogWarning("Unknown object is being dragged");
        }
    }
示例#4
0
    public void SetRequiredMenusActive(bool doActivate)
    {
        // Get city transform
        // structure: 6City-5HeroParty-4PartyPanel-3Row-2Cell-1UnitEquipmentControl-EquipmentButton(this)
        //City city = transform.parent.parent.parent.parent.parent.parent.GetComponent<City>();
        // Get city screen
        EditPartyScreen editPartyScreen = transform.root.GetComponentInChildren <UIManager>().GetComponentInChildren <EditPartyScreen>(true);

        // verify if City screen is active = we are in a city
        if (editPartyScreen)
        {
            //City city = cityScreen.City;
            // do actions for each HeroParty
            foreach (HeroPartyUI heroPartyUI in transform.root.GetComponentInChildren <UIManager>().GetComponentsInChildren <HeroPartyUI>(true))
            {
                // verify if heroPartyUI has linked Party
                if (heroPartyUI.LHeroParty != null)
                {
                    // activate/deactivate party panel
                    heroPartyUI.GetComponentInChildren <PartyPanel>(true).gameObject.SetActive(doActivate);
                }
            }
            // verify if we are in city or hero party edit mode
            if (editPartyScreen.LCity != null)
            {
                // activate/deactivate city control butons
                transform.root.GetComponentInChildren <UIManager>().GetComponentsInChildren <CityHealButton>(true)[0].gameObject.SetActive(doActivate);
                transform.root.GetComponentInChildren <UIManager>().GetComponentsInChildren <CityResurectButton>(true)[0].gameObject.SetActive(doActivate);
            }
            transform.root.GetComponentInChildren <UIManager>().GetComponentsInChildren <CityDismissButton>(true)[0].gameObject.SetActive(doActivate);
            // activate/deactivate ReturnBtn
            transform.root.GetComponentInChildren <UIManager>().GetComponentsInChildren <CityBackButton>(true)[0].gameObject.SetActive(doActivate);
            // activate/deactivate Unit Equipment back button
            transform.root.Find("MiscUI/BottomControlPanel/RightControls/HeroEquipmentBackButton").gameObject.SetActive(!doActivate);
            // activate/deactivate focus panels
            FocusPanel[] focusPanels = transform.root.GetComponentInChildren <UIManager>().GetComponentsInChildren <FocusPanel>(true);
            for (int i = 0; i < focusPanels.Length; i++)
            {
                // verify if focus panel is about to be disabled
                if (false == doActivate)
                {
                    // save original linked object of each focus panel
                    originalState.FocusPanelsLinkedObject[i] = focusPanels[i].focusedObject;
                    // disable focus panel
                    focusPanels[i].gameObject.SetActive(doActivate);
                }
                else
                {
                    // verify if there was linked game object to focus panel
                    if (originalState.FocusPanelsLinkedObject[i] != null)
                    {
                        // restore original state of the focus panel (before disable)
                        focusPanels[i].focusedObject = originalState.FocusPanelsLinkedObject[i];
                        focusPanels[i].gameObject.SetActive(true);
                    }
                }
            }
            // activate/deactivate HireHeroPanel
            if (false == doActivate)
            {
                originalState.HireHeroPanel = transform.root.GetComponentInChildren <UIManager>().transform.Find("HireHeroPanel").gameObject.activeSelf;
                transform.root.GetComponentInChildren <UIManager>().transform.Find("HireHeroPanel").gameObject.SetActive(doActivate);
            }
            else
            {
                transform.root.GetComponentInChildren <UIManager>().transform.Find("HireHeroPanel").gameObject.SetActive(originalState.HireHeroPanel);
            }
            // activate/deactivate HireCommonUnitButtons
            if (false == doActivate)
            {
                originalState.HireCommonUnitButtons = transform.root.GetComponentInChildren <UIManager>().transform.Find("HireCommonUnitButtons").gameObject.activeSelf;
                transform.root.GetComponentInChildren <UIManager>().transform.Find("HireCommonUnitButtons").gameObject.SetActive(doActivate);
            }
            else
            {
                transform.root.GetComponentInChildren <UIManager>().transform.Find("HireCommonUnitButtons").gameObject.SetActive(originalState.HireCommonUnitButtons);
            }
            // Activate/deactivate unit info panel
            UnitInfoPanel unitInfoPanel = transform.root.Find("MiscUI/UnitInfoPanel").GetComponent <UnitInfoPanel>();
            if (!doActivate)
            {
                // activate unit info panel
                // get party unit, structure: 2UnitCanvas(Clone)-1UnitEquipmentControl-EquipmentButton(this)
                PartyUnit partyUnit = transform.parent.parent.GetComponent <PartyUnitUI>().LPartyUnit;
                // activate unit info panel
                unitInfoPanel.ActivateAdvance(partyUnit, UnitInfoPanel.Align.Right, false, UnitInfoPanel.ContentMode.Short);
            }
            else
            {
                // deactivate unit info panel
                unitInfoPanel.gameObject.SetActive(false);
            }
            // Disable/Enable unit info panel background
            //unitInfoPanel.transform.Find("Background").gameObject.SetActive(doActivate);
        }
    }