예제 #1
0
    public void SetActiveState(EditPartyScreenActiveState requiredState, bool doActivate)
    {
        // if doActivate is true,
        // then we are really swiching to this new state
        // otherwise it means that we are deactivating old state and returning to Normal state
        // this should not happen for Normal state, so here is check, for this
        if (requiredState == EditPartyScreenActiveState.Normal)
        {
            Debug.LogError("Unexpected condition");
        }
        // 1st return previous state to Normal, if it is already not Normal
        // this only needed if we are activating new state, while previous state was not normal
        if ((editPartyScreenActiveState != EditPartyScreenActiveState.Normal) && (requiredState != editPartyScreenActiveState) && (doActivate == true))
        {
            SetActiveState(editPartyScreenActiveState, false);
        }
        // Update
        editPartyScreenActiveState = requiredState;
        // instruct party and garnizon panels to highlight differently cells with and without units
        // loop through all active hero parties
        foreach (HeroPartyUI heroPartyUI in transform.parent.GetComponentsInChildren <HeroPartyUI>())
        {
            // Set active state (highlight)
            switch (editPartyScreenActiveState)
            {
            case EditPartyScreenActiveState.ActiveDismiss:
                heroPartyUI.GetComponentInChildren <PartyPanel>().SetActiveDismiss(doActivate);
                break;

            case EditPartyScreenActiveState.ActiveHeal:
                heroPartyUI.GetComponentInChildren <PartyPanel>().SetActiveHeal(doActivate);
                break;

            case EditPartyScreenActiveState.ActiveResurect:
                heroPartyUI.GetComponentInChildren <PartyPanel>().SetActiveResurect(doActivate);
                break;

            case EditPartyScreenActiveState.ActiveUnitDrag:
                heroPartyUI.GetComponentInChildren <PartyPanel>().SetActiveUnitDrag(doActivate);
                break;

            case EditPartyScreenActiveState.ActiveItemDrag:
                // replaced with events:
                // verify if we are not in equipment view mode, when party panel is disabled
                //if (heroPartyUI.GetComponentInChildren<PartyPanel>())
                //    heroPartyUI.GetComponentInChildren<PartyPanel>().SetActiveItemDrag(doActivate);
                //else if (transform.root.Find("MiscUI").GetComponentInChildren<HeroEquipment>())
                //    transform.root.Find("MiscUI").GetComponentInChildren<HeroEquipment>().SetActiveItemDrag(doActivate);
                //else
                //    Debug.LogWarning("Unknown condition");
                break;

            default:
                Debug.LogError("Unknown condition");
                break;
            }
        }
        // verfiy if there is a city garnizon == we are in city edit mode and not in hero party edit mode
        // and verify if there is already party in city
        if (transform.GetComponentInParent <UIManager>())
        {
            // verify if garnizon party is present
            if ((transform.GetComponentInParent <UIManager>().GetHeroPartyByMode(PartyMode.Garnizon, false) != null)
                // verify if there is party which is visiting city
                && (transform.GetComponentInParent <UIManager>().GetHeroPartyByMode(PartyMode.Party, false) == null))
            {
                // activate hire hero panel
                transform.parent.Find("HireHeroPanel").gameObject.SetActive(true);
            }
            else
            {
                // deactivate hire hero panel
                transform.parent.Find("HireHeroPanel").gameObject.SetActive(false);
            }
        }
        // Update cursor
        if (doActivate)
        {
            switch (requiredState)
            {
            case EditPartyScreenActiveState.ActiveDismiss:
                CursorController.Instance.SetDismissUnitCursor();
                break;

            case EditPartyScreenActiveState.ActiveHeal:
                CursorController.Instance.SetHealUnitCursor();
                break;

            case EditPartyScreenActiveState.ActiveResurect:
                CursorController.Instance.SetResurectUnitCursor();
                break;

            case EditPartyScreenActiveState.ActiveHeroEquipment:
                CursorController.Instance.SetInvenotryUnitCursor();
                break;

            case EditPartyScreenActiveState.ActiveUnitDrag:
                CursorController.Instance.SetDragUnitCursor();
                break;

            case EditPartyScreenActiveState.ActiveItemDrag:
                // replaced with event
                //CursorController.Instance.SetGrabHandCursor();
                break;

            default:
                Debug.LogError("Unknown condition");
                break;
            }
        }
        else
        {
            CursorController.Instance.SetNormalCursor();
            // if doActivate was false
            // this means that we need to return to normal state.
            // that what we did by passing doActivate variable to other functions
            // so we only need to set here state to normal
            editPartyScreenActiveState = EditPartyScreenActiveState.Normal;
        }
    }
예제 #2
0
    // context is destination unit slot
    public void OnUnitSlotLeftClickEvent(System.Object context)
    {
        // verify if context is correct
        if (context is UnitSlot)
        {
            // init unit slot from context
            UnitSlot unitSlot = (UnitSlot)context;
            Debug.Log("UnitSlot ActOnClick in City");
            // Get city state
            EditPartyScreenActiveState cityState = EditPartyScreenActiveState;
            // Verify if city state is not normal
            if (EditPartyScreenActiveState.Normal != cityState)
            {
                DeactivateActiveToggle();
            }
            // Get party unit UI in this slot
            PartyUnitUI unitUI = unitSlot.GetComponentInChildren <PartyUnitUI>();
            // Verify if unit is found
            if (unitUI)
            {
                // act based on the city (and cursor) state
                switch (cityState)
                {
                case EditPartyScreenActiveState.Normal:
                    // do nothing for now
                    break;

                case EditPartyScreenActiveState.ActiveDismiss:
                    // cache unit slot to dismiss (it is used in OnDismissYesConfirmation())
                    unitSlotToDismissCache = unitSlot;
                    // try to dismiss unit, if it is possible
                    TryToDismissUnit(unitUI.LPartyUnit);
                    break;

                case EditPartyScreenActiveState.ActiveHeal:
                    // try to heal unit, if it is possible
                    Debug.Log("Show Heal Unit confirmation box");
                    break;

                case EditPartyScreenActiveState.ActiveResurect:
                    // try to resurect unit, if it is possible
                    Debug.Log("Show Resurect Unit confirmation box");
                    break;

                case EditPartyScreenActiveState.ActiveUnitDrag:
                    // ??
                    break;

                case EditPartyScreenActiveState.ActiveItemDrag:
                    // this should not be triggered here, because it should be triggered in the unit slot drop handler when item is being dropped in it
                    Debug.LogWarning("Unpredicted condition");
                    break;

                default:
                    Debug.LogError("Unknown state");
                    break;
                }
            }
            else
            {
                Debug.LogWarning("Unit no found");
            }
            // Verify if city state is not normal
            if (EditPartyScreenActiveState.Normal != cityState)
            {
                // disable previous city state
                SetActiveState(cityState, false);
            }
        }
    }