Exemple #1
0
    public void SetData()
    {
        Debug.Log("Set player data");
        //Set player health
        BarController player = GameObject.Find("Captain").GetComponent <BarController>();

        player.SetHealth(playerHealth);

        //Set Coins
        player.SetCoins(playerCoins);

        //Set Resources
        player.SetResources(playerResources);

        //Set Score
        player.SetScore(playerScore);

        //Set Crafting Cost
        player.craftingCost = playerCraftingCost;

        //Set key
        player.foundKey = playerKey;

        //Set Player Revived State
        player.SetPlayerRevived(playerRevived);

        //Set Extra Stats
        player.upgradedDamage  = playerUpgradedAttack;
        player.upgradedDefence = playerUpgradedDefence;
        player.upgradedHealth  = playerUpgradedHealth;
        player.upgradedSpeed   = playerUpgradedSpeed;

        //Set challenge counter
        player.challengeCounters = playerChallengeCounter;

        //Set Inventory
        PlayerInventory inventoryScript = GameObject.Find("Captain").GetComponent <PlayerInventory>();

        inventoryScript.slotID     = this.slotID;
        inventoryScript.slotValue  = this.slotValue;
        inventoryScript.slotName   = this.slotName;
        inventoryScript.slotDesc   = this.slotDesc;
        inventoryScript.slotSprite = this.slotSprite;
        inventoryScript.slotType   = this.slotType;
        inventoryScript.slotStack  = this.slotStack;
        //inventoryScript.slotIcon = this.slotIcon;
        for (int i = 0; i < playerInventory.Length; i++)
        {
            inventoryScript.slotIcon[i].sprite = inventoryScript.slotSprite[i];
            if (inventoryScript.slotIcon[i].sprite == null)
            {
                inventoryScript.slotIcon[i].sprite = inventoryScript.emptySlotSprite;
            }
            inventoryScript.EnableItem(playerInventory[i]);
        }

        //Set Villagers
        GameObject.Find("PickUpRange").GetComponent <PlayerInteract>().UnlockedVillagers = villageState;

        //Set Key
    }