Esempio n. 1
0
    // Use this for initialization
    public void OnClickStartGame()
    {
        PlayerStatus.ResourcesCount    = 100;
        PlayerStatus.GoldCount         = 100;
        PlayerStatus.ShipPos           = new Vector3(0, 0, 0);
        PlayerStatus.ShipHealthMax     = 100;
        PlayerStatus.ShipHealthCurrent = 100;
        PlayerStatus.AmmoCount         = 20;

        QuestsStatus.testQuestStatus = -1;

        IslandStats.IslandLocations = GetComponent <IslandGeneration>().generateIslands();

        SceneManager.LoadScene(SceneIndexes.WorldMap());

        PlayerStatus.Ship = new Ship(
            "FTL",                                                                                                 // name
            "Your trusty old sloop. She may not be much, but she served you well during your time as a merchant.", // description
            1000,                                                                                                  // value
            Ship.ShipClass.SLOOP,                                                                                  // ship class
            100,                                                                                                   // base hull health
            10,                                                                                                    // base/necessary crew health/count
            50                                                                                                     // base sail health
            );

        //for (int i = 0; i < 10; i++)
        //    PlayerStatus.Inventory.AddItem(new CrewWeapon(
        //                                    "Sword",                        // name
        //                                    "A four-foot long steel blade with a leather-bound hilt. A well made sword, but nothing to brag about.", // description
        //                                    50,                             // value
        //                                    CrewWeapon.WeaponMaterial.STEEL,// weapon material
        //                                    100,                            // current condition
        //                                    100,                            // maximum condition
        //                                    2));                            // damage
        //for (int i = 0; i < 4; i++)
        //    PlayerStatus.Inventory.AddItem(new ShipWeapon(
        //                                    "Basic Cannon",   // name
        //                                    "The old and reliable 20mm naval gun, a common weapon used by merchant, pirate, and naval vessels alike.", // description
        //                                    50,                             // value
        //                                    ShipWeapon.WeaponType.CANNON,   // weapon type
        //                                    Ammunition.AmmoType.CANNONBALL, // ammo type
        //                                    2,                              // cooldown
        //                                    10));                           // damage
        //PlayerStatus.Inventory.AddItem(new Consumable(
        //                                    "Health Potion",                // name
        //                                    "A blood-red potion, used to magically heal an individual's wounds.", // description
        //                                    5,                              // value
        //                                    Consumable.Effect.HEAL,         // effect
        //                                    10),                            // magnitude
        //                                    4);                             // quantity
        //PlayerStatus.Inventory.AddItem(new Ammunition(
        //                                    "Explosive Rounds",             // name
        //                                    "Filled to the brim with brimstone, these cannonballs violently explode on impact, greviously wounding enemy crew.", // description
        //                                    1,                             // value
        //                                    Ammunition.AmmoType.CANNONBALL, // weapon material
        //                                    1,                              // hull damage multiplier
        //                                    3,                              // crew damage multiplier
        //                                    1),                             // sail damage multiplier
        //                                    100);                           // quantity
    }
Esempio n. 2
0
        void Awake()
        {
            if (_instance != null && _instance != this)
            {
                Destroy(gameObject);
            }
            else
            {
                _instance = this;
            }

            //Copy the inspector list items to the masterLevelList
            StartCoroutine(InitializeLevelsList());

            if (SceneManager.GetActiveScene().name.Contains("Editor"))
            {
                isInEditor = true;
            }
            else
            {
                isInEditor = false;
            }

            if (!isInEditor)
            {
                currentActive     = loadTo;
                asyncLoadingScene = SceneManager.LoadSceneAsync((int)loadTo, LoadSceneMode.Additive);
                OnLoadNewScene.Invoke();
                GetNextLevelInfo();
            }
        }
