Exemplo n.º 1
0
        public override void Execute(Level level)
        {
            ClientAvatar ca = level.GetPlayerAvatar();
            GameObject   go = level.GameObjectManager.GetGameObjectByID(m_vBuildingId);

            if (go != null)
            {
                if (go.ClassId == 4)
                {
                    Trap t            = (Trap)go;
                    int  upgradeLevel = t.GetUpgradeLevel();
                    var  rd           = t.GetTrapData().GetBuildResource(upgradeLevel);
                    int  sellPrice    = t.GetTrapData().GetSellPrice(upgradeLevel);
                    ca.CommodityCountChangeHelper(0, rd, sellPrice);
                    level.GameObjectManager.RemoveGameObject(t);
                }
                else if (go.ClassId == 6)
                {
                    Deco d         = (Deco)go;
                    var  rd        = d.GetDecoData().GetBuildResource();
                    int  sellPrice = d.GetDecoData().GetSellPrice();
                    if (rd.PremiumCurrency)
                    {
                        ca.SetDiamonds(ca.GetDiamonds() + sellPrice);
                    }
                    else
                    {
                        ca.CommodityCountChangeHelper(0, rd, sellPrice);
                    }
                    level.GameObjectManager.RemoveGameObject(d);
                }
                else
                {
                    //TODO BUILDING

                    /*
                     * Building b = (Building)go;
                     * level.GameObjectManager.RemoveGameObject(b);
                     * */
                }
            }
        }
        public override void Execute(Level level)
        {
            ClientAvatar avatar         = level.GetPlayerAvatar();
            GameObject   gameObjectById = level.GameObjectManager.GetGameObjectByID(m_vBuildingId);

            if (gameObjectById == null)
            {
                return;
            }
            if (gameObjectById.ClassId == 4)
            {
                Trap         trap          = (Trap)gameObjectById;
                int          upgradeLevel  = trap.GetUpgradeLevel();
                ResourceData buildResource = trap.GetTrapData().GetBuildResource(upgradeLevel);
                int          sellPrice     = trap.GetTrapData().GetSellPrice(upgradeLevel);
                avatar.CommodityCountChangeHelper(0, (Data)buildResource, sellPrice);
                level.GameObjectManager.RemoveGameObject((GameObject)trap);
            }
            else
            {
                if (gameObjectById.ClassId != 6)
                {
                    return;
                }
                Deco         deco          = (Deco)gameObjectById;
                ResourceData buildResource = deco.GetDecoData().GetBuildResource();
                int          sellPrice     = deco.GetDecoData().GetSellPrice();
                if (buildResource.PremiumCurrency)
                {
                    avatar.SetDiamonds(avatar.GetDiamonds() + sellPrice);
                }
                else
                {
                    avatar.CommodityCountChangeHelper(0, (Data)buildResource, sellPrice);
                }
                level.GameObjectManager.RemoveGameObject((GameObject)deco);
            }
        }
