Esempio n. 1
0
    /*
     * セーブデータを読み込む
     */
    public void Load()
    {
        bool is_shown_map = (SceneManager.GetActiveScene().name == "SimpleMapping");

        if (PlayerPrefs.HasKey("mappedPosList"))
        {
            if (this.mapped.transform.childCount > 0)
            {
                foreach (Transform child in this.mapped.transform)
                {
                    GameObject.Destroy(child.gameObject);
                }
            }
            Vector3[]    posList   = PlayerPrefsX.GetVector3Array("mappedPosList");
            Quaternion[] rotList   = PlayerPrefsX.GetQuaternionArray("mappedRotList");
            Vector3[]    scaleList = PlayerPrefsX.GetVector3Array("mappedScaleList");
            for (int i = 0; i < posList.Length; i++)
            {
                GameObject obj = Object.Instantiate(this.originBox) as GameObject;
                obj.transform.position   = posList[i];
                obj.transform.rotation   = rotList[i];
                obj.transform.localScale = scaleList[i];
                obj.transform.parent     = this.mapped.transform;
                obj.GetComponent <Renderer>().enabled = is_shown_map;
            }
        }
        else
        {
            //セーブデータがない場合,何もしない
        }
    }
Esempio n. 2
0
    public void Load()
    {
        StopAllCoroutines();
        Vector3[] monsterLocations = PlayerPrefsX.GetVector3Array("monsterLocations");
        int[]     monsterTypes     = PlayerPrefsX.GetIntArray("monsterTypes");
        if (monsterLocations != null && monsterTypes != null)
        {
            foreach (Transform child in transform)
            {
                GameObject.Destroy(child.gameObject);
            }

            for (int i = 0; i < monsterLocations.Length; i++)
            {
                int     monsterType    = monsterTypes[i];
                Vector3 targetLocation = monsterLocations[i];

                GameObject   monsterPrefab = monsterPrefabs[monsterType];
                MonsterMover mover         = monsterPrefab.GetComponent <MonsterMover>();

                InstantiateMonster(monsterPrefab, mover, targetLocation, monsterType);
            }
        }
        StartCoroutine(Respawn());
    }
Esempio n. 3
0
    private void StartFromCheckpoint()
    {
        if (PlayerPrefs.GetString("mpName", "NA") == "NA")
        {
            transform.position = LoadPositionFromPrefs();
        }
        else
        {
            string     name         = PlayerPrefs.GetString("mpName");
            Vector3[]  platformsPos = PlayerPrefsX.GetVector3Array("platformsPosArray");
            GameObject correctPM    = null;
            var        pms          = FindObjectsOfType <PlatformMover>();
            for (int i = 0; i < pms.Length; i++)
            {
                var pm = pms[i];
                pm.LoadWithPos(platformsPos[i]);
                if (pm.name == name)
                {
                    correctPM = pm.gameObject;
                }
            }

            //gameObject.transform.SetParent(correctPM.transform);
            var pos = new Vector2(correctPM.transform.position.x, correctPM.transform.position.y + placementOffset);
            transform.position = pos;
        }
    }
Esempio n. 4
0
    public static int LoadTheGame(int loadSlot) //should be 1-4
    {
        //check if load exists, if not doesn't load the game
        if (PlayerPrefsX.GetVector3("respawn" + loadSlot) == null)
        {
            return(-1); //failure
        }
        plants.Clear();
        loadedSlot = loadSlot;
        //LOADS THE GAME
        SceneManager.LoadScene(PlayerPrefs.GetString("activeScene" + loadSlot));

        //change update player next respawn
        spawnLocation         = PlayerPrefsX.GetVector3("respawn" + loadSlot);
        Globals.player.health = PlayerPrefs.GetInt("playerHealth" + loadSlot);
        inventory             = PlayerPrefsX.GetIntArray("playerInventory" + loadSlot);
        print(inventory);

        PlayerPrefsX.GetBool("lavaBossBeaten" + loadSlot, lavaBossBeaten);
        PlayerPrefsX.GetBool("windBossBeaten" + loadSlot, windBossBeaten);
        PlayerPrefsX.GetBool("caveBossBeaten" + loadSlot, caveBossBeaten);

        Vector3[] tempPlantPositions  = PlayerPrefsX.GetVector3Array("PlantPositions" + loadSlot);
        int[]     tempPlantTypes      = PlayerPrefsX.GetIntArray("PlantTypes" + loadSlot);
        String[]  tempPlantScenes     = PlayerPrefsX.GetStringArray("PlantScenes" + loadSlot);
        int[]     tempPlantDirections = PlayerPrefsX.GetIntArray("PlantDirections" + loadSlot);


        for (int i = 0; i < tempPlantDirections.Length; i++)
        {
            plants.Add(new PlantData(tempPlantPositions[i], tempPlantScenes[i], (Direction)tempPlantDirections[i]), tempPlantTypes[i]);
        }

        return(1); //success
    }
    /// <summary>
    /// Get list position from ArrayPrefs.
    /// </summary>
    /// <returns></returns>
    public List <Vector3> GetVec3List( )
    {
        Vector3[]      arr  = PlayerPrefsX.GetVector3Array(PlayerPrefsKeys.POSITION.ToString( ));
        List <Vector3> list = new List <Vector3>();

        list.AddRange(arr);
        return(list);
    }
