コード例 #1
0
 /**
  * 检查响应内容是否正确
  *
  * @param object 请求响应内容
  */
 private void checkResponse(Dictionary <string, object> dic)
 {
     if (dic.ContainsKey("status") && "failure".Equals(dic.getString("status")))
     {
         throw new Exception($"{dic.getString("message")}");
     }
 }
コード例 #2
0
 /**
  * 校验请求结果
  *
  * @param response 请求结果
  * @return 如果请求结果正常,则返回JSONObject
  */
 private void checkResponse(Dictionary <string, object> dic)
 {
     if (dic.ContainsKey("errcode") && dic.getInt32("errcode") != 0)
     {
         throw new Exception($"errcode: {dic.getString("errcode")}, errmsg: {dic.getString("errmsg")}");
     }
 }
コード例 #3
0
 /**
  * 校验请求结果
  *
  * @param response 请求结果
  * @return 如果请求结果正常,则返回Exception
  */
 private void checkResponse(Dictionary <string, object> dic)
 {
     if (dic.ContainsKey("message") && dic.ContainsKey("name"))
     {
         throw new Exception($"{dic.getString("getString")}, {dic.getString("name")}");
     }
 }
コード例 #4
0
 /**
  * 校验请求结果
  *
  * @param response 请求结果
  * @return 如果请求结果正常,则返回Exception
  */
 private void checkResponse(Dictionary <string, object> dic)
 {
     if (dic.ContainsKey("error") || dic.ContainsKey("error_description"))
     {
         throw new Exception($"{dic.getString("error")}: {dic.getString("error_description")}");
     }
 }
コード例 #5
0
ファイル: DictionaryTest.cs プロジェクト: teopeurt/quickfix
 public void testSetGetString()
 {
     testObject.setString("key1", "value1");
     testObject.setString("key2", "value2");
     testObject.setString("key3", "value3");
     Assert.AreEqual("value1", testObject.getString("key1"));
     Assert.AreEqual("value2", testObject.getString("key2"));
     Assert.AreEqual("value3", testObject.getString("key3"));
 }
コード例 #6
0
        /**
         * 校验请求结果
         *
         * @param response 请求结果
         * @return 如果请求结果正常,则返回Exception
         */
        private void checkResponse(Dictionary <string, object> dic)
        {
            string message   = dic.getString("message");
            var    data      = dic.getString("data").parseObject();
            int    errorCode = data.getInt32("error_code");

            if ("error".Equals(message) || errorCode != 0)
            {
                throw new Exception(data.getString("description"));
            }
        }
コード例 #7
0
 /**
  * 校验响应结果
  *
  * @param object 接口返回的结果
  */
 private void checkResponse(Dictionary <string, object> dic)
 {
     if (dic.ContainsKey("NSP_STATUS"))
     {
         throw new Exception(dic.getString("error"));
     }
     if (dic.ContainsKey("error"))
     {
         throw new Exception(dic.getString("sub_error") + ":" + dic.getString("error_description"));
     }
 }
コード例 #8
0
        /**
         * 校验请求结果
         *
         * @param response 请求结果
         * @return 如果请求结果正常,则返回Exception
         */
        private void checkResponse(Dictionary <string, object> dic)
        {
            if (dic.Count == 0)
            {
                throw new Exception("请求所返回的数据为空!");
            }

            if (!"0".Equals(dic.getString("c")))
            {
                throw new Exception($"{dic.getString("m")}");
            }
        }
