LoadLevel() public method

public LoadLevel ( int index ) : void
index int
return void
Beispiel #1
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.Space) || Input.GetMouseButtonDown(1))
     {
         lvlload.LoadLevel(1);
     }
 }
    public void PutSpelerInTeam()
    {
        btnJoin.gameObject.SetActive(false);
        btnGo.gameObject.SetActive(false);
        //get selected item from dropdown
        var menuIndex = dropdown.GetComponent <Dropdown>().value;
        var menuValue = dropdown.GetComponent <Dropdown>().options[menuIndex].text;

        Debug.Log(menuValue);

        //get teamid from the team dictionary throug the teamname
        var teamId = teamlijst[menuValue];

        //create the url for adding player
        var url = "Team/" + teamId + "/AddSpeler?spelerID=" + Info.spelerId;

        if (teamId == -1) //team id -1 => developer bypass (offline mode)
        {
            //Debug.Log("bypassing");
            Info.TeamNaam = menuValue;
            Info.TeamId   = teamId;
            levelLoader.LoadLevel(nextLevel);
        }

        StartCoroutine(api.Get2(url, NextLevel));
    }
Beispiel #3
0
    void OnGUI()
    {
        // Make a background box
        Rect rect = new Rect(0, 0, Screen.width, Screen.height);

        GUI.Box(rect, "");
        GUIStyle centeredStyle = GUI.skin.GetStyle("Label");

        centeredStyle.alignment        = TextAnchor.UpperCenter;
        centeredStyle.fontSize         = 48;
        centeredStyle.normal.textColor = Color.yellow;

        // centered and at top of screen
        GUI.Label(new Rect(rect.center[0] - 100, rect.center[1] - 200, 200, 150), "Final Score");
        GUI.Label(new Rect(rect.center[0] - 100, rect.center[1] - 80, 200, 100), "5/5");

        string victory = "";

        victory = "Winner";

        GUI.Label(new Rect(rect.center[0] - 100, rect.center[1] + 100, 200, 100), victory);
        if (GUI.Button(new Rect(rect.center[0] - 50, rect.center[1], 110, 20), "Return To Base"))
        {
            loader.LoadLevel("level_select");
        }

        // Make the second button.
        if (GUI.Button(new Rect(rect.center[0] - 50, rect.center[1] + 40, 110, 20), "Quit"))
        {
            loader.LoadLevel("start_menu");
        }
    }
Beispiel #4
0
    public void Quit()
    {
        Time.timeScale   = 1;
        Cursor.lockState = CursorLockMode.None;
        Cursor.visible   = true;
        pauseMenu.SetActive(false);

        loader.LoadLevel(0);
    }
Beispiel #5
0
 public void PlayGame()
 {
     StartCoroutine(LD.LoadLevel(SceneManager.GetActiveScene().buildIndex + 1));
     //SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
     Time.timeScale         = 1f;
     Health.health          = 3;
     ScoreScript.scoreValue = 0;
     //health reset
 }
Beispiel #6
0
    private void Start()
    {
        //Elizabeth's note: 0 is the tutorial scene, so no facts needed. If the scene index is not 0, pop open the fact box.

        /*if (SceneManager.GetActiveScene().buildIndex != 0)
         * {
         *  FactManager.instance.openFactBox();
         * }*/
        levelLoader.LoadLevel(currentLevel);
    }
Beispiel #7
0
    public void BackToMenuNextLevel()
    {
        LevelProgressManager.SaveLevelProgress(LevelProgressManager.levelProgress + 1);
        gameFinishUIObject.SetActive(false);
        gameOverUIObject.SetActive(false);
        gameUIObject.SetActive(false);
        levelLoader.LoadLevel(0);

        //SceneManager.LoadScene(0);
    }
 public void EndLevel()
 {
     PlayerPrefs.SetInt("Score", score);
     PlayerPrefs.SetString("Level", Application.loadedLevelName);
     if (winState)
     {
         PlayerPrefs.SetInt("Win", 1);
         loader.LoadLevel("game_over");
     }
     else
     {
         PlayerPrefs.SetInt("Win", 0);
         loader.LoadLevel("game_over");
     }
 }
 protected override void Start()
 {
     this.OnPointerClickAsObservable()
     .First()
     .Subscribe(_ => levelLoader.LoadLevel())
     .AddTo(this);
 }
