Example #1
0
        public void getLocation()
        {
            Mouse_Control  = FindObjectOfType <Mouse_Touch>();
            SData          = FindObjectOfType <ShopData>();
            shops          = new GameObject[SData.datamanager.Count];
            shops_Position = new Vector3[SData.datamanager.Count];
            type           = new string[SData.datamanager.Count];

            for (int i = 0; i < SData.datamanager.Count; i++)
            {
                //shops[i] = shop;
                shops[i]          = GameObject.Find(SData.datamanager[i].type);
                shops[i].name     = SData.datamanager[i].type + "_" + SData.datamanager[i].shop_name + "_" + SData.datamanager[i].shop_id + "_" + SData.datamanager[i].shop_info_id;
                shops_Position[i] = Conversions.GeoToWorldPosition(double.Parse(SData.datamanager[i].lat), double.Parse(SData.datamanager[i].lon),
                                                                   _map.CenterMercator,
                                                                   _map.WorldRelativeScale).ToVector3xz();
                shops_Position[i].y += 4;
                //Mouse_Control.setShopinfo(SData.datamanager[i].shop_id.ToString(), SData.datamanager[i].shop_info_id);
                //Mouse_Control.url = SData.datamanager[i].shop_info_id;
                //Debug.Log(SData.datamanager[i].shop_info_id);
                Instantiate(shops[i], shops_Position[i], Quaternion.identity);
                shops[i].name = SData.datamanager[i].type;
            }

            /*
             * SData = FindObjectOfType<ShopData>();
             * shops = new GameObject[SData.datamanager.Count];
             * shops_Position = new Vector3[SData.datamanager.Count];
             * type = new string[SData.datamanager.Count];
             *
             * for (int i = 0; i < SData.datamanager.Count; i++)
             * {
             *  Debug.Log(SData.datamanager[i].shop_id);
             *  Debug.Log(SData.datamanager[i].shop_name);
             *  Debug.Log(SData.datamanager[i].lat);
             *  Debug.Log(SData.datamanager[i].lon);
             *  Debug.Log(SData.datamanager[i].type);
             *
             *  //shops[i] = shop;
             *  shops[i] = GameObject.Find(SData.datamanager[i].type);
             *  shops[i].name = SData.datamanager[i].shop_name+"_"+ SData.datamanager[i].shop_id;
             *  shops_Position[i] = Conversions.GeoToWorldPosition(double.Parse(SData.datamanager[i].lat), double.Parse(SData.datamanager[i].lon),
             *                                                     _map.CenterMercator,
             *                                                     _map.WorldRelativeScale).ToVector3xz();
             *  shops_Position[i].y += 4;
             *
             *  Instantiate(shops[i], shops_Position[i], Quaternion.identity);
             *  shops[i].name = SData.datamanager[i].type;
             * }
             */

            Debug.Log("get_Location");
            FindObjectOfType <MapBoxAnimation>().Delete();
            LocationProvider.OnLocationUpdated += LocationProvider_OnLocationUpdated;
        }
Example #2
0
    //State machine
    public void ChangeState(CustomerAIState newState)
    {
        switch (newState)
        {
        case CustomerAIState.Shopping:
            if (m_targetShop != null)
            {
                if (m_shoppingList.Contains(m_targetShop) && m_targetShop.ShoppingAmount < 0.0f)
                {
                    m_shoppingList.Remove(m_targetShop);
                    PickNextShop();
                }
                else
                {
                    RequestShopPath(m_targetShop.ShopObject);
                }
            }
            else
            {
                PickNextShop();
            }
            Speed = 5.0f;
            break;

        case CustomerAIState.Hungry:
            m_targetShop                = new ShopData();
            m_targetShop.ShopObject     = OverSeer.GetShop(Shop.ShopEnum.Cafe);
            m_targetShop.ShoppingAmount = Hunger;
            RequestShopPath(m_targetShop.ShopObject);
            Speed = 5.0f;
            break;

        case CustomerAIState.Pissed:
            m_targetShop                = new ShopData();
            m_targetShop.ShopObject     = OverSeer.GetShop(Shop.ShopEnum.WC, Random.Range(1, 3));
            m_targetShop.ShoppingAmount = Bladder;
            RequestShopPath(m_targetShop.ShopObject);
            Speed = 7.5f;
            break;

        case CustomerAIState.Running:
            RequestExitPath();
            Speed = 10;
            break;

        case CustomerAIState.Satisfied:
            RequestExitPath();
            Speed = 5.0f;
            break;

        default:
            break;
        }
        CustomerState = newState;
    }
