예제 #1
0
파일: Save.cs 프로젝트: GreenCalx/LD47
    bool Load(String s)
    {
        if (!File.Exists(s))
        {
            return(false);
        }
        BinaryFormatter   BF = new BinaryFormatter();
        SurrogateSelector ss = new SurrogateSelector();

        ss.AddSurrogate(typeof(Vector3),
                        new StreamingContext(StreamingContextStates.All),
                        new Vector3SerializationSurrogate());
        ss.AddSurrogate(typeof(Quaternion),
                        new StreamingContext(StreamingContextStates.All),
                        new QuaternionSerializationSurrogate());
        ss.AddSurrogate(typeof(Color),
                        new StreamingContext(StreamingContextStates.All),
                        new ColorSerializationSurrogate());
        BF.SurrogateSelector = ss;
        using (FileStream stream = new FileStream(Application.persistentDataPath + "/" + FileName + ".save", FileMode.Open, FileAccess.Read))
        {
            IS = BF.Deserialize(stream) as InputSaver;
            IS.setParent(this.gameObject.transform.parent.transform.parent.gameObject);
            stream.Close();
        }
        return(true);
    }
예제 #2
0
    void Awake()
    {
        if (RESET)
        {
            PlayerPrefs.DeleteAll();
        }

#if UNITY_ANDROID
        // isAndroid = true;
#endif
        //  Cursor.visible = false;

        if (FORCE_LOCAL_SCORE > 0)
        {
            PlayerPrefs.SetInt("scoreLevel_1", FORCE_LOCAL_SCORE);
        }


        if (!mInstance)
        {
            mInstance = this;
        }
        else
        {
            Destroy(this.gameObject);
            return;
        }
        DontDestroyOnLoad(this);

        if (LevelDataDebug.Instance)
        {
            playMode = PlayModes.STORYMODE;
            DEBUG    = LevelDataDebug.Instance.isDebbug;
            this.isArcadeMultiplayer = LevelDataDebug.Instance.isArcadeMultiplayer;
            this.playOnlyBosses      = LevelDataDebug.Instance.playOnlyBosses;
            this.playMode            = LevelDataDebug.Instance.playMode;
            this.forceVideogameID    = LevelDataDebug.Instance.videogameID;
            this.forceMissionID      = LevelDataDebug.Instance.missionID;
            this.testAreaName        = LevelDataDebug.Instance.testArea;
        }

        events                  = GetComponent <Events>();
        missions                = GetComponent <Missions>();
        multiplayerData         = GetComponent <MultiplayerData>();
        videogamesData          = GetComponent <VideogamesData> ();
        inputSaver              = GetComponent <InputSaver> ();
        inputSavedAutomaticPlay = GetComponent <InputSavedAutomaticPlay> ();
        versusManager           = GetComponent <VersusManager> ();
        handWriting             = GetComponent <HandWriting> ();
        texts = GetComponent <Texts> ();

        // GetComponent<Tracker>().Init();
        GetComponent <CurvedWorldManager>().Init();

        voicesManager.Init();

        events.SetVolume += SetVolume;
    }
예제 #3
0
 private void Awake()
 {
     if (saver == null)
     {
         DontDestroyOnLoad(gameObject);
         saver = this;
     }
     else if (saver != this)
     {
         Destroy(gameObject);
     }
 }