Exemplo n.º 3
0
        public JObject Save()
        {
            ClientAvatar pl       = m_vLevel.GetPlayerAvatar();
            var          jsonData = new JObject();

            jsonData.Add("exp_ver", 1);
            jsonData.Add("android_client", pl.GetAndroid());
            jsonData.Add("active_layout", pl.GetActiveLayout());
            jsonData.Add("war_layout", pl.GetActiveLayout());
            jsonData.Add("layout_state", new JArray {
                0, 0, 0, 0, 0, 0
            });

            JArray JBuildings = new JArray();
            int    c          = 0;

            foreach (GameObject go in new List <GameObject>(m_vGameObjects[0]))
            {
                Building b = (Building)go;
                JObject  j = new JObject();
                j.Add("data", b.GetBuildingData().GetGlobalID());
                j.Add("id", 500000000 + c);
                b.Save(j);
                JBuildings.Add(j);
                c++;
            }
            jsonData.Add("buildings", JBuildings);

            JArray JTraps = new JArray();
            int    u      = 0;

            foreach (GameObject go in new List <GameObject>(m_vGameObjects[4]))
            {
                Trap    t = (Trap)go;
                JObject j = new JObject();
                j.Add("data", t.GetTrapData().GetGlobalID());
                j.Add("id", 504000000 + u);
                t.Save(j);
                JTraps.Add(j);
                u++;
            }
            jsonData.Add("traps", JTraps);

            JArray JDecos = new JArray();
            int    e      = 0;

            foreach (GameObject go in new List <GameObject>(m_vGameObjects[6]))
            {
                Deco    d = (Deco)go;
                JObject j = new JObject();
                j.Add("data", d.GetDecoData().GetGlobalID());
                j.Add("id", 506000000 + e);
                d.Save(j);
                JDecos.Add(j);
                e++;
            }
            jsonData.Add("decos", JDecos);

            JArray JObstacles = new JArray();
            int    o          = 0;

            foreach (GameObject go in new List <GameObject>(m_vGameObjects[3]))
            {
                Obstacle d = (Obstacle)go;
                JObject  j = new JObject();
                j.Add("data", d.GetObstacleData().GetGlobalID());
                j.Add("id", 503000000 + o);
                d.Save(j);
                JObstacles.Add(j);
                o++;
            }
            jsonData.Add("obstacles", JObstacles);

            m_vObstacleManager.Save(jsonData);

            var cooldowns = new JArray();

            jsonData.Add("cooldowns", cooldowns);
            var newShopBuildings = new JArray
            {
                4,
                0,
                7,
                4,
                7,
                4,
                4,
                1,
                7,
                8,
                275,
                5,
                4,
                4,
                1,
                5,
                0,
                0,
                0,
                4,
                1,
                4,
                1,
                3,
                1,
                1,
                2,
                2,
                2,
                1,
                1,
                1
            };

            jsonData.Add("newShopBuildings", newShopBuildings);
            var newShopTraps = new JArray {
                6, 6, 5, 0, 0, 5, 5, 0, 3
            };

            jsonData.Add("newShopTraps", newShopTraps);
            var newShopDecos = new JArray
            {
                1,
                4,
                1,
                1,
                1,
                1,
                1,
                1,
                1,
                1,
                1,
                1,
                1,
                1,
                1,
                1,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0
            };

            jsonData.Add("newShopDecos", newShopDecos);
            jsonData.Add("troop_req_msg", "UCS Developement Team");
            jsonData.Add("last_league_rank", m_vLevel.GetPlayerAvatar().GetLeagueId());
            jsonData.Add("last_league_shuffle", 1);
            jsonData.Add("last_season_seen", 1);
            jsonData.Add("last_news_seen", 999);
            jsonData.Add("edit_mode_shown", true);
            jsonData.Add("war_tutorials_seen", 1);
            jsonData.Add("war_base", true);
            jsonData.Add("help_opened", true);
            jsonData.Add("bool_layout_edit_shown_erase", false);


            return(jsonData);
        }
        public JObject Save()
        {
            JArray JBuildings = new JArray();
            int    c          = 0;

            foreach (GameObject go in new List <GameObject>(this.GameObjects[0]))
            {
                Building b = (Building)go;
                JObject  j = new JObject {
                    { "data", b.GetBuildingData().GetGlobalID() }, { "id", 500000000 + c }
                };
                b.Save(j);
                JBuildings.Add(j);
                c++;
            }

            JArray JTraps = new JArray();
            int    u      = 0;

            foreach (GameObject go in new List <GameObject>(this.GameObjects[4]))
            {
                Trap    t = (Trap)go;
                JObject j = new JObject {
                    { "data", t.GetTrapData().GetGlobalID() }, { "id", 504000000 + u }
                };
                t.Save(j);
                JTraps.Add(j);
                u++;
            }

            JArray JObstacles = new JArray();
            int    o          = 0;

            foreach (GameObject go in new List <GameObject>(this.GameObjects[3]))
            {
                Obstacle d = (Obstacle)go;
                JObject  j = new JObject {
                    { "data", d.GetObstacleData().GetGlobalID() }, { "id", 503000000 + o }
                };
                d.Save(j);
                JObstacles.Add(j);
                o++;
            }

            JArray JDecos = new JArray();
            int    e      = 0;

            foreach (GameObject go in new List <GameObject>(this.GameObjects[6]))
            {
                Deco    d = (Deco)go;
                JObject j = new JObject {
                    { "data", d.GetDecoData().GetGlobalID() }, { "id", 506000000 + e }
                };
                d.Save(j);
                JDecos.Add(j);
                e++;
            }

            Avatar pl       = this.Level.Avatar;
            var    jsonData = new JObject
            {
                //{"exp_ver", 1},
                { "buildings", JBuildings },
                { "obstacles", JObstacles },
                { "traps", JTraps },
                { "decos", JDecos }
            };

            return(jsonData);
        }