// Start is called before the first frame update void Start() { LoadChestData(); buttonE.SetActive(false); anim = GetComponent <Animator>(); gameResources = GameObject.FindGameObjectWithTag("Player").GetComponent <GameResourcesCounter>(); }
void Start() { inventory = GameObject.FindGameObjectWithTag("PlayerCanvas").GetComponent <Inventory>(); resourcesCounter = GetComponent <GameResourcesCounter>(); anim = GetComponent <Animator>(); rigidbody2d = GetComponent <Rigidbody2D>(); LoadPlayer(); currentHealth = HealthPlayer; inventoryPanel.gameObject.SetActive(false); }
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(); }
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; }
private void Start() { gameResources = GameObject.FindGameObjectWithTag("Player").GetComponent <GameResourcesCounter>(); }