Beispiel #10
0
    void OnMouseUp()
    {
        //switch to main_game scene
        LevelLoader loader = GameObject.Find("Utilities").GetComponent <LevelLoader> ();

        loader.LoadLevel("level_select");
    }
Beispiel #11
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        Debug.Log(other);
        GameObject target = other.gameObject;

        Debug.Log(target);
        Debug.Log(target.layer);
        if (target.tag == "player")
        {
            Debug.Log("Collision with player at: " + transform.position);
            Destroy(target);
            Debug.Log("ending...");
            //StartCoroutine(gameEnd());
            levelLoader.LoadLevel("StartMenu");
        }
        else if (target.tag == "brick")
        {
            Debug.Log("Transform of explosion: " + transform.position);
            Tilemap bricks = other.gameObject.GetComponent <Tilemap>();
            Debug.Log("Tilemap at: " + bricks.WorldToCell(transform.position));
            Debug.Log("Tilemap is: " + bricks.GetType());
            Tile brick = bricks.GetTile <Tile>(bricks.WorldToCell(transform.position));

            //if (brick != null) {
            //    Debug.Log("brick is: " + brick.GetType());
            //}
        }
    }
Beispiel #12
0
    IEnumerator Fading(string sceneName)
    {
        anim.SetBool("Fade", true);
        yield return(new WaitForSeconds(1.0f));

        loader.LoadLevel(sceneName);
    }
Beispiel #13
0
 // Update is called once per frame
 void Update()
 {
     if (Input.anyKey)
     {
         levelLoader.LoadLevel(1);
     }
 }
    public void StartAgain()
    {
        playerPrefsManager.SetUnlockedLevels(1);
        LevelLoader loader = new LevelLoader();

        loader.LoadLevel(0);
    }
 void OnTriggerEnter2D(Collider2D Col)
 {
     if (Col.CompareTag("Player"))
     {
         levelLoader.LoadLevel(SceneManager.GetActiveScene().buildIndex, 0);
     }
 }
Beispiel #16
0
    // Start is called before the first frame update
    void Start()
    {
        MaxHearts     = GlobalDataScript.MaxAccelerant;
        CurrentHearts = GlobalDataScript.AccelerantInHand;
        MaxFireValue  = GlobalDataScript.MaxHealth;
        PlayerObj.GetComponent <PlayerController>().MeleeDamage  = GlobalDataScript.MeleeWeaponDmg;
        PlayerObj.GetComponent <PlayerController>().RangedDamage = GlobalDataScript.RangeWeaponDmg;
        //speed is handled in playercontroller start

        fadeWhiteGroup     = FadeWhitePanel.GetComponent <CanvasGroup>();
        fadeWhiteTextGroup = FadeWhiteTextPanel.GetComponent <CanvasGroup>();
        fadeBlackGroup     = FadeBlackPanel.GetComponent <CanvasGroup>();
        fadeBlackTextGroup = FadeBlackTextPanel.GetComponent <CanvasGroup>();

        fireController               = FireObj.GetComponent <FireController>();
        fireController.MaxValue      = MaxFireValue;
        fireMeterController          = FireMeterObj.GetComponent <FireMeterController>();
        fireMeterController.MaxValue = MaxFireValue;
        FireValue = MaxFireValue;
        if (GlobalDataScript.Day >= 4)
        {
            AudioSource audio = GetComponent <AudioSource>();
            audio.clip = audioBossMusic;
            audio.Play();
        }
        Level level = LevelLoader.LoadLevel(Levels[GlobalDataScript.Day]);

        FindLastEnemySpawnTime(level);
        LaunchLevel(level);
        Egg.GetComponent <SpriteRenderer>().sprite = EggSprits[GlobalDataScript.Day];
    }
 void OnTriggerEnter2D(Collider2D col)
 {
     if (col.gameObject.name == "Player")
     {
         levelLoader.LoadLevel("SelectMenu");
     }
 }
    /// <summary>
    /// Checks the conditionList to see if it satisfys any TransitionStates.
    /// If it does, then the associated scene is loaded
    /// </summary>
    public void checkState()
    {
        foreach (TransitionState t in transitionStates)
        {
            bool check = true;

            foreach (Precondition c in t.transitionConditions)
            {
                if (!c.checkCondition())
                {
                    //transition state not statisfied
                    check = false;
                    break;
                }
            }

            if (!check)
            {
                //transition state not statisfied
                continue;
            }

            //change scene to specified scene
            Debug.Log("Transition state achieved, loading scene:  " + t.sceneName);
            loader.LoadLevel(t.sceneName);
        }
    }
