36 lines
807 B
C#
36 lines
807 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public abstract class Upgrade : MonoBehaviour
|
|
{
|
|
[SerializeField]protected float[] cost;
|
|
[SerializeField]protected string upgradeName;
|
|
protected int lvlUnlocked;
|
|
[SerializeField]protected Sprite[] sprites;
|
|
[SerializeField]protected PlayerController player;
|
|
|
|
private void Start() {
|
|
lvlUnlocked = 0;
|
|
}
|
|
public float GetCost(){
|
|
return cost[lvlUnlocked];
|
|
}
|
|
|
|
public string GetName(){
|
|
return name;
|
|
}
|
|
|
|
public virtual void Activate(){
|
|
UpgradeAttempt();
|
|
}
|
|
|
|
protected bool UpgradeAttempt(){
|
|
if(lvlUnlocked < sprites.Length && player.OnUpgrade(this)){
|
|
lvlUnlocked++;
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|