コード例 #1
0
    private void AddTrapToShop(TrapData trapData)
    {
        var trap = Instantiate(trapMenuItem, Vector2.zero, Quaternion.identity);

        trap.transform.SetParent(trapList, false);
        trap.transform.Find(trapMenuItem_picturePath).GetComponent <Image>().sprite = trapData.shopImage;
    }
コード例 #2
0
        public void Load(JObject jsonObject)
        {
            JArray jsonBuildings = (JArray)jsonObject["buildings"];

            foreach (JObject jsonBuilding in jsonBuildings)
            {
                BuildingData bd = (BuildingData)ObjectManager.DataTables.GetDataById(jsonBuilding["data"].ToObject <int>());
                Building     b  = new Building(bd, m_vLevel);
                AddGameObject(b);
                b.Load(jsonBuilding);
            }

            JArray jsonTraps = (JArray)jsonObject["traps"];

            foreach (JObject jsonTrap in jsonTraps)
            {
                TrapData td = (TrapData)ObjectManager.DataTables.GetDataById(jsonTrap["data"].ToObject <int>());
                Trap     t  = new Trap(td, m_vLevel);
                AddGameObject(t);
                t.Load(jsonTrap);
            }

            JArray jsonDecos = (JArray)jsonObject["decos"];

            foreach (JObject jsonDeco in jsonDecos)
            {
                DecoData dd = (DecoData)ObjectManager.DataTables.GetDataById(jsonDeco["data"].ToObject <int>());
                Deco     d  = new Deco(dd, m_vLevel);
                AddGameObject(d);
                d.Load(jsonDeco);
            }
        }
コード例 #3
0
    public bool AttachToTrap(PlayerController player, Collider2D hit)
    {
        Rigidbody2D hitRigidbody     = hit.attachedRigidbody;
        Rigidbody2D trapRigidbody    = player.trapCollider.attachedRigidbody;
        int         playerIndex      = player.playerId;
        int         otherPlayerIndex = 1 - playerIndex;
        int         frame            = Time.frameCount;

        // Release current joint from other player

        TrapData.ForceReleaseResult forceReleaseResult = m_trapDatas[otherPlayerIndex].ForceRelease(frame);
        if (forceReleaseResult == TrapData.ForceReleaseResult.Challenged)
        {
            return(false);
        }

        // Add new joint from current player

        var fixedJoint = hitRigidbody.gameObject.AddComponent <FixedJoint2D>();

        fixedJoint.connectedBody = trapRigidbody;

        m_trapDatas[playerIndex] = new TrapData(player, fixedJoint, frame);

        return(true);
    }
コード例 #4
0
    public static ScenarioState CollectItem(this ScenarioState state, ItemData item, EntityData collector)
    {
        switch (item.itemCategory)
        {
        case ItemCategory.Treasure:
            if (collector != state.player)
            {
                break;
            }
            TreasureData treasure = item as TreasureData;
            state.inventory.gold += treasure.value;
            state.items.Remove(item);
            break;

        case ItemCategory.Trap:
            TrapData trap = item as TrapData;
            ApplyTrapToEntity(state, trap, collector);
            break;

        case ItemCategory.Artifact:
            if (collector != state.player)
            {
                break;
            }
            state.inventory.artifacts++;
            state.items.Remove(item);
            break;

        default:
            break;
        }

        return(state);
    }
コード例 #5
0
    public bool checkForTrap(GridPosition checkPosition)
    {
        bool tripped = false;

        Debug.Log("Check for Trap");
        List <GameObject> actionObjects = GameObject.Find("Game Controller").GetComponent <GameController>().actionObjects;
        GameObject        trippedTrap   = null;

        foreach (GameObject actionObject in actionObjects)
        {
            if (actionObject.GetComponent <ActionObject>() is TrapData)
            {
                TrapData trap = actionObject.GetComponent <TrapData>();
                if (trap.position.Equals(checkPosition))
                {
                    trippedTrap = actionObject;
                    Debug.Log("Trap Tripped");
                }
            }
        }
        if (trippedTrap != null)
        {
            canMove = false;
            takeDamage(trippedTrap.GetComponent <TrapData>().damage);
            actionObjects.Remove(trippedTrap);
            Destroy(trippedTrap);
            tripped = true;
        }
        return(tripped);
    }
コード例 #6
0
        internal void FinishConstruction(bool NoWorker = false)
        {
            TrapData Data = this.TrapData;

            if (this.UpgradeLevel + 1 > Data.MaxLevel)
            {
                Logging.Error(this.GetType(), "Unable to upgrade the building because the level is out of range! - " + Data.Name + ".");
                this.SetUpgradeLevel(Data.MaxLevel);
            }
            else
            {
                this.SetUpgradeLevel(this.UpgradeLevel + 1);
            }

            if (!NoWorker)
            {
                if (this.VillageType == 0)
                {
                    this.Level.WorkerManager.DeallocateWorker(this);
                }
                else
                {
                    this.Level.WorkerManagerV2.DeallocateWorker(this);
                }
            }


            this.Level.Player.AddExperience(GamePlayUtil.TimeToXp(Data.GetBuildTime(this.UpgradeLevel)));
            this.ConstructionTimer = null;
        }