Beispiel #19
0
    // Use this for initialization
    void Start()
    {
        levelLoader = new LevelLoader();

        levelLoader.LoadLevel(GameProperties.levelFilePath);


        playgroundController.ConstructLevel(levelLoader.LoadedLevel, levelLoader.LevelLength, levelLoader.LevelWidth);

        environmentManager.UpdateEnvironment(levelLoader.LevelWidth, levelLoader.LevelLength, playgroundController.obstaclesGridTiles);


        var randomSnakeDirection = Utils.GenerateRandomDirection();

        playgroundController.AddSnake(randomSnakeDirection, GameProperties.initialSnakeLength);

        snakeController.InitSnake(randomSnakeDirection);


        SetupListeners();

        GameProperties.playerScore = 0;

        OnGameResumed();
    }
Beispiel #20
0
    public IEnumerator TestLoadScene_NetworkManager_NonNullObjectExpected()
    {
        SceneManager.LoadScene("MainMenuScene");
        yield return(new WaitForSeconds(3));

        MainMenuSceneInit initializer = GameObject.Find("Initializer").GetComponent <MainMenuSceneInit>();

        initializer.ChangeScene("NewGameMapScene");
        yield return(new WaitForSeconds(3));

        GameApp gameApp = GameObject.Find("GameApp").GetComponent <GameApp>();

        gameApp.PersistAllParameters(SceneManager.GetActiveScene().name);
        gameApp.Parameters.Remove("ServerAddress");
        gameApp.Parameters.Remove("ServerPort");
        gameApp.Parameters.Add("ServerAddress", "127.0.0.1");
        gameApp.Parameters.Add("ServerPort", "9994");
        LevelLoader levelLoader = GameObject.Find("LevelLoader").GetComponent <LevelLoader>();

        levelLoader.LoadLevel("NewGameScene");
        yield return(new WaitForSeconds(3));

        NewGameSceneInit newGameSceneInit = GameObject.Find("Initializer").GetComponent <NewGameSceneInit>();

        newGameSceneInit.AddPlayer();
        newGameSceneInit.AddPlayer();
        ServerNetworkManager serverNetworkManager = GameObject.Find("ServerNetworkManager").GetComponent <ServerNetworkManager>();

        Assert.IsNotNull(serverNetworkManager);
    }
Beispiel #21
0
 //Load the next level
 public void GameStart()
 {
     Time.timeScale = 1f;
     loader.LoadLevel(SceneManager.GetActiveScene().buildIndex + 1);
     gameOver = false;
     gameObject.SetActive(false);
 }
Beispiel #22
0
    public IEnumerator TestYear_Next2Turns_2401Expected()
    {
        SceneManager.LoadScene("MainMenuScene");
        yield return(new WaitForSeconds(3));

        MainMenuSceneInit initializer = GameObject.Find("Initializer").GetComponent <MainMenuSceneInit>();

        initializer.ChangeScene("NewGameMapScene");
        yield return(new WaitForSeconds(3));

        GameApp gameApp = GameObject.Find("GameApp").GetComponent <GameApp>();

        gameApp.PersistAllParameters(SceneManager.GetActiveScene().name);
        gameApp.Parameters.Remove("ServerAddress");
        gameApp.Parameters.Remove("ServerPort");
        gameApp.Parameters.Add("ServerAddress", "127.0.0.1");
        gameApp.Parameters.Add("ServerPort", "9981");
        LevelLoader levelLoader = GameObject.Find("LevelLoader").GetComponent <LevelLoader>();

        levelLoader.LoadLevel("NewGameScene");
        yield return(new WaitForSeconds(3));

        NewGameSceneInit newGameSceneInit = GameObject.Find("Initializer").GetComponent <NewGameSceneInit>();

        newGameSceneInit.AddPlayer();
        newGameSceneInit.AddPlayer();
        List <GameApp.PlayerMenu> playerMenuList = new List <GameApp.PlayerMenu>();

        GameApp.PlayerMenu player1 = new GameApp.PlayerMenu
        {
            name       = "player1",
            password   = "******",
            race       = "human",
            playerType = "L"
        };
        GameApp.PlayerMenu player2 = new GameApp.PlayerMenu
        {
            name       = "player12",
            password   = "******",
            race       = "human",
            playerType = "L"
        };
        playerMenuList.Add(player1);
        playerMenuList.Add(player2);
        gameApp.SavePlayersFromMenu(playerMenuList);
        ServerNetworkManager serverNetworkManager = GameObject.Find("ServerNetworkManager").GetComponent <ServerNetworkManager>();

        serverNetworkManager.SetupNewGame();
        yield return(new WaitForSeconds(3));

        GameController gameController = GameObject.Find("GameController").GetComponent <GameController>();

        gameController.NextTurn();
        yield return(new WaitForSeconds(3));

        gameController.NextTurn();
        yield return(new WaitForSeconds(3));

        Assert.AreEqual(gameController.year, 2401);
    }
 public void LoadLevel()
 {
     int[] eqStat = FindObjectOfType <PlayerData_Battle> ().GetEqStatus();
     if (eqStat[0] != -1 && eqStat[1] != -1)
     {
         if (selectedLevel != -1)
         {
             ResourcesUIControl.TurnUION(false);
             SceneLoader.LoadScene(3);
             LevelLoader.LoadLevel(selectedLevel);
         }
         else
         {
             PopUpControler.CallPopUp(
                 "notice",
                 "Select A Level",
                 "Please select Avaiable level before battle Start",
                 "");
         }
     }
     else
     {
         PopUpControler.CallPopUp(
             "notice",
             "Check Equipment",
             "Please wear some equipment before battle, wear a WEAPON and ARMOR",
             "");
     }
 }
