171 lines
4.8 KiB
C#
171 lines
4.8 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class Upgrade
|
|
{
|
|
public string name = "MT";
|
|
public int amount = 0;
|
|
|
|
public Upgrade(string n)
|
|
{
|
|
name = n;
|
|
}
|
|
}
|
|
public class Upgrades
|
|
{
|
|
public Upgrade mopUpgrade = new Upgrade("Mop Radius");
|
|
public Upgrade speedUpgrade = new Upgrade("Move speed");
|
|
public Upgrade ropeUpgrade = new Upgrade("Longer Rope");
|
|
public Upgrade healthUpgrade = new Upgrade("More health");
|
|
public Upgrade damageUpgrade = new Upgrade("More rope damage");
|
|
public Upgrade bloodUpgrade = new Upgrade("MORE BLOOD!");
|
|
public Upgrade reelUpgrade = new Upgrade("Faster rope reel speed");
|
|
}
|
|
|
|
public class Upgrader : MonoBehaviour
|
|
{
|
|
public GameObject player1;
|
|
public GameObject player2;
|
|
|
|
public BloodComputeShader bloodManager;
|
|
public RopeSimulator rope;
|
|
|
|
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 *= mopSizeIncrease;
|
|
upgrades.mopUpgrade.amount++;
|
|
}
|
|
|
|
/// Increases move speed by 10%
|
|
public void UpgradeSpeed()
|
|
{
|
|
player1.GetComponent<PlayerMovement>().moveSpeed *= speedIncrease;
|
|
player2.GetComponent<PlayerMovement>().moveSpeed *= speedIncrease;
|
|
upgrades.speedUpgrade.amount++;
|
|
}
|
|
|
|
public void RopeUpgrade()
|
|
{
|
|
// todo: public methods
|
|
upgrades.ropeUpgrade.amount++;
|
|
}
|
|
|
|
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++;
|
|
}
|
|
|
|
}
|