Esempio n. 3
0
    private void Update()
    {
        if ((Input.GetButton("Submit")) && isVisiting)
        {
            SceneManager.LoadScene(SceneIndexes.IslandVisitation());
        }

        if ((Input.GetButton("Menu")) && !moveLock && (player.velocity.x == 0) && (player.velocity.y == 0))
        //If moveLock is true, the player is either dead or in a menu. In either case, tab shouldn't open the stats panel
        {
            moveLock = true;

            goldCount.text      = "";
            resourcesCount.text = "";

            statsPanel.SetActive(true);
        }

        if (Input.GetButton("Cancel") && !moveLock && (player.velocity.x == 0) && (player.velocity.y == 0))

        {
            moveLock = true;

            goldCount.text      = "";
            resourcesCount.text = "";

            savePanel.SetActive(true);
        }

        if (!moveLock) //With the if statement, the gold count and resources count will be reset upon leaving the stats menu
        {
            SetGold();
            SetResources();
        }
    }
Esempio n. 4
0
    private IEnumerator ILoadScene(SceneIndexes sceneBuildIndex, int animationIndex = 0)
    {
        Animator anim  = _animators[animationIndex];
        float    timer = 0;
        float    minimumTransitionTime = 0;

        AnimationClip[] animationClips = anim.runtimeAnimatorController.animationClips;

        for (int i = 0; i < animationClips.Length - 1; i++) // skip the last animation
        {
            minimumTransitionTime += animationClips[i].length;
        }

        // Start animation
        anim.SetTrigger("Start");

        AsyncOperation asyncLoadLevel = SceneManager.LoadSceneAsync(sceneBuildIndex.ToString(), LoadSceneMode.Single);

        asyncLoadLevel.allowSceneActivation = false;


        while (!asyncLoadLevel.isDone)
        {
            // only allows a scene change if the first part of the transition has been completed
            timer += Time.deltaTime;
            if (timer > minimumTransitionTime)
            {
                asyncLoadLevel.allowSceneActivation = true;
            }

            yield return(null);
        }

        anim.SetTrigger("End");
    }
Esempio n. 5
0
        private IEnumerator LoadSceneDelayed(SceneIndexes scene, float delayTime)
        {
            yield return(new WaitForSeconds(delayTime));

            LoadScene(scene);
            StartCoroutine(TrackLoadProgress(scene, true));
        }
Esempio n. 6
0
 /// <summary>
 /// Load the specifed scene at asynchronously with 'Single' load mode.
 /// </summary>
 /// <param name="newSceneIndex"></param>
 public void ChangeToSpecifiedScene(SceneIndexes newSceneIndex)
 {
     if (!currentlySwitching)
     {
         StartCoroutine(LoadNewScene((int)newSceneIndex));
     }
 }
        /// <summary>
        /// will unload A scene Async
        /// </summary>
        /// <param name="sceneToUnload">the scene to unload</param>
        /// <param name="mode">the unloading options</param>
        public IEnumerator UnloadSceneAsync(SceneIndexes sceneToUnload, UnloadSceneOptions mode = UnloadSceneOptions.None)
        {
            yield return(new WaitForEndOfFrame());

            StartCoroutine(Loading(true));
            _scenesLoading.Add(SceneManager.UnloadSceneAsync((int)sceneToUnload, mode));
            StartProgressCounters();
        }
Esempio n. 8
0
        public void ChangeScene(SceneIndexes scene) //Change scene from current scene to the selected one
        {
            SetLoadingScreen(true, true);
            StartCoroutine(LoadSceneDelayed(scene, fadeTime));
            //LoadScene(scene);

            //StartCoroutine(TrackLoadProgress(scene, true));
        }
Esempio n. 9
0
    public static void ReturnToMap(int goldReward, int resourcesReward, Vector3 returnPos) //if returnPos is the same location the ship was in before, pass in PlayerStatus.ShipPos
    {
        PlayerStatus.GoldCount      += goldReward;
        PlayerStatus.ResourcesCount += resourcesReward;
        PlayerStatus.ShipPos         = returnPos;

        SceneManager.LoadScene(SceneIndexes.WorldMap());
    }
Esempio n. 10
0
    public void LoadGame(SceneIndexes scene)
    {
        loadingScreen.gameObject.SetActive(true);
        scenesLoading.Add(SceneManager.UnloadSceneAsync(SceneManager.GetSceneAt(1)));
        scenesLoading.Add(SceneManager.LoadSceneAsync((int)scene, LoadSceneMode.Additive));

        StartCoroutine(GetSceneLoadProgress(3));
    }
