Exemplo n.º 1
0
    /// <summary>
    /// Set global game config data, such as API endpoints, given a valid input string
    /// </summary>
    /// <param name="data">Data to be used to set config; must conform to GameConfig model.</param>
    /// <param name="configTypeOverride">May be used to override config type in editor only (development, staging, production).</param>
    public static void SetGameConfig(string data, string configTypeOverride=null) {

        // Set config only if there is none set
        if(config != null) 
            return;

        // Set global config
        config = JsonReader.Deserialize<GameConfig>(data);
        
        // Set the current game config based on the environment
        #if UNITY_EDITOR
        
            currentConfig = config.local;

            // If override set, use that
            if(configTypeOverride != null) {
                if(configTypeOverride == "development")
                    currentConfig = config.development;
                else if(configTypeOverride == "staging")
                    currentConfig = config.staging;
                else if(configTypeOverride == "production")
                    currentConfig = config.production;
            }


        #elif DEVELOPMENT_BUILD
           currentConfig = config.development;
        #elif IS_PRODUCTION
           currentConfig = config.production;
        #else
           currentConfig = config.staging;
        #endif

    }
 public async Task<GameServer[]> GetGameServersAsync(GameEnvironment gameEnvironment, string script,
     string serverLoginPart, int pageIndex)
 {
     var delay = _defaultDelay;
     await Task.Delay(TimeSpan.FromSeconds(delay));
     return _dataLoader.GetGameServers(gameEnvironment, script, serverLoginPart, pageIndex).ToArray();
 }
 public async Task<ServerFilterMatchOrdersSummaryItem[]> GetServerFilterMatchOrdersSummaryAsync(
     GameEnvironment gameEnvironment, string script, string serverLogin)
 {
     var delay = _defaultDelay;
     await Task.Delay(TimeSpan.FromSeconds(delay));
     return _dataLoader.GetServerFilterMatchOrdersSummary(gameEnvironment, script, serverLogin).ToArray();
 }
Exemplo n.º 4
0
 public GameServer[] GetGameServers(GameEnvironment gameEnvironment, string script,
     string serverLoginPart, int pageIndex)
 {
     int pageSize = 15;
     if (serverLoginPart == null)
     {
         serverLoginPart = "";
     }
     return _gameServers[gameEnvironment]
         .Where(s => (s.Script == script || string.IsNullOrEmpty(script)) && s.Login.StartsWith(serverLoginPart))
         .Skip(pageIndex * pageSize)
         .Take(pageSize)
         .ToArray();
 }
Exemplo n.º 5
0
 public Dictionary<string, int> GetMatchOrdersSummary(GameEnvironment gameEnvironment)
 {
     if (gameEnvironment == GameEnvironment.SMStorm)
     {
         return new Dictionary<string, int>
         {
             {"Battle", 12},
             {"Elite", 6},
             {"Combo", 4}
         };
     }
     return new Dictionary<string, int>
     {
         {"Cup", 12},
         {"Endurance", 6},
         {"TimeAttack", 4}
     };
 }
Exemplo n.º 6
0
        public LevelEndHUD(GameEnvironment env)
            : base(env.Controller)
        {
            Environment = env;

            Sound.PlayCue("stage_clear");

            /////

            // Background color.
            m_background = new RectangleWidget(this, ScreenSize.X * 0.5f, ScreenSize.Y * 0.5f);
            m_background.PositionPercent = new Vector2(0.5f, 0.5f);
            m_background.Position = new Vector2(0.0f, 20.0f);
            m_background.VertexColor = Color.Black;
            m_background.Alpha = 0.5f;
            m_background.Zindex = 1.0f;
            AddChild(m_background);

            // Title.
            TextWidget winTitle = new TextWidget(this, "font", "You win!");
            winTitle.PositionPercent = new Vector2(0.5f, 0.5f);
            winTitle.Position = new Vector2(0.0f, -50.0f);
            winTitle.Zindex = 0.5f;
            AddChild(winTitle);

            // Score.
            TextWidget score = new TextWidget(this, "font", String.Format("Time: {0:0.00} seconds.", env.LevelTimeSpent));
            score.PositionPercent = new Vector2(0.5f, 0.5f);
            score.Position = new Vector2(0.0f, 0.0f);
            score.Zindex = 0.5f;
            AddChild(score);

            // Press key to exit.
            TextWidget exit = new TextWidget(this, "font", "Press SPACE for Main Menu");
            exit.PositionPercent = new Vector2(0.5f, 0.5f);
            exit.Position = new Vector2(0.0f, 50.0f);
            exit.Zindex = 0.5f;
            AddChild(exit);
        }
