Esempio n. 1
0
    void OnSelectGeneral()
    {
        if (state != 0)
        {
            return;
        }

        state = 2;

        selectIdx        = generalsList.GetSelectIndex();
        selectGeneralIdx = (int)generalsList.GetSelectItem().GetItemData();

        generalsList.gameObject.GetComponent <MenuDisplayAnim>().SetAnim(MenuDisplayAnim.AnimType.OutToLeft);

        OnChangeGeneralInfo();
    }
Esempio n. 2
0
    void OnConfirmButton()
    {
        confirmBox.SetActive(false);

        int         gIdx  = (int)generalsInfoList.GetSelectItem().GetItemData();
        GeneralInfo gInfo = Informations.Instance.GetGeneralInfo(gIdx);

        CityObjectsData cityData = (CityObjectsData)objsList.GetSelectItem().GetItemData();

        int data = cityData.code;

        if (data == -1)
        {
            state = 0;

            string objName = ZhongWen.Instance.GetEquipmentName(gInfo.equipment);
            int    code    = (1 << 16) + gInfo.equipment;

            List <int> o = Informations.Instance.GetCityInfo(gInfo.city).objects;
            o.Add(code);

            CityObjectsData d = new CityObjectsData(gInfo.city, code);

            objsList.AddItem(objName).SetItemData(d);


            EquipmentInfo eInfo = Informations.Instance.GetEquipmentInfo(gInfo.equipment);
            if (eInfo.type == 0)
            {
                gInfo.intellect -= eInfo.data;
            }
            else if (eInfo.type == 3)
            {
                gInfo.strength -= eInfo.data;
            }

            gInfo.equipment = -1;
            objsList.DeleteItem(objsList.GetSelectIndex());
        }
        else
        {
            List <int> objs = Informations.Instance.GetCityInfo(cityData.city).objects;

            int code = data & 0xFFFF;
            int type = data >> 16;

            int cObjIdx = 0;
            for (; cObjIdx < objs.Count; cObjIdx++)
            {
                if ((int)objs[cObjIdx] == cityData.code)
                {
                    break;
                }
            }

            objs.RemoveAt(cObjIdx);

            switch (type)
            {
            case 1:
                state = 0;

                if (gInfo.equipment != -1)
                {
                    string objName = ZhongWen.Instance.GetEquipmentName(gInfo.equipment);
                    int    d       = (1 << 16) + gInfo.equipment;

                    cityData.code = d;

                    objsList.GetSelectItem().GetComponent <exSpriteFont>().text = objName;
                    objsList.GetSelectItem().SetItemData(cityData);
                    objsList.SetItemSelected(-1, false);

                    objs.Insert(cObjIdx, d);
                }
                else
                {
                    objsList.DeleteItem(objsList.GetSelectIndex());
                }

                ChangeGeneralsEquitment(gInfo, code);
                break;

            case 2:
                state = 2;

                gInfo.arms += code;
                objsList.DeleteItem(objsList.GetSelectIndex());

                dialogue.SetDialogue(Informations.Instance.GetKingInfo(Controller.kingIndex).generalIdx,
                                     ZhongWen.Instance.GetGeneralName(gIdx) + ZhongWen.Instance.jublzh + ZhongWen.Instance.GetArmsName(code) + ZhongWen.Instance.denengli,
                                     MenuDisplayAnim.AnimType.InsertFromBottom);

                break;

            case 3:
                state = 2;

                gInfo.formation += code;
                objsList.DeleteItem(objsList.GetSelectIndex());

                dialogue.SetDialogue(Informations.Instance.GetKingInfo(Controller.kingIndex).generalIdx,
                                     ZhongWen.Instance.GetGeneralName(gIdx) + ZhongWen.Instance.xuehuile + ZhongWen.Instance.GetFormationName(code),
                                     MenuDisplayAnim.AnimType.InsertFromBottom);

                break;
            }
        }

        generalsInfoList.GetSelectItem().GetComponent <exSpriteFont>().text = GetGeneralInfo(gIdx);
        OnSelectGeneral();
    }