Upgrader done

This commit is contained in:
SpoodyTheOne 2024-02-03 18:07:52 +01:00
parent 17be113edc
commit dd2733a506
4 changed files with 1146 additions and 10 deletions

File diff suppressed because it is too large Load Diff

View File

@ -21,8 +21,10 @@ public class BloodComputeShader : MonoBehaviour
public Material instancedMaterial;
public float size;
public float scoreMult = 1.0f;
public int activeParticles = 0;
public int score = 0;
public long score = 0;
public float squeakVolume = 0.0f;
public AudioSource squeakPlayer;
@ -145,7 +147,7 @@ public class BloodComputeShader : MonoBehaviour
activeParticles -= (int)bufferData[0];
score += (int)bufferData[0];
score += (int)(bufferData[0] * scoreMult);
squeakVolume += 0.1f;

View File

@ -22,6 +22,17 @@ public class HealthComponent : MonoBehaviour, ISquezeDamageReceiver
currentHealth = maxHealth;
}
public int getMaxHealth() {
return maxHealth;
}
public void setMaxHealth(int amount, bool heal = false) {
maxHealth = amount;
if (heal)
currentHealth = amount;
}
public void TakeDamage(int damage)
{
currentHealth -= damage;

View File

@ -33,35 +33,138 @@ public class Upgrader : MonoBehaviour
public Upgrades upgrades { get; private set; }
public float mopSizeIncrease = 1.1f;
public float speedIncrease = 1.1f;
public int ropeIncrease = 2;
public float healthIncrease = 1.1f;
public float damageIncrease = 1.1f;
public float bloodIncrease = 1.1f;
public int upgradeCost = 10000;
private RectTransform Player1Cursor;
private RectTransform Player2Cursor;
private PlayerInput Player1Input;
private PlayerInput Player2Input;
private float acceptTime = 0f;
// Start is called before the first frame update
void Start()
{
Player1Cursor = transform.Find("Player1 Cursor").GetComponent<RectTransform>();
Player2Cursor = transform.Find("Player2 Cursor").GetComponent<RectTransform>();
Player1Input = player1.GetComponent<PlayerInput>();
Player2Input = player2.GetComponent<PlayerInput>();
}
bool canUpgrade()
{
return bloodManager.score >= upgradeCost;
}
// Update is called once per frame
void Update()
{
if (canUpgrade())
{
int p1a = (int)((Mathf.Atan2(Player1Input.look.y, Player1Input.look.x) / Mathf.PI * 2) * 8);
int p2a = (int)((Mathf.Atan2(Player2Input.look.y, Player2Input.look.x) / Mathf.PI * 2) * 8);
if (p1a == p2a)
{
if (acceptTime > 2f)
{
switch (p1a)
{
case 0:
UpgradeMopSize();
break;
case 1:
UpgradeSpeed();
break;
case 2:
RopeUpgrade();
break;
case 3:
HealthUpgrade();
break;
case 4:
DamageUpgrade();
break;
case 5:
BloodUpgrade();
break;
case 6:
ReelUpgrade();
break;
case 7:
break;
}
bloodManager.score -= upgradeCost;
acceptTime = 0f;
}
else
acceptTime += Time.deltaTime;
}
else
acceptTime = 0f;
}
Player1Cursor.localPosition = Player1Input.look.normalized * (125 - 12);
Player2Cursor.localPosition = Player2Input.look.normalized * (125 - 12);
}
/// Increases mop radius by 10%
public void UpgradeMopSize()
{
bloodManager.CleanRadius *= 1.1f;
bloodManager.CleanRadius *= mopSizeIncrease;
upgrades.mopUpgrade.amount++;
}
/// Increases move speed by 10%
public void UpgradeSpeed()
{
player1.GetComponent<PlayerMovement>().moveSpeed *= 1.1f;
player2.GetComponent<PlayerMovement>().moveSpeed *= 1.1f;
player1.GetComponent<PlayerMovement>().moveSpeed *= speedIncrease;
player2.GetComponent<PlayerMovement>().moveSpeed *= speedIncrease;
upgrades.speedUpgrade.amount++;
}
public void RopeUpgrade() {
public void RopeUpgrade()
{
// todo: public methods
upgrades.ropeUpgrade.amount++;
}
// public void
public void HealthUpgrade()
{
var comp1 = player1.GetComponent<HealthComponent>();
comp1.setMaxHealth((int)(comp1.getMaxHealth() * healthIncrease));
var comp2 = player2.GetComponent<HealthComponent>();
comp2.setMaxHealth((int)(comp2.getMaxHealth() * healthIncrease));
upgrades.healthUpgrade.amount++;
}
public void DamageUpgrade()
{
// todo: public rope methods
upgrades.damageUpgrade.amount++;
}
public void BloodUpgrade()
{
bloodManager.scoreMult *= bloodIncrease;
upgrades.bloodUpgrade.amount++;
}
public void ReelUpgrade()
{
// todo rope methods
upgrades.reelUpgrade.amount++;
}
}