Exemplo n.º 7
0
 public ScriptMatchOrdersSummaryItem[] GetScriptMatchOrdersSummary(
     GameEnvironment gameEnvironment, string script)
 {
     return new[]
     {
         new ScriptMatchOrdersSummaryItem
         {
             GameServer = new GameServer
             {
                 Login = "******",
                 Name = "server name 1",
                 Script = "Combo"
             },
             MatchOrdersCount = 2
         },
         new ScriptMatchOrdersSummaryItem
         {
             GameServer = new GameServer
             {
                 Login = "******",
                 Name = "server name 2",
                 Script = "Battle"
             },
             MatchOrdersCount = 4
         },
         new ScriptMatchOrdersSummaryItem
         {
             GameServer = new GameServer
             {
                 Login = "******",
                 Name = "server name 3",
                 Script = "Royal"
             },
             MatchOrdersCount = 3
         }
     };
 }
Exemplo n.º 8
0
 public string[] GetGameScripts(GameEnvironment gameEnvironment)
 {
     return _scripts[gameEnvironment].ToArray();
 }
 public async Task<Dictionary<string, int>> GetMatchOrdersSummaryAsync(GameEnvironment gameEnvironment)
 {
     var delay = _defaultDelay;
     await Task.Delay(TimeSpan.FromSeconds(delay));
     return _dataLoader.GetMatchOrdersSummary(gameEnvironment);
 }
 public async Task<Dictionary<string, int>> GetMatchOrdersSummaryAsync(GameEnvironment gameEnvironment)
 {
     CreateClient();
     return await _client.GetMatchOrdersSummaryAsync(gameEnvironment);
 }
 public async Task<string[]> GetGameScriptsAsync(GameEnvironment gameEnvironment)
 {
     var delay = _defaultDelay;
     await Task.Delay(TimeSpan.FromSeconds(delay));
     return _dataLoader.GetGameScripts(gameEnvironment).ToArray();
 }
Exemplo n.º 12
0
	public void SetEnvironment(GameEnvironment env) {
		this.env = env;
		Build ();

	}
 public async Task<GameServer[]> GetGameServersAsync(GameEnvironment gameEnvironment, string script,
     string serverLoginPart, int pageIndex)
 {
     CreateClient();
     return await _client.GetGameServersAsync(gameEnvironment, script, serverLoginPart, pageIndex);
 }
Exemplo n.º 14
0
 public ServerFilterMatchOrdersSummaryItem[] GetServerFilterMatchOrdersSummary(
     GameEnvironment gameEnvironment, string script, string serverLogin)
 {
     return new[]
     {
         new ServerFilterMatchOrdersSummaryItem
         {
             UserLogin = "******",
             UserNick = "user nick 1",
             PlayersMinCount = 3
         },
         new ServerFilterMatchOrdersSummaryItem
         {
             UserLogin = "******",
             UserNick = "user nick 2",
             PlayersMinCount = 5
         },
         new ServerFilterMatchOrdersSummaryItem
         {
             UserLogin = "******",
             UserNick = "user nick 3",
             PlayersMinCount = 4
         }
     };
 }
Exemplo n.º 15
0
 private string[] GetCachedScripts(GameEnvironment gameEnvironment)
 {
     string[] scripts;
     _cachedScripts.TryGetValue(gameEnvironment, out scripts);
     return scripts;
 }
