示例#1
0
    void OnEnable()
    {
        if (gameData == null)
        {
            gameData = gameObject.GetComponent <Game_Data>();
        }

        if (gameInputController == null)
        {
            gameInputController = gameObject.GetComponent <Game_Input_Contoller>();
        }

        if (p1WinSprite == null)
        {
            p1WinSprite = p1WinSprite.gameObject.transform.GetChild(0).gameObject;
        }

        if (p2WinSprite == null)
        {
            p2WinSprite = p2WinSprite.gameObject.transform.GetChild(1).gameObject;
        }

        gameData.playerPoints[0] = 0;
        gameData.playerPoints[1] = 0;

        StartCoroutine(CreatePlayer(0, new Vector3(-7, 1, 0), 0));
        StartCoroutine(CreatePlayer(1, new Vector3(7, 1, 0), 0));
    }
示例#2
0
    public void LoadVar(Game_Data data)
    {
        data.g_scene       = g_scene;
        data.g_HP          = g_HP;
        data.g_MP          = g_MP;
        data.g_totalSkills = g_totalSkills;
        data.g_equipSkill  = g_equipSkill;

        data.g_posX = g_posX;
        data.g_posY = g_posY;

        data.g_keys = g_keys;

        data.g_clear [0] = g_clear [0];
        data.g_clear [1] = g_clear [1];
        data.g_clear [2] = g_clear [2];


        data.g_totalPuzzle = g_totalPuzzle;
        data.g_puzzleState = new bool[data.g_totalPuzzle];

        for (int i = 0; i < data.g_puzzleState.Length; i++)
        {
            data.g_puzzleState[i] = g_puzzleState[i];
        }
    }
示例#3
0
    public IEnumerator Upload_Data(Game_Data gd)
    {
        yield return(new WaitForEndOfFrame());

        WWWForm wwwform = new WWWForm();

        wwwform.AddField("Phone", gd.Phone);
        wwwform.AddField("FName", gd.FName);
        wwwform.AddField("LName", gd.LName);
        wwwform.AddField("Email", gd.Email);
        wwwform.AddField("File_Name", gd.File_Name);
        wwwform.AddBinaryData("Upload_File", Take_Photo(), "myphoto.png", "image/png");
        WWW w = new WWW(url, wwwform);

        yield return(w);

        if (!string.IsNullOrEmpty(w.error))
        {
            print(w.error);
        }
        else
        {
            print("File sent succesfully!");
        }
    }
示例#4
0
    void OnEnable()
    {
        if (playerData == null)
        {
            playerData = gameObject.GetComponent <Player_Data>();
        }

        if (gameData == null)
        {
            gameData = GameObject.Find("Game Controller").GetComponent <Game_Data>();
        }

        if (balloonRB2D == null)
        {
            balloonRB2D = gameObject.transform.GetChild(0).GetComponent <Rigidbody2D>();
        }

        if (pointsAnimator == null)
        {
            pointsAnimator = gameObject.transform.GetChild(0).gameObject.GetComponentInChildren <Animator>();
        }

        previousHits = playerData.hits;

        UpdatePointsAnimation();

        //subscription to the hit
        Ballon_Hit_Detective.BalloonWasHit += MonitorHealth;
    }
示例#5
0
    bool[] g_puzzleState;     //Trạng thái của n puzzle trong màn chơi hiện tại.
    //Đối với puzzle chính, chỉ áp dụng khi g_clear[i] = false.

    public DataSave(Game_Data data)
    {
        g_scene       = data.g_scene;
        g_HP          = data.g_HP;
        g_MP          = data.g_MP;
        g_totalSkills = data.g_totalSkills;
        g_equipSkill  = data.g_equipSkill;

        g_posX = data.g_posX;
        g_posY = data.g_posY;

        g_keys = data.g_keys;

        g_clear[0] = data.g_clear[0];
        g_clear[1] = data.g_clear[1];
        g_clear[2] = data.g_clear[2];


        g_totalPuzzle = data.g_totalPuzzle;
        g_puzzleState = new bool[g_totalPuzzle];

        for (int i = 0; i < g_totalPuzzle; i++)
        {
            g_puzzleState[i] = data.g_puzzleState[i];
        }
    }
示例#6
0
    public static void Save(Game_Data data)
    {
        BinaryFormatter bf     = new BinaryFormatter();
        FileStream      stream = new FileStream(Application.persistentDataPath + "/data.sav", FileMode.Create);
        DataSave        dt     = new DataSave(data);

        bf.Serialize(stream, dt);
        stream.Close();
    }
    public static void saveData(Game_Data Game_Data)
    {
        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Application.persistentDataPath + "/gameData.Sav"; // sets save path relative to correct base destination
        FileStream      stream    = new FileStream(path, FileMode.Create);

        saveFile File = new saveFile(Game_Data);  // creates a new save file using current game data as input for the file

        formatter.Serialize(stream, File);
        stream.Close();
    }