Example #3
0
 /// <summary>
 /// Adds a new shop.
 /// </summary>
 /// <param name="shop">Shop to add</param>
 private void AddShop(IDictionary <string, ShopData> shopData, ShopData shop)
 {
     if (shopData.ContainsKey(shop.Name))
     {
         _logger.LogWarning(GameResourcesConstants.Errors.ObjectIgnoredMessage, "Shop", shop.Name, "already declared");
     }
     else
     {
         shopData.Add(shop.Name, shop);
     }
 }
Example #4
0
        /// <inheritdoc />
        public void Load()
        {
            IEnumerable <string> files = Directory.GetFiles(GameResources.ResourcePath, "character*.inc", SearchOption.AllDirectories);

            foreach (string file in files)
            {
                using (var npcFile = new IncludeFile(file))
                {
                    foreach (IStatement npcStatement in npcFile.Statements)
                    {
                        if (!(npcStatement is Block npcBlock))
                        {
                            continue;
                        }

                        string npcId   = npcStatement.Name;
                        string npcName = npcId;

                        // We gets the npc name.
                        foreach (IStatement npcInfoStatement in npcBlock.Statements)
                        {
                            if (npcInfoStatement is Instruction instruction && npcInfoStatement.Name == "SetName")
                            {
                                if (instruction.Parameters.Count > 0)
                                {
                                    npcName = this._texts[instruction.Parameters.First().ToString()];
                                }
                            }
                        }

                        //TODO: implement other npc settings (image, music, actions...)
                        //      + constants for statement (like SetName)

                        // We gets shop and dialog of this npc.
                        ShopData   shop   = this._shops.GetShopData(npcId);
                        DialogData dialog = this._dialogs.GetDialogData(npcId, this._configuration.Language);

                        var npc = new NpcData(npcId, npcName, shop, dialog);

                        if (this._npcData.ContainsKey(npc.Id))
                        {
                            this._npcData[npc.Id] = npc;
                            this._logger.LogWarning(GameResources.ObjectOverridedMessage, "NPC", npc.Id, "already declared");
                        }
                        else
                        {
                            this._npcData.Add(npc.Id, npc);
                        }
                    }
                }
            }

            this._logger.LogInformation($"-> {this._npcData.Count} NPCs loaded.");
        }
Example #5
0
        public static void OnPurchase()
        {
            ShopData.CurrentShopCell = ShopData.SelectedShopCell;
            var bullet = ShopData.GetBulletByCell(ShopData.SelectedShopCell);

            ShopData.AddAvailableBullet(bullet);
            Events.LaunchEvent(Events.Types.SelectShopCell, Scenes.ActiveScene);
            Events.LaunchEvent(Events.Types.ReduceCurrency, Scenes.ActiveScene);

            Server.Report(Server.ReportComands.Purchase);
        }
Example #6
0
        public AbstractLevelData(MapHolder holder, int mapLevel = 1)
        {
            map           = holder;
            this.mapLevel = mapLevel;
            tutorialLevel = false;
            shopData      = null;

            LevelReward = new DropInfo();

            DnaReward = 0;
        }
Example #7
0
    public static void SaveShop(Item[] items, int attributeCount)
    {
        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Application.persistentDataPath + "/shop.nt";
        FileStream      stream    = new FileStream(path, FileMode.Create);

        ShopData data = new ShopData(items, attributeCount);

        formatter.Serialize(stream, data);
        stream.Close();
    }
Example #8
0
    public static void SaveShop(GameManager manager)
    {
        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Application.persistentDataPath + "/manager.pdd";
        FileStream      stream    = new FileStream(path, FileMode.Create);

        ShopData data = new ShopData(manager);

        formatter.Serialize(stream, data);
        stream.Close();
    }
Example #9
0
 public void SetUp(ShopData shopData, PlayerState playerState)
 {
     _data                 = shopData;
     _playerState          = playerState;
     _healthCountText.text = $"X{_data.HealthShopData.Count}";
     _healthPriceText.text = $"{_data.HealthShopData.Price}";
     _ammoCountText.text   = $"X{_data.AmmoShopData.Count}";
     _ammoPriceText.text   = $"{_data.AmmoShopData.Price}";
     _minePriceText.text   = $"{_data.MineShopData.Price}";
     _barrelPriceText.text = $"{_data.BarrelShopData.Price}";
 }