Esempio n. 11
0
 private void LoadMainMenu()
 {
     if (currentScene != SceneIndexes.MASTER)
     {
         SceneManager.UnloadSceneAsync((int)currentScene);
     }
     SceneManager.LoadSceneAsync((int)SceneIndexes.MAIN_MENU, LoadSceneMode.Additive);
     currentScene = SceneIndexes.MAIN_MENU;
 }
Esempio n. 12
0
        private void UpdateCurrentScene() //Update currentScene value for tracking purposes
        {
            SceneIndexes temp = currentScene;

            currentScene = (SceneIndexes)UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex;
            if (temp != currentScene)
            {
                pastScene = temp;
            }
        }
Esempio n. 13
0
    public void LoadScene(SceneIndexes from, SceneIndexes to)
    {
        loadingCamera.gameObject.SetActive(true);

        loadingScreen.gameObject.SetActive(true);

        scenesLoading.Add(SceneManager.UnloadSceneAsync((int)from));
        scenesLoading.Add(SceneManager.LoadSceneAsync((int)to, LoadSceneMode.Additive));

        StartCoroutine(GetSceneLoadProgress());
    }
Esempio n. 14
0
    private void OnClickFlee()
    {
        //TODO: incorporate the possibility of a variety of enemy ships
        //TODO: add some sort of randomness and a chance to fail, for if the ship is not hostile

        EnemyStatus.ShipHealthMax     = 50;
        EnemyStatus.ShipHealthCurrent = 50;
        EnemyStatus.GoldCount         = 50;
        EnemyStatus.ResourcesCount    = 20;
        SceneManager.LoadScene(SceneIndexes.Combat());
    }
Esempio n. 15
0
    public void ChangeScene(SceneIndexes scene) //Change scene from current scene to the selected one
    {
        //if (unloadCurrentOnChange)
        //{
        //    loadingScenes.Add(UnityEngine.SceneManagement.SceneManager.UnloadSceneAsync((int)currentScene));
        //}

        //SetLoadingScreen(true, true);
        LoadScene(scene);

        StartCoroutine(TrackLoadProgress(scene, true));
    }
        /// <summary>
        /// will load a scene async
        /// </summary>
        /// <param name="sceneToLoad">the scene to load</param>
        /// <param name="mode">the loading options</param>
        public IEnumerator LoadSceneAsync(SceneIndexes sceneToLoad, LoadSceneMode mode)
        {
            yield return(new WaitForEndOfFrame());

            Application.backgroundLoadingPriority = loadingSpeed;
            //Debug.Log($"started loading {sceneToLoad.ToString()}");
            StartCoroutine(Loading(true));
            var sceneLoadDing = SceneManager.LoadSceneAsync((int)sceneToLoad, mode);

            _scenesLoading.Add(sceneLoadDing);
            StartProgressCounters();
        }
Esempio n. 17
0
 public void SetSelectLevel(int index)
 {
     //If the index given was actually valid
     if (Enum.IsDefined(typeof(SceneIndexes), index))
     {
         m_selectedLevelIndex = (SceneIndexes)index;
     }
     else //Otherwise, select a default level
     {
         m_selectedLevelIndex = SceneIndexes.LEVEL_ONE;
     }
     m_levelSelected = true;
 }
Esempio n. 18
0
        public void ReloadLevelWithSlow()
        {
            SceneIndexes currentScene     = SceneManager.instance.currentScene;
            int          levelToLoadIndex = (int)currentScene;

            if (slowTimeOnCompletion == true)
            {
                if (slowLoadCoroutine == null)
                {
                    slowLoadCoroutine = StartCoroutine(SlowDownAndLoad(levelToLoadIndex));
                }
            }
        }
Esempio n. 19
0
    public bool LoadScene(SceneIndexes sceneBuildIndex, int animationIndex = 0)
    {
        if (SceneManager.GetActiveScene().name != sceneBuildIndex.ToString() &&
            animationIndex >= 0 && animationIndex < _animators.Length)
        {
            StartCoroutine(ILoadScene(sceneBuildIndex, animationIndex));
            return(true);
        }

        else
        {
            Debug.LogWarning("Trying to load identical scene or reach a scene that does not exist!", this);
            return(false);
        }
    }