コード例 #7
0
ファイル: Buy_Trap.cs プロジェクト: PizzaDevv/ObjectClash
        internal override void Decode()
        {
            this.X = this.Reader.ReadInt32();
            this.Y = this.Reader.ReadInt32();

            this.TrapData = this.Reader.ReadData <TrapData>();

            base.Decode();
        }
コード例 #8
0
ファイル: Trap.cs プロジェクト: wildrabbit/7drl-lib
 protected override void DoInit(BaseEntityDependencies dependencies)
 {
     _trapData     = (TrapData)_entityData;
     _triggerTrait = new TriggerTrait();
     _triggerTrait.Init(this, _entityController);
     _entitiesAtTrap = new Dictionary <BaseEntity, float>();
     _entityEvents   = dependencies.GameEvents.Entities;
     _entityEvents.EntitiesRemoved += EntitiesRemoved;
     _trapEvents = dependencies.GameEvents.Traps;
 }
コード例 #9
0
ファイル: DataRetriever.cs プロジェクト: gewl/Hamminatics
    public static TrapData GetTrapData(string trapName)
    {
        if (cachedTrapData.ContainsKey(trapName))
        {
            return(cachedTrapData[trapName]);
        }

        TrapData loadedTrapData = Resources.Load <TrapData>(TRAP_DIR + trapName);

        cachedTrapData[trapName] = loadedTrapData;
        return(Instantiate(loadedTrapData));
    }
コード例 #10
0
    public override ItemData Copy()
    {
        TrapData copy = ScriptableObject.CreateInstance(typeof(TrapData)) as TrapData;

        copy.trapCategory = trapCategory;
        copy.value        = value;
        copy.sprite       = sprite;
        copy.ID           = ID;
        copy.Duration     = Duration;
        copy.Position     = Position;

        return(copy);
    }
コード例 #11
0
        public static WorldObjectData GetData(string name)
        {
            WorldObjectData data = null;

            switch (name)
            {
            case "Person":
                data = new PersonData();
                break;

            case "Castle":
                data = new CastleData();
                break;

            case "Tree":
                data = new TreeData();
                break;

            case "Rock":
                data = new RockData();
                break;

            case "Trap":
                data = new TrapData();
                break;

            case "FakeTree":
                data = new FakeTreeData();
                break;

            case "Cottage":
                data = new CottageData();
                break;

            case "Candle":
                data = new CandleData();
                break;

            case "Water":
                data = new WaterData();
                break;

            case "Bridge":
                data = new BridgeData();
                break;

            default:
                break;
            }
            return(data);
        }
コード例 #12
0
ファイル: TrapResult.cs プロジェクト: moto2002/snowbattle
 public override void ParseJsonData(LitJson.JsonData data)
 {
     base.ParseJsonData(data);
     LitJson.JsonData trapDataList = data[EResultManager.sSchemeTrapList];
     for (int i = 0; i < trapDataList.Count; i++)
     {
         TrapData tmpData = new TrapData();
         tmpData.mTrapId        = int.Parse(trapDataList[i][EResultManager.sTrapSerNo].ToString());
         tmpData.mTrapType      = (ENTrapType)int.Parse(trapDataList[i][EResultManager.sTrapType].ToString());
         tmpData.mTrapState     = (Trap.TrapState) int.Parse(trapDataList[i][EResultManager.sTrapOptType].ToString());
         tmpData.mBlackBoardStr = trapDataList[i][EResultManager.sTrapBlackboardStr].ToString();
         mTrapDataList.Add(tmpData);
     }
 }
コード例 #13
0
        public override void Execute(Level level)
        {
            ClientAvatar avatar   = level.GetPlayerAvatar();
            TrapData     dataById = (TrapData)CSVManager.DataTables.GetDataById(TrapId);
            Trap         trap     = new Trap((Data)dataById, level);

            if (!avatar.HasEnoughResources(dataById.GetBuildResource(0), dataById.GetBuildCost(0)) || level.HasFreeWorkers())
            {
                return;
            }
            ResourceData buildResource = dataById.GetBuildResource(0);

            avatar.CommodityCountChangeHelper(0, (Data)buildResource, -dataById.GetBuildCost(0));
            trap.StartConstructing(X, Y);
            level.GameObjectManager.AddGameObject((GameObject)trap);
        }