Example #10
0
    void Start()
    {
        shopData = new ShopData();

        //加载XML.
        shopData.ReadXmlByPath(xmlPath);
        shopData.ReadMasonryandshopState(savePath);

        //shopData.shopList:

        Debug.Log(shopData.masonryCount);

        for (int i = 0; i < shopData.shopState.Count; i++)
        {
            Debug.Log(shopData.shopState[i]);
        }

        ui_ShopItem = Resources.Load <GameObject>("UI/ShopItem");

        //左右按钮事件.
        leftButton  = GameObject.Find("LeftButton");
        rightButton = GameObject.Find("RightButton");
        button_Play = GameObject.Find("Play");
        UIEventListener.Get(leftButton).onClick  = LeftButtonClick;
        UIEventListener.Get(rightButton).onClick = RightButtonClick;
        UIEventListener.Get(button_Play).onClick = PlayButtonClick;

        //UI与xml数据的同步.
        masonryNums = GameObject.Find("Masonry/MasonryNum").GetComponent <UILabel>();
        //UpdateUI();

        //读取PlayerPerfs中的钻石数.
        int tempMasonry = PlayerPrefs.GetInt("MasonryCount", 0);

        if (tempMasonry > 0)
        {
            int masonry = shopData.masonryCount + tempMasonry;
            //更新UI
            UpdateUIMasonry(masonry);
            //更新XML中的数据.
            shopData.UpdateXMLData(savePath, "MasonryCount", masonry.ToString());
            //清空PlayerPrefs
            PlayerPrefs.SetInt("MasonryCount", 0);
        }
        else
        {
            //更新UI.
            UpdateUIMasonry(shopData.masonryCount);
        }

        SetPlayerInfo(shopData.shopList[0].Model);

        CreateAllShopUI();
    }
Example #11
0
 public void Setup(ShopData data)
 {
     if (data.Shape)
     {
         _buyNewButton.gameObject.SetActive(false);
     }
     else
     {
         _buyNewButton.gameObject.SetActive(true);
     }
 }
Example #12
0
 string GetProductPrice(ShopData shopData)
 {
     if (IAPManager.storeController.products.WithID("com.funmagic.projectl." + shopData.id).metadata.localizedPriceString != null)
     {
         return(IAPManager.storeController.products.WithID("com.funmagic.projectl." + shopData.id).metadata.localizedPriceString);
     }
     else
     {
         return(shopData.price);
     }
 }
Example #13
0
    public static void SaveShop(ShopButtons shop)
    {
        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Application.persistentDataPath + "/shop.fun";
        FileStream      stream    = new FileStream(path, FileMode.Create);

        ShopData data = new ShopData(shop);

        formatter.Serialize(stream, data);
        stream.Close();
    }
Example #14
0
    public bool BuyItem(int id)
    {
        ShopData data = ShopRespository.GetShopData(id);

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

        return(true);
    }
Example #15
0
        /// <summary>
        /// Order to Xml object converter.
        /// </summary>
        /// <returns>Order representation as xml element.</returns>
        public XElement ToXml()
        {
            XElement q = new XElement(
                "Order",
                new XAttribute("Id", Id),
                ClientData.ToXml(),
                GoodsData.ToXml(),
                ShopData.ToXml());

            return(q);
        }
Example #16
0
 /// <summary>
 /// Adds a new shop.
 /// </summary>
 /// <param name="shop">Shop to add</param>
 private void AddShop(ShopData shop)
 {
     if (this._shopData.ContainsKey(shop.Name))
     {
         this._logger.LogWarning(GameResources.ObjectIgnoredMessage, "Shop", shop.Name, "already declared");
     }
     else
     {
         this._shopData.Add(shop.Name, shop);
     }
 }
