void OnChange()
    {
        GameModeType _mode = (GameModeType)Enum.Parse(typeof(GameModeType), popupList.value);

        if (Enum.IsDefined(typeof(GameModeType), _mode))
        {
            Global.GameSetting().modeSelected = Global.GameSetting().modes[_mode];
        }

        var _setting = modePrfs.Find((_entity) => _entity.mode == _mode);

        if (_setting != null)
        {
            if (m_Mode != null)
            {
                GameObject.Destroy(m_Mode);
            }

            m_Mode = GameObject.Instantiate(_setting.prefab) as GameObject;
            m_Mode.transform.parent        = modeParent.transform;
            m_Mode.transform.localPosition = Vector3.zero;
            m_Mode.transform.localScale    = Vector3.one;
        }
        else
        {
            Debug.LogError("The setting " + _mode.ToString() + " prefab is missing.");
        }
    }
Exemplo n.º 2
0
        public Message PrepareRegisterBotMessage(string name, GameModeType gamemode)
        {
            Message m = new Message();

            m.AddParameter(new StringParameter("type", "register"));
            m.AddParameter(new StringParameter("clientType", "bot"));
            m.AddParameter(new StringParameter("name", name));
            m.AddParameter(new StringParameter("game", String.Join(" ", Regex.Split(gamemode.ToString(), @"(?<!^)(?=[A-Z])"))));
            return(m);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Returns the actual index value of this game mode relative to game provider's mode index offset.
        /// </summary>
        public static int GetIndex(this GameModeType context)
        {
            string contextStr = context.ToString();

            foreach (var provider in (GameProviderType[])Enum.GetValues(typeof(GameProviderType)))
            {
                if (contextStr.StartsWith(provider.ToString(), StringComparison.OrdinalIgnoreCase))
                {
                    return((int)context - (int)provider);
                }
            }
            throw new Exception("Failed to determine the index value for game mode: " + context);
        }
    // Token: 0x060007D6 RID: 2006 RVA: 0x0003602C File Offset: 0x0003422C
    public void Draw()
    {
        GUILayout.BeginHorizontal(new GUILayoutOption[0]);
        foreach (object obj in Enum.GetValues(typeof(GameModeType)))
        {
            GameModeType gameModeType = (GameModeType)((int)obj);
            if (GUILayout.Button(gameModeType.ToString(), new GUILayoutOption[0]))
            {
                this.gameMode = gameModeType;
            }
        }
        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal(new GUILayoutOption[0]);
        this.scroll1 = GUILayout.BeginScrollView(this.scroll1, new GUILayoutOption[0]);
        GUILayout.Label(TeamID.NONE.ToString(), new GUILayoutOption[0]);
        for (int i = 0; i < Singleton <SpawnPointManager> .Instance.GetSpawnPointCount(this.gameMode, TeamID.NONE); i++)
        {
            Vector3    vector;
            Quaternion quaternion;
            Singleton <SpawnPointManager> .Instance.GetSpawnPointAt(i, this.gameMode, TeamID.NONE, out vector, out quaternion);

            GUILayout.Label(i + ": " + vector, new GUILayoutOption[0]);
        }
        GUILayout.EndScrollView();
        this.scroll2 = GUILayout.BeginScrollView(this.scroll2, new GUILayoutOption[0]);
        GUILayout.Label(TeamID.BLUE.ToString(), new GUILayoutOption[0]);
        for (int j = 0; j < Singleton <SpawnPointManager> .Instance.GetSpawnPointCount(this.gameMode, TeamID.BLUE); j++)
        {
            Vector3    vector;
            Quaternion quaternion;
            Singleton <SpawnPointManager> .Instance.GetSpawnPointAt(j, this.gameMode, TeamID.BLUE, out vector, out quaternion);

            GUILayout.Label(j + ": " + vector, new GUILayoutOption[0]);
        }
        GUILayout.EndScrollView();
        this.scroll3 = GUILayout.BeginScrollView(this.scroll3, new GUILayoutOption[0]);
        GUILayout.Label(TeamID.RED.ToString(), new GUILayoutOption[0]);
        for (int k = 0; k < Singleton <SpawnPointManager> .Instance.GetSpawnPointCount(this.gameMode, TeamID.RED); k++)
        {
            Vector3    vector;
            Quaternion quaternion;
            Singleton <SpawnPointManager> .Instance.GetSpawnPointAt(k, this.gameMode, TeamID.RED, out vector, out quaternion);

            GUILayout.Label(k + ": " + vector, new GUILayoutOption[0]);
        }
        GUILayout.EndScrollView();
        GUILayout.EndHorizontal();
    }
    public static GameModeDef CreateDef(GameModeType _mode)
    {
        switch ( _mode)
        {
        case GameModeType.NULL:
            Debug.LogWarning("Trying to instantiate GameMode NULL.");
            return new GameModeDef();

        case GameModeType.TEST: return new GameModeTestDef();
        case GameModeType.DEATH_MATCH: return new GameModeDeathMatchDef();

        default:
            Debug.LogWarning("Undefined mode " + _mode.ToString() + ".");
            return new GameModeDef();
        }
    }
    public static GameModeDef CreateDef(GameModeType _mode)
    {
        switch (_mode)
        {
        case GameModeType.NULL:
            Debug.LogWarning("Trying to instantiate GameMode NULL.");
            return(new GameModeDef());

        case GameModeType.TEST: return(new GameModeTestDef());

        case GameModeType.DEATH_MATCH: return(new GameModeDeathMatchDef());

        default:
            Debug.LogWarning("Undefined mode " + _mode.ToString() + ".");
            return(new GameModeDef());
        }
    }
Exemplo n.º 7
0
 /// <summary> Which level this GameMode starts on </summary>
 public virtual int GetStartingLevel()
 {
     return(PlayerPrefs.GetInt(GameModeType.ToString() + Constants.PPKeys.StartingLevel, 1));
 }