コード例 #14
0
        public override void Execute(Level level)
        {
            ClientAvatar ca = level.GetPlayerAvatar();

            TrapData td = (TrapData)ObjectManager.DataTables.GetDataById(TrapId);
            Trap     t  = new Trap(td, level);

            if (ca.HasEnoughResources(td.GetBuildResource(0), td.GetBuildCost(0)))
            {
                if (level.HasFreeWorkers())
                {
                    ResourceData rd = td.GetBuildResource(0);
                    ca.CommodityCountChangeHelper(0, rd, -td.GetBuildCost(0));

                    t.StartConstructing(X, Y);
                    level.GameObjectManager.AddGameObject(t);
                }
            }
        }
コード例 #15
0
    static void ApplyTrapToEntity(ScenarioState state, TrapData trap, EntityData entity)
    {
        state.items.Remove(trap);

        switch (trap.trapCategory)
        {
        case TrapCategory.InstantDamage:
            entity.DealDamage(trap.value, state);
            break;

        case TrapCategory.Warp:
            break;

        default:
            break;
        }

        // TODO: Add handling for if trap has a modifier (buff/debuff to apply)
    }
コード例 #16
0
        public CombatComponent(GameObject GameObject) : base(GameObject)
        {
            if (GameObject is Building)
            {
                Building     Building = (Building)GameObject;
                BuildingData bd       = Building.BuildingData;

                if (bd.AmmoCount > 0)
                {
                    this.Ammo = bd.AmmoCount;
                }

                if (bd.AltAttackMode)
                {
                    this.AltAttackMode = true;
                }

                if (bd.AimRotateStep > 0)
                {
                    this.AimRotateStep = true;
                }
            }
            else if (GameObject is Trap)
            {
                Trap     Trap = (Trap)GameObject;
                TrapData td   = Trap.TrapData;
                if (td.HasAltMode)
                {
                    this.AltTrapAttackMode = true;
                }

                if (td.DirectionCount > 0)
                {
                    this.AltDirectionMode = true;
                }
            }
        }
コード例 #17
0
ファイル: TrapManager.cs プロジェクト: gomdroi/StoneRice
    public void SaveTraps(int _stageNum, bool _isNewStage = false)
    {
        if (_isNewStage)
        {
            List <TrapData> curStageTraps = new List <TrapData>();

            //트랩 데이터 카피
            for (int i = 0; i < trapInfoList.Count; i++)
            {
                TrapData trap = new TrapData();
                trap = trapInfoList[i].trapData;
                curStageTraps.Add(trap);
            }

            stageTraps.Add(curStageTraps);
        }
        else if (!_isNewStage)
        {
            for (int i = 0; i < trapInfoList.Count; i++)
            {
                stageTraps[_stageNum][i] = (TrapData)trapInfoList[i].trapData;
            }
        }
    }
コード例 #18
0
        /// <summary>
        /// Creates the data for the specified row.
        /// </summary>
        /// <param name="Row">The row.</param>
        internal Data Create(Row Row)
        {
            Data Data;

            switch (this.Index)
            {
            case 0:
            {
                Data = new BuildingData(Row, this);
                break;
            }

            case 1:
            {
                Data = new LocaleData(Row, this);
                break;
            }

            case 2:
            {
                Data = new ResourceData(Row, this);
                break;
            }

            case 3:
            {
                Data = new CharacterData(Row, this);
                break;
            }

            case 6:
            {
                Data = new BuildingClassData(Row, this);
                break;
            }

            case 7:
            {
                Data = new ObstacleData(Row, this);
                break;
            }

            case 8:
            {
                Data = new EffectData(Row, this);
                break;
            }

            case 9:
            {
                Data = new ParticleEmitterData(Row, this);
                break;
            }

            case 10:
            {
                Data = new ExperienceLevelData(Row, this);
                break;
            }

            case 11:
            {
                Data = new TrapData(Row, this);
                break;
            }

            case 12:
            {
                Data = new AllianceBadgeData(Row, this);
                break;
            }

            case 13:
            {
                Data = new GlobalData(Row, this);
                break;
            }

            case 14:
            {
                Data = new TownhallLevelData(Row, this);
                break;
            }

            case 15:
            {
                Data = new PrototypeData(Row, this);
                break;
            }

            case 16:
            {
                Data = new NpcData(Row, this);
                break;
            }

            case 17:
            {
                Data = new DecoData(Row, this);
                break;
            }

            case 18:
            {
                Data = new ResourcePackData(Row, this);
                break;
            }

            case 20:
            {
                Data = new MissionData(Row, this);
                break;
            }

            case 21:
            {
                Data = new BillingPackageData(Row, this);
                break;
            }

            case 22:
            {
                Data = new AchievementData(Row, this);
                break;
            }

            case 25:
            {
                Data = new SpellData(Row, this);
                break;
            }

            case 26:
            {
                Data = new HintData(Row, this);
                break;
            }

            case 27:
            {
                Data = new LandingShipData(Row, this);
                break;
            }

            case 28:
            {
                Data = new ArtifactData(Row, this);
                break;
            }

            case 29:
            {
                Data = new ArtifactBonusData(Row, this);
                break;
            }

            case 30:
            {
                Data = new DeepseaParameterData(Row, this);
                break;
            }

            case 31:
            {
                Data = new ExplorationCostData(Row, this);
                break;
            }

            case 34:
            {
                Data = new ResourceShipData(Row, this);
                break;
            }

            case 35:
            {
                Data = new LootBoxData(Row, this);
                break;
            }

            case 36:
            {
                Data = new LiberatedIncomeData(Row, this);
                break;
            }

            case 37:
            {
                Data = new RegionData(Row, this);
                break;
            }

            case 38:
            {
                Data = new DefenseRewardData(Row, this);
                break;
            }

            case 39:
            {
                Data = new LocatorData(Row, this);
                break;
            }

            case 40:
            {
                Data = new EventData(Row, this);
                break;
            }

            case 41:
            {
                Data = new FootstepData(Row, this);
                break;
            }

            case 42:
            {
                Data = new PersistentEventRewardData(Row, this);
                break;
            }

            case 43:
            {
                Data = new CommunityLinkData(Row, this);
                break;
            }

            case 44:
            {
                Data = new ShieldData(Row, this);
                break;
            }

            case 45:
            {
                Data = new AbTestData(Row, this);
                break;
            }

            case 46:
            {
                Data = new LetterData(Row, this);
                break;
            }

            case 47:
            {
                Data = new RankData(Row, this);
                break;
            }

            case 48:
            {
                Data = new CountryData(Row, this);
                break;
            }

            case 51:
            {
                Data = new BoomboxData(Row, this);
                break;
            }

            case 52:
            {
                Data = new HeroData(Row, this);
                break;
            }

            case 53:
            {
                Data = new HeroAbilityData(Row, this);
                break;
            }

            case 54:
            {
                Data = new OfferData(Row, this);
                break;
            }

            case 55:
            {
                Data = new DeepLinkData(Row, this);
                break;
            }

            case 56:
            {
                Data = new SectorData(Row, this);
                break;
            }

            case 57:
            {
                Data = new SectorBonusData(Row, this);
                break;
            }

            default:
            {
                Data = new Data(Row, this);
                break;
            }
            }

            return(Data);
        }