Beispiel #24
0
        protected override void LoadContent()
        {
            currentTime = 0;
            spriteBatch = new SpriteBatch(GraphicsDevice);

            SpriteLayer.CollisionLayer = new CollisionLayer(this);
            SpriteLayer.GameOverLayer  = new GameOverLayer(this);
            SpriteLayer.YouWinLayer    = new YouWinLayer(this);
            SpriteLayer.HuDLayer       = new HuDLayer(this);

            this.Layers = new List <SpriteLayer>();

            //Ideally, the layers are drawn in this order
            this.Layers.Add(SpriteLayer.BackgroundLayer);
            this.Layers.Add(SpriteLayer.CollisionLayer);
            this.Layers.Add(SpriteLayer.GameOverLayer);
            this.Layers.Add(SpriteLayer.YouWinLayer);
            this.Layers.Add(SpriteLayer.HuDLayer);

            LevelLoader.LoadLevel(this, LEVEL);

            SpriteLayer.CollisionLayer.AddSprite(this.Mario = SpriteFactory.CreateMario(this));

            this.backgroundSong     = Content.Load <Song>("Music/background");
            this.invincibleSong     = Content.Load <Song>("Music/invincible");
            this.spedBackgroundSong = Content.Load <Song>("Music/spedbackground");
            MediaPlayer.Play(this.backgroundSong);
            MediaPlayer.IsRepeating = true;
            MediaPlayer.Volume      = 0.3f;

            pointGenerator = new PointTextGenerator(this);
        }
Beispiel #25
0
        void ReloadLevel()
        {
            Manager_Battle.SelectedWeaponManager.UnscribeFromGlobalEvents();
            Manager_Battle.UnscribeFromGlobalevents();

            LevelLoader.LoadLevel(UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex);
        }
 private void Update()
 {
     if (videoPlayer.time / 1 + 1 >= videoPlayer.clip.length)
     {
         StartCoroutine(levelLoader.LoadLevel(timeScale: timeScale));
     }
 }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        // при срабатывание тригера проверяется тег , если нож попал в бревно
        // - нож становится дочерним объектом бревна
        // - создается система частиц
        // - уничтожается компонент у ножа ,что бы не выполнять лишний  update

        if (collision.tag == "Log")
        {
            transform.SetParent(collision.transform);

            GameObject particle = Instantiate(shavings, transform.position + new Vector3(0, 1.2f), Quaternion.identity);
            Destroy(particle, 5f);

            speed = 0;
            collision.GetComponent <LogRotate>().CountKnife();
            Destroy(kc);
        }
        else if (collision.tag == "Knife")
        {
            // Удаление ножа и загрузка нового уровня

            Destroy(gameObject);
            LevelLoader levelLoader = new LevelLoader();
            levelLoader.LoadLevel(1);
        }
    }