コード例 #9
0
        /**
         * Carrega dados do arquivo de configuracao quickfix.
         * @param settings
         * @param dadosGlobais
         */
        public SessaoFIX(
            SessionSettings settings,
            DadosGlobais dadosGlobais,
            LinkedBlockingQueue <MarketDataSnapshotFullRefresh> filaMensagensFIXInstantaneo,
            LinkedBlockingQueue <MarketDataIncrementalRefresh> filaMensagensFIXIncremental,
            LinkedBlockingQueue <string> filaMensagensRetransmissorBMF)
        {
            instrumentosAssinados =
                new SortedDictionary <string, DadosInstrumentosBMF>();

            this.filaMensagensFIXInstantaneo   = filaMensagensFIXInstantaneo;
            this.filaMensagensFIXIncremental   = filaMensagensFIXIncremental;
            this.filaMensagensRetransmissorBMF = filaMensagensRetransmissorBMF;

            object [] objsessions = settings.getSessions().ToArray();
            foreach (object objsession in objsessions)
            {
                SessionID session = (SessionID)objsession;
                try
                {
                    Dictionary dictionary = settings.get(session);

                    if (dictionary.has(FIX_RAWDATA))
                    {
                        senha = dictionary.getString(FIX_RAWDATA);
                    }

                    if (dictionary.has(FIX_NEWPASSWORD))
                    {
                        novaSenha = dictionary.getString(FIX_NEWPASSWORD);
                    }

                    if (dictionary.has(FIX_FILTRO_LISTA_INSTRUMENTOS))
                    {
                        padraoInstrumentos = new Regex(
                            dictionary.getString(FIX_FILTRO_LISTA_INSTRUMENTOS));
                    }
                }

                catch (ConfigError e)
                {
                    logger.Error("Falha de configuracao: " + e.Message);
                }
                catch (FieldConvertError e)
                {
                    logger.Error("Falha de conversao: " + e.Message);
                }
            }
        }
コード例 #10
0
    void updateAvailableInfo()
    {
        InvestigationManager im             = InvestigationManager.GetInstance();
        List <Investigation> investigations = im.getAvailableInvestigations();

        if (investigations.Count == 0)
        {
            investigationButton.interactable = false;

            investigationButtonText.text = Dictionary.getString("ALL_RESEARCHED");
            nameText.text        = "";
            priceText.text       = "";
            descriptionText.text = "";
        }
        else
        {
            Investigation selectedInvest = im.getInvestigation(selectedId);
            nameText.text                    = selectedInvest.getName();
            priceText.text                   = " " + Dictionary.getString("COST") + " " + selectedInvest.getCost();
            descriptionText.text             = selectedInvest.getDesc();
            investigationButton.interactable = true;
            investigationButtonText.text     = Dictionary.getString("RESEARCH");
            //selectedInvest.printInfo ();
        }
    }
コード例 #11
0
 /**
  * 校验请求结果
  *
  * @param response 请求结果
  * @return 如果请求结果正常,则返回Exception
  */
 private void checkResponse(Dictionary <string, object> dic)
 {
     if (dic.ContainsKey("error_code"))
     {
         throw new Exception($"{dic.getString("error_msg")}");
     }
 }
        public void onPurchaseSucceeded(string data, string receipt)
        {
            Dictionary <string, object> response = (Dictionary <string, object>)Unibill.Impl.MiniJSON.jsonDecode(data);

            var productId     = (string)response ["productId"];
            var transactionId = response.getString("transactionIdentifier");

            // If we're restoring, make sure it isn't a consumable.
            if (restoreInProgress)
            {
                if (remapper.canMapProductSpecificId(productId))
                {
                    if (remapper.getPurchasableItemFromPlatformSpecificId(productId).PurchaseType == PurchaseType.Consumable)
                    {
                        // Silently ignore this consumable.
                        logger.Log("Ignoring restore of consumable: " + productId);
                        // We must close the transaction or storekit will keep sending it to us.
                        storekit.finishTransaction(transactionId);
                        return;
                    }
                }
            }

            biller.onPurchaseSucceeded(productId, receipt, transactionId);
        }
コード例 #13
0
    public static void readPlagues(List <Plague> plagueList)
    {
        TextAsset file = Resources.Load("json/plagues", typeof(TextAsset)) as TextAsset;

        if (file != null)
        {
            JSONNode node = JSON.Parse(file.text);
            for (int j = 0; j < node["PLAGUES"].Count; ++j)
            {
                JSONNode nodeDeeper  = node["PLAGUES"][j];
                int      id          = nodeDeeper ["ID"].AsInt;
                string   name        = Dictionary.getString(nodeDeeper["NAME"].Value);
                string   description = Dictionary.getString(nodeDeeper["DESCRIPTION"].Value);
                string   img         = nodeDeeper["IMAGE"].Value;
                int      monthIn     = nodeDeeper ["MONTH_IN"].AsInt;
                int      monthOut    = nodeDeeper ["MONTH_OUT"].AsInt;
                int      baseDmg     = nodeDeeper ["BASE_DMG"].AsInt;
                Plague   plg         = new Plague(id, name, description, img, monthIn, monthOut, baseDmg);
                plagueList.Add(plg);
            }
        }
        else
        {
            Debug.Log("File json/plagues not loaded");
        }
    }
コード例 #14
0
    public void testSetGetSessionID()
    {
        Dictionary dictionary1 = new Dictionary();

        dictionary1.setString("ConnectionType", "initiator");
        Dictionary dictionary2 = new Dictionary();

        dictionary2.setString("ConnectionType", "acceptor");

        SessionID sessionID1 = new SessionID("FIX.4.0", "SENDER1", "TARGET1");
        SessionID sessionID2 = new SessionID("FIX.4.0", "SENDER2", "TARGET2");
        SessionID sessionID3 = new SessionID("FIX.4.0", "SENDER3", "TARGET3");

        testObject.set(sessionID1, dictionary1);
        testObject.set(sessionID2, dictionary2);
        dictionary1 = testObject.get(sessionID1);
        dictionary2 = testObject.get(sessionID2);

        Assert.AreEqual("initiator", dictionary1.getString("ConnectionType"));
        Assert.AreEqual("acceptor", dictionary2.getString("ConnectionType"));

        try
        {
            testObject.get(sessionID3);
            Assert.Fail();
        }
        catch (ConfigError) {}
    }
コード例 #15
0
 /**
  * 检查响应内容是否正确
  *
  * @param object 请求响应内容
  */
 private void checkResponse(Dictionary <string, object> dic)
 {
     if (dic.ContainsKey("error"))
     {
         throw new Exception($"{dic.getString("error").parseObject().getString("message")}");
     }
 }
コード例 #16
0
    public override List <Pair <string, string> > getSpecificBuildingInfo()
    {
        string measurementUnprepared = "kg.";
        string riceUnpreparedInfo    = riceUnprepared.ToString();

        if (riceUnprepared > 1000)
        {
            riceUnpreparedInfo    = (riceUnprepared / 1000).ToString();
            measurementUnprepared = "t.";
        }

        string measurementPrepared = "kg.";
        string ricePreparedInfo    = ricePrepared.ToString();

        if (ricePrepared > 1000)
        {
            ricePreparedInfo    = (ricePrepared / 1000).ToString();
            measurementPrepared = "t.";
        }

        string measurementCapacity = "kg.";
        string capacityInfo        = this.getCapacity1().ToString();

        if (this.getCapacity1() > 1000)
        {
            capacityInfo        = (this.getCapacity1() / 1000).ToString();
            measurementCapacity = "t.";
        }
        m_specificBuildingInfo.Clear();
        m_specificBuildingInfo.Add(new Pair <string, string>(Dictionary.getString("RICE_TO_SEPARATE"), riceUnpreparedInfo + " " + measurementUnprepared));
        m_specificBuildingInfo.Add(new Pair <string, string>(Dictionary.getString("RICE_READY_TO_DRY"), ricePreparedInfo + " " + measurementPrepared));
        m_specificBuildingInfo.Add(new Pair <string, string>(Dictionary.getString("CURRENT_MAX_CAPACITY"), capacityInfo + " " + measurementCapacity));

        return(m_specificBuildingInfo);
    }
コード例 #17
0
    public static List <Phase> readPhaseInfo()
    {
        List <Phase> phasesInfo = new List <Phase> ();

        TextAsset file = Resources.Load("json/phases", typeof(TextAsset)) as TextAsset;

        if (file != null)
        {
            JSONNode node = JSON.Parse(file.text);
            for (int j = 0; j < node["PHASES"].Count; ++j)
            {
                Phase    newPhase   = new Phase();
                JSONNode nodeDeeper = node["PHASES"][j];
                newPhase.Name        = Dictionary.getString(nodeDeeper["NAME"].Value);
                newPhase.Description = Dictionary.getString(nodeDeeper["DESCRIPTION"].Value);
                newPhase.ActionsInfo = new List <string>();
                for (int i = 0; i < nodeDeeper["ACTIONS_INFO"].Count; ++i)
                {
                    newPhase.ActionsInfo.Add(Dictionary.getString(nodeDeeper["ACTIONS_INFO"][i].Value));
                }
                phasesInfo.Add(newPhase);
            }
        }
        return(phasesInfo);
    }
コード例 #18
0
    public static Dictionary <int, Investigation> getReadInvestigations()
    {
        Dictionary <int, Investigation> invList = new Dictionary <int, Investigation> ();

        TextAsset file = Resources.Load("json/investigations", typeof(TextAsset)) as TextAsset;

        if (file != null)
        {
            JSONNode node = JSON.Parse(file.text);
            for (int j = 0; j < node["INVESTIGATIONS"].Count; ++j)
            {
                JSONNode      nodeDeeper  = node["INVESTIGATIONS"][j];
                int           id          = nodeDeeper ["ID"].AsInt;
                string        name        = Dictionary.getString(nodeDeeper["NAME"].Value);
                string        description = Dictionary.getString(nodeDeeper["DESCRIPTION"].Value);
                string        img         = nodeDeeper["IMAGE"].Value;
                int           year        = nodeDeeper ["YEAR"].AsInt;
                int           req         = nodeDeeper ["REQ"].AsInt;
                int           cost        = nodeDeeper ["COST"].AsInt;
                Investigation inv         = new Investigation(id, name, description, img, year, req, cost);
                invList.Add(id, inv);
            }
        }
        else
        {
            Debug.Log("File json/investigations not loaded");
        }

        return(invList);
    }
コード例 #19
0
    private void updateBuildingWork()
    {
        Building building = BuildingsManager.GetInstance().getBuilding(m_buildingID);
        string   workInfo = building.getWorkInfo();

        m_buldingWork.text = workInfo + Dictionary.getString("PROCESSED_PER_DAY");
    }
コード例 #20
0
    public override List <Pair <string, string> > getSpecificBuildingInfo()
    {
        string measurementUnprepared = "kg.";
        string riceUnpreparedInfo    = riceUnprepared.ToString();

        if (riceUnprepared > 1000)
        {
            double riceUnprRounded = Math.Round(riceUnprepared / 1000.0f, 2);
            riceUnpreparedInfo    = string.Format("{0:0.00}", riceUnprRounded);
            measurementUnprepared = "t.";
        }

        string measurementCapacity = "kg.";
        string capacityInfo        = getCapacity1().ToString();

        if (this.getCapacity1() > 1000)
        {
            double capacity = Math.Round(getCapacity1() / 1000.0f, 2);
            capacityInfo        = string.Format("{0:0.00}", capacity);
            measurementCapacity = "t.";
        }

        m_specificBuildingInfo.Clear();
        m_specificBuildingInfo.Add(new Pair <string, string>(Dictionary.getString("LEFT_TO_PROCESS"), "" + riceUnpreparedInfo + " " + measurementUnprepared));
        m_specificBuildingInfo.Add(new Pair <string, string>(Dictionary.getString("MAXIMUM_CAPACITY_IS"), capacityInfo + " " + measurementCapacity));
        m_specificBuildingInfo.Add(new Pair <string, string>("", ""));

        return(m_specificBuildingInfo);
    }