コード例 #19
0
        internal override void Process()
        {
            if (this.Parameters.Length >= 1)
            {
                if (int.TryParse(this.Parameters[0], out this.VillageID))
                {
                    Player Player = this.Device.GameMode.Level.Player;

                    switch (this.VillageID)
                    {
                    case 0:
                    {
                        var WorkerManager = this.Device.GameMode.Level.WorkerManager;
                        if (WorkerManager.GameObjects.Count != 0)
                        {
                            do
                            {
                                WorkerManager.GameObjects.Remove(0);
                            } while (WorkerManager.GameObjects.Count != 0);
                        }

                        Parallel.ForEach(this.Device.GameMode.Level.GameObjectManager.Filter.GetGameObjects(0, 0), GameObject =>
                            {
                                Building Building = (Building)GameObject;
                                BuildingData Data = Building.BuildingData;

                                if (Building.Locked)
                                {
                                    Building.Locked = false;
                                }

                                if (Building.Constructing)
                                {
                                    Building.ConstructionTimer = null;
                                }

                                Building.SetUpgradeLevel(Data.MaxLevel);
                            });

                        Parallel.ForEach(this.Device.GameMode.Level.GameObjectManager.Filter.GetGameObjects(4, 0), GameObject =>
                            {
                                Trap Trap     = (Trap)GameObject;
                                TrapData Data = (TrapData)Trap.Data;

                                if (Trap.Constructing)
                                {
                                    Trap.ConstructionTimer = null;
                                }

                                Trap.SetUpgradeLevel(Data.MaxLevel);
                            });

                        this.SendChatMessage("Successfully maxed your normal village's buildings' levels. Enjoy!");

                        new OwnHomeDataMessage(this.Device).Send();

                        break;
                    }

                    case 1:
                    {
                        if (Player.TownHallLevel2 > 0)
                        {
                            var WorkerManagerV2 = this.Device.GameMode.Level.WorkerManagerV2;
                            if (WorkerManagerV2.GameObjects.Count != 0)
                            {
                                do
                                {
                                    WorkerManagerV2.GameObjects.Remove(0);
                                } while (WorkerManagerV2.GameObjects.Count != 0);
                            }

                            Parallel.ForEach(this.Device.GameMode.Level.GameObjectManager.Filter.GetGameObjects(0, 1), GameObject =>
                                {
                                    Building Building = (Building)GameObject;
                                    BuildingData Data = Building.BuildingData;

                                    if (Building.Locked)
                                    {
                                        if (Data.IsHeroBarrack)
                                        {
                                            if (Building.HeroBaseComponent != null)
                                            {
                                                var data = CSV.Tables.Get(Gamefile.Heroes).GetData(Data.HeroType);
                                                if (data is HeroData)
                                                {
                                                    var HeroData = (HeroData)data;
                                                    Player.HeroUpgrades.Set(HeroData, 0);
                                                    Player.HeroStates.Set(HeroData, 3);

                                                    if (HeroData.HasAltMode)
                                                    {
                                                        Player.HeroModes.Set(HeroData, 0);
                                                    }
                                                }
                                            }
                                        }

                                        Building.Locked = false;
                                    }

                                    if (Building.Constructing)
                                    {
                                        Building.ConstructionTimer = null;
                                    }

                                    Building.SetUpgradeLevel(Data.MaxLevel);
                                });

                            Parallel.ForEach(this.Device.GameMode.Level.GameObjectManager.Filter.GetGameObjects(4, 1), GameObject =>
                                {
                                    Trap Trap     = (Trap)GameObject;
                                    TrapData Data = (TrapData)Trap.Data;

                                    if (Trap.Constructing)
                                    {
                                        Trap.ConstructionTimer = null;
                                    }

                                    Trap.SetUpgradeLevel(Data.MaxLevel);
                                });

                            this.SendChatMessage("Successfully maxed your builder village's buildings' levels. Enjoy!");

                            new OwnHomeDataMessage(this.Device).Send();
                        }
                        else
                        {
                            this.SendChatMessage("Please visit the builder village first before running this mode!");
                        }

                        break;
                    }


                    case 2:
                    {
                        if (Player.TownHallLevel2 > 0)
                        {
                            var WorkerManager = this.Device.GameMode.Level.WorkerManager;
                            if (WorkerManager.GameObjects.Count != 0)
                            {
                                do
                                {
                                    WorkerManager.GameObjects.Remove(0);
                                } while (WorkerManager.GameObjects.Count != 0);
                            }

                            var WorkerManagerV2 = this.Device.GameMode.Level.WorkerManagerV2;
                            if (WorkerManagerV2.GameObjects.Count != 0)
                            {
                                do
                                {
                                    WorkerManagerV2.GameObjects.Remove(0);
                                } while (WorkerManagerV2.GameObjects.Count != 0);
                            }

                            Parallel.ForEach(this.Device.GameMode.Level.GameObjectManager.Filter.GetGameObjects(0, 0), GameObject =>
                                {
                                    Building Building = (Building)GameObject;
                                    BuildingData Data = Building.BuildingData;

                                    if (Building.Locked)
                                    {
                                        Building.Locked = false;
                                    }

                                    if (Building.Constructing)
                                    {
                                        Building.ConstructionTimer = null;
                                    }


                                    Building.SetUpgradeLevel(Data.MaxLevel);
                                });

                            Parallel.ForEach(this.Device.GameMode.Level.GameObjectManager.Filter.GetGameObjects(0, 1), GameObject =>
                                {
                                    Building Building = (Building)GameObject;
                                    BuildingData Data = Building.BuildingData;

                                    if (Building.Locked)
                                    {
                                        if (Data.IsHeroBarrack)
                                        {
                                            if (Building.HeroBaseComponent != null)
                                            {
                                                var data = CSV.Tables.Get(Gamefile.Heroes).GetData(Data.HeroType);
                                                if (data is HeroData)
                                                {
                                                    var HeroData = (HeroData)data;
                                                    Player.HeroUpgrades.Set(HeroData, 0);
                                                    Player.HeroStates.Set(HeroData, 3);

                                                    if (HeroData.HasAltMode)
                                                    {
                                                        Player.HeroModes.Set(HeroData, 0);
                                                    }
                                                }
                                            }
                                        }

                                        Building.Locked = false;
                                    }

                                    if (Building.Constructing)
                                    {
                                        Building.ConstructionTimer = null;
                                    }

                                    Building.SetUpgradeLevel(Data.MaxLevel);
                                });

                            Parallel.ForEach(this.Device.GameMode.Level.GameObjectManager.Filter.GetGameObjects(4, 0), GameObject =>
                                {
                                    Trap Trap     = (Trap)GameObject;
                                    TrapData Data = (TrapData)Trap.Data;

                                    if (Trap.Constructing)
                                    {
                                        Trap.ConstructionTimer = null;
                                    }

                                    Trap.SetUpgradeLevel(Data.MaxLevel);
                                });

                            Parallel.ForEach(this.Device.GameMode.Level.GameObjectManager.Filter.GetGameObjects(4, 1), GameObject =>
                                {
                                    Trap Trap     = (Trap)GameObject;
                                    TrapData Data = (TrapData)Trap.Data;

                                    if (Trap.Constructing)
                                    {
                                        Trap.ConstructionTimer = null;
                                    }

                                    Trap.SetUpgradeLevel(Data.MaxLevel);
                                });

                            this.SendChatMessage("Successfully maxed both of your village's buildings' levels. Enjoy!");

                            new OwnHomeDataMessage(this.Device).Send();
                        }
                        else
                        {
                            this.SendChatMessage("Please visit the builder village first before running this mode!");
                        }

                        break;
                    }

                    default:
                        this.Help = new StringBuilder();
                        this.Help.AppendLine(
                            "Available village types:\n\t0 = Normal Village\n\t1 = Builder Village (Make sure you have unlocked the builder base first!)\n\t2 = All Villages (Make sure you have unlocked the builder base first!)");
                        this.Help.AppendLine("Command:\n\t/maxlevels {village_id}");
                        this.SendChatMessage(this.Help.ToString());
                        this.Help = null;
                        break;
                    }
                }
                else
                {
                    this.Help = new StringBuilder();
                    this.Help.AppendLine(
                        "Available village types:\n\t0 = Normal Village\n\t1 = Builder Village (Make sure you have unlocked the builder base first!)\n\t2 = All Villages (Make sure you have unlocked the builder base first!)");
                    this.Help.AppendLine("Command:\n\t/maxlevels {village_id}");
                    this.SendChatMessage(this.Help.ToString());
                    this.Help = null;
                }
            }
            else
            {
                this.Help = new StringBuilder();
                this.Help.AppendLine(
                    "Available village types:\n\t0 = Normal Village\n\t1 = Builder Village (Make sure you have unlocked the builder base first!)\n\t2 = All Villages (Make sure you have unlocked the builder base first!)");
                this.Help.AppendLine("Command:\n\t/maxlevels {village_id}");
                this.SendChatMessage(this.Help.ToString());
                this.Help = null;
            }
        }
