Ressources

Catégorie scripts.

Le panda anti Adblock

playerSkills.cs

Script pour l'utilisation des points de compétence
Copier
								
									
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class playerSkills : MonoBehaviour {

    public GameObject UIpannel;
    public Text pointsText;

    public int availablePoints;
    public string openKey;

    private bool isOpen;
    private PlayerInventory playerinv;

	// Use this for initialization
	void Start () {
        playerinv = gameObject.GetComponent< PlayerInventory>();
	}
	
	// Update is called once per frame
	void Update () {
        if (Input.GetKeyDown(openKey)) {
            isOpen = !isOpen;
        }

        if (isOpen) {
            pointsText.text = "Points disponibles : "+availablePoints;
            UIpannel.SetActive(true);
        }
        else
        {
            UIpannel.SetActive(false);
        }
	}

    public void addHealthMax(float amountHp)
    {
        if (availablePoints >= 1) {
            playerinv.maxHealth += amountHp;
            playerinv.currentHealth += amountHp;
            availablePoints -= 1;
        }
    }

    public void addManaMax(float amountMana)
    {
        if (availablePoints >= 1)
        {
            playerinv.maxMana += amountMana;
            playerinv.currentMana += amountMana;
            availablePoints -= 1;
        }
    }
}