예제 #1
0
 public Building(Data data, Level level) : base(data, level) 
 {
     this.Locked = GetBuildingData().Locked;
     AddComponent(new HitpointComponent());
     if (GetBuildingData().IsHeroBarrack)
     {
         HeroData hd = ObjectManager.DataTables.GetHeroByName(GetBuildingData().HeroType);
         AddComponent(new HeroBaseComponent(this, hd));
     }
     if (GetBuildingData().UpgradesUnits)
         AddComponent(new UnitUpgradeComponent(this));
     if (GetBuildingData().UnitProduction[0] > 0)
         AddComponent(new UnitProductionComponent(this));
     if (GetBuildingData().HousingSpace[0] > 0)
     {
         if (GetBuildingData().Bunker)
             AddComponent(new BunkerComponent());
         else
             AddComponent(new UnitStorageComponent(this, 0));
     }
     if (GetBuildingData().Damage[0] > 0)
         AddComponent(new CombatComponent());
     if (GetBuildingData().ProducesResource != String.Empty)
         AddComponent(new ResourceProductionComponent());
     if (GetBuildingData().MaxStoredGold[0] > 0 ||
         GetBuildingData().MaxStoredElixir[0] > 0 ||
         GetBuildingData().MaxStoredDarkElixir[0] > 0 ||
         GetBuildingData().MaxStoredWarGold[0] > 0 ||
         GetBuildingData().MaxStoredWarElixir[0] > 0 ||
         GetBuildingData().MaxStoredWarDarkElixir[0] > 0)
         AddComponent(new ResourceStorageComponent(this));
 }
예제 #2
0
 public ConstructionItem(Data data, Level level)
     : base(data, level)
 {
     m_vLevel = level;
     m_vIsConstructing = false;
     this.UpgradeLevel = -1;
 }
        private Level m_vLevel; //a1 + 8

        public GameObject(Data data, Level level)
        {
            m_vLevel = level;
            m_vData = data;
            m_vComponents = new List<Component>();
            for (int i = 0; i < 11; i++)
                m_vComponents.Add(new Component());
        }
예제 #4
0
파일: Data.cs 프로젝트: tempdban/UCR-1
        public static void LoadData(Data obj, Type objectType, CSVRow row)
        {
            foreach (var prop in objectType.GetProperties())
            {
                if (prop.PropertyType.IsGenericType)
                {
                    var listType = typeof(List<>);
                    var genericArgs = prop.PropertyType.GetGenericArguments();
                    var concreteType = listType.MakeGenericType(genericArgs);
                    var newList = Activator.CreateInstance(concreteType);

                    var add = concreteType.GetMethod("Add");

                    var indexerName =
                        ((DefaultMemberAttribute)
                            newList.GetType().GetCustomAttributes(typeof(DefaultMemberAttribute), true)[0]).MemberName;
                    var indexerProp = newList.GetType().GetProperty(indexerName);

                    for (var i = row.GetRowOffset(); i < row.GetRowOffset() + row.GetArraySize(prop.Name); i++)
                    {
                        var v = row.GetValue(prop.Name, i - row.GetRowOffset());
                        if (v == string.Empty && i != row.GetRowOffset())
                            v = indexerProp.GetValue(newList, new object[] { i - row.GetRowOffset() - 1 }).ToString();

                        if (v == string.Empty)
                        {
                            var o = genericArgs[0].IsValueType ? Activator.CreateInstance(genericArgs[0]) : "";
                            add.Invoke(newList, new[] { o });
                        }
                        else
                            add.Invoke(newList, new[] { Convert.ChangeType(v, genericArgs[0]) });
                    }
                    prop.SetValue(obj, newList);
                }
                else
                {
                    if (row.GetValue(prop.Name, 0) == string.Empty)
                        prop.SetValue(obj, null, null);
                    else
                        prop.SetValue(obj, Convert.ChangeType(row.GetValue(prop.Name, 0), prop.PropertyType), null);
                }
            }
        }
