public void LoadSceneCode(SceneCode sceneCode)
    {
        ExitSceneCode(currentSceneCode);
        EnterSceneCode(sceneCode);
        currentSceneCode = sceneCode;

        player.playerRuntimeData.currentSceneCode = sceneCode;
    }
    public void EnterSceneCode(SceneCode sceneCode)
    {
        GameObject sceneGO = GameObject.Find("/Scenes").transform.Find(sceneCode.ToString()).gameObject;

        sceneGO?.SetActive(true);

        Camera.main.GetComponent <BasicFollower>().cameraClamp = sceneGO.GetComponent <SceneCodeUtil>().CameraClamp;
    }
    public void EnterSceneCode(SceneCode sceneCode)
    {
        GameObject sceneGO = GameObject.Find("/Scenes").transform.Find(sceneCode.ToString()).gameObject;

        sceneGO?.SetActive(true);

        Camera.main.GetComponent <BasicFollower>().cameraClamp = sceneGO.GetComponent <SceneCodeUtil>().CameraClamp;

        UIEventListener.Instance.OnInfomationChange(new UIEventListener.InfomationChangeData(SceneCodeDisplayName.names[(int)sceneCode]));
    }
Beispiel #4
0
 public static void LoadScene(SceneCode sceneCode)
 {
     if (TheMatrix.Instance == null)
     {
         SceneManager.LoadScene(GetScene(sceneCode));
     }
     else
     {
         StartCoroutine(LoadSceneCoroutine(sceneCode));
     }
 }
Beispiel #5
0
 public static IEnumerator LoadSceneCoroutine(SceneCode sceneCode)
 {
     loadConfirmed = false;
     SceneToLoad   = sceneCode;
     OnPendingLoadScene?.Invoke();
     Log("Pending Load Scene:" + sceneCode);
     while (!loadConfirmed)
     {
         yield return(0);
     }
     Log("Load Confirmed!");
     SceneManager.LoadScene(GetScene(sceneCode));
 }
Beispiel #6
0
 public void SetPlayerRuntimeSaveData(PlayerRuntimeSaveData playerRuntimeSaveData)
 {
     currentHitPoints   = playerRuntimeSaveData.currentHitPoints;
     currentStunPoints  = playerRuntimeSaveData.currentStunPoints;
     currentDecayPoints = playerRuntimeSaveData.currentStunPoints;
     currentSceneCode   = (SceneCode)playerRuntimeSaveData.currentSceneCode;
     lastLittleSunID    = playerRuntimeSaveData.lastLittleSunID;
     string[] lastPos = playerRuntimeSaveData.lastPosition.Split(',');
     lastPosition = new Vector2(float.Parse(lastPos[0]), float.Parse(lastPos[1]));
     playerStock  = playerRuntimeSaveData.playerStock;
     playerSlot   = playerRuntimeSaveData.playerSlot;
     // Debug.Log(playerRuntimeSaveData.lastPosition);
     isLoaded = true;
 }
    public static void ChangeScene(SceneCode newScene)
    {
        if (CurrentScene.buildIndex != -1)
        {
            SceneManager.UnloadSceneAsync(CurrentScene);
        }

        if (newScene == SceneCode.Null)
        {
            CurrentScene = new Scene();
            return;
        }
        SceneManager.LoadScene((int)newScene, LoadSceneMode.Additive);
    }
Beispiel #8
0
        public PlayerRuntimeSaveData(float currentHitPoints, float currentStunPoints, float currentDecayPoints,
                                     SceneCode currentSceneCode, int lastLittleSunID, Vector2 lastPosition, PlayerStock playerStock, PlayerSlot playerSlot)
        {
            this.currentHitPoints   = currentHitPoints;
            this.currentStunPoints  = currentStunPoints;
            this.currentDecayPoints = currentDecayPoints;
            this.currentSceneCode   = (int)currentSceneCode;
            this.lastLittleSunID    = lastLittleSunID;
            string strLastPos = lastPosition.ToString();

            this.lastPosition = strLastPos.Substring(1, strLastPos.Length - 2);
            this.playerStock  = playerStock;
            this.playerSlot   = playerSlot;
            // Debug.Log(this.lastPosition);
        }
    private void DemonSceneCode(SceneCode sceneCode)
    {
        ResetAllSceneCode();
        Transform centerPoint = GameObject.Find("/Scenes").transform.Find(sceneCode.ToString()).Find("CenterPoint");

        if (centerPoint == null)
        {
            centerPoint                  = new GameObject("CenterPoint").transform;
            centerPoint.position         = Vector3.zero;
            centerPoint.transform.parent = GameObject.Find("/Scenes").transform.Find(sceneCode.ToString());
        }

        EnterSceneCode(sceneCode);
        //Debug.Log(demonScenes[index].ToString());
        Camera.main.transform.position = new Vector3(centerPoint.position.x, centerPoint.position.y, Camera.main.transform.position.z);
        Camera.main.GetComponent <BasicFollower>().UpdateCameraFollowing(centerPoint);
    }
