Exemple #1
0
 void HireSingleUnit(Transform callerCell, PartyUnit hiredUnitTemplate, bool doCreateUI = true)
 {
     if (VerifySingleUnitHire(hiredUnitTemplate))
     {
         // create unit
         HireGenericUnit(hiredUnitTemplate, LCity.GetHeroPartyByMode(PartyMode.Garnizon), callerCell.Find("UnitSlot"), doCreateUI);
         if (doCreateUI)
         {
             // Update city garnizon panel to fill in required information and do required adjustments;
             transform.GetComponentInParent <UIManager>().GetHeroPartyUIByMode(PartyMode.Garnizon, false).GetComponentInChildren <PartyPanel>(true).OnChange(PartyPanel.ChangeType.HireSingleUnit, callerCell);
             // Instruct Right focus panel to update information
             transform.parent.Find("RightFocus").GetComponent <FocusPanel>().OnChange(FocusPanel.ChangeType.HireSingleUnit);
         }
     }
 }
Exemple #2
0
 void HireDoubleUnit(Transform callerCell, PartyUnit hiredUnitTemplate, bool doCreateUI = true)
 {
     if (VerifyDoubleUnitHire(callerCell, hiredUnitTemplate))
     {
         // get parent for new cell
         // if it is double size, then place it in the wide cell
         // if hired unit is double unit, then we actually need to change its parent to the wide
         // hierarchy: [Top/Middle/Bottom panel]-[Front/Back/Wide]-callerCell
         // create unit
         HireGenericUnit(hiredUnitTemplate, LCity.GetHeroPartyByMode(PartyMode.Garnizon), callerCell.parent.Find("Wide/UnitSlot"), doCreateUI);
         if (doCreateUI)
         {
             // update panel
             transform.GetComponentInParent <UIManager>().GetHeroPartyUIByMode(PartyMode.Garnizon, false).GetComponentInChildren <PartyPanel>(true).OnChange(PartyPanel.ChangeType.HireDoubleUnit, callerCell);
             // Instruct Right focus panel to update information
             transform.parent.Find("RightFocus").GetComponent <FocusPanel>().OnChange(FocusPanel.ChangeType.HireDoubleUnit);
         }
     }
 }
Exemple #3
0
    void ActivateCityView()
    {
        // get hero party in city, if it is present
        HeroParty   heroParty   = LCity.GetHeroPartyByMode(PartyMode.Party);
        HeroPartyUI heroPartyUI = null;

        // verify if there is party in a city
        if (heroParty != null)
        {
            // Get HeroParty UI
            heroPartyUI = transform.root.Find("MiscUI/LeftHeroParty").GetComponent <HeroPartyUI>();
            // assign HeroParty to left hero party UI
            heroPartyUI.GetComponent <HeroPartyUI>().LHeroParty = heroParty;
            // activate left hero party UI
            heroPartyUI.gameObject.SetActive(true);
            // assign party leader to left focus panel
            if (transform.root.Find("MiscUI/LeftFocus") == null)
            {
                Debug.LogWarning("1");
            }
            if (transform.root.Find("MiscUI/LeftFocus").GetComponent <FocusPanel>() == null)
            {
                Debug.LogWarning("2");
            }
            if (transform.root.Find("MiscUI/LeftFocus").GetComponent <FocusPanel>().focusedObject == null)
            {
                Debug.LogWarning("3");
            }
            if (heroPartyUI == null)
            {
                Debug.LogWarning("4");
            }
            if (heroPartyUI.GetPartyLeaderUI() == null)
            {
                Debug.LogWarning("5");
            }
            if (heroPartyUI.GetPartyLeaderUI().gameObject == null)
            {
                Debug.LogWarning("6");
            }
            transform.root.Find("MiscUI/LeftFocus").GetComponent <FocusPanel>().focusedObject = heroPartyUI.GetPartyLeaderUI().gameObject;
            // activate left Focus panel
            transform.root.Find("MiscUI/LeftFocus").gameObject.SetActive(true);
        }
        else
        {
            // activate left Focus panel
            // without linked hero it will trigger no-party info
            transform.root.Find("MiscUI/LeftFocus").gameObject.SetActive(true);
            // activate hire hero panel
            transform.root.Find("MiscUI/HireHeroPanel").gameObject.SetActive(true);
        }
        // Get HeroParty UI
        heroPartyUI = transform.root.Find("MiscUI/RightHeroParty").GetComponent <HeroPartyUI>();
        // assign City garnizon HeroParty to right hero party UI
        heroPartyUI.LHeroParty = LCity.GetHeroPartyByMode(PartyMode.Garnizon);
        // activate right hero party UI
        heroPartyUI.gameObject.SetActive(true);
        // activate hire common units panel
        transform.root.Find("MiscUI/HireCommonUnitButtons").gameObject.SetActive(true);
        // assign city to right focus panel
        transform.root.Find("MiscUI/RightFocus").GetComponent <FocusPanel>().focusedObject = LCity.gameObject;
        // activate right Focus panel
        transform.root.Find("MiscUI/RightFocus").gameObject.SetActive(true);
    }