예제 #4
0
파일: Save.cs 프로젝트: GreenCalx/LD47
    public void EndLevel()
    {
        if (IsRecording)
        {
            IS.EndFrame.Init();

            String Path = Application.persistentDataPath + "/" + FileName + ".save";
            if (!IsSerializing && !IsReplaying && IS.InputsFrame.Count != 0)
            {
                BinaryFormatter   BF = new BinaryFormatter();
                SurrogateSelector ss = new SurrogateSelector();
                ss.AddSurrogate(typeof(Vector3),
                                new StreamingContext(StreamingContextStates.All),
                                new Vector3SerializationSurrogate());
                ss.AddSurrogate(typeof(Quaternion),
                                new StreamingContext(StreamingContextStates.All),
                                new QuaternionSerializationSurrogate());
                ss.AddSurrogate(typeof(Color),
                                new StreamingContext(StreamingContextStates.All),
                                new ColorSerializationSurrogate());

                BF.SurrogateSelector = ss;

                FileStream file = File.Create(Path);
                IsSerializing = true;
                BF.Serialize(file, IS);
                IsSerializing = false;
                file.Close();

                IS = new InputSaver();
                IS.setParent(this.gameObject.transform.parent.transform.parent.gameObject);
            }
        }

#if false
        if (IsReplaying)
        {
            CompareEndFrames();
        }
#endif
    }
예제 #5
0
 public void EvaluateInput(InputButton button, InputEvent ievent)
 {
     if (!player)
     {
         if (!started)
         {
             StartReplay();
         }
         if (replayIndex >= 0)
         {
             if (replayIndex < inputs.Count)
             {
                 for (int i = replayIndex; i < inputs.Count; ++i)
                 {
                     InputSaver saver = inputs[replayIndex];
                     var        ts    = Time.time - replayStartTs;
                     if (ts >= saver.ts)
                     {
                         if (suicide)
                         {
                             Transform obj = instantiatedObject.transform.Find("Visual");
                             if (obj != null && rotateToZeroTimer < 0)
                             {
                                 FreezeObject(obj);
                             }
                         }
                         button = saver.ib;
                         ievent = saver.ie;
                         replayIndex++;
                         if (saver.hasTrans)
                         {
                             instantiatedObject.transform.position = Vector3.Lerp(instantiatedObject.transform.position, saver.pos, 0.1f);
                             instantiatedObject.transform.rotation = Quaternion.Lerp(instantiatedObject.transform.rotation, saver.rot, 0.1f);
                         }
                         SendMovementToController(button, ievent);
                     }
                     else
                     {
                         EvaluateAllInputs();
                         return;
                     }
                 }
             }
             else
             {
                 allFinished = true;
                 instantiatedObject.layer = LayerMask.NameToLayer("Corpses");
                 Transform obj = instantiatedObject.transform.Find("Visual");
                 if (obj != null && rotateToZeroTimer < 0)
                 {
                     FreezeObject(obj);
                 }
                 //ResetMovement();
                 return;
             }
         }
     }
     else
     {
         var ts = Time.time - originalStartTs;
         if (IsDead())
         {
             ResetMovement();
             return;
         }
         if (!suicide)
         {
             Debug.Log("adding more inputs: " + button.ToString() + ", event: " + ievent + ", ts: " + ts);
             Transform trans = instantiatedObject.transform;
             if (controller.ShouldSaveTransform())
             {
                 inputs.Add(new InputSaver(button, ievent, ts, trans.position, trans.rotation));
             }
             else
             {
                 inputs.Add(new InputSaver(button, ievent, ts));
             }
             SendMovementToController(button, ievent);
         }
     }
 }
