예제 #1
0
    public BuildingUnit CreateBuildingUnit(string unit_name, int id, Vector3 pos)
    {
        GDSKit.building unit_gds = GDSKit.building.GetInstance(unit_name);

        GameObject building_unit_gameobj = ObjectPoolManager.Instance().GetObject(unit_gds.resource_name);

        building_unit_gameobj.transform.SetParent(cache_root_unit_node);

        BuildingUnit building_unit = building_unit_gameobj.GetComponent <BuildingUnit>();

        // 属性相关设置
        building_unit.unit_name    = unit_name;
        building_unit.unit_type    = UnitType.Building;
        building_unit.unit_id      = id;
        building_unit.resource_key = unit_gds.resource_name;
        building_unit.position     = pos;

        if (all_unit_list.ContainsKey(building_unit.unit_id))
        {
            Debug.LogError("相同名字的unit已经在管理器里了 id : " + building_unit.unit_id);
            return(null);
        }

        all_unit_list.Add(building_unit.unit_id, building_unit);
        buiding_unit_list.Add(building_unit.unit_id, building_unit);

        return(building_unit);
    }
예제 #2
0
        public static void AddInstance(building obj)
        {
            string _key_ = obj.GetKeyInDict();

            if (_dict_.ContainsKey(_key_))
            {
                UnityEngine.Debug.LogWarning("在名为building的GDS文件中已经存在: " + _key_);
                return;
            }
            _dict_.Add(_key_, obj);
        }
예제 #3
0
        private static building CreateInstance(string[] objArr)
        {
            building _ret_ = new building();

            _ret_.building_name = String.Intern(CSVParser.GetAsString(objArr[0]));

            _ret_.resource_name = String.Intern(CSVParser.GetAsString(objArr[1]));

            _ret_.building_hp = CSVParser.GetAsInt(objArr[2]);

            _ret_.vision = CSVParser.GetAsInt(objArr[3]);

            _ret_.can_revive_hero = CSVParser.GetAsBool(objArr[4]);



            return(_ret_);
        }
예제 #4
0
        public static void Initialize(List <string[]> data)
        {
            if (_isInited_)
            {
                return;
            }

            foreach (var objArr in data)
            {
                building _value_ = CreateInstance(objArr);
                PostProcessor(_value_);
                string _key_ = _value_.GetKeyInDict();

                _dict_.Add(_key_, _value_);
            }

            _isInited_ = true;
        }
예제 #5
0
        public static building GetInstance(string building_name)
        {
            if (!_isInited_)
            {
                return(null);
            }
            string _key_ = building_name.ToString();

            if (null != _externalDataSource_)
            {
                return(_externalDataSource_.Invoke(typeof(building), _key_) as building);
            }
            else
            {
                building _ret_ = null;
                if (!_dict_.TryGetValue(_key_, out _ret_))
                {
                    throw new Exception("在名为building的GDS文件中没有发现key : " + _key_);
                }
                return(_ret_);
            }
        }
예제 #6
0
 static partial void PostProcessor(building instance);