示例#1
0
    public static void HandleRoomVariable(string varName, string url)
    {
        int id = -1;

        if (int.TryParse(varName.Substring(("prdurl").Length), out id))
        {
            ProductManagementScreen prodScreen = GetAll()[id];
            prodScreen.HandleNewURL(url);
        }
        else
        {
            Debug.LogError("Bad id from " + varName);
        }
    }
示例#2
0
    public void InitSim(string overrideSimType = "")
    {
        string companyName = "";

        switch (playMode)
        {
        case SimPlayMode.SINGLE_PLAYER:

            // until Industry Masters releases single player for more types of sims
            simType = (overrideSimType == "") ? "uimx_sustain" : overrideSimType;

            if (room != null && room.ContainsVariable("company"))
            {
                companyName = room.GetVariable("company").GetStringValue();
                if (room.ContainsVariable("starttime"))
                {
                    string startTimeStr = room.GetVariable("starttime").GetStringValue();

                    DateTime startTime = MsgStringToDateTime(startTimeStr);
                    Debug.Log("Sim was started: " + startTime.ToString());

                    if (forceNewGame || DateTime.UtcNow.Subtract(startTime).TotalHours >= 1.0)
                    {
                        Debug.Log("Last business simulation finished, start a new one");
                        // start a new game
                        companyName = GetUniqueCompanyName();
                        SetNewCompanyName(companyName);
                        forceNewGame = false;
                    }
                }
                else
                {
                    Debug.LogError("room needs to have a starttime variable setup on the server");
                }
            }
            else
            {
                Debug.LogError("Shouldn't get here -- Need to create a company variable via the server interface!!!");
                // create a company name -- this won't be persistent though, it dies when this user disconnects
                companyName = GetUniqueCompanyName();
                SetNewCompanyName(companyName);
            }
            AutoLogin(companyName);
            break;

        case SimPlayMode.MULTI_PLAYER:
            gameID      = TeamInfo.Inst.GetBizSimGameId(CommunicationManager.CurrentTeamID);
            simType     = (overrideSimType == "") ? TeamInfo.Inst.GetSimType(CommunicationManager.CurrentTeamID) : overrideSimType;
            simType     = string.IsNullOrEmpty(simType) ? "uimx_sustain" : simType;
            companyName = GetMultiplayerTeamName();
            AutoLogin(companyName);
            break;

        case SimPlayMode.DEMO:
            simType = (overrideSimType == "") ? "uimx_sustain" : overrideSimType;
            AutoLogin("Demo");
            break;

        case SimPlayMode.ADMIN_PLAYER:
            Debug.LogError("Admin Player is not currently implemented");
            break;
        }

        SetupSimType(simType);

        // update current tabs
        for (int i = 0; room != null && i < productMgr.NumProducts; ++i)
        {
            if (room.ContainsVariable("cat" + i))
            {
                HandleTabMsg(room, "cat" + i);
            }
        }

        for (int i = 0; i < ProductManagementScreen.GetAll().Count; ++i)
        {
            string varName = "prdurl" + i;
            if (room != null && room.ContainsVariable(varName))
            {
                ProductManagementScreen screen = ProductManagementScreen.GetAll()[i];
                string url = (screen.Initialized) ? BizSimScreen.GetStageItemURL(screen.StageItem) : room.GetVariable(varName).GetStringValue();
                screen.HandleNewURL(url);
                if (overrideSimType != "")
                {
                    ProductManagementScreen.GetAll()[i].UpdateServerWithNewURL(url);
                }
            }
        }
        MainCameraController.Inst.snapCamMakesPlayersInvisible = true;
    }