Esempio n. 6
0
    private void Start()
    {
        var anArray = PlayerPrefsX.GetVector3Array("VectorsArray");

        target.AddRange(anArray);
        foreach (var vector in target)
        {
            points.Add(Instantiate(point, vector, Quaternion.identity));
        }
        gameObject.transform.position = PlayerPrefsX.GetVector3("position", transform.position);
    }
Esempio n. 7
0
    IEnumerator delayStart()
    {
        //wait until evertyhing loads
        yield return(new WaitForSeconds(1f));

        //When we load the application we want to load our position and rotation
        if (PlayerPrefsX.GetVector3Array(this.gameObject.name + "PaintPos") != null)
        {
            // print("data found");
            this.GetComponent <LineRenderer>().SetPositions(PlayerPrefsX.GetVector3Array(this.gameObject.name + "PaintPos"));
        }
    }
Esempio n. 8
0
    public void LoadBalls(string saveName)
    {
        ClearBalls();

        ballPosTemp.AddRange(PlayerPrefsX.GetVector3Array(saveName + "balls"));

        for (int i = 0; i < ballPosTemp.Count; i++)
        {
            CreateBall(ballPosTemp [i]);
        }
        ballPosTemp.Clear();
    }
Esempio n. 9
0
 /*
  * セーブデータを読み込む
  */
 public static void Load(GameObject parent)
 {
     if (PlayerPrefs.HasKey("mappedPosList"))
     {
         Vector3[] posList = PlayerPrefsX.GetVector3Array("mappedPosList");
         for (int i = 0; i < posList.Length; i++)
         {
             FingerMapper.MarkPoint(parent, posList[i]);
         }
         Debug.Log("Loaded mappedPosList");
     }
 }
Esempio n. 10
0
    private void ActivateCoinFromArr(List <GameObject> coin_lst, string prefix, float mass)
    {
        if (PlayerPrefs.HasKey(prefix + "Count"))
        {
            int coinCount = PlayerPrefs.GetInt(prefix + "Count");
            if (coinCount > 0)
            {
                Vector3[]    positions = PlayerPrefsX.GetVector3Array(prefix + "Position");
                Quaternion[] rotations = PlayerPrefsX.GetQuaternionArray(prefix + "Quaternion");
                string[]     names     = PlayerPrefsX.GetStringArray(prefix + "Name");

                for (int i = 0; i < coin_lst.Count; ++i)
                {
                    if (i < coinCount)
                    {
                        if (!coin_lst[i].activeInHierarchy)
                        {
                            coin_lst[i].SetActive(true);
                        }
                        coin_lst[i].GetComponent <Rigidbody>().freezeRotation = false;
                        coin_lst[i].GetComponent <Rigidbody>().mass           = mass;
                        coin_lst[i].transform.rotation = rotations[i];
                        coin_lst[i].transform.position = positions[i];
                        coin_lst[i].name             = names[i];
                        coin_lst[i].transform.parent = coin_parent;
                        coin_lst[i].GetComponent <CoinScript>().isLanded   = false;
                        coin_lst[i].GetComponent <CoinScript>().giantShake = true;
                        coin_lst[i].GetComponent <CoinScript>().enabled    = false;
                    }
                    else
                    {
                        if (coin_lst[i].activeInHierarchy)
                        {
                            coin_lst[i].GetComponent <CoinScript>().enabled = false;
                            coin_lst[i].SetActive(false);
                            coin_lst[i].GetComponent <Rigidbody>().freezeRotation = true; //////////////////////// Freeze Rotation
                        }
                    }
                }
            }
        }
    }
