Finished upgrader
This commit is contained in:
parent
42fa9de511
commit
325cf8e7bc
|
@ -181,7 +181,7 @@ MonoBehaviour:
|
|||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 10913, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_Type: 0
|
||||
m_Type: 3
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
|
@ -256,7 +256,7 @@ MonoBehaviour:
|
|||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 10913, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_Type: 0
|
||||
m_Type: 3
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
|
@ -741,7 +741,7 @@ MonoBehaviour:
|
|||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 10913, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_Type: 0
|
||||
m_Type: 3
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
|
@ -1031,7 +1031,7 @@ MonoBehaviour:
|
|||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 10913, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_Type: 0
|
||||
m_Type: 3
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
|
@ -1278,7 +1278,7 @@ MonoBehaviour:
|
|||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 10913, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_Type: 0
|
||||
m_Type: 3
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
|
@ -1479,7 +1479,7 @@ GameObject:
|
|||
- component: {fileID: 1197965564}
|
||||
- component: {fileID: 1197965566}
|
||||
m_Layer: 5
|
||||
m_Name: UpgradeMenu
|
||||
m_Name: MenuForUpgrades
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
|
@ -1527,7 +1527,7 @@ MonoBehaviour:
|
|||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 0.392}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
|
@ -1535,7 +1535,7 @@ MonoBehaviour:
|
|||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 10913, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_Type: 0
|
||||
m_Type: 3
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
|
@ -1942,7 +1942,7 @@ MonoBehaviour:
|
|||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 10913, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_Type: 0
|
||||
m_Type: 3
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
|
@ -2117,7 +2117,7 @@ MonoBehaviour:
|
|||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 10913, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_Type: 0
|
||||
m_Type: 3
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
|
@ -2236,7 +2236,7 @@ MonoBehaviour:
|
|||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 10913, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_Type: 0
|
||||
m_Type: 3
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine;
|
||||
|
||||
public class Upgrade
|
||||
|
@ -35,10 +36,11 @@ public class Upgrader : MonoBehaviour
|
|||
|
||||
public float mopSizeIncrease = 1.1f;
|
||||
public float speedIncrease = 1.1f;
|
||||
public int ropeIncrease = 2;
|
||||
public float ropeIncrease = 1.1f;
|
||||
public float healthIncrease = 1.1f;
|
||||
public float damageIncrease = 1.1f;
|
||||
public float bloodIncrease = 1.1f;
|
||||
public float reelIncrease = 1.1f;
|
||||
|
||||
public int upgradeCost = 10000;
|
||||
|
||||
|
@ -50,6 +52,10 @@ public class Upgrader : MonoBehaviour
|
|||
|
||||
private float acceptTime = 0f;
|
||||
|
||||
private Image background;
|
||||
|
||||
private Image[] upgradeImages = new Image[8];
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
@ -58,11 +64,41 @@ public class Upgrader : MonoBehaviour
|
|||
|
||||
Player1Input = player1.GetComponent<PlayerInput>();
|
||||
Player2Input = player2.GetComponent<PlayerInput>();
|
||||
|
||||
background = GetComponent<Image>();
|
||||
|
||||
int idx = 0;
|
||||
|
||||
foreach (Image i in GetComponentsInChildren<Image>())
|
||||
{
|
||||
if (i.gameObject.name.StartsWith("Upgrade"))
|
||||
upgradeImages[idx++] = i;
|
||||
}
|
||||
|
||||
// Debug.Log("Found " + idx + " upgrades");
|
||||
|
||||
upgrades = new Upgrades();
|
||||
}
|
||||
|
||||
bool canUpgrade()
|
||||
{
|
||||
return bloodManager.score >= upgradeCost;
|
||||
// return bloodManager.score >= upgradeCost;
|
||||
return true;
|
||||
}
|
||||
|
||||
int getRegion(float x, float y, int regions)
|
||||
{
|
||||
if (x + y == 0)
|
||||
return -1;
|
||||
|
||||
float angle = Mathf.Atan2(x, -y) + Mathf.PI;
|
||||
float regionSize = (Mathf.PI * 2.0f) / ((float)regions);
|
||||
int region = (int)((((Mathf.PI * 2.0f) - angle) / regionSize) + 0.5f);
|
||||
|
||||
if (region > regions - 1)
|
||||
return 0;
|
||||
|
||||
return region;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
|
@ -70,10 +106,13 @@ public class Upgrader : MonoBehaviour
|
|||
{
|
||||
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)
|
||||
int p1a = getRegion(Player1Input.look.x, Player1Input.look.y, 8);
|
||||
int p2a = getRegion(Player2Input.look.x, Player2Input.look.y, 8);
|
||||
|
||||
Debug.Log(p1a);
|
||||
|
||||
if (p1a != -1 && p2a == p1a)
|
||||
{
|
||||
if (acceptTime > 2f)
|
||||
{
|
||||
|
@ -95,7 +134,7 @@ public class Upgrader : MonoBehaviour
|
|||
DamageUpgrade();
|
||||
break;
|
||||
case 5:
|
||||
BloodUpgrade();
|
||||
BloodUpgrade();
|
||||
break;
|
||||
case 6:
|
||||
ReelUpgrade();
|
||||
|
@ -108,10 +147,30 @@ public class Upgrader : MonoBehaviour
|
|||
acceptTime = 0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
acceptTime += Time.deltaTime;
|
||||
|
||||
foreach (Image i in upgradeImages)
|
||||
{
|
||||
i.fillAmount = 1f;
|
||||
}
|
||||
|
||||
upgradeImages[p1a].fillAmount = acceptTime / 2f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (acceptTime > 0f)
|
||||
{
|
||||
foreach (Image i in upgradeImages)
|
||||
{
|
||||
i.fillAmount = 1f;
|
||||
}
|
||||
}
|
||||
|
||||
acceptTime = 0f;
|
||||
// background.fillAmount = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
Player1Cursor.localPosition = Player1Input.look.normalized * (125 - 12);
|
||||
|
@ -136,6 +195,7 @@ public class Upgrader : MonoBehaviour
|
|||
public void RopeUpgrade()
|
||||
{
|
||||
// todo: public methods
|
||||
rope.ropeMaxLength *= ropeIncrease;
|
||||
upgrades.ropeUpgrade.amount++;
|
||||
}
|
||||
|
||||
|
@ -152,6 +212,7 @@ public class Upgrader : MonoBehaviour
|
|||
public void DamageUpgrade()
|
||||
{
|
||||
// todo: public rope methods
|
||||
// rope.da
|
||||
upgrades.damageUpgrade.amount++;
|
||||
}
|
||||
|
||||
|
@ -164,6 +225,7 @@ public class Upgrader : MonoBehaviour
|
|||
public void ReelUpgrade()
|
||||
{
|
||||
// todo rope methods
|
||||
rope.ropeExtendSpeed *= reelIncrease;
|
||||
upgrades.reelUpgrade.amount++;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue