Beispiel #1
0
    private void readbotsEdit(string response)
    {
        HttpBotsWrapper bots = JsonUtility.FromJson <HttpBotsWrapper>(response);

        GameManager.instance.LoadedBots = buildBotArray(false, bots);
        MenuManager.instance.spawnbotEdit();
        MenuManager.instance.populateBotsDropDown();
    }
Beispiel #2
0
    private BotBuilder[] buildBotArray(bool replaceSelected, HttpBotsWrapper bots)
    {
        BotBuilder[] botArrayTmp = new BotBuilder[3] {
            new BotBuilder(), new BotBuilder(), new BotBuilder()
        };

        foreach (HttpBots botInfo in bots.wrap)
        {
            int        id     = int.Parse(botInfo.botsSlot);
            BotBuilder botAct = botArrayTmp[id];
            botAct.platform      = botInfo.botsPlatform;
            botAct.botID         = botInfo.botsId;
            botAct.botsPrefered  = botInfo.botsPrefered;
            botAct.ownerID       = botInfo.ownerID;
            botAct.botsName      = botInfo.botsName;
            botAct.rotationSpeed = float.Parse(botInfo.botsRotationSpeed);
            botAct.speed         = float.Parse(botInfo.botsSpeed);
            string            jsonAnchorPrepared = "{\"botsAnchorInfo\":" + botInfo.botsAnchorInfo + "}";
            JsonAnchorWrapper listPartsJson      = JsonUtility.FromJson <JsonAnchorWrapper>(jsonAnchorPrepared);
            botAct.listParts = new AnchorInfo[listPartsJson.botsAnchorInfo.Length];
            int i = 0;
            foreach (JsonAnchor jsonAnchor in listPartsJson.botsAnchorInfo)
            {
                botAct.listParts[i] = new AnchorInfo();
                AnchorInfo AnchorAct = botAct.listParts[i];
                AnchorAct.anchorPos = jsonAnchor.anchorPos;
                AnchorAct.itemName  = jsonAnchor.itemName;
                i++;
            }
            if (replaceSelected)
            {
                if (botInfo.botsPrefered == "true")
                {
                    PlayerPrefs.SetInt("botsPrefered", id);
                    GameManager.instance.SelectedBotIndex = id;
                }
            }
        }
        return(botArrayTmp);
    }
Beispiel #3
0
    private void readbots(string response)
    {
        HttpBotsWrapper bots = JsonUtility.FromJson <HttpBotsWrapper>(response);

        GameManager.instance.LoadedBots = buildBotArray(true, bots);
    }