예제 #5
0
 public void CommodityCountChangeHelper(int commodityType, Data data, int count)
 {
     if(data.GetDataType() == 2)
     {
         if(commodityType == 0)
         {
             int resourceCount = GetResourceCount((ResourceData)data);
             int newResourceValue = Math.Max(resourceCount + count, 0);
             if(count >= 1)
             {
                 int resourceCap = GetResourceCap((ResourceData)data);
                 if (resourceCount < resourceCap)
                 {
                     if (newResourceValue > resourceCap)
                     {
                         newResourceValue = resourceCap;
                     }
                 }
             }
             SetResourceCount((ResourceData)data, newResourceValue);
         }
     }
 }
예제 #6
0
파일: Avatar.cs 프로젝트: Tobiti/ucs
 public void CommodityCountChangeHelper(int commodityType, Data data, int count)
 {
     if(data.GetDataType() == 2)
     {
         if(commodityType == 0)
         {
             int resourceCount = GetResourceCount((ResourceData)data);
             int newResourceValue = Math.Max(resourceCount + count, 0);
             if(count >= 1)
             {
                 int resourceCap = GetResourceCap((ResourceData)data);
                 if (resourceCount < resourceCap)
                 {
                     if (newResourceValue > resourceCap)
                     {
                         newResourceValue = resourceCap;
                     }
                 }
             }
             Debugger.WriteLine(string.Format("Old Resources: {0} New Resources: {1} Resource Cap: {2}", GetResourceCount((ResourceData)data), newResourceValue, GetResourceCap((ResourceData)data)), null, 5);
             SetResourceCount((ResourceData)data, newResourceValue);
         }
     }
 }
예제 #7
0
 public int GetDataIndex(List<DataSlot> dsl, Data d)
 {
     return dsl.FindIndex(ds => ds.Data == d);
 }
예제 #8
0
 public Obstacle(Data data, Level l) : base(data, l)
 {
     m_vLevel = l;
 }
 public Data CreateItem(CSVRow row)
 {
     Data d = new Data(row, this);
     switch (m_vIndex)
     {
         case 0:
             d = new BuildingData(row, this);
             break;
         case 2:
             d = new ResourceData(row, this);
             break;
         case 3:
             d = new CharacterData(row, this);
             break;
         case 7:
             d = new ObstacleData(row, this);
             break;
         case 10:
             d = new ExperienceLevelData(row, this);
             break;
         case 11:
             d = new TrapData(row, this);
             break;
         case 12:
             d = new LeagueData(row, this);
             break;
         case 13:
             d = new GlobalData(row, this);
             break;
         case 14:
             d = new TownhallLevelData(row, this);
             break;
         case 16:
             d = new NpcData(row, this);
             break;
         case 17:
             d = new DecoData(row, this);
             break;
         case 19:
             d = new ShieldData(row, this);
             break;
         case 22:
             d = new AchievementData(row, this);
             break;
         case 23:
             d = new Data(row, this);
             break;
         case 24:
             d = new Data(row, this);
             break;
         case 25:
             d = new SpellData(row, this);
             break;
         case 27:
             d = new HeroData(row, this);
             break;
         /*case 28:
             d = new WarData(dic);
             break;*/
         default:
             break;
     }
     return d;
 }
예제 #10
0
 public Trap(Data data, Level l) : base(data, l)
 {
     AddComponent(new TriggerComponent());
 }
예제 #11
0
 public void Load(JObject jsonObject)
 {
     Data = ObjectManager.DataTables.GetDataById(jsonObject["global_id"].ToObject<int>());
     Value = jsonObject["value"].ToObject<int>();
 }
예제 #12
0
 public void Decode(BinaryReader br)
 {
     Data = br.ReadDataReference();
     Value = br.ReadInt32WithEndian();
 }
예제 #13
0
 public DataSlot(Data d, int value)
 {
     Data = d;
     Value = value;
 }
예제 #14
0
 public Deco(Data data, Level l) : base(data, l)
 {
     m_vLevel = l;
 }