Example #17
0
 static public int IOSPay_RetryLostOrder_s(IntPtr l)
 {
     try {
         ShopData.IOSPay_RetryLostOrder();
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Example #18
0
        public static void Buy_Req(InPacket lea, Client c)
        {
            int CharacterID = lea.ReadInt();
            int ItemID      = lea.ReadInt();
            int Slot        = lea.ReadShort();
            int Quantity    = lea.ReadShort();
            var chr         = c.Character;

            try
            {
                Map       map    = MapFactory.GetMap(chr.MapX, chr.MapY);
                Character Seller = null;
                foreach (Character find in map.Characters)
                {
                    if (find.CharacterID == CharacterID)
                    {
                        Seller = find;
                    }
                }

                ShopData Item     = Seller.Shop.Find(i => ItemID == i.ItemID && Slot == i.TargetSlot);
                byte     Type     = InventoryType.getItemType(ItemID);
                byte     FreeSlot = chr.Items.GetNextFreeSlot((InventoryType.ItemType)Type);

                if (Item.Quantity < Quantity || Item == null)
                {
                    PlayerShopPacket.Buy(c, 0);
                    return;
                }

                chr.Money -= (Item.Price * Quantity);
                InventoryPacket.getInvenMoney(c, chr.Money, -(Item.Price * Quantity));
                chr.Items.Add(new Item(Item.ItemID, (short)Quantity, Item.Spirit, Item.Level1, Item.Level2, Item.Level3, Item.Level4, Item.Level5, Item.Level6, Item.Level7, Item.Level8, Item.Level9, Item.Level10, Item.Fusion, Item.IsLocked, Item.Icon, Item.Term, Type, FreeSlot));
                InventoryHandler.UpdateInventory(c, Type);
                //Seller.Shop.Remove(Item);
                Seller.Items.Remove((byte)Item.SourceType, (byte)Item.SourceSlot);
                Seller.Items.Add(new Item(Item.ItemID, (short)(Item.Quantity - Quantity), Item.Spirit, Item.Level1, Item.Level2, Item.Level3, Item.Level4, Item.Level5, Item.Level6, Item.Level7, Item.Level8, Item.Level9, Item.Level10, Item.Fusion, Item.IsLocked, Item.Icon, Item.Term, (byte)Item.SourceType, (byte)Item.SourceSlot));
                Item.Quantity      = Item.Quantity - Quantity;
                Seller.Shop.Money += (Item.Price * Quantity);
                Seller.Money      += (Item.Price * Quantity);
                PlayerShopPacket.ShopInfo(c, Seller, CharacterID);
                InventoryHandler.UpdateInventory(Seller.Client, (byte)Item.SourceType);
                PlayerShopPacket.SellInfo(Seller.Client);
                InventoryPacket.getInvenMoney(Seller.Client, Seller.Money, Item.Price * Quantity);

                PlayerShopPacket.Buy(c, 1);
            }
            catch
            {
                PlayerShopPacket.Buy(c, 0);
                return;
            }
        }
Example #19
0
    override public void Set(PurchasableData shopData)
    {
        _shopData = (ShopData)shopData;
        _title.SetText(_shopData.ShopName);
        _cost.SetText(_shopData.InitialCostString);
        _income.SetText(_shopData.InitialIncomeString);
        _incomeRate.SetText(_shopData.InitialIncomeDropSpeedString);
        _background.sprite = _shopData.UiSprite;

        _button = GetComponent <Button>();
        _button.onClick.AddListener(SetPanel);
    }
    public ShopData loadShopDetails()
    {
        BinaryFormatter binaryFormatter = new BinaryFormatter();
        FileStream      file            = File.Open(Application.persistentDataPath + shopFileName, FileMode.Open);

        //Retrieving the saved data in the form of a ShopData class
        ShopData storedData = (ShopData)binaryFormatter.Deserialize(file);

        file.Close();

        return(storedData);
    }
Example #21
0
    IEnumerator GetDataShops(WWW www)
    {
        //Wait for request to complete
        yield return(www);

        if (www.error == null)
        {
            jsonData = www.text;
            Debug.Log(jsonData);

            //Data is in json format, we need to parse the Json.
            JSONArray jsonArrayShops = JSONArray.Parse(jsonData);

            //parse text to array of strings
            jsonData        = jsonData.Replace("[", "");
            jsonData        = jsonData.Replace("]", "");
            jsonDataObjects = jsonData.Split('}');

            for (int i = 0; i < jsonDataObjects.Length; i++)
            {
                jsonDataObjects[i] = jsonDataObjects[i] + "}";

                if (i > 0)
                {
                    jsonDataObjects[i] = jsonDataObjects[i].Substring(1);
                }
            }

            if (jsonArrayShops == null)
            {
                Debug.Log("No data converted");
            }
            else
            {
                for (int i = 0; i < jsonArrayShops.Length; i++)
                {
                    foundShop = new ShopData();

                    //Data is in json format, we need to parse the Json.
                    JSONObject jsonObjectShop = JSONObject.Parse(jsonDataObjects[i]);

                    if (jsonObjectShop["description"].Str == nameShop.text)
                    {
                        shopId = Convert.ToInt32(jsonObjectShop["id"].Number);
                    }
                }
            }
        }
        else
        {
            Debug.Log(www.error);
        }
    }
Example #22
0
        public override void Generate()
        {
            shopData = new ShopData();

            shopData.AddItem(new HpPotion(1), 1);
            shopData.AddItem(new CCAADoubleattackChanceUpgrade(1), 10);
            shopData.AddItem(new Heal(5), 10);

            start = map.GenerateDungeonRegion(0, 0, 40, true, false, false, levelOneSeeds);           // 0 0
            mid   = map.GenerateDungeonRegion(1, 0, 43, false, true, false, levelTwoSeeds);           // 0, 2
            end   = map.GenerateDungeonRegion(2, 0, 45, false, true, true, levelThree, 1, 2);         // 0, 2
        }
Example #23
0
    // Start is called before the first frame update
    void Start()
    {
        // calls some other function to get the number of souls
        int souls = 100;

        shopping = new ShopData(souls);

        state = shopState.Ready;

        purchaseItem = "None";
        purchaseCost = 0;
    }
Example #24
0
 static public int ClearData(IntPtr l)
 {
     try {
         ShopData self = (ShopData)checkSelf(l);
         self.ClearData();
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Example #25
0
    IEnumerator ServerShopDataCheck(ShopData shopData)
    {
        WWWForm form = new WWWForm();

        form.AddField("userID", User.Instance.userID, System.Text.Encoding.UTF8);
        form.AddField("type", 3);
        form.AddField("shopID", shopData.id, System.Text.Encoding.UTF8);
        string php    = "ShopInfo.php";
        string result = "";

        yield return(StartCoroutine(WebServerConnectManager.Instance.WWWCoroutine(php, form, x => result = x)));
    }
Example #26
0
 private void Awake()
 {
     //Ensures there will only be one instance of "ShopData" ever.
     if (instance != null && instance != this)
     {
         Destroy(this.gameObject);
     }
     else
     {
         instance = this;
     }
 }
Example #27
0
    private void OnClickBuy(ButtonScript obj, object args, int param1, int param2)
    {
        ArtifactConfigData configData = ArtifactConfigData.GetData(GamePlayer.Instance.MagicTupoLevel / 5, (int)JobType.JT_Axe);

        if (configData == null)
        {
            return;
        }
        int shopid = ShopData.GetShopId(configData._ItemId_1);

        QuickBuyUI.ShowMe(shopid);
    }
        public override void run()
        {
            try
            {
                Account p = _client._player;
                if (p == null)
                {
                    return;
                }
                if (p.LoadedShop || erro > 0)
                {
                    goto SendPacket;
                }

                p.LoadedShop = true;
                for (int i = 0; i < ShopManager.ShopDataItems.Count; i++)
                {
                    ShopData data = ShopManager.ShopDataItems[i];
                    _client.SendPacket(new SHOP_GET_ITEMS_PAK(data, ShopManager.TotalItems));
                }
                for (int i = 0; i < ShopManager.ShopDataGoods.Count; i++)
                {
                    ShopData data = ShopManager.ShopDataGoods[i];
                    _client.SendPacket(new SHOP_GET_GOODS_PAK(data, ShopManager.TotalGoods));
                }
                _client.SendPacket(new SHOP_GET_REPAIR_PAK());
                _client.SendPacket(new SHOP_TEST2_PAK());
                int cafe = p.pc_cafe;
                if (cafe == 0)
                {
                    for (int i = 0; i < ShopManager.ShopDataMt1.Count; i++)
                    {
                        ShopData data = ShopManager.ShopDataMt1[i];
                        _client.SendPacket(new SHOP_GET_MATCHING_PAK(data, ShopManager.TotalMatching1));
                    }
                }
                else
                {
                    for (int i = 0; i < ShopManager.ShopDataMt2.Count; i++)
                    {
                        ShopData data = ShopManager.ShopDataMt2[i];
                        _client.SendPacket(new SHOP_GET_MATCHING_PAK(data, ShopManager.TotalMatching2));
                    }
                }
SendPacket:
                _client.SendPacket(new SHOP_LIST_PAK());
            }
            catch (Exception ex)
            {
                SaveLog.fatal(ex.ToString());
                Printf.b_danger("[SHOP_LIST_REC.run] Erro fatal!");
            }
        }
Example #29
0
 void RetryShowAD(string result)
 {
     if (result == "yes")
     {
         UpdateMoneyDataByShop(tempAdFailData);
     }
     else
     {
         tempAdFailData = null;
         return;
     }
 }
    public void saveShopDetails(Dictionary <int, CharacterOptionsForDimensions> choices)
    {
        BinaryFormatter binaryFormatter = new BinaryFormatter();
        FileStream      file            = File.Create(Application.persistentDataPath + shopFileName);

        //Zipping all the data into the Shop Data class
        ShopData newData = new ShopData(choices);

        //Storing the data
        binaryFormatter.Serialize(file, newData);
        file.Close();
    }