예제 #1
0
 // Start is called before the first frame update
 void Start()
 {
     LoadChestData();
     buttonE.SetActive(false);
     anim          = GetComponent <Animator>();
     gameResources = GameObject.FindGameObjectWithTag("Player").GetComponent <GameResourcesCounter>();
 }
예제 #2
0
 void Start()
 {
     inventory        = GameObject.FindGameObjectWithTag("PlayerCanvas").GetComponent <Inventory>();
     resourcesCounter = GetComponent <GameResourcesCounter>();
     anim             = GetComponent <Animator>();
     rigidbody2d      = GetComponent <Rigidbody2D>();
     LoadPlayer();
     currentHealth = HealthPlayer;
     inventoryPanel.gameObject.SetActive(false);
 }
예제 #3
0
    public static void SavePlayer(PlayerController player, GameResourcesCounter gameResources)
    {
        BinaryFormatter formatter = new BinaryFormatter();

        string     path   = Application.persistentDataPath + "/player.data";
        FileStream stream = new FileStream(path, FileMode.Create);

        PlayerData data = new PlayerData(player, gameResources);

        formatter.Serialize(stream, data);
        stream.Close();
    }
예제 #4
0
    public PlayerData(PlayerController player, GameResourcesCounter gameResources)
    {
        health = player.HealthPlayer;

        GoldCount  = gameResources.gold;
        WoodCount  = gameResources.wood;
        StoneCount = gameResources.stone;

        position    = new float[3];
        position[0] = player.transform.position.x;
        position[1] = player.transform.position.y;
        position[2] = player.transform.position.z;
    }
예제 #5
0
 private void Start()
 {
     gameResources = GameObject.FindGameObjectWithTag("Player").GetComponent <GameResourcesCounter>();
 }