Exemplo n.º 1
0
        /// <summary>
        ///     Creates a new data item.
        /// </summary>
        public LogicData CreateItem(CSVRow row)
        {
            LogicData data = null;

            switch (this._tableIndex)
            {
            case 0:
            {
                data = new LogicBuildingData(row, this);
                break;
            }

            case 1:
            {
                data = new LogicLocaleData(row, this);
                break;
            }

            case 2:
            {
                data = new LogicResourceData(row, this);
                break;
            }

            case 3:
            {
                data = new LogicCharacterData(row, this);
                break;
            }

            case 5:
            {
                data = new LogicProjectileData(row, this);
                break;
            }

            case 6:
            {
                data = new LogicBuildingClassData(row, this);
                break;
            }

            case 7:
            {
                data = new LogicObstacleData(row, this);
                break;
            }

            case 8:
            {
                data = new LogicEffectData(row, this);
                break;
            }

            case 9:
            {
                data = new LogicParticleEmitterData(row, this);
                break;
            }

            case 10:
            {
                data = new LogicExperienceLevelData(row, this);
                break;
            }

            case 11:
            {
                data = new LogicTrapData(row, this);
                break;
            }

            case 12:
            {
                data = new LogicAllianceBadgeData(row, this);
                break;
            }

            case 13:
            {
                data = new LogicGlobalData(row, this);
                break;
            }

            case 14:
            {
                data = new LogicTownhallLevelData(row, this);
                break;
            }

            case 15:
            {
                data = new LogicAlliancePortalData(row, this);
                break;
            }

            case 16:
            {
                data = new LogicNpcData(row, this);
                break;
            }

            case 17:
            {
                data = new LogicDecoData(row, this);
                break;
            }

            case 18:
            {
                data = new LogicResourcePackData(row, this);
                break;
            }

            case 19:
            {
                data = new LogicShieldData(row, this);
                break;
            }

            case 20:
            {
                data = new LogicMissionData(row, this);
                break;
            }

            case 21:
            {
                data = new LogicBillingPackageData(row, this);
                break;
            }

            case 22:
            {
                data = new LogicAchievementData(row, this);
                break;
            }

            case 23:
            {
                data = new LogicFaqData(row, this);
                break;
            }

            case 25:
            {
                data = new LogicSpellData(row, this);
                break;
            }

            case 26:
            {
                data = new LogicHintData(row, this);
                break;
            }

            case 27:
            {
                data = new LogicHeroData(row, this);
                break;
            }

            case 28:
            {
                data = new LogicLeagueData(row, this);
                break;
            }

            case 29:
            {
                data = new LogicNewsData(row, this);
                break;
            }

            case 30:
            {
                data = new LogicWarData(row, this);
                break;
            }

            case 31:
            {
                data = new LogicRegionData(row, this);
                break;
            }

            case 32:
            {
                data = new LogicGlobalData(row, this);
                break;
            }

            case 33:
            {
                data = new LogicAllianceBadgeLayerData(row, this);
                break;
            }

            case 34:
            {
                data = new LogicAllianceLevelData(row, this);
                break;
            }

            case 36:
            {
                data = new LogicVariableData(row, this);
                break;
            }

            case 37:
            {
                data = new LogicGemBundleData(row, this);
                break;
            }

            case 38:
            {
                data = new LogicVillageObjectData(row, this);
                break;
            }

            case 39:
            {
                data = new LogicCalendarEventFunctionData(row, this);
                break;
            }

            case 40:
            {
                data = new LogicBoomboxData(row, this);
                break;
            }

            case 41:
            {
                data = new LogicEventEntryData(row, this);
                break;
            }

            case 42:
            {
                data = new LogicDeeplinkData(row, this);
                break;
            }

            case 43:
            {
                data = new LogicLeague2Data(row, this);
                break;
            }

            default:
            {
                Debugger.Error("Invalid data table id: " + this._tableIndex);
                break;
            }
            }

            return(data);
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Loads automaticaly the data.
        /// </summary>
        public void AutoLoadData()
        {
            foreach (PropertyInfo propertyInfo in this.GetType().GetProperties(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public))
            {
                if (propertyInfo.CanWrite)
                {
                    if (propertyInfo.PropertyType.IsArray)
                    {
                        Type elementType = propertyInfo.PropertyType.GetElementType();

                        if (elementType == typeof(int))
                        {
                            int   arraySize = this._row.GetBiggestArraySize();
                            int[] array     = new int[arraySize];

                            for (int i = 0; i < arraySize; i++)
                            {
                                array[i] = this.GetIntegerValue(propertyInfo.Name, i);
                            }

                            propertyInfo.SetValue(this, array);
                        }
                        else if (elementType == typeof(bool))
                        {
                            int    arraySize = this._row.GetBiggestArraySize();
                            bool[] array     = new bool[arraySize];

                            for (int i = 0; i < arraySize; i++)
                            {
                                array[i] = this.GetBooleanValue(propertyInfo.Name, i);
                            }

                            propertyInfo.SetValue(this, array);
                        }
                        else if (elementType == typeof(string))
                        {
                            int      arraySize = this._row.GetBiggestArraySize();
                            string[] array     = new string[arraySize];

                            for (int i = 0; i < arraySize; i++)
                            {
                                array[i] = this.GetValue(propertyInfo.Name, i);
                            }

                            propertyInfo.SetValue(this, array);
                        }
                    }
                    else if (propertyInfo.PropertyType == typeof(LogicData) || propertyInfo.PropertyType.BaseType == typeof(LogicData))
                    {
                        LogicData data = (LogicData)propertyInfo.GetValue(this);

                        if (data != null)
                        {
                            data.AutoLoadData();
                        }
                    }
                    else
                    {
                        Type elementType = propertyInfo.PropertyType;

                        if (elementType == typeof(bool))
                        {
                            propertyInfo.SetValue(this, this.GetBooleanValue(propertyInfo.Name, 0));
                        }
                        else if (elementType == typeof(int))
                        {
                            propertyInfo.SetValue(this, this.GetIntegerValue(propertyInfo.Name, 0));
                        }
                        else if (propertyInfo.PropertyType == typeof(string))
                        {
                            propertyInfo.SetValue(this, this.GetValue(propertyInfo.Name, 0));
                        }
                    }
                }
            }
        }