示例#8
0
    public saveFile(Game_Data Game_Data)   // constructor stores values from the game_data input
    {
        //CoreStats
        playerlevel = Game_Data.playerlevel;
        playerMoney = Game_Data.playerMoney;
        currentXP   = Game_Data.currentXP;
        targetXP    = Game_Data.targetXP;
        highScore   = Game_Data.highScore;

        //Tracking Stats
        totalEnemiesDestroyed = Game_Data.totalEnemiesDestroyed;
        totalScore            = Game_Data.totalScore;
        totalGamesPlayed      = Game_Data.totalGamesPlayed;
        totalXP         = Game_Data.totalXP;
        totalHighScores = Game_Data.totalHighScores;

        //Settings Options
        gameVolume = Game_Data.gameVolume;

        //Endless progress
        completedEndlessLevel1 = Game_Data.completedEndlessLevel1;
        completedEndlessLevel2 = Game_Data.completedEndlessLevel2;
        completedEndlessLevel3 = Game_Data.completedEndlessLevel3;
        completedEndlessLevel4 = Game_Data.completedEndlessLevel4;
        completedEndlessLevel5 = Game_Data.completedEndlessLevel5;

        //Survival progress
        completedSurvivalLevel1 = Game_Data.completedSurvivalLevel1;
        completedSurvivalLevel2 = Game_Data.completedSurvivalLevel2;
        completedSurvivalLevel3 = Game_Data.completedSurvivalLevel3;
        completedSurvivalLevel4 = Game_Data.completedSurvivalLevel4;
        completedSurvivalLevel5 = Game_Data.completedSurvivalLevel5;

        //Elimination progress
        completedEliminationLevel1 = Game_Data.completedEliminationLevel1;
        completedEliminationLevel2 = Game_Data.completedEliminationLevel2;
        completedEliminationLevel3 = Game_Data.completedEliminationLevel3;
        completedEliminationLevel4 = Game_Data.completedEliminationLevel4;
        completedEliminationLevel5 = Game_Data.completedEliminationLevel5;

        //Skin Unlocks
        skin1Unlocked  = Game_Data.skin1Unlocked;
        skin2Unlocked  = Game_Data.skin2Unlocked;
        skin3Unlocked  = Game_Data.skin3Unlocked;
        skin4Unlocked  = Game_Data.skin4Unlocked;
        skin5Unlocked  = Game_Data.skin5Unlocked;
        skin6Unlocked  = Game_Data.skin6Unlocked;
        skin7Unlocked  = Game_Data.skin7Unlocked;
        skin8Unlocked  = Game_Data.skin8Unlocked;
        skin9Unlocked  = Game_Data.skin9Unlocked;
        skin10Unlocked = Game_Data.skin10Unlocked;
        skinCount      = Game_Data.skinCount;
        skinOfChoice   = Game_Data.skinOfChoice;
    }
    void Awake()
    {
        gameData = null;
        gameData = new Game_Data ();
        gameData.Reset ();

        gameSaver = null;
        gameSaver = new Game_Saver ("GameSlots.txt");

        debugState = false;
    }
示例#10
0
    public static bool Load(Game_Data data)
    {
        if (File.Exists(Application.persistentDataPath + "/data.sav"))
        {
            BinaryFormatter bf     = new BinaryFormatter();
            FileStream      stream = new FileStream(Application.persistentDataPath + "/data.sav", FileMode.Open);

            DataSave dt = bf.Deserialize(stream) as DataSave;
            dt.LoadVar(data);
            stream.Close();
            return(true);
        }
        return(false);
    }
示例#11
0
 public Player_Local(T_Player_Local player, Game_Data data)
 {
     user_id        = player.user_id;
     map            = data.maps[player.map_id];
     ship           = data.ships_players[player.ship_id];
     ammunition     = data.ammunitions[player.ammunition_id];
     nickname       = player.nickname;
     hitpoints      = player.hitpoints;
     shields        = player.shields;
     level          = player.level;
     position       = new Vector3((float)player.position_x, (float)player.position_y, 0);
     scrap          = player.scrap;
     credits        = player.credits;
     experience     = player.experience;
     ranking_points = player.ranking_points;
     model          = null;
 }
示例#12
0
    public void GetDataFromSave(Game_Data saveTemp)
    {
        sceneID    = saveTemp.g_scene;
        isCleared  = saveTemp.g_clear[sceneID];
        puzzleList = new bool[saveTemp.g_totalPuzzle];
        Keys       = saveTemp.g_keys;

        for (int i = 0; i < puzzleList.Length; i++)
        {
            puzzleList[i] = saveTemp.g_puzzleState[i];
        }

        //Player Related Data
        if (player != null)
        {
            totalSkills   = saveTemp.g_totalSkills;
            skillEquipped = saveTemp.g_equipSkill;

            player.transform.position = new Vector2(saveTemp.g_posX, saveTemp.g_posY);
            player.GetComponent <PlayerControl>().HP = saveTemp.g_HP;
            player.GetComponent <PlayerControl>().MP = saveTemp.g_MP;
        }
    }