Beispiel #28
0
    // return current level
    public float newPoints(float XP, float currentLevel, float XPgained)
    {
        //if your current points is higher than those required to level up
        if (XPgained >= (pointsReqdForNextLevel(XP)))
        {
            // get the next level
            float newlevel = ++currentLevel;

            // what to do if this is the final level
            if (newlevel == 4)
            {
                ll.LoadLevel("EndGame");
                return(newlevel);
            }
            else
            {
                // start next scene
                StartCoroutine(UIManager.Instance.NewLevel(newlevel));
                string strlevel = newlevel.ToString();
                StartCoroutine(ll.LoadNextLevel(strlevel));
                return(newlevel);
            }
        }

        else
        {
            return(currentLevel);
        }
    }
Beispiel #29
0
    void LoadMap(string path)
    {
        try
        {
            if (File.Exists(path))
            {
                FileStream fStream = File.Open(path, FileMode.Open, System.IO.FileAccess.Read);

                //Deserialize from xml
                DataContractSerializer serializer = new DataContractSerializer(typeof(CompleteLevel), null, 1000, false, true, null);
                CompleteLevel          cl         = serializer.ReadObject(fStream) as CompleteLevel;
                fStream.Close();

                List <SerializableTile> temp = cl.MapTiles;
                foreach (SerializableTile item in temp)
                {
                    Tile tempTile = new Tile(item.Index, levelLoader.tileIndexer[item.Index].Obj, item.Name, item.Rotation, item.Layer, item.X, item.Y, item.Dimensions, item.Category);
                    levelTiles.Add(new CombinedTile(tempTile, null));
                }

                levelLoader.LoadLevel(levelTiles);

                Debug.Log("Loaded " + path);
            }
        }
        catch (System.Exception ex)
        {
            Debug.Log("Failure during loading the level. Error: " + ex);
            ReturnToMenu("Failure during loading the level. Error: " + ex);
        }
    }
Beispiel #30
0
 public GameController(string levelName, string levelString, string namesFileContent)
     : this()
 {
     this.levelName = levelName;
     level          = LevelLoader.LoadLevel(levelString);
     CharName.BuildCache(namesFileContent);
 }
        /// <summary>
        /// Gets all the variables in the level ready for play.
        /// </summary>
        public void Initialize()
        {
            GRID_SCALE = 1.0f;

            Tiles = new List<Tile>();
            selectedTile = null;

            ActivateLevel();

            #region Testing
            /*
            // Add a Tile to the Grid
            GridPiece gp1 = new GridPiece();
            GridPiece gp2 = new GridPiece();
            GridPiece gp3 = new GridPiece();

            Grid[1, 6].PutInPiece(gp1);
            Grid[1, 7].PutInPiece(gp2);
            Grid[0, 7].PutInPiece(gp3);

            gp3.AddHitBox(new HitBox((int)(gp3.gSlot.Position.X + 50), (int)(gp3.gSlot.Position.Y + 100), 200, 50, 0));

            Tile t = new Tile(this);

            t.Add(gp1);
            t.Add(gp2);
            t.Add(gp3);

            Tiles.Add(t);

            // Add a second tile to test further
            GridPiece gp4 = new GridPiece();
            GridPiece gp5 = new GridPiece();

            Grid[3, 3].PutInPiece(gp4);
            Grid[3, 2].PutInPiece(gp5);

            Tile t2 = new Tile(this);

            t2.Add(gp4);
            t2.Add(gp5);

            Tiles.Add(t2);

            // Add a third Tile to test even further
            GridPiece gp6 = new GridPiece();
            GridPiece gp7 = new GridPiece();
            GridPiece gp8 = new GridPiece();
            GridPiece gp9 = new GridPiece();

            Grid[12, 4].PutInPiece(gp6);
            Grid[12, 5].PutInPiece(gp7);
            Grid[12, 6].PutInPiece(gp8);
            Grid[12, 7].PutInPiece(gp9);

            Tile t3 = new Tile(this);

            t3.Add(gp6);
            t3.Add(gp7);
            t3.Add(gp8);
            t3.Add(gp9);

            Tiles.Add(t3);
             * */
            #endregion

            // LoadLevel testing
            LevelLoader loader = new LevelLoader("1-1.xml", Content, this);
            loader.LoadLevel();

            SetGridStart(GRID_DEFAULT_X, GRID_DEFAULT_Y);
        }