Beispiel #1
0
        /// <summary>
        /// 实例化一个装备
        /// </summary>
        /// <param name="buildingTypeId">建筑类型</param>
        /// <returns></returns>
        public Equip InstantiateEquip(int buildingTypeId)
        {
            if (!_BuildingTemplates.ContainsKey(buildingTypeId))
            {
                return(null);
            }

            BuildingTemplate temp = _BuildingTemplates[buildingTypeId];

            if (!temp.GenEquip)
            {
                return(null);
            }

            var lst = temp.GenEquiList;

            int id = CalcEquipWeight(ref lst);

            if (id == 0)
            {
                return(null);
            }

            EquipTemplate tmp = _EquipTemplates[id];

            if (tmp == null)
            {
                return(null);
            }

            var equip = new Equip(_EquipUdid++);

            return(equip);
        }
Beispiel #2
0
        public bool Init()
        {
            try
            {
                TextAsset txt = Resources.Load <TextAsset>("Config/Building/desc");
                if (txt != null)
                {
                    CleanUp();
                    Dictionary <string, object> o = MiniJSON.Json.Deserialize(txt.text) as Dictionary <string, object>;

                    _NobodyDesc = o["nobody"].ToString();
                    object a   = o["building_options"];
                    var    lst = (List <object>)a;
                    foreach (var i in lst)
                    {
                        OptionTemplate op = new OptionTemplate();
                        op.ReadJs((Dictionary <string, object>)i);
                        _OptionTemplates.Add(op._Id, op);
                    }

                    lst = o["building"] as List <object>;
                    foreach (var i in lst)
                    {
                        BuildingTemplate tmp = new BuildingTemplate();
                        tmp.ReadJs((Dictionary <string, object>)i);
                        _BuildingTemplates.Add(tmp.Type, tmp);
                    }

                    lst = o["equips"] as List <object>;
                    foreach (var i in lst)
                    {
                        EquipTemplate tmp = new EquipTemplate();
                        tmp.ReadJs((Dictionary <string, object>)i);
                        _EquipTemplates.Add(tmp.TypeId, tmp);
                    }

                    var names = o["names"] as Dictionary <string, object>;
                    GameData.Instance.SurvivorMgr.SetNameConfig(names);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(false);
            }
            return(true);
        }