Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        // Set the screen size
        GetComponent <CanvasScaler>().referenceResolution = ScreenData.GetScreenSize();

        // Initialize Components
        graphicRaycaster = GetComponent <GraphicRaycaster>();

        int creation = SaveClass.GetPlayerPrefInt(SaveClass.Save_Keys.Key_Level_Editor_Creation);

        if (creation == 1)
        {
            RefTileMap.CreateNew(SaveClass.GetPlayerPrefInt(SaveClass.Save_Keys.Key_Level_Editor_Row), SaveClass.GetPlayerPrefInt(SaveClass.Save_Keys.Key_Level_Editor_Col));
        }
        else if (creation == 0)
        {
            RefTileMap.Load(SaveClass.GetPlayerPrefString(SaveClass.Save_Keys.Key_Level));

            // Assign current values to editor UI
            MapName.text = RefTileMap.Name;
            var parameters = RefTileMap.ObjectiveParams.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries);
            RefObjectiveParam.text = parameters[0];
        }
        else
        {
            Application.LoadLevel("MainMenuScene");
        }
    }
Exemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        // Start the music
        SoundManager.PlayBackgroundMusic(SoundManager.BackgroundMusic.Battle_Music);

        // Load the the tilemap file
        GameTileMapReference.Load(SaveClass.GetPlayerPrefString(SaveClass.Save_Keys.Key_Level), 15);

        // Set up the objective
        setObjective();

        // Load Player Settings
        playerSetting = GetComponent <PlayerSettings>();
        playerSetting.Load();

        // Load weapons on player
        // Player 1
        RPGPlayer player = PlayerList[0];
        Weapon    weapon = null;

        // Left weapon
        weapon = Instantiate(LeftWeapons[SaveClass.GetPlayerPrefInt(SaveClass.Save_Keys.Key_Player1_Left)]);
        weapon.transform.parent     = player.transform;
        weapon.transform.position   = player.transform.position;
        weapon.transform.localScale = new Vector3(1, 1, 1);
        player.LeftWeapon           = weapon;
        // Right weapon
        weapon = Instantiate(RightWeapons[SaveClass.GetPlayerPrefInt(SaveClass.Save_Keys.Key_Player1_Right)]);
        weapon.transform.parent     = player.transform;
        weapon.transform.position   = player.transform.position;
        weapon.transform.localScale = new Vector3(1, 1, 1);
        player.RightWeapon          = weapon;
        // Load Skin
        player.PlayerSkin = playerSetting.CurrentFirstSkin;

        // Player 2
        player = PlayerList[1];
        // Left weapon
        weapon = Instantiate(LeftWeapons[SaveClass.GetPlayerPrefInt(SaveClass.Save_Keys.Key_Player2_Left)]);
        weapon.transform.parent     = player.transform;
        weapon.transform.position   = player.transform.position;
        weapon.transform.localScale = new Vector3(1, 1, 1);
        player.LeftWeapon           = weapon;
        // Right weapon
        weapon = Instantiate(RightWeapons[SaveClass.GetPlayerPrefInt(SaveClass.Save_Keys.Key_Player2_Right)]);
        weapon.transform.parent     = player.transform;
        weapon.transform.position   = player.transform.position;
        weapon.transform.localScale = new Vector3(1, 1, 1);
        player.RightWeapon          = weapon;
        // Load Skin
        // -- Special Case for Second Player as we don't want to override the default skin
        if (playerSetting.CurrentSecondSkin != null)
        {
            player.PlayerSkin = playerSetting.CurrentSecondSkin;
        }
    }
Exemplo n.º 3
0
    public void LoadLevelEditor()
    {
        string name = SaveClass.GetPlayerPrefString(SaveClass.Save_Keys.Key_Level);

        if (name == "")
        {
            return;
        }
        PlayerPrefs.SetInt(SaveClass.GetKey(SaveClass.Save_Keys.Key_Level_Editor_Creation), 0);
        Application.LoadLevel("NewLevelEditor");
    }
Exemplo n.º 4
0
    public void StartGame()
    {
        // Player 1 Left
        IEnumerator <Toggle> activeToggle = Player1Left.ActiveToggles().GetEnumerator();

        activeToggle.MoveNext();
        Toggle currentToggle = activeToggle.Current;

        PlayerPrefs.SetInt(SaveClass.GetKey(SaveClass.Save_Keys.Key_Player1_Left), (int)currentToggle.GetComponent <WeaponIdentifier>().Type);

        // Player 1 Right
        activeToggle = Player1Right.ActiveToggles().GetEnumerator();
        activeToggle.MoveNext();
        currentToggle = activeToggle.Current;
        PlayerPrefs.SetInt(SaveClass.GetKey(SaveClass.Save_Keys.Key_Player1_Right), (int)currentToggle.GetComponent <WeaponIdentifier>().Type);

        // Player 2 Left
        activeToggle = Player2Left.ActiveToggles().GetEnumerator();
        activeToggle.MoveNext();
        currentToggle = activeToggle.Current;
        PlayerPrefs.SetInt(SaveClass.GetKey(SaveClass.Save_Keys.Key_Player2_Left), (int)currentToggle.GetComponent <WeaponIdentifier>().Type);

        // Player 2 Right
        activeToggle = Player2Right.ActiveToggles().GetEnumerator();
        activeToggle.MoveNext();
        currentToggle = activeToggle.Current;
        PlayerPrefs.SetInt(SaveClass.GetKey(SaveClass.Save_Keys.Key_Player2_Right), (int)currentToggle.GetComponent <WeaponIdentifier>().Type);

        string name = SaveClass.GetPlayerPrefString(SaveClass.Save_Keys.Key_Level);

        if (name == "")
        {
            return;
        }
        Application.LoadLevel("GameScene");
    }
Exemplo n.º 5
0
 public static void SaveScore()
 {
     PlayerPrefs.SetInt(currentScoreKey, currentScore);
     PlayerPrefs.Save();
     HighScoreSystem.Instance.SendScore(new ScoreEntry(SaveClass.GetPlayerPrefString(SaveClass.Save_Keys.Key_Name), currentScore));
 }
Exemplo n.º 6
0
 // Update is called once per frame
 void Update()
 {
     MapName.text = SaveClass.GetPlayerPrefString(SaveClass.Save_Keys.Key_Level);
 }
Exemplo n.º 7
0
 public void Load(int id)
 {
     SkinSpriteUrl = SaveClass.GetPlayerPrefString(SaveClass.Save_Keys.Key_Skin_URL, "_" + id);
     Load();
 }