Esempio n. 1
0
        public override void Process()
        {
            Device.Player.Avatar.Wall_Group_ID++;
            foreach (var WallXY in WallXYs)
            {
                var bd = (Buildings)CSV.Tables.Get(Gamefile.Buildings).GetDataWithID(WallID);
                if (!Device.Player.Avatar.Variables.IsBuilderVillage)
                {
                    var b = new Building(bd, Device.Player);

                    if (Device.Player.Avatar.HasEnoughResources(bd.GetBuildResource(0).GetGlobalId(),
                                                                bd.GetBuildCost(0)))
                    {
                        if (Device.Player.HasFreeVillageWorkers)
                        {
                            var rd = bd.GetBuildResource(0);
                            Device.Player.Avatar.Resources.Minus(rd.GetGlobalId(), bd.GetBuildCost(0));

                            var a = (Combat_Component)b.GetComponent(1, false);
                            a.WallI = Device.Player.Avatar.Wall_Group_ID;
                            b.StartConstructing(WallXY, Device.Player.Avatar.Variables.IsBuilderVillage);
                            Device.Player.GameObjectManager.AddGameObject(b);
                        }
                    }
                }
                else
                {
                    var b = new Builder_Building(bd, Device.Player);
                    if (Device.Player.Avatar.HasEnoughResources(bd.GetBuildResource(0).GetGlobalId(),
                                                                bd.GetBuildCost(0)))
                    {
                        if (Device.Player.HasFreeBuilderWorkers)
                        {
                            var rd = bd.GetBuildResource(0);
                            Device.Player.Avatar.Resources.Minus(rd.GetGlobalId(), bd.GetBuildCost(0));
                            var a = (Combat_Component)b.GetComponent(1, false);
                            a.WallI = Device.Player.Avatar.Wall_Group_ID;
                            b.StartConstructing(WallXY, Device.Player.Avatar.Variables.IsBuilderVillage);
                            Device.Player.GameObjectManager.AddGameObject(b);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        internal override void Process()
        {
            var ca = this.Device.Player.Avatar;
            var bd = (Buildings)CSV.Tables.Get(Gamefile.Buildings).GetDataWithID(BuildingId);

            if (!ca.Variables.IsBuilderVillage)
            {
                var b = new Building(bd, this.Device.Player);

                if (ca.HasEnoughResources(bd.GetBuildResource(0).GetGlobalID(), bd.GetBuildCost(0)))
                {
                    if (bd.IsWorkerBuilding())
                    {
                        if (this.Device.Player.VillageWorkerManager.WorkerCount > 0)
                        {
                            int Cost = 0;
                            var row  = CSV.Tables.Get(Gamefile.Globals);
                            if (this.Device.Player.VillageWorkerManager.WorkerCount == 1)
                            {
                                Cost = ((Globals)row.GetData("WORKER_COST_2ND")).NumberValue;
                            }
                            else if (this.Device.Player.VillageWorkerManager.WorkerCount == 2)
                            {
                                Cost = ((Globals)row.GetData("WORKER_COST_3RD")).NumberValue;
                            }
                            else if (this.Device.Player.VillageWorkerManager.WorkerCount == 3)
                            {
                                Cost = ((Globals)row.GetData("WORKER_COST_4TH")).NumberValue;
                            }
                            else if (this.Device.Player.VillageWorkerManager.WorkerCount >= 4)
                            {
                                Cost = ((Globals)row.GetData("WORKER_COST_5TH")).NumberValue;
                            }

                            var rd = bd.GetBuildResource(0);
                            ca.Resources.Minus(rd.GetGlobalID(), Cost);
                        }
                        b.StartConstructing(this.Vector, false);
                        this.Device.Player.GameObjectManager.AddGameObject(b);
                        return;
                    }

                    if (this.Device.Player.HasFreeVillageWorkers)
                    {
                        var rd = bd.GetBuildResource(0);
                        ca.Resources.Minus(rd.GetGlobalID(), bd.GetBuildCost(0));

                        b.StartConstructing(this.Vector, this.Device.Player.Avatar.Variables.IsBuilderVillage);
                        this.Device.Player.GameObjectManager.AddGameObject(b);
                    }
                }
            }
            else
            {
                var b = new Builder_Building(bd, this.Device.Player);
                if (ca.HasEnoughResources(bd.GetBuildResource(0).GetGlobalID(), bd.GetBuildCost(0)))
                {
                    if (bd.IsWorker2Building())
                    {
                        b.StartConstructing(this.Vector, true);
                        this.Device.Player.GameObjectManager.AddGameObject(b);
                        return;
                    }

                    if (this.Device.Player.HasFreeBuilderVillageWorkers)
                    {
                        var rd = bd.GetBuildResource(0);
                        ca.Resources.Minus(rd.GetGlobalID(), bd.GetBuildCost(0));

                        b.StartConstructing(this.Vector, true);
                        this.Device.Player.GameObjectManager.AddGameObject(b);
                    }
                }
            }
        }
Esempio n. 3
0
        public override void Process()
        {
            var ca = Device.Player.Avatar;
            var bd = (Buildings)CSV.Tables.Get(Gamefile.Buildings).GetDataWithID(BuildingId);

            if (bd != null)
            {
                if (!ca.Variables.IsBuilderVillage)
                {
                    var b = new Building(bd, Device.Player);

                    if (ca.HasEnoughResources(bd.GetBuildResource(0).GetGlobalId(), bd.GetBuildCost(0)))
                    {
                        if (bd.IsWorkerBuilding())
                        {
                            if (Device.Player.VillageWorkerManager.GetFreeWorkers() > 0)
                            {
                                var Cost = 0;
                                var row  = CSV.Tables.Get(Gamefile.Globals);
                                if (Device.Player.VillageWorkerManager.GetTotalWorkers() == 1)
                                {
                                    Cost = ((Globals)row.GetData("WORKER_COST_2ND")).NumberValue;
                                }
                                else if (Device.Player.VillageWorkerManager.GetTotalWorkers() == 2)
                                {
                                    Cost = ((Globals)row.GetData("WORKER_COST_3RD")).NumberValue;
                                }
                                else if (Device.Player.VillageWorkerManager.GetTotalWorkers() == 3)
                                {
                                    Cost = ((Globals)row.GetData("WORKER_COST_4TH")).NumberValue;
                                }
                                else if (Device.Player.VillageWorkerManager.GetTotalWorkers() >= 4)
                                {
                                    Cost = ((Globals)row.GetData("WORKER_COST_5TH")).NumberValue;
                                }

                                var rd = bd.GetBuildResource(0);
                                ca.Resources.Minus(rd.GetGlobalId(), Cost);
                            }
                            b.StartConstructing(XY, false);
                            Device.Player.GameObjectManager.AddGameObject(b);
                            return;
                        }

                        if (Device.Player.HasFreeVillageWorkers)
                        {
                            var rd = bd.GetBuildResource(0);
                            ca.Resources.Minus(rd.GetGlobalId(), bd.GetBuildCost(0));

                            b.StartConstructing(XY, false);
                            Device.Player.GameObjectManager.AddGameObject(b);
                        }
                    }
                }
                else
                {
                    var b = new Builder_Building(bd, Device.Player);
                    if (ca.HasEnoughResources(bd.GetBuildResource(0).GetGlobalId(), bd.GetBuildCost(0)))
                    {
                        if (bd.IsWorker2Building())
                        {
                            b.StartConstructing(XY, true);
                            Device.Player.GameObjectManager.AddGameObject(b);
                            return;
                        }

                        if (Device.Player.HasFreeBuilderWorkers)
                        {
                            var rd = bd.GetBuildResource(0);
                            ca.Resources.Minus(rd.GetGlobalId(), bd.GetBuildCost(0));

                            b.StartConstructing(XY, true);
                            Device.Player.GameObjectManager.AddGameObject(b);
                        }
                    }
                }
            }
            else
            {
                new Out_Of_Sync(this.Device).Send();
            }
        }