Esempio n. 20
0
        public IEnumerator TrackLoadProgress(SceneIndexes scene, bool setActiveOnLoad) //Track all scenes that are loading, and calculate a load progress from that. Once scene is loaded, set it as active
        {
            float loadProgress;

            for (int i = 0; i < loadingScenes.Count; i++)
            {
                if (loadingScenes[i] == null)
                {
                    Debug.LogWarning("It's null " + loadingScenes.Count);
                }

                while (loadingScenes[i].isDone == false)
                {
                    loadProgress = 0;

                    foreach (AsyncOperation operation in loadingScenes)
                    {
                        loadProgress += operation.progress;
                    }

                    //Calculate load progress
                    loadProgress = loadProgress / loadingScenes.Count;
                    UpdateLoadingBar(loadProgress);
                    yield return(null);
                }
            }

            yield return(new WaitForSeconds(0.5f));

            if (unloadCurrentOnChange && (int)currentScene < UnityEngine.SceneManagement.SceneManager.sceneCountInBuildSettings)
            {
                UnityEngine.SceneManagement.SceneManager.UnloadSceneAsync((int)currentScene);
            }

            if (setActiveOnLoad)
            {
                //if (ifScene_CurrentlyLoaded_inEditor(UnityEngine.SceneManagement.SceneManager.GetSceneByBuildIndex((int)scene).name))
                //{
                //    UnityEngine.SceneManagement.SceneManager.SetActiveScene(UnityEngine.SceneManagement.SceneManager.GetSceneByBuildIndex((int)scene));
                //}
                UnityEngine.SceneManagement.SceneManager.SetActiveScene(UnityEngine.SceneManagement.SceneManager.GetSceneByBuildIndex((int)scene));
                UpdateCurrentScene();
            }

            yield return(new WaitForSeconds(0.5f));

            SetLoadingScreen(false, true);
        }
Esempio n. 21
0
    public void Load()
    {
        if (File.Exists(Application.dataPath + "/saves/SaveData.dat"))
        {
            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Open(Application.dataPath + "/saves/SaveData.dat", FileMode.Open);

            data = (Savedata)bf.Deserialize(file);

            CopyLoadData();

            file.Close();

            SceneManager.LoadScene(SceneIndexes.WorldMap());
        }
    }
        public void ChangeScene(SceneIndexes index, Action onCompleteCallBack = null)
        {
            if (index == CurrentScene)
            {
                return;
            }

            OnBeginSceneChange?.Invoke(CurrentScene);

            if (CurrentScene != SceneIndexes.Persistent)
            {
                loadingProgressList.Add(UnityEngine.SceneManagement.SceneManager.UnloadSceneAsync((int)CurrentScene));
            }
            loadingProgressList.Add(UnityEngine.SceneManagement.SceneManager.LoadSceneAsync((int)index, LoadSceneMode.Additive));

            CurrentScene = index;
            StartCoroutine(GetLoadingProgress(onCompleteCallBack));
        }
Esempio n. 23
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////A REVOIR

        IEnumerator LoadScene(SceneIndexes sceneIndex)
        {
            //Debug.LogWarning("Loading scene " + (SceneIndexes)sceneIndex);

//===============================================================================================================================================// FADE OUT Transition
            UIManager.instance.TransitionStart();

            _FadeToBlack();

            yield return(new WaitForSeconds(transitionDuration));                                     //wait for the screen to be black

            SceneManager.UnloadSceneAsync((int)currentActive);                                        //unload the title screen scene
            asyncLoadingScene = SceneManager.LoadSceneAsync((int)sceneIndex, LoadSceneMode.Additive); //start loading gameScene
            currentActive     = sceneIndex;                                                           //set the current active scene

            while (!asyncLoadingScene.isDone)
            {
                yield return(null);                              //wait for scene to finish loading
            }
//===============================================================================================================================================//


            if (sceneIndex == SceneIndexes.GAME)
            {
                //once the scene has been loaded
                GetNextLevelInfo();
                SaveCurrentLevel(); //saves the level that has been loaded as the furthest level the player has reached
                GenerateNextLevel();
                masterLevelQueue.Dequeue();
            }

//===============================================================================================================================================// FADE IN Transition
            _FadeFromBlack();

            UIManager.instance.CheckActiveScene();                      //update which canvas is being used (based on scene), disable others

            yield return(new WaitForSeconds(transitionDuration * .7f)); //wait for the screen to be black

            UIManager.instance.TransitionOver();

            //===============================================================================================================================================//
        }