コード例 #20
0
ファイル: DataTable.cs プロジェクト: nako75/GL.Servers
        /// <summary>
        /// Creates the data for the specified row.
        /// </summary>
        /// <param name="Row">The row.</param>
        internal Data Create(Row Row)
        {
            Data Data;

            switch (this.Index)
            {
            case 1:
            {
                Data = new BuildingData(Row, this);
                break;
            }

            case 2:
            {
                Data = new LocaleData(Row, this);
                break;
            }

            case 3:
            {
                Data = new ResourceData(Row, this);
                break;
            }

            case 4:
            {
                Data = new CharacterData(Row, this);
                break;
            }

            case 6:
            {
                Data = new ProjectileData(Row, this);
                break;
            }

            case 7:
            {
                Data = new BuildingClassData(Row, this);
                break;
            }

            case 8:
            {
                Data = new ObstacleData(Row, this);
                break;
            }

            case 9:
            {
                Data = new EffectData(Row, this);
                break;
            }

            case 10:
            {
                Data = new ParticleEmitterData(Row, this);
                break;
            }

            case 11:
            {
                Data = new ExperienceLevelData(Row, this);
                break;
            }

            case 12:
            {
                Data = new TrapData(Row, this);
                break;
            }

            case 13:
            {
                Data = new AllianceBadgeData(Row, this);
                break;
            }

            case 14:
            {
                Data = new GlobalData(Row, this);
                break;
            }

            case 15:
            {
                Data = new TownhallLevelData(Row, this);
                break;
            }

            case 16:
            {
                Data = new AlliancePortalData(Row, this);
                break;
            }

            case 17:
            {
                Data = new NpcData(Row, this);
                break;
            }

            case 18:
            {
                Data = new DecoData(Row, this);
                break;
            }

            case 19:
            {
                Data = new ResourcePackData(Row, this);
                break;
            }

            case 20:
            {
                Data = new ShieldData(Row, this);
                break;
            }

            case 21:
            {
                Data = new MissionData(Row, this);
                break;
            }

            case 22:
            {
                Data = new BillingPackageData(Row, this);
                break;
            }

            case 23:
            {
                Data = new AchievementData(Row, this);
                break;
            }

            case 25:
            {
                Data = new FaqData(Row, this);
                break;
            }

            case 26:
            {
                Data = new SpellData(Row, this);
                break;
            }

            case 27:
            {
                Data = new HintData(Row, this);
                break;
            }

            case 28:
            {
                Data = new HeroData(Row, this);
                break;
            }

            case 29:
            {
                Data = new LeagueData(Row, this);
                break;
            }

            case 30:
            {
                Data = new NewData(Row, this);
                break;
            }

            case 34:
            {
                Data = new AllianceBadgeLayerData(Row, this);
                break;
            }

            case 37:
            {
                Data = new VariableData(Row, this);
                break;
            }

            case 38:
            {
                Data = new GemBundleData(Row, this);
                break;
            }

            case 39:
            {
                Data = new VillageObjectData(Row, this);
                break;
            }

            default:
            {
                Data = new Data(Row, this);
                break;
            }
            }

            return(Data);
        }