コード例 #21
0
    public Building(JSONNode data, BUILDINGS type)
    {
        _level = 0;
        _i     = _j = 0;
        _info  = Dictionary.getString(data ["info"]);
        Debug.Assert(_info != null);
        _horizontalTiles = (uint)data ["size"][0].AsInt;
        _verticalTiles   = (uint)data ["size"][1].AsInt;
        _description     = Dictionary.getString(data["description"].Value);
        _hasActions      = data["hasActions"].AsBool;
        //_constructionLevels = JsonConvert.DeserializeObject<List<ConstructionLevel>> (data ["levels"]);
        _constructionLevels = new List <ConstructionLevel> ();
        for (int i = 0; i < data["levels"].Count; ++i)
        {
            JSONNode          level = data["levels"][i];
            ConstructionLevel cl    = new ConstructionLevel();
            cl.cost      = level["cost"].AsInt;
            cl.capacity1 = level["capacity1"].AsInt;
            cl.capacity2 = level["capacity2"].AsInt;
            cl.imgPath   = level["img"];
            _constructionLevels.Add(cl);
        }
        _currentImgPath = _constructionLevels [0].imgPath;
        _type           = type;

        _selected = false;
        //_outlineMaterial = Resources.Load("Materials/Outline", typeof(Material)) as Material;
    }
コード例 #22
0
    public void selectBuilding(BUILDINGS buildingID)
    {
        if (buildingID != m_selectedID)
        {
            m_selectedID = buildingID;
            int index = m_buildingsID.IndexOf(buildingID);
            selectedPage = index / itemsPerPage;
            int positionSelected = index % itemsPerPage;
            buyLeftPanel.gameObject.SetActive(false);
            buyCenterPanel.gameObject.SetActive(false);
            buyRightPanel.gameObject.SetActive(false);
            BuildingsManager buildingsMan = BuildingsManager.GetInstance();
            int initialObject             = itemsPerPage * selectedPage;
            for (int i = 0; i < itemsPerPage && i < m_buildingsID.Count - initialObject; ++i)
            {
                Building buildingToAdd = buildingsMan.getBuilding(m_buildingsID[initialObject + i]);
                //int objectPrice = buildingToAdd.getInitialCost();
                string quantityText = Dictionary.getString("P_UPGR_LEVEL") + (buildingToAdd.getCurrentLevel() + 1);

                switch (i)
                {
                case 0:
                    buyLeftPanel.gameObject.SetActive(true);
                    changePanel(buyLeftPanel, m_buildingsID[initialObject + i], buildingToAdd.getImgPath(), PanelPosition.LEFT, quantityText);
                    break;

                case 1:
                    buyCenterPanel.gameObject.SetActive(true);
                    changePanel(buyCenterPanel, m_buildingsID[initialObject + i], buildingToAdd.getImgPath(), PanelPosition.CENTER, quantityText);
                    break;

                case 2:
                    buyRightPanel.gameObject.SetActive(true);
                    changePanel(buyRightPanel, m_buildingsID[initialObject + i], buildingToAdd.getImgPath(), PanelPosition.RIGHT, quantityText);
                    break;
                }
            }
            switch (positionSelected)
            {
            case 0:
                changePanelToSelected(buyLeftPanel);
                changePanelToUnselected(buyCenterPanel);
                changePanelToUnselected(buyRightPanel);
                break;

            case 1:
                changePanelToUnselected(buyLeftPanel);
                changePanelToSelected(buyCenterPanel);
                changePanelToUnselected(buyRightPanel);
                break;

            case 2:
                changePanelToUnselected(buyLeftPanel);
                changePanelToUnselected(buyCenterPanel);
                changePanelToSelected(buyRightPanel);
                break;
            }
        }
        updateBuildingInfo();
    }
コード例 #23
0
        /**
         * Carrega dados para troca de senha.
         * @param settings
         * @param filaNovaSenha
         */
        public SessaoFIX(
            SessionSettings settings,
            string novaSenha,
            LinkedBlockingQueue <string> filaNovaSenha)
        {
            this.filaNovaSenha = filaNovaSenha;
            this.novaSenha     = novaSenha;

            object[] objsessions = settings.getSessions().ToArray();
            foreach (object objsession in objsessions)
            {
                SessionID session = (SessionID)objsession;
                try
                {
                    Dictionary dictionary = settings.get(session);
                    if (dictionary.has(FIX_RAWDATA))
                    {
                        senha = dictionary.getString(FIX_RAWDATA);
                    }
                }

                catch (ConfigError e)
                {
                    logger.Error("Falha de configuracao: " + e.Message);
                }
                catch (FieldConvertError e)
                {
                    logger.Error("Falha de conversao: " + e.Message);
                }
            }
        }
コード例 #24
0
    public override List <Pair <string, string> > getSpecificBuildingInfo()
    {
        m_specificBuildingInfo.Clear();
        if (estaCrescut())
        {
            m_specificBuildingInfo.Add(new Pair <string, string> (Dictionary.getString("PLANTER_PLANTS_AVAILABLE"), _plantes.ToString()));
        }
        else if (estaCreixent())
        {
            m_specificBuildingInfo.Add(new Pair <string, string> (Dictionary.getString("PLANTER_GROWING"), _diesSembrat * 100 / (float)DIAS_HASTA_CRECER + " %"));
        }
        else if (esEpocaDeSembrar())
        {
            m_specificBuildingInfo.Add(new Pair <string, string> (Dictionary.getString("PLANTER_NOT_SOWN"), ""));
        }
        else
        {
            m_specificBuildingInfo.Add(new Pair <string, string> (Dictionary.getString("PLANTER_NOT_PHASE"), ""));
        }

        m_specificBuildingInfo.Add(new Pair <string, string>("", ""));
        m_specificBuildingInfo.Add(new Pair <string, string>(Dictionary.getString("CURRENT_MAX_CAPACITY"), (getMaxPlantes()).ToString()));

        return(m_specificBuildingInfo);
    }
コード例 #25
0
    private void showBuildingsSelectedPage(List <BUILDINGS> buildingsID)
    {
        buyLeftPanel.gameObject.SetActive(false);
        buyCenterPanel.gameObject.SetActive(false);
        buyRightPanel.gameObject.SetActive(false);
        BuildingsManager buildingsMan = BuildingsManager.GetInstance();
        int initialObject             = itemsPerPage * selectedPage;

        for (int i = 0; i < itemsPerPage && i < buildingsID.Count - initialObject; ++i)
        {
            Building buildingToAdd = buildingsMan.getBuilding(buildingsID[initialObject + i]);
            //int objectPrice = buildingToAdd.getInitialCost();
            string quantityText = Dictionary.getString("P_UPGR_LEVEL") + (buildingToAdd.getCurrentLevel() + 1);

            switch (i)
            {
            case 0:
                buyLeftPanel.gameObject.SetActive(true);
                changePanel(buyLeftPanel, buildingsID[initialObject + i], buildingToAdd.getImgPath(), PanelPosition.LEFT, quantityText);
                break;

            case 1:
                buyCenterPanel.gameObject.SetActive(true);
                changePanel(buyCenterPanel, buildingsID[initialObject + i], buildingToAdd.getImgPath(), PanelPosition.CENTER, quantityText);
                break;

            case 2:
                buyRightPanel.gameObject.SetActive(true);
                changePanel(buyRightPanel, buildingsID[initialObject + i], buildingToAdd.getImgPath(), PanelPosition.RIGHT, quantityText);
                break;
            }
        }
    }
コード例 #26
0
    public void newYear()
    {
        // Se dan por investigadas las que se estaban investigando
        foreach (Investigation i in m_invest.Values)
        {
            if (i.isInvestigating())
            {
                m_invest[i.getID()].setInvestigating(false);
                m_invest[i.getID()].setPurchased(true);
                doInvestigatedEffect(i.getID());
            }
        }

        // Se crean carteles para nuevas invs disponibles
        List <Investigation> availableInvs = getAvailableInvestigations();
        TimeManager          tm            = GameObject.Find("Logic").GetComponent <TimeManager>();

        for (int i = availableInvs.Count - 1; i >= 0; --i)
        {
            Investigation currentInv = availableInvs [i];
            if (currentInv.getYear() == tm.getCurrentYear())
            {
                GameObject panelTemplate = Resources.Load("Prefabs/InvestigationUnlockedFocusLayer") as GameObject;
                GameObject panelInstance = GameObject.Instantiate(panelTemplate);
                GameObject panel         = panelInstance.transform.FindChild("InvestigationUnlockedPanel").gameObject;
                string     text          = Dictionary.getString("INVESTIGATION_UNLOCKED") + " " + currentInv.getName();
                panel.GetComponent <InvestigationUnlockedPanel> ().ChangeText(text);
            }
        }
    }