Esempio n. 24
0
        // Start is called before the first frame update
        void Start()
        {
            //Singleton
            if (instance == null)
            {
                instance = this;
                DontDestroyOnLoad(instance.gameObject);
            }
            else
            {
                Destroy(gameObject);
            }

            //Set loading screen to inspector value and do not animate
            SetLoadingScreen(loadingScreenVisible, false);
            //Reset loadingScenes list
            loadingScenes = new List <AsyncOperation>();
            UpdateCurrentScene();
            pastScene = currentScene;
        }
Esempio n. 25
0
 public void OnClickMainMenu()
 {
     SceneManager.LoadScene(SceneIndexes.MainMenu());
 }
Esempio n. 26
0
 public void LoadScene(SceneIndexes scene) //Load the selected scene async
 {
     loadingScenes.Add(UnityEngine.SceneManagement.SceneManager.LoadSceneAsync((int)scene, LoadSceneMode.Additive));
 }
 private void ConcludeTutorial()
 {
     SceneManager.LoadScene(SceneIndexes.WorldMap());
 }
Esempio n. 28
0
 public void LoadScene(int sceneIndex)
 {
     SceneManager.LoadSceneAsync(sceneIndex, LoadSceneMode.Additive);
     SceneManager.UnloadSceneAsync((int)currentScene);
     currentScene = (SceneIndexes)sceneIndex;
 }
Esempio n. 29
0
 public void LoadWorldMap()
 {
     SceneManager.LoadScene(SceneIndexes.WorldMap());
 }
Esempio n. 30
0
    private void FixedUpdate()
    {
        float horVel = Input.GetAxis("Horizontal");
        float verVel = Input.GetAxis("Vertical");

        //sprite.transform.eulerAngles = lastRotation;

        if (!moveLock)
        {
            speed           = new Vector2(horVel, verVel);
            player.velocity = speed * speedMult;
            //player.AddForce(speed * speedMult);
        }

        if (((horVel != 0) || (verVel != 0)) && !moveLock) //As long as a key is being pressed—!moveLock is included so it doesn't break in menus
        {
            zRotation = ((float)Math.Atan(player.velocity.y / player.velocity.x)) * (float)(180 / Math.PI);

            if (player.velocity.x >= 0)
            {
                lastRotation = new Vector3(0, 0, zRotation + 180);
                sprite.transform.eulerAngles = lastRotation;
            }
            else
            {
                lastRotation = new Vector3(0, 0, zRotation);
                sprite.transform.eulerAngles = lastRotation;
            }

            lastRotation = sprite.transform.eulerAngles;
        }


        if ((speed.x != 0) || (speed.y != 0)) //As long as the ship is in motion
        {
            depletionCounter++;               //Deplete resources
            if ((depletionCounter == depletionRate) && !moveLock)
            {
                PlayerStatus.ResourcesCount--;
                depletionCounter = 0;
            }


            float rand = UnityEngine.Random.value;

            if (rand > 1 - chanceHolder) //Check for random encounter
            {
                chanceHolder = .0001f;
                EnemyStatus.ShipHealthMax     = 50;
                EnemyStatus.ShipHealthCurrent = 50;
                EnemyStatus.GoldCount         = 50;
                EnemyStatus.ResourcesCount    = 20;
                SceneManager.LoadScene(SceneIndexes.Combat());
            }
            else
            {
                chanceHolder += encounterChance;
            }
        }

        PlayerStatus.ShipPos = transform.position;
    }