示例#13
0
    public void LoadDataToSave(Game_Data saveTemp)
    {
        saveTemp.g_scene          = sceneID;
        saveTemp.g_keys           = Keys;
        saveTemp.g_clear[sceneID] = isCleared;
        saveTemp.g_totalPuzzle    = puzzleList.Length;
        saveTemp.g_puzzleState    = new bool[puzzleList.Length];

        for (int i = 0; i < saveTemp.g_puzzleState.Length; i++)
        {
            saveTemp.g_puzzleState[i] = puzzleList[i];
        }

        //Player Related Data
        if (player != null)
        {
            saveTemp.g_totalSkills = totalSkills;
            saveTemp.g_equipSkill  = skillEquipped;
            saveTemp.g_posX        = player.transform.position.x;
            saveTemp.g_posY        = player.transform.position.y;
            saveTemp.g_HP          = player.GetComponent <PlayerControl>().HP;
            saveTemp.g_MP          = player.GetComponent <PlayerControl>().MP;
        }
    }
示例#14
0
 // Start is called before the first frame update
 void Start()
 {
     gameData = GameObject.FindWithTag("Game Data").GetComponent <Game_Data>();
 }
 // Start is called before the first frame update
 void Start()
 {
     gameData = GameObject.FindWithTag("Game Data").GetComponent <Game_Data>();
     gameObject.GetComponent <SpriteRenderer>().material = gameData.playerSkins[gameData.skinOfChoice - 1];     // sets player material to currently saved user selection stored in game data
     clickOverwrite = GameObject.FindWithTag("Game Data").GetComponent <Game_Data>().mouseMode;
 }
示例#16
0
 // Start is called before the first frame update
 void Start()
 {
     InvokeRepeating("OnceASecond", 1.0f, 1.0f);
     gameData        = GameObject.FindWithTag("Game Data").GetComponent <Game_Data>();
     scoreMultiplier = 1;
 }
    public Game_Data GetSavedData(int index)
    {
        Game_Data retValue = new Game_Data();

        reader = new StreamReader (GAME_SLOT_PATH);

        string tmp = "";
        string token = "";

        int x = 0;

        for (int i = 0; i < index; i++)
        {
            tmp = reader.ReadLine ();
        }

        if(tmp[0] != '0')
        {
            //-----ACTO---------------------------------------
            token = "" + tmp[0];

            if (!Int32.TryParse(token, out x)) { x = ParseBrute1(token); }

            retValue.act = x;

            //-----PROGRESO-----------------------------------
            token = "" + tmp[2] + tmp[3];

            if (!Int32.TryParse(token, out x)){ x = ParseBrute2(token); }

            retValue.progress = x;

            //-----LAST SCENE---------------------------------
            token = "" + tmp[5];

            if (!Int32.TryParse(token, out x)){ x = ParseBrute1("" + tmp[5]); }

            retValue.last_scene = x;

            //-----ITEMS--------------------------------------
            for(int j = 7; j < 23; j+=3)//7, 10, 13, 16, 19, 22
            {
                token = "" + tmp[(3*j) + 7] + tmp[(3*j) + 8];

                retValue.objectList[j] = retValue.ItemFromStr(token);
            }
        }

        reader.Close ();

        Debug.Log (retValue);

        return retValue;
    }
    public void SaveProgress(Game_Data data)
    {
        string tmp;
        string[] lines = {"", "", ""};

        reader = new StreamReader (GAME_SLOT_PATH);

        for(int i = 0; i < 3; i++)
        {
            lines[i] = reader.ReadLine();

            if(current_slot + 1 == i)
            {
                tmp = data.act + ":";

                if(data.progress < 10) tmp += "0";

                tmp += data.progress + ":" + data.last_scene + ":";

                for (int j = 0; j < data.MAX_ITEMS - 1; j++)
                {
                    tmp += data.ItemNumString(data.objectList[i]) + ",";
                }

                tmp += data.ItemNumString(data.objectList[data.MAX_ITEMS - 1]);

                lines[i] = tmp;
            }
        }

        System.IO.File.WriteAllLines(GAME_SLOT_PATH, lines);
    }
    void Start()  // Start is called before the first frame update
    {
        gameData = GameObject.FindWithTag("Game Data").GetComponent <Game_Data>();

        refreshUIElements();
    }
 private void Awake()
 {
     testSingleton();
     gameData = GameObject.FindWithTag("Game Data").GetComponent <Game_Data>();
 }