コード例 #27
0
    public void testSetGetSessionID()
    {
        Dictionary dictionary1 = new Dictionary();
        dictionary1.setString( "ConnectionType", "initiator" );
        Dictionary dictionary2 = new Dictionary();
        dictionary2.setString( "ConnectionType", "acceptor" );

        SessionID sessionID1 = new SessionID( "FIX.4.0", "SENDER1", "TARGET1" );
        SessionID sessionID2 = new SessionID( "FIX.4.0", "SENDER2", "TARGET2" );
        SessionID sessionID3 = new SessionID( "FIX.4.0", "SENDER3", "TARGET3" );

        testObject.set( sessionID1, dictionary1 );
        testObject.set( sessionID2, dictionary2 );
        dictionary1 = testObject.get( sessionID1 );
        dictionary2 = testObject.get( sessionID2 );

        Assert.AreEqual( "initiator", dictionary1.getString("ConnectionType") );
        Assert.AreEqual( "acceptor", dictionary2.getString("ConnectionType") );

        try
        {
            testObject.get( sessionID3 );
            Assert.Fail();
        }
        catch( ConfigError ) {}
    }
コード例 #28
0
    //specific camp 1 -> number of busy workers
    //specific camp 2 -> number total of workers
    //specific camp 3 -> current capacity
    public override List <Pair <string, string> > getSpecificBuildingInfo()
    {
        m_specificBuildingInfo.Clear();
        m_specificBuildingInfo.Add(new Pair <string, string>(Dictionary.getString("BUSY_WORKERS"), WorkerManager.GetInstance().BusyWorkers.ToString()));
        m_specificBuildingInfo.Add(new Pair <string, string>(Dictionary.getString("WORKERS_TOTAL"), WorkerManager.GetInstance().Workers.ToString()));
        m_specificBuildingInfo.Add(new Pair <string, string>(Dictionary.getString("CURRENT_MAX_CAPACITY"), this.getCapacity1().ToString()));

        return(m_specificBuildingInfo);
    }
コード例 #29
0
    public static Dictionary <int, ChunkAction> readActions()
    {
        Dictionary <int, ChunkAction> actions = new Dictionary <int, ChunkAction> ();

        TextAsset file = Resources.Load("json/terrain_actions", typeof(TextAsset)) as TextAsset;

        if (file != null)
        {
            JSONNode node = JSON.Parse(file.text);
            for (int j = 0; j < node["ACTIONS"].Count; ++j)
            {
                JSONNode    nodeDeeper      = node["ACTIONS"][j];
                int         id              = nodeDeeper ["ID"].AsInt;
                bool        isRequired      = nodeDeeper["IS_REQUIRED"].Value.Equals("TRUE");
                bool        hasPenalization = nodeDeeper["PENALIZATION"].Value.Equals("TRUE");
                string      name            = Dictionary.getString(nodeDeeper["NAME"].Value);
                string      desc            = Dictionary.getString(nodeDeeper["DESCRIPTION"].Value);
                int         duration        = nodeDeeper ["DURATION"].AsInt;
                bool        addAsDone       = nodeDeeper ["ADD_AS_DONE"].Value.Equals("TRUE");
                bool        needCanal       = nodeDeeper["NEED_CANAL"].Value.Equals("TRUE");
                int         workersNeeded   = nodeDeeper["WORKERS_NEEDED"].AsInt;
                int         priority        = nodeDeeper["PRIORITY"].AsInt;
                ChunkAction chunkAction     = new ChunkAction(id, isRequired, hasPenalization, name, desc, duration, addAsDone, needCanal, workersNeeded, priority);             //TMP should be info and title instead of name and name
                for (int i = 0; i < nodeDeeper["DEPENDENCIES"].Count; ++i)
                {
                    chunkAction.addDependency(nodeDeeper["DEPENDENCIES"][i]["TYPE"].Value, nodeDeeper["DEPENDENCIES"][i]["VALUE"].Value);
                }
                for (int i = 0; i < nodeDeeper["OBJECTS_ID"].Count; ++i)
                {
                    chunkAction.addObjectRequired(nodeDeeper["OBJECTS_ID"][i].AsInt);
                }

                for (int i = 0; i < nodeDeeper["ANIMATION"].Count; ++i)
                {
                    chunkAction.addAnimation(nodeDeeper["ANIMATION"][i].Value);
                }

                for (int i = 0; i < nodeDeeper["INVESTIGATION_REQUIRED"].Count; ++i)
                {
                    chunkAction.addInvestigationRequired(nodeDeeper["INVESTIGATION_REQUIRED"][i].AsInt);
                }

                for (int i = 0; i < nodeDeeper["ACTION_PARTNERS"].Count; ++i)
                {
                    chunkAction.addActionPartner(nodeDeeper["ACTION_PARTNERS"][i].AsInt);
                }

                actions.Add(id, chunkAction);
            }
        }
        else
        {
            Debug.Log("File json/terrain_actions not loaded");
        }
        return(actions);
    }