Beispiel #10
0
    public void InitPlayerRuntimeData(D_PlayerStateMachine playerData)
    {
        currentHitPoints   = playerData.PD_maxHitPoint;
        currentStunPoints  = playerData.PD_maxStunPoint;
        currentDecayPoints = 0f;
        currentSceneCode   = SceneCode.Gulch_Main;
        lastLittleSunID    = -1;
        playerStock        = new PlayerStock(new List <ItemData.WeaponRuntimeData>(), new List <ItemData.WearableRuntimeData>(),
                                             new List <ItemData.ConsumableRuntimeData>(), new List <ItemData.KeyItemRuntimeData>());

        for (int i = 0; i < (int)ItemData.Weapon.Count; ++i)
        {
            playerStock.Pick(new ItemData.WeaponRuntimeData((ItemData.Weapon)i, i % 3));
        }

        for (int i = 0; i < (int)ItemData.Wearable.Count; ++i)
        {
            playerStock.Pick(new ItemData.WearableRuntimeData((ItemData.Wearable)i));
        }

        for (int i = 0; i < (int)ItemData.Consumable.Count; ++i)
        {
            playerStock.Pick(new ItemData.ConsumableRuntimeData((ItemData.Consumable)i, i * 10 % 99 + 1));
        }

        for (int i = 0; i < (int)ItemData.Consumable.Count; ++i)
        {
            playerStock.Pick(new ItemData.ConsumableRuntimeData((ItemData.Consumable)i, i * 10 % 99 + 1));
        }

        for (int i = 0; i < (int)ItemData.Consumable.Count; ++i)
        {
            playerStock.Pick(new ItemData.ConsumableRuntimeData((ItemData.Consumable)i, i * 10 % 99 + 1));
        }

        for (int i = 0; i < (int)ItemData.KeyItem.Count; ++i)
        {
            playerStock.Pick(new ItemData.KeyItemRuntimeData((ItemData.KeyItem)i));
        }

        // use default weapon and none wearables
        playerSlot = new PlayerSlot(0, 0, 1);
    }
    private IEnumerator ReloadScene(SceneCode sceneCode, Vector3 position)
    {
        yield return(new WaitForSeconds(uiHandler.uiEffectHandler.OnPlayUIEffect(UIEffect.Transition_CrossFade, UIEffectAnimationClip.start)));

        player.ResetPlayerStatus();
        LoadSceneCode(sceneCode);
        player.SetPosition(position);

        yield return(new WaitForEndOfFrame());

        Camera.main.GetComponent <BasicFollower>().ClampCamera(player.transform.position);
        Camera.main.GetComponent <BasicFollower>().UpdateCameraFollowing(player.transform);

        yield return(new WaitForSeconds(DarkWaitDuration));

        player.stateMachine.InitializeState(player.wakeupState);

        yield return(new WaitForSeconds(uiHandler.uiEffectHandler.OnPlayUIEffect(UIEffect.Transition_CrossFade, UIEffectAnimationClip.end)));
    }
    public IEnumerator UnloadScene(SceneCode id)
    {
        var name = Scenes.FirstOrDefault(s => s.Code == id)?.Name;

        if (name == null)
        {
            Debug.Log("Cannot found scene " + id + " in the project...");
            yield return(null);
        }

        var sceneTask = SceneManager.UnloadSceneAsync(name);

        while (!sceneTask.isDone)
        {
            yield return(null);
        }

        Debug.Log("Scene " + id + " is unloaded!");
    }
Beispiel #13
0
 public string ParseSceneCode(SceneCode sceneCode)
 {
     return(SceneCodeDisplayName.names[(int)sceneCode]);
 }
Beispiel #14
0
 // API---------------------------------
 public static string GetScene(SceneCode sceneCode) => Setting.sceneCodeMap[sceneCode];
    public void ExitSceneCode(SceneCode sceneCode)
    {
        GameObject sceneGO = GameObject.Find("/Scenes").transform.Find(sceneCode.ToString()).gameObject;

        sceneGO?.SetActive(false);
    }