コード例 #21
0
 public Trap(Obj_AI_Base trap, TrapData data)
 {
     this.theTrap     = trap;
     this.Data        = data;
     this.DisplayName = data.DisplayName;
 }
コード例 #22
0
        internal Data Create(Row _Row)
        {
            Data _Data;

            switch ((Gamefile)this.Index)
            {
            case Gamefile.Buildings:
                _Data = new BuildingData(_Row, this);
                break;

            case Gamefile.Locales:
                _Data = new LocaleData(_Row, this);
                break;

            case Gamefile.Resources:
                _Data = new ResourceData(_Row, this);
                break;

            case Gamefile.Characters:
                _Data = new CharacterData(_Row, this);
                break;

            case Gamefile.Building_Classes:
                _Data = new BuildingClassData(_Row, this);
                break;

            case Gamefile.Obstacles:
                _Data = new ObstacleData(_Row, this);
                break;

            case Gamefile.Traps:
                _Data = new TrapData(_Row, this);
                break;

            case Gamefile.Globals:
                _Data = new GlobalData(_Row, this);
                break;

            case Gamefile.Experience_Levels:
                _Data = new ExperienceLevelData(_Row, this);
                break;

            case Gamefile.Townhall_Levels:
                _Data = new TownhallLevelData(_Row, this);
                break;

            case Gamefile.Npcs:
                _Data = new NpcData(_Row, this);
                break;

            case Gamefile.Decos:
                _Data = new DecoData(_Row, this);
                break;

            case Gamefile.Shields:
                _Data = new ShieldData(_Row, this);
                break;

            case Gamefile.Missions:
                _Data = new MissionData(_Row, this);
                break;

            case Gamefile.Achievements:
                _Data = new AchievementData(_Row, this);
                break;

            case Gamefile.Spells:
                _Data = new SpellData(_Row, this);
                break;

            case Gamefile.Heroes:
                _Data = new HeroData(_Row, this);
                break;

            case Gamefile.Leagues:
                _Data = new LeagueData(_Row, this);
                break;

            case Gamefile.Regions:
                _Data = new RegionData(_Row, this);
                break;

            case Gamefile.AllianceBadgeLayer:
                _Data = new AllianceBadgeLayerData(_Row, this);
                break;

            case Gamefile.Variables:
                _Data = new VariableData(_Row, this);
                break;

            case Gamefile.Village_Objects:
                _Data = new VillageObjectData(_Row, this);
                break;

            default:
                _Data = new Data(_Row, this);
                break;
            }

            return(_Data);
        }
