Open
Description
using System;
using System.Collections.Generic;
using UnityEngine;
public class PlayerManager : MonoBehaviour
{
[HideInInspector]
public List collectedFood;
private GameManager _GameManager;
private CanvasUiManager _CanvasUiManager;
public float cashCollectAnimDuration, moneySpriteAnimSpeed, moneySpriteScaleAnimDuration;
public int moneyUiVibrate;
public Vector3 scaleValue;
public GameObject moneySprite;
public Transform moneyUiPos;
private bool canAnimate = true;
private void Start()
{
_CanvasUiManager = FindObjectOfType<CanvasUiManager>();
_GameManager = FindObjectOfType<GameManager>();
}
}
public class MonoBehaviour
{
}
internal class _CanvasUiManager
{
}
private void OnTriggerStay(Collider other)
{
if (other.gameObject.CompareTag("Table"))
{
Table table = other.GetComponent<Table>();
print("Check");
if (table.isFull)
{
int i = -1;
for (int k = collectedFood.Count - 1; k >= 0; k--)
{
if (!table.isFoodDelivered)
{
i++;
if (collectedFood[k].foodName == table.orderedFoodName)
{
collectedFood[k].PayCash(table.tableTopTramsform);
FindObjectOfType<AudioManager>().Play("FoodServe");
table.isFoodDelivered = true;
collectedFood.Remove(collectedFood[k]);
for (int j = k; j < collectedFood.Count; j++)
{
collectedFood[j].DownYPose();
}
break;
}
}
}
}
}
}
private void print(global::System.String v)
{
}
Tweener tweener;
public PlayerManager()
{
}
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("BuyPoint"))
{
print("BuyPointEnter");
other.GetComponent<BuyPoint>().StartSpend();
}
if (other.gameObject.CompareTag("Money"))
{
other.gameObject.tag = "Untagged";
FindObjectOfType<AudioManager>().Play("MoneyCollect");
other.transform.DOMove(transform.position, cashCollectAnimDuration)
.OnComplete(delegate ()
{
Destroy(other.gameObject);
Vector3 pos = Camera.main.WorldToScreenPoint(transform.position);
GameObject moneySp = Instantiate(moneySprite, pos, Quaternion.Euler(0, 0, 0));
moneySp.transform.parent = _CanvasUiManager.transform;
tweener = moneySp.transform.DOMove(moneyUiPos.position, moneySpriteAnimSpeed)
.OnComplete(delegate ()
{
_GameManager.AddMoney(2);
print("Money");
if (canAnimate)
{
canAnimate = false;
moneyUiPos.DOPunchScale(scaleValue, moneySpriteScaleAnimDuration, moneyUiVibrate)
.OnComplete(delegate ()
{
canAnimate = true;
});
}
Destroy(moneySp);
});
});
}
if (other.gameObject.CompareTag("WaiterSpawner"))
{
other.GetComponent<WaiterSpawner>().buyWaiterMenu.SetActive(true);
other.GetComponent<WaiterSpawner>().CheckButtonActive();
}
}
private void OnTriggerExit(Collider other)
{
if (other.gameObject.CompareTag("BuyPoint")) ;
other.GetComponent<BuyPoint>().StopSpend();
if (other.gameObject.CompareTag("WaiterSpawner"))
other.GetComponent<WaiterSpawner>().buyWaiterMenu.SetActive(false);
}
}
public PlayerManager()
{
}