コード例 #30
0
        public void onProductListReceived(string productListString)
        {
            Dictionary <string, object> responseHash = (Dictionary <string, object>)Unibill.Impl.MiniJSON.jsonDecode(productListString);

            onUserIdRetrieved(responseHash.getString("userId"));

            Dictionary <string, object> products = responseHash.getHash("products");

            if (products.Count == 0)
            {
                callback.logError(UnibillError.AMAZONAPPSTORE_GETITEMDATAREQUEST_NO_PRODUCTS_RETURNED);
                callback.onSetupComplete(false);
                return;
            }

            HashSet <PurchasableItem> productsReceived = new HashSet <PurchasableItem>();

            foreach (var identifier in products.Keys)
            {
                var item = remapper.getPurchasableItemFromPlatformSpecificId(identifier.ToString());
                Dictionary <string, object> details = (Dictionary <string, object>)products[identifier];

                PurchasableItem.Writer.setAvailable(item, true);
                PurchasableItem.Writer.setLocalizedPrice(item, details["price"].ToString());
                PurchasableItem.Writer.setLocalizedTitle(item, (string)details["localizedTitle"]);
                PurchasableItem.Writer.setLocalizedDescription(item, (string)details["localizedDescription"]);
                PurchasableItem.Writer.setISOCurrencySymbol(item, details.getString("isoCurrencyCode"));
                PurchasableItem.Writer.setPriceInLocalCurrency(item, decimal.Parse(details.getString("priceDecimal")));
                productsReceived.Add(item);
            }

            HashSet <PurchasableItem> productsNotReceived = new HashSet <PurchasableItem> (db.AllPurchasableItems);

            productsNotReceived.ExceptWith(productsReceived);
            if (productsNotReceived.Count > 0)
            {
                foreach (PurchasableItem product in productsNotReceived)
                {
                    this.unknownAmazonProducts.Add(remapper.mapItemIdToPlatformSpecificId(product));
                    callback.logError(UnibillError.AMAZONAPPSTORE_GETITEMDATAREQUEST_MISSING_PRODUCT, product.Id, remapper.mapItemIdToPlatformSpecificId(product));
                }
            }
        }
コード例 #31
0
    public void testSetGetDefault()
    {
        Dictionary dictionary = new Dictionary();
        dictionary.setString( "ConnectionType", "initiator" );

        testObject.set( dictionary );
        dictionary = testObject.get();

        Assert.AreEqual( "initiator", dictionary.getString( "ConnectionType" ) );
    }
コード例 #32
0
        private string getAvatarUrl(Dictionary <string, object> userObj)
        {
            // image is a map data structure
            var jsonObject = userObj.getString("image").parseObject();

            if (jsonObject.Count == 0)
            {
                return(null);
            }
            return(jsonObject.getString("60x60").parseObject().getString("url"));
        }