Exemple #1
0
    /// <summary>
    /// Called when stats for a user have been downloaded.
    /// </summary>
    /// <param name="value"></param>
    private void UserStatsReceived(ManagedSteam.CallbackStructures.UserStatsReceived value)
    {
        // Make sure that the callback is for this game
        Debug.Log("value.GameID: " + value.GameID.ToString() + "; Steamworks.SteamInterface.AppID: " + Steamworks.SteamInterface.AppID.ToString());
        Debug.Log("value.Result: " + value.Result);

        if (value.GameID.AsUInt64 == (Steamworks.SteamInterface.AppID.AsUInt64))
        {
            if (value.Result != ManagedSteam.SteamTypes.Result.OK)
            {
                UnityEngine.Debug.LogError("Failed to download stats.");
                return;
            }

            // The stats have been downloaded successfully

            IStats stats = Steamworks.SteamInterface.Stats;

            // Read the value of an INT stat named TestStatInt and a FLOAT stat named TestStatFloat.
            int intData;
            float floatData;
            if (!stats.GetStat("TestStatInt", out intData))
            {
                UnityEngine.Debug.LogWarning("Failed to read TestStatInt");
            }
            if (!stats.GetStat("TestStatFloat", out floatData))
            {
                UnityEngine.Debug.LogWarning("Failed to read TestStatFloat");
            }

            UnityEngine.Debug.Log("TestStatInt = " + intData.ToString());
            UnityEngine.Debug.Log("TestStatFloat = " + floatData.ToString());


            // Change the stat values and save them
            intData++;
            floatData += 0.5f;
            if (!stats.SetStat("TestStatInt", intData))
            {
                UnityEngine.Debug.LogWarning("Failed to write TestStatInt");
            }
            if (!stats.SetStat("TestStatFloat", floatData))
            {
                UnityEngine.Debug.LogWarning("Failed to write TestStatFloat");
            }

            // Tell the steam client that we want to upload the new stat values.
            // This will cause the UserStatsStored method to be called once the upload is complete.
            stats.StoreStats();
        }
    }
        public FrameworkCore()
            : base()
        {
#if WINDOWS && STEAM
            steam = new ManagedSteam();
#endif



            game = this;

#if LiveEnabled
            Components.Add(new GamerServicesComponent(this));

            //DELETE ME
            //Guide.SimulateTrialMode = true;
#endif

            options        = new Options();
            storageManager = new StorageManager();


            highScores = new HighScoreEntry();


#if WINDOWS
            OptionsData optionsData = storageManager.LoadOptionsPC();
            options.bloom      = optionsData.bloom;
            options.fullscreen = optionsData.isFullscreen;

            options.renderPlanets = optionsData.renderPlanets;
            options.mousewheel    = optionsData.mousewheel;
            options.sensitivity   = optionsData.sensitivity;
            options.hardwaremouse = optionsData.hardwaremouse;
            options.manualDefault = optionsData.manualDefault;

            options.resolutionX = optionsData.VideoWidth;
            options.resolutionY = optionsData.VideoHeight;

            options.p1UseMouse = optionsData.player1UseMouse;
            options.p2UseMouse = optionsData.player2UseMouse;

            options.fixedTimeStep = optionsData.fixedTimeStep;
            options.vsync         = optionsData.vsync;

            if (options.hardwaremouse)
            {
                Game.IsMouseVisible = true;
            }
#endif



            graphics = new GraphicsDeviceManager(this);
#if XBOX
            if (GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width < 1920)
            {
                graphics.PreferredBackBufferHeight = 720;
                graphics.PreferredBackBufferWidth  = 1280;
            }
            else
            {
                graphics.PreferredBackBufferHeight = 1080;
                graphics.PreferredBackBufferWidth  = 1920;
            }
#elif ONLIVE
            graphics.PreferredBackBufferHeight = 720;
            graphics.PreferredBackBufferWidth  = 1280;
            graphics.IsFullScreen = true;
#else
            //PC
            //graphics.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
            //graphics.PreferredBackBufferWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;


            graphics.PreferredBackBufferHeight = optionsData.VideoHeight;
            graphics.PreferredBackBufferWidth  = optionsData.VideoWidth;
            graphics.IsFullScreen = optionsData.isFullscreen;

            game.IsFixedTimeStep = optionsData.fixedTimeStep;
            graphics.SynchronizeWithVerticalRetrace = optionsData.vsync;
            graphics.ApplyChanges();
#endif



            particles = new ParticleManager(this);

            contentManager = new ContentManager(Services, "Content");

            boltManager = new BoltManager(this, particles);



            bloomComponent = new BloomComponent(this);


            Meshrenderer       = new MeshRenderer();
            playerMeshRenderer = new MeshRenderer();

            playbackSystem   = new PlaybackSystem();
            worldTextManager = new WorldTextManager(this);
            debrismanager    = new DebrisManager();
            hulkmanager      = new HulkManager();



            audioManager = new AudioManager();

            sysmenumanager = new SysMenuManager();
            level          = new Level();

            for (int i = 0; i < 4; i++)
            {
                PlayerIndex index = PlayerIndex.One;

                if (i == 0)
                {
                    index = PlayerIndex.One;
                }
                else if (i == 1)
                {
                    index = PlayerIndex.Two;
                }
                else if (i == 2)
                {
                    index = PlayerIndex.Three;
                }
                else
                {
                    index = PlayerIndex.Four;
                }

                menuInputs[i] = new InputManager(index);
            }

#if WINDOWS
    #if !TRIAL
            //check for full version files.
            isPirated = IsMissingFiles();
    #endif
#endif
        }
        private void GetUGCDetails(ManagedSteam.SteamTypes.UGCHandle handle)
        {
            //Print("GetUGCDetails");

            ManagedSteam.SteamTypes.AppID appID;
            string name;
            int fileSize;
            ManagedSteam.SteamTypes.SteamID steamID;

            bool result = Cloud.GetUGCDetails(handle, out appID, out name, out fileSize, out steamID);

            //Print(result.ToString());
            if (result)
            {
                //Print(appID.ToString());
                //Print(name);
                //Print(fileSize.ToString());
                //Print(steamID.ToString());
            }

            //Print("GetUGCDetails Done");
        }
        private void ReadUGCData(ManagedSteam.SteamTypes.UGCHandle handle, int fileSize)
        {
            byte[] fileData = new byte[fileSize];
            int bytesRead = Cloud.UGCRead(handle, fileData);
            if (bytesRead != fileSize)
            {
                Failed();
            }

            string sharedString = GetStringData(fileData, bytesRead);
            //Print(sharedString);
        }
Exemple #5
0
 /// <summary>
 /// Called when stats have been saved to the steam servers.
 /// </summary>
 /// <param name="value"></param>
 private void UserStatsStored(ManagedSteam.CallbackStructures.UserStatsStored value)
 {
     // Make sure that the callback is for this game
     if (value.GameID.AsUInt64 == (Steamworks.SteamInterface.AppID.AsUInt64))
     {
         if (value.Result == ManagedSteam.SteamTypes.Result.OK)
         {
             UnityEngine.Debug.Log("Stats saved to the server successfully.");
         }
         else
         {
             UnityEngine.Debug.LogWarning("Failed to save stats to the server.");
         }
     }
 }