Пример #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);
         }
     }
 }
Пример #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);
         }
     }
 }
Пример #3
0
    public void SetHireUnitPnlButtonActive(bool activate)
    {
        // get garnizon UI
        HeroPartyUI garnizonUI = GetComponentInParent <UIManager>().GetHeroPartyUIByMode(PartyMode.Garnizon);

        // this is only needed in garnizon mode, only in this mode hire buttons are present
        // verify if garnizon is present
        if (garnizonUI)
        {
            // Debug.Log("Activate or Deactivate Hire Unit Buttons in City Garnizon");
            foreach (UnitSlot unitSlot in garnizonUI.GetComponentsInChildren <UnitSlot>(true))
            {
                // verify if we are not checking wide cell, because there is no + button in wide cells
                if (unitSlot.GetComponent <UnitSlotDropHandler>().CellSize != UnitSize.Double)
                {
                    // verify if we need to activate
                    if (activate
                        // Verify if city capacity is enough
                        && (LCity.GetUnitsCapacity() > garnizonUI.LHeroParty.GetLeadershipConsumedByPartyUnits())
                        // verify if drop slot doesn't have an !active! unit in it
                        && (!unitSlot.GetComponentInChildren <PartyUnitUI>(false))
                        // verify if wide cell is not active = occupied in the same row
                        && (!unitSlot.transform.parent.parent.Find(PartyPanel.Cell.Wide.ToString()).gameObject.activeSelf)
                        )
                    {
                        //Debug.Log("Activate + button in " + horisontalPanel + "/" + cell + " cell");
                        SetHireUnitButtonActiveByCell(true, unitSlot.GetUnitPPRow(), unitSlot.GetUnitPPCell());
                        // And bring panel to the front
                        BringHireUnitPnlButtonToTheFront();
                    }
                    else
                    {
                        //Debug.Log("Deactivate + button in " + horisontalPanel + "/" + cell + " cell");
                        SetHireUnitButtonActiveByCell(false, unitSlot.GetUnitPPRow(), unitSlot.GetUnitPPCell());
                    }
                }
            }
        }
    }
Пример #4
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);
    }
Пример #5
0
        /// <summary>
        /// Get supplier detail information include products
        /// </summary>
        /// <param name="supplier_id">supplier id</param>
        /// <returns>Instance of BSupplier object</returns>
        public BSupplier GetSupplierFullInfo(int supplier_id, bool getProduct = false)
        {
            BSupplier supplier = null;

            using (KuanMaiEntities db = new KuanMaiEntities())
            {
                supplier = (from s in db.Supplier
                            join user in db.User on s.User_ID equals user.User_ID into LUser
                            from l_user in LUser.DefaultIfEmpty()
                            join shop in db.Shop on s.Shop_ID equals shop.Shop_ID into LShop
                            from l_shop in LShop.DefaultIfEmpty()
                            join city in db.Common_District on s.City_ID equals city.id into LCity
                            from l_city in LCity.DefaultIfEmpty()
                            join province in db.Common_District on s.Province_ID equals province.id into LProvince
                            from l_province in LProvince.DefaultIfEmpty()
                            where s.Supplier_ID == supplier_id
                            select new BSupplier
                {
                    ID = s.Supplier_ID,
                    Name = s.Name,
                    Address = s.Address,
                    City = l_city != null ? new BArea {
                        ID = l_city.id, Name = l_city.name
                    } : new BArea {
                        ID = 0, Name = ""
                    },
                    ContactPerson = s.Contact_Person,
                    Created = s.Create_Time,
                    Created_By = l_user != null ? new BUser
                    {
                        ID = l_user.User_ID,
                        Name = l_user.Name,
                        Mall_ID = l_user.Mall_ID,
                        Mall_Name = l_user.Mall_Name
                    } : new BUser
                    {
                        ID = 0,
                        Name = "",
                        Mall_ID = "",
                        Mall_Name = ""
                    },
                    Enable = (bool)s.Enabled,
                    Fax = s.Fax,
                    Phone = s.Phone,
                    Province = l_province != null ? new BArea {
                        ID = l_province.id, Name = l_province.name
                    } : new BArea {
                        ID = 0, Name = ""
                    },
                    Remark = s.Remark,
                    Shop = l_shop != null ? new BShop
                    {
                        ID = l_shop.Shop_ID,
                        Title = l_shop.Name
                    } : new BShop
                    {
                        ID = 0,
                        Title = ""
                    }
                }).FirstOrDefault <BSupplier>();

                if (supplier != null && getProduct)
                {
                    List <BProduct> products   = null;
                    var             productIds = from s in db.Product_Supplier
                                                 where s.Supplier_ID == supplier.ID && s.Enabled == true
                                                 select s.Product_ID;

                    products = (from p in db.Product
                                where p.Parent_ID == 0 && productIds.Contains(p.Product_ID)
                                select new BProduct
                    {
                        ID = p.Product_ID,
                        Title = p.Name
                    }).ToList <BProduct>();

                    supplier.Products = products;
                }
            }
            return(supplier);
        }