コード例 #23
0
        internal override void Execute()
        {
            Level      Level      = this.Device.GameMode.Level;
            GameObject GameObject = Level.GameObjectManager.Filter.GetGameObjectById(this.Id);

            if (GameObject != null)
            {
                if (GameObject is Building)
                {
                    Building Building = (Building)GameObject;
                    if (Building.UpgradeAvailable)
                    {
                        BuildingData Data         = (BuildingData)Building.Data;
                        ResourceData ResourceData = this.UseAltResource ? Data.AltBuildResourceData(Building.GetUpgradeLevel() + 1) : Data.BuildResourceData;

                        if (ResourceData != null)
                        {
                            if (Level.Player.Resources.GetCountByData(ResourceData) >= Data.BuildCost[Building.GetUpgradeLevel() + 1])
                            {
                                if (Data.VillageType == 0 ? Level.WorkerManager.FreeWorkers > 0 : Level.WorkerManagerV2.FreeWorkers > 0)
                                {
                                    Level.Player.Resources.Remove(ResourceData, Data.BuildCost[Building.GetUpgradeLevel() + 1]);
                                    Building.StartUpgrade();

                                    if (Data.IsTownHall2)
                                    {
                                        if (Level.Player.TownHallLevel2 == 0)
                                        {
                                            foreach (var gameObject in Level.GameObjectManager.GameObjects[0][1])
                                            {
                                                Building     building2 = (Building)gameObject;
                                                BuildingData data2     = building2.BuildingData;
                                                if (building2.Locked)
                                                {
                                                    if (!data2.Locked)
                                                    {
#if DEBUG
                                                        Logging.Info(this.GetType(), $"Builder Building: Unlocking {data2.Name} with ID {gameObject.Id}");
#endif
                                                        building2.Locked = false;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            else
                            {
                                Logging.Error(this.GetType(), "Unable to upgrade the building. The player doesn't have enough resources.");
                            }
                        }
                        else
                        {
                            Logging.Error(this.GetType(), "Unable to upgrade the building. The resource data is null");
                        }
                    }
                    else
                    {
                        Logging.Error(this.GetType(), "Unable to upgrade the building. Upgrade is not available.");
                    }
                }
                else if (GameObject is Trap)
                {
                    Trap Trap = (Trap)GameObject;
                    if (Trap.UpgradeAvailable)
                    {
                        TrapData     Data         = Trap.TrapData;
                        ResourceData ResourceData = Data.BuildResourceData;

                        if (ResourceData != null)
                        {
                            if (Level.Player.Resources.GetCountByData(ResourceData) >= Data.BuildCost[Trap.GetUpgradeLevel() + 1])
                            {
                                if (Data.VillageType == 0 ? Level.WorkerManager.FreeWorkers > 0 : Level.WorkerManagerV2.FreeWorkers > 0)
                                {
                                    Level.Player.Resources.Remove(ResourceData, Data.BuildCost[Trap.GetUpgradeLevel() + 1]);
                                    Trap.StartUpgrade();
                                }
                            }
                            else
                            {
                                Logging.Error(this.GetType(), "Unable to upgrade the Trap. The player doesn't have enough resources.");
                            }
                        }
                        else
                        {
                            Logging.Error(this.GetType(), "Unable to start upgrade the Trap. The resources data is null.");
                        }
                    }
                    else
                    {
                        Logging.Error(this.GetType(), "Unable to upgrade the building. Upgrade is not available.");
                    }
                }
                else if (GameObject is VillageObject)
                {
                    VillageObject     VillageObject = (VillageObject)GameObject;
                    VillageObjectData Data          = VillageObject.VillageObjectData;
                    ResourceData      ResourceData  = Data.BuildResourceData;

                    if (ResourceData != null)
                    {
                        if (Level.Player.Resources.GetCountByData(ResourceData) >= Data.BuildCost[VillageObject.GetUpgradeLevel() + 1])
                        {
                            if (Data.VillageType == 0 ? Level.WorkerManager.FreeWorkers > 0 : Level.WorkerManagerV2.FreeWorkers > 0)
                            {
                                Level.Player.Resources.Remove(ResourceData, Data.BuildCost[VillageObject.GetUpgradeLevel() + 1]);
                                VillageObject.StartUpgrade();
                            }
                        }
                        else
                        {
                            Logging.Error(this.GetType(), "Unable to upgrade the VillageObject. The player doesn't have enough resources.");
                        }
                    }
                    else
                    {
                        Logging.Error(this.GetType(), "Unable to start upgrade the VillageObject. The resources data is null.");
                    }
                }
                else
                {
                    Logging.Error(this.GetType(), $"Unable to determined Game Object type. Game Object type {GameObject.Type}.");
                }
            }
            else
            {
                Logging.Error(this.GetType(), "Unable to upgrade the gameObject. GameObject is null");
#if COMMAND_DEBUG
                Device.Account.Player.Debug.Dump();
#endif
            }
        }
コード例 #24
0
        internal override void Load(JToken Json)
        {
            TrapData Data = this.TrapData;

            if (this.VillageType == 0)
            {
                this.Level.WorkerManager.DeallocateWorker(this);
            }
            else
            {
                this.Level.WorkerManagerV2.DeallocateWorker(this);
            }

            int ConstructionTime;
            int ConstructionTimeEnd;

            if (JsonHelper.GetJsonNumber(Json, "const_t", out ConstructionTime) && JsonHelper.GetJsonNumber(Json, "const_t_end", out ConstructionTimeEnd))
            {
                if (ConstructionTime > -1)
                {
                    int startTime = (int)TimeUtils.ToUnixTimestamp(this.Level.Player.LastTick);
                    int duration  = ConstructionTimeEnd - startTime;
                    if (duration < 0)
                    {
                        duration = 0;
                    }
                    //ConstructionTime = Math.Min(ConstructionTime, Data.GetBuildTime(this.UpgradeLevel + 1));

                    this.ConstructionTimer = new Timer();
                    this.ConstructionTimer.StartTimer(this.Level.Player.LastTick, duration);
                    if (this.VillageType == 0)
                    {
                        this.Level.WorkerManager.AllocateWorker(this);
                    }
                    else
                    {
                        if (this.UpgradeLevel > -1)
                        {
                            this.Level.WorkerManagerV2.AllocateWorker(this);
                        }
                    }
                }
            }

            int Level;

            if (JsonHelper.GetJsonNumber(Json, "lvl", out Level))
            {
                if (Level < -1)
                {
                    Logging.Error(this.GetType(), "An error has been throwed when the loading of building - Load an illegal upgrade level. Level : " + Level);
                    this.SetUpgradeLevel(0);
                }
                else if (Level > Data.MaxLevel)
                {
                    Logging.Error(this.GetType(), $"An error has been throwed when the loading of building - Loaded upgrade level {Level + 1} is over max! (max = {Data.MaxLevel + 1}) id {this.Id} data id {Data.GlobalId}");
                    this.SetUpgradeLevel(Data.MaxLevel);
                }
                else
                {
                    this.SetUpgradeLevel(Level);
                }
            }

            JsonHelper.GetJsonBoolean(Json, "needs_repair", out this.NeedRepair);

            base.Load(Json);
        }