Example #1
0
    /*      *** End of Fields ***     */


    // Start is called before the first frame update
    void Start()
    {
        isPlayingOnMobile      = Application.isMobilePlatform;                 //Checking if the player is playing on mobile
        player_Rigidbody       = player_GameObject.GetComponent <Rigidbody>(); //Getting reference to the player's rigidbody component
        player_Speed           = 8f;                                           //Setting the player's default speed
        player_ControlsEnabled = true;                                         //Enabling Player Controls
        Debug.Log("Time to Complete Level: " + Level_Info.getCurrLevelTimeToComplete());
        timeRemaining = Level_Info.getCurrLevelTimeToComplete();
        isGameOver    = false;
        isGamePaused  = false;
    }
Example #2
0
 public void CreateAlllevel()//加载关卡数据
 {
     for (int i = 0; i < level_Data_All.Count; i++)
     {
         Resources_Management.Instance.Load <GameObject>("UI/Level", level_create, (LevelToggle) =>
         {
             level_All.Add(LevelToggle);
             LevelToggle.GetComponent <Toggle>().group = levelItemGroup;
             Level_Info info = LevelToggle.GetComponent <Level_Info>();
             info.Namedata(this.level_Data_All[i]);
         });
     }
 }
Example #3
0
    public void Applying_Settings(GameObject settings)
    {
        Level_Info l_info = settings.GetComponentInChildren <Level_Info>();

        Level_Info.map_size_height         = int.Parse(settings.GetComponentInChildren <Map_Height>().GetComponentInChildren <Text>().text);
        Level_Info.map_size_width          = int.Parse(settings.GetComponentInChildren <Map_Width>().GetComponentInChildren <Text>().text);
        Level_Info.hydrolocator_radius     = int.Parse(settings.GetComponentInChildren <Hydrolocator_Radius>().GetComponentInChildren <Text>().text);
        Level_Info.hydrolocator_amounts    = int.Parse(settings.GetComponentInChildren <Hydrolocator_Amounts>().GetComponentInChildren <Text>().text);
        Level_Info.treasure_chests_amounts = int.Parse(settings.GetComponentInChildren <Treasure_Chests_Amounts>().GetComponentInChildren <Text>().text);

        GameObject info = settings.GetComponentInChildren <Info>().gameObject;

        info.GetComponentInChildren <Map_Height>().GetComponentInChildren <Text>().text              = Level_Info.map_size_height.ToString();
        info.GetComponentInChildren <Map_Width>().GetComponentInChildren <Text>().text               = Level_Info.map_size_width.ToString();
        info.GetComponentInChildren <Hydrolocator_Radius>().GetComponentInChildren <Text>().text     = Level_Info.hydrolocator_radius.ToString();
        info.GetComponentInChildren <Hydrolocator_Amounts>().GetComponentInChildren <Text>().text    = Level_Info.hydrolocator_amounts.ToString();
        info.GetComponentInChildren <Treasure_Chests_Amounts>().GetComponentInChildren <Text>().text = Level_Info.treasure_chests_amounts.ToString();
    }
Example #4
0
    /*
     *  Handles when the collision between the player and a trigger
     *
     */
    private void OnTriggerEnter(Collider other)
    {
        //Checking if the GameObject the Player Collided with was a collectable
        if (other.gameObject.CompareTag("collectable"))
        {
            other.gameObject.SetActive(false); //Hidding the object that the player came in contact
            playerScore++;                     //Incrementing the players score
            updatePlayerScore();

            //Checking if the player has reached the max score for this level
            if (playerScore >= maxScore)
            {
                if (Level_Info.loadNextLevel() == -1)
                {
                    playerInstruction_Text.text = "You win";
                    Player_Controls.isGameOver  = true; //This allows the player to keep moving around the final level
                }
            }
        }
    }
Example #5
0
    // Start is called before the first frame update
    void Start()
    {
        //Getting the highest score the player can get for this level
        maxScore = Level_Info.getCurrLevelMaxScore();

        //Checking if a message needs to be displayed
        string levelMessage = Level_Info.getCurrLevelMessage();

        if (levelMessage != null)
        {
            playerInstruction_Text.text = levelMessage;
        }
        else
        {
            playerInstruction_Text.text = "";    //Displaying nothing in the message area text
        }

        Debug.Log("Current Scene Name: " + Level_Info.getCurrentSceneName());
        Debug.Log("The max score for this level is " + maxScore);
    }
Example #6
0
    public void SaveLevel()
    {
        Level_Data Level = Level_Data.Level_Info.GetComponent<Level_Data>();

        BinaryFormatter bf = new BinaryFormatter();
        FileStream file = File.Create(Application.persistentDataPath + "LevelInfo.dat");

        Level_Info NewLevel = new Level_Info();

        NewLevel.m_fSpawn_Intervial = Level.m_fSpawn_Intervial;
        NewLevel.m_fSpawn_Timer = Level.m_fSpawn_Timer;
        NewLevel.m_iAmount_Enemy_Spawn = Level.m_iAmount_Enemy_Spawn;
        NewLevel.m_iEnemy_Level = Level.m_iEnemy_Level;

        bf.Serialize(file, NewLevel);
        file.Close();
    }