Exemplo n.º 16
0
        public HUD(GameEnvironment env)
            : base(env.Controller)
        {
            Environment = env;

            // Cursor.
            Cursor = new Widget(this);
            Cursor.LoadTexture(contentManager, "bullet_arrow");
            Cursor.Registration = new Vector2(Cursor.Texture.Width, Cursor.Texture.Height) * 0.5f;
            Cursor.Scale = 0.2f;
            AddChild(Cursor);

            // Arrow pointing towards boss.
            BossDirection = new Widget(this);
            BossDirection.LoadTexture(contentManager, "arrow");
            BossDirection.Registration = new Vector2(BossDirection.Texture.Width, BossDirection.Texture.Height) * 0.5f;
            BossDirection.PositionPercent = new Vector2(1.0f, 1.0f);
            BossDirection.Position = new Vector2(-75.0f, -75.0f);
            AddChild(BossDirection);

            /////

            // Boss health meter.
            BossHealth = new RectangleWidget(this, ScreenSize.X * 0.75f - 4.0f, 20.0f - 4.0f);
            BossHealth.PositionPercent = new Vector2(0.5f, 0.0f);
            BossHealth.Position = new Vector2(0.0f, 20.0f);
            BossHealth.VertexColor = Color.DarkRed;
            BossHealth.Zindex = 0.0f;
            AddChild(BossHealth);

            // Boss health background.
            BossHealthBG = new RectangleWidget(this, ScreenSize.X * 0.75f, 20.0f);
            BossHealthBG.PositionPercent = new Vector2(0.5f, 0.0f);
            BossHealthBG.Position = new Vector2(0.0f, 20.0f);
            BossHealthBG.VertexColor = Color.Black;
            BossHealthBG.Zindex = 1.0f;
            AddChild(BossHealthBG);

            /////

            // Ship health meter.
            ShipHealth = new RectangleWidget(this, ScreenSize.X * 0.25f - 4.0f, 20.0f - 4.0f);
            ShipHealth.PositionPercent = new Vector2(0.0f, 1.0f);
            ShipHealth.Position = new Vector2(10.0f + ScreenSize.X * 0.25f / 2, -20.0f);
            ShipHealth.VertexColor = Color.Green;
            ShipHealth.Zindex = 0.5f;
            ShipHealth.Alpha = 0.0f;
            AddChild(ShipHealth);

            // Ship health shield.
            ShipHealthShield = new RectangleWidget(this, ScreenSize.X * 0.25f - 4.0f, 20.0f - 4.0f);
            ShipHealthShield.PositionPercent = new Vector2(0.0f, 1.0f);
            ShipHealthShield.Position = new Vector2(10.0f + ScreenSize.X * 0.25f / 2, -20.0f);
            ShipHealthShield.VertexColor = Color.LightBlue;
            ShipHealthShield.Zindex = 0.0f;
            ShipHealthShield.Alpha = 0.0f;
            AddChild(ShipHealthShield);

            // Ship health background.
            ShipHealthBG = new RectangleWidget(this, ScreenSize.X * 0.25f, 20.0f);
            ShipHealthBG.PositionPercent = new Vector2(0.0f, 1.0f);
            ShipHealthBG.Position = new Vector2(10.0f + ScreenSize.X * 0.25f / 2, -20.0f);
            ShipHealthBG.VertexColor = Color.Black;
            ShipHealthBG.Zindex = 1.0f;
            ShipHealthBG.Alpha = 0.0f;
            AddChild(ShipHealthBG);

            /////

            // Sputnik time left.
            SputnikTimeLeft = new RectangleWidget(this, 100.0f - 4.0f, 10.0f - 4.0f);
            SputnikTimeLeft.VertexColor = Color.White;
            SputnikTimeLeft.Zindex = 0.0f;
            SputnikTimeLeft.Alpha = 0.0f;
            AddChild(SputnikTimeLeft);

            // Sputnik time left background.
            SputnikTimeLeftBG = new RectangleWidget(this, 100.0f, 10.0f);
            SputnikTimeLeftBG.VertexColor = Color.Black;
            SputnikTimeLeftBG.Zindex = 1.0f;
            SputnikTimeLeftBG.Alpha = 0.0f;
            AddChild(SputnikTimeLeftBG);
        }
 public async Task<ScriptMatchOrdersSummaryItem[]> GetScriptMatchOrdersSummaryAsync(
     GameEnvironment gameEnvironment, string script)
 {
     CreateClient();
     return await _client.GetScriptMatchOrdersSummaryAsync(gameEnvironment, script);
 }
 public async Task<ServerFilterMatchOrdersSummaryItem[]> GetServerFilterMatchOrdersSummaryAsync(
     GameEnvironment gameEnvironment, string script, string serverLogin)
 {
     CreateClient();
     return await _client.GetServerFilterMatchOrdersSummaryAsync(gameEnvironment, script, serverLogin);
 }
Exemplo n.º 19
0
 public MockGameTile(GameEnvironment world)
     : base(world)
 {
 }
 public async Task<string[]> GetGameScriptsAsync(GameEnvironment gameEnvironment)
 {
     CreateClient();
     return await _client.GetGameScriptsAsync(gameEnvironment);
 }