예제 #6
0
    void Awake()
    {
        Random.seed = 42;

        if (RESET)
        {
            PlayerPrefs.DeleteAll();
        }
        //  Cursor.visible = false;

        if (FORCE_LOCAL_SCORE > 0)
        {
            PlayerPrefs.SetInt("scoreLevel_1", FORCE_LOCAL_SCORE);
        }

        mInstance = this;
        DontDestroyOnLoad(this);


        //setAvatarUpgrades();
        // levelUnlockedID = PlayerPrefs.GetInt("levelUnlocked_0");
        events                  = GetComponent <Events>();
        missions                = GetComponent <Missions>();
        competitions            = GetComponent <Competitions>();
        multiplayerData         = GetComponent <MultiplayerData>();
        videogamesData          = GetComponent <VideogamesData> ();
        inputSaver              = GetComponent <InputSaver> ();
        inputSavedAutomaticPlay = GetComponent <InputSavedAutomaticPlay> ();
        versusManager           = GetComponent <VersusManager> ();

        if (totalJoysticks > 0)
        {
            multiplayerData.player1 = true;
        }
        if (totalJoysticks > 1)
        {
            multiplayerData.player2 = true;
        }
        if (totalJoysticks > 2)
        {
            multiplayerData.player3 = true;
        }
        if (totalJoysticks > 3)
        {
            multiplayerData.player4 = true;
        }

        // competitions.Init();
        if (userData)
        {
            userData.Init();
        }

        GetComponent <Tracker>().Init();
        GetComponent <Missions>().Init();
        GetComponent <CurvedWorldManager>().Init();

        // GetComponent<DataController>().Init();
        //levelUnlocked_level_1 = PlayerPrefs.GetInt("levelUnlocked_level_1");
        //levelUnlocked_level_2 = PlayerPrefs.GetInt("levelUnlocked_level_2");

        levelUnlocked_level_1 = 100;
        levelUnlocked_level_2 = 100;

        voicesManager.Init();

        events.SetVolume += SetVolume;
    }
예제 #7
0
    void Awake()
    {
        if (RESET)
        {
            PlayerPrefs.DeleteAll();
        }
#if UNITY_ANDROID || UNITY_IOS
        isAndroid                   = true;
        isAdmin                     = false;
        controlsType                = ControlsType.GYROSCOPE;
        useOptimizedSettings        = true;
        playMode                    = PlayModes.STORYMODE;
        isAndroid                   = true;
        Application.targetFrameRate = 60;
#elif UNITY_WEBGL
        useOptimizedSettings = true;
        playMode             = PlayModes.STORYMODE;
        isAndroid            = false;
#elif UNITY_EDITOR
        Application.targetFrameRate = 60;
#elif UNITY_STANDALONE
        Application.targetFrameRate = 60;
#endif


        string _controlsType = PlayerPrefs.GetString("controlsType");
        if (_controlsType == "GYROSCOPE")
        {
            controlsType = ControlsType.GYROSCOPE;
        }
        else if (_controlsType == "VIRTUAL_JOYSTICK")
        {
            controlsType = ControlsType.VIRTUAL_JOYSTICK;
        }


        if (isAndroid)
        {
            // pixelSize = (int)((float)Screen.height * (0.003f));
            if (SystemInfo.graphicsShaderLevel >= 30)
            {
                useRetroPixelPro = true;
            }
            else
            {
                useRetroPixelPro = false;
            }
        }
        //  Cursor.visible = false;



        if (!mInstance)
        {
            mInstance = this;
        }
        else
        {
            Destroy(this.gameObject);
            return;
        }
        DontDestroyOnLoad(this);

        events                  = GetComponent <Events>();
        missions                = GetComponent <Missions>();
        multiplayerData         = GetComponent <MultiplayerData>();
        videogamesData          = GetComponent <VideogamesData>();
        inputSaver              = GetComponent <InputSaver>();
        inputSavedAutomaticPlay = GetComponent <InputSavedAutomaticPlay>();
        versusManager           = GetComponent <VersusManager>();
        handWriting             = GetComponent <HandWriting>();
        assetsBundleLoader      = GetComponent <AssetsBundleLoader> ();
        framesController        = GetComponent <FramesController>();

        if (LevelDataDebug.Instance)
        {
            playMode = PlayModes.STORYMODE;
            DEBUG    = LevelDataDebug.Instance.isDebbug;
            this.isArcadeMultiplayer = LevelDataDebug.Instance.isArcadeMultiplayer;
            this.playOnlyBosses      = LevelDataDebug.Instance.playOnlyBosses;
            this.playMode            = LevelDataDebug.Instance.playMode;
            this.testAreaName        = LevelDataDebug.Instance.testArea;
            if (Data.Instance.playMode == PlayModes.STORYMODE)
            {
                multiplayerData.player1 = multiplayerData.player1_played = true;
            }
        }

        // GetComponent<Tracker>().Init();
        GetComponent <CurvedWorldManager>().Init();
    }