Esempio n. 11
0
 public void LoadGifts()
 {
     if (PlayerPrefs.HasKey("GiftCount"))
     {
         int giftCount = PlayerPrefs.GetInt("GiftCount");
         if (giftCount > 0)
         {
             //				Quaternion[] gift_rotation  = PlayerPrefsX.GetQuaternionArray("GiftQuaternion");
             Vector3[] gift_position = PlayerPrefsX.GetVector3Array("GiftPosition");
             string[]  gift_name     = PlayerPrefsX.GetStringArray("GiftName");
             for (int i = 0; i < giftCount; i++)
             {
                 GameObject newGift = GetGift(gift_name[i]);
                 Debug.Log(" sdasd     asdsadsdss          " + gift_name[i]);
                 newGift.SetActive(true);
                 giftsOnPlatform.Add(newGift);
             }
         }
     }
 }
Esempio n. 12
0
    public static unitoken[] LoadUnitokens()
    {
        transientPositions = PlayerPrefsX.GetVector3Array(keys[0]);
        unitokenLabels     = PlayerPrefsX.GetStringArray(keys[1]);

        //if(rngLoad)
        //Random.InitState(42);

        unitoken[] loadedTokens = new unitoken[transientPositions.Length];

        for (int i = 0; i < loadedTokens.Length; i++)
        {
            unitoken newToken = new unitoken();
            newToken.Label             = unitokenLabels[i];
            newToken.TransientPosition = transientPositions[i] + new Vector3(0, 0, Random.Range(-1.0f, 1.0f));
            //newToken.Initialize(unitokenLabels[i],transientPositions[i]);

            loadedTokens[i] = newToken;
        }
        return(loadedTokens);
    }
Esempio n. 13
0
 public void LoadGiftsRev2(List <GameObject> objects, string prefix)
 {
     if (PlayerPrefs.HasKey(prefix + "Count"))
     {
         int count = PlayerPrefs.GetInt(prefix + "Count");
         if (count > 0)
         {
             Quaternion[] rotations = PlayerPrefsX.GetQuaternionArray(prefix + "Quaternion");
             Vector3[]    positions = PlayerPrefsX.GetVector3Array(prefix + "Position");
             string[]     names     = PlayerPrefsX.GetStringArray(prefix + "Name");
             for (int i = 0; i < count; i++)
             {
                 GameObject gobject = GetInActiveObject(objects);
                 gobject.transform.rotation = rotations[i];
                 gobject.transform.position = positions[i];
                 gobject.name = names[i];
                 gobject.SetActive(true);
                 Debug.Log(gobject.name);
             }
         }
     }
 }
 /// <summary>
 /// Get data in ArrayPrefs for delete.
 /// </summary>
 /// <param name="playerPrefsKey"></param>
 /// <param name="type"></param>
 /// <param name="color"></param>
 /// <param name="index"></param>
 private void Del_Filter(string playerPrefsKey, KeyType type, ColorType color, int index)
 {
     if (type == KeyType.INT && color == ColorType.NULL)
     {
         int[] arr = PlayerPrefsX.GetIntArray(playerPrefsKey);
         Del(playerPrefsKey, arr, index);
     }
     else if (type == KeyType.STRING && color == ColorType.NULL)
     {
         string[] arr = PlayerPrefsX.GetStringArray(playerPrefsKey);
         Del(playerPrefsKey, arr, index);
     }
     else if (type == KeyType.VECTOR3 && color == ColorType.NULL)
     {
         Vector3[] arr = PlayerPrefsX.GetVector3Array(playerPrefsKey);
         Del(playerPrefsKey, arr, index);
     }
     else if (type == KeyType.COLOR && color != ColorType.NULL)
     {
         Color[] arr = PlayerPrefsX.GetColorArray(playerPrefsKey);
         Del(playerPrefsKey, arr, color, index);
     }
 }