public LogicData GetDataParameter(int idx, LogicDataType tableIdx)
        {
            if (this.IsValidParameter(idx))
            {
                int value = LogicStringUtil.ConvertToInt(this.m_parameters[idx]);

                if (value != 0)
                {
                    LogicData data = LogicDataTables.GetDataById(value, tableIdx);

                    if (data != null)
                    {
                        return(data);
                    }

                    this.m_errorHandler.WarningFunction(this.m_calendarEvent, this, this.m_functionData.GetParameterName(idx),
                                                        string.Format("Unable to find data by id {0} from tableId {1}.", value, tableIdx));
                }
                else
                {
                    this.m_errorHandler.WarningFunction(this.m_calendarEvent, this, this.m_functionData.GetParameterName(idx),
                                                        string.Format("Expected globalId got {0}.", value));
                }
            }

            return(null);
        }
示例#2
0
        public override void Decode(ByteStream stream)
        {
            this.m_gameObjectId = stream.ReadInt();
            this.m_unitType     = (LogicDataType)stream.ReadInt();
            this.m_unitData     = (LogicCombatItemData)ByteStreamHelper.ReadDataReference(stream, this.m_unitType != 0 ? LogicDataType.SPELL : LogicDataType.CHARACTER);

            base.Decode(stream);
        }
示例#3
0
        public override void Destruct()
        {
            base.Destruct();

            this.m_gameObjectId = 0;
            this.m_unitType     = 0;
            this.m_unitData     = null;
        }
示例#4
0
        public LogicUnitProduction(LogicLevel level, LogicDataType unitProductionType, int villageType)
        {
            this.m_level              = level;
            this.m_villageType        = villageType;
            this.m_unitProductionType = unitProductionType;

            this.m_slots = new LogicArrayList <LogicUnitProductionSlot>();
        }
        public override void Decode(ByteStream stream)
        {
            this.m_newShopItemsIndex = stream.ReadInt();
            this.m_newShopItemsType  = (LogicDataType)stream.ReadInt();
            this.m_newShopItemsCount = stream.ReadInt();

            base.Decode(stream);
        }
示例#6
0
        public LogicDataTable(CSVTable table, LogicDataType index)
        {
            this.m_tableIndex = index;
            this.m_table      = table;
            this.m_items      = new LogicArrayList <LogicData>();

            this.LoadTable();
        }
        public static LogicData ReadDataReference(ByteStream stream, LogicDataType tableIndex)
        {
            int globalId = stream.ReadInt();

            if (GlobalID.GetClassID(globalId) == (int)tableIndex + 1)
            {
                return(LogicDataTables.GetDataById(globalId));
            }
            return(null);
        }
示例#8
0
        public static LogicData GetDataById(int globalId, LogicDataType dataType)
        {
            LogicData data = LogicDataTables.GetDataById(globalId);

            if (data.GetDataType() != dataType)
            {
                return(null);
            }

            return(data);
        }
示例#9
0
        public static void InitDataTable(CSVNode node, LogicDataType index)
        {
            if (index == LogicDataType.ANIMATION)
            {
                if (LogicDataTables.m_animationTable != null)
                {
                    LogicDataTables.m_animationTable.SetTable(node);
                }
                else
                {
                    LogicDataTables.m_animationTable = new LogicAnimationTable(node, index);
                }
            }
            else
            {
                if (LogicDataTables.m_tables[(int)index] != null)
                {
                    LogicDataTables.m_tables[(int)index].SetTable(node.GetTable());
                }
                else
                {
                    switch (index)
                    {
                    case LogicDataType.GLOBAL:
                        LogicDataTables.m_tables[(int)index] = new LogicGlobals(node.GetTable(), index);
                        break;

                    case LogicDataType.CLIENT_GLOBAL:
                        LogicDataTables.m_tables[(int)index] = new LogicClientGlobals(node.GetTable(), index);
                        break;

                    default:
                        LogicDataTables.m_tables[(int)index] = new LogicDataTable(node.GetTable(), index);
                        break;
                    }
                }
            }
        }
 public LogicNewShopItemsSeenCommand(int index, int type, int count)
 {
     this.m_newShopItemsIndex = index;
     this.m_newShopItemsType  = (LogicDataType)type;
     this.m_newShopItemsCount = count;
 }
示例#11
0
 public void Destruct()
 {
     this.m_fileName   = null;
     this.m_tableIndex = 0;
     this.m_type       = 0;
 }
示例#12
0
 public LogicUpgradeUnitCommand(LogicCombatItemData combatItemData, int gameObjectId)
 {
     this.m_unitData     = combatItemData;
     this.m_gameObjectId = gameObjectId;
     this.m_unitType     = this.m_unitData.GetDataType();
 }
示例#13
0
 public static LogicDataTable GetTable(LogicDataType tableIndex)
 {
     return(LogicDataTables.m_tables[(int)tableIndex]);
 }
 public LogicClientGlobals(CSVTable table, LogicDataType index) : base(table, index)
 {
 }
 public LogicAnimationTable(CSVNode node, LogicDataType index) : base(node.GetTable(), index)
 {
 }
        public override int Execute(LogicLevel level)
        {
            if (this.m_gameObjectData != null && level.GetUnplacedObjectCount(this.m_gameObjectData) > 0)
            {
                if (level.GetVillageType() == this.m_gameObjectData.GetVillageType())
                {
                    LogicDataType dataType = this.m_gameObjectData.GetDataType();

                    if (dataType == LogicDataType.BUILDING)
                    {
                        LogicBuildingData buildingData = (LogicBuildingData)this.m_gameObjectData;

                        if (level.IsValidPlaceForBuilding(this.m_x, this.m_y, buildingData.GetWidth(), buildingData.GetHeight(), null))
                        {
                            if (!level.RemoveUnplacedObject(this.m_gameObjectData, this.m_upgradeLevel))
                            {
                                return(-63);
                            }

                            LogicBuilding building = (LogicBuilding)LogicGameObjectFactory.CreateGameObject(this.m_gameObjectData, level, level.GetVillageType());

                            building.SetPositionXY(this.m_x << 9, this.m_y << 9);
                            level.GetGameObjectManager().AddGameObject(building, -1);
                            building.FinishConstruction(false, true);
                            building.SetUpgradeLevel(this.m_upgradeLevel);
                        }

                        return(0);
                    }

                    if (dataType == LogicDataType.TRAP)
                    {
                        LogicTrapData trapData = (LogicTrapData)this.m_gameObjectData;

                        if (level.IsValidPlaceForBuilding(this.m_x, this.m_y, trapData.GetWidth(), trapData.GetHeight(), null))
                        {
                            if (!level.RemoveUnplacedObject(this.m_gameObjectData, this.m_upgradeLevel))
                            {
                                return(-64);
                            }

                            LogicTrap trap = (LogicTrap)LogicGameObjectFactory.CreateGameObject(this.m_gameObjectData, level, level.GetVillageType());

                            trap.SetPositionXY(this.m_x << 9, this.m_y << 9);
                            trap.FinishConstruction(false);
                            trap.SetUpgradeLevel(this.m_upgradeLevel);
                            level.GetGameObjectManager().AddGameObject(trap, -1);
                        }

                        return(0);
                    }

                    if (dataType == LogicDataType.DECO)
                    {
                        LogicDecoData decoData = (LogicDecoData)this.m_gameObjectData;

                        if (level.IsValidPlaceForBuilding(this.m_x, this.m_y, decoData.GetWidth(), decoData.GetHeight(), null))
                        {
                            if (!level.RemoveUnplacedObject(this.m_gameObjectData, this.m_upgradeLevel))
                            {
                                return(-65);
                            }

                            LogicDeco deco = (LogicDeco)LogicGameObjectFactory.CreateGameObject(this.m_gameObjectData, level, level.GetVillageType());

                            deco.SetPositionXY(this.m_x << 9, this.m_y << 9);
                            level.RemoveUnplacedObject(this.m_gameObjectData, this.m_upgradeLevel);
                            level.GetGameObjectManager().AddGameObject(deco, -1);
                        }

                        return(0);
                    }

                    return(-3);
                }

                return(-35);
            }

            return(0);
        }
示例#17
0
 public void Destruct()
 {
     this.m_items.Destruct();
     this.m_tableName  = null;
     this.m_tableIndex = 0;
 }
示例#18
0
 public LogicDataTableResource(string fileName, LogicDataType tableIndex, int type)
 {
     this.m_fileName   = fileName;
     this.m_tableIndex = tableIndex;
     this.m_type       = type;
 }