First Reward system (Gold)
This commit is contained in:
parent
caf73dfc25
commit
998cc81e0a
5 changed files with 33 additions and 6 deletions
|
@ -7784,7 +7784,7 @@ MonoBehaviour:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
prepTime: 2
|
prepTime: 2
|
||||||
product_name: beer
|
product_name: beer
|
||||||
product_value: 1
|
product_value: 10
|
||||||
product_sprite: {fileID: 21300000, guid: 17d59b2d4d882c04480a40119a442279, type: 3}
|
product_sprite: {fileID: 21300000, guid: 17d59b2d4d882c04480a40119a442279, type: 3}
|
||||||
stock: 5
|
stock: 5
|
||||||
--- !u!61 &1165291009
|
--- !u!61 &1165291009
|
||||||
|
|
|
@ -82,13 +82,13 @@ public class Client_controller : MonoBehaviour, IUsable
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Log("Display order (or something else) of "+gameObject.name);
|
Debug.Log(gameObject.name+" doesn't want that");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Log("Display order (or something else) of "+gameObject.name);
|
Debug.Log(gameObject.name+" doesn't want that");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,11 @@ public class Client_controller : MonoBehaviour, IUsable
|
||||||
Mug obj = currentMug.GetComponent<Mug>();
|
Mug obj = currentMug.GetComponent<Mug>();
|
||||||
if(obj !=null)
|
if(obj !=null)
|
||||||
{
|
{
|
||||||
obj.consume();
|
//Reward
|
||||||
|
Consumable content = obj.consume();
|
||||||
|
int money = (int)(content.Value*(1.0f+waitTimer/waitingTime)); //Reward = value order + Tips (value * waitTime)
|
||||||
|
ClientManager.Instance.clientReward(money);
|
||||||
|
|
||||||
//Drop mug
|
//Drop mug
|
||||||
obj.drop(gameObject.transform.position+ (Vector3)Vector2.down * 0.2f);
|
obj.drop(gameObject.transform.position+ (Vector3)Vector2.down * 0.2f);
|
||||||
currentMug=null;
|
currentMug=null;
|
||||||
|
|
|
@ -6,7 +6,7 @@ using UnityEditor;
|
||||||
//Define the system managing the clients. (Singleton)
|
//Define the system managing the clients. (Singleton)
|
||||||
public sealed class ClientManager : MonoBehaviour
|
public sealed class ClientManager : MonoBehaviour
|
||||||
{
|
{
|
||||||
int nbMaxClients = 10;
|
int nbMaxClients = 1;
|
||||||
bool clientSpawnReady = false;
|
bool clientSpawnReady = false;
|
||||||
float clientSpawnTimer = 0.5f; //Intial time before first spawn (pseudo-random after that)
|
float clientSpawnTimer = 0.5f; //Intial time before first spawn (pseudo-random after that)
|
||||||
float maxTimeNewClients = 2.0f;
|
float maxTimeNewClients = 2.0f;
|
||||||
|
@ -40,6 +40,12 @@ public sealed class ClientManager : MonoBehaviour
|
||||||
return false; //No new client
|
return false; //No new client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: Reputation
|
||||||
|
public void clientReward(int money)
|
||||||
|
{
|
||||||
|
GameSystem.Instance.gold+=money;
|
||||||
|
}
|
||||||
|
|
||||||
//Destroy a client
|
//Destroy a client
|
||||||
public void clientLeave(GameObject client)
|
public void clientLeave(GameObject client)
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,6 +14,20 @@ public sealed class GameSystem : MonoBehaviour
|
||||||
float slowScale = 0.5f; //Default scale for slow mode
|
float slowScale = 0.5f; //Default scale for slow mode
|
||||||
private float fixedDeltaTime;
|
private float fixedDeltaTime;
|
||||||
|
|
||||||
|
//TODO : Effect on gold change
|
||||||
|
//Money
|
||||||
|
private int _gold;
|
||||||
|
public int gold
|
||||||
|
{
|
||||||
|
get{return _gold;}
|
||||||
|
set{
|
||||||
|
if(value<0)
|
||||||
|
value=0;
|
||||||
|
_gold = value;
|
||||||
|
Debug.Log("Gold : "+_gold);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void startService()
|
public void startService()
|
||||||
{
|
{
|
||||||
serviceTimer=serviceTime;
|
serviceTimer=serviceTime;
|
||||||
|
@ -71,6 +85,7 @@ public sealed class GameSystem : MonoBehaviour
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
startService();
|
startService();
|
||||||
|
gold=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
|
|
|
@ -43,10 +43,12 @@ public class Mug : MonoBehaviour, IGrabable
|
||||||
Debug.Log(gameObject.name+" cannot be filled (already full) with "+new_content.Type);
|
Debug.Log(gameObject.name+" cannot be filled (already full) with "+new_content.Type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void consume() //Empty Mug of its Consumable
|
public Consumable consume() //Return Mug content and empty it
|
||||||
{
|
{
|
||||||
|
Consumable output = content;
|
||||||
content=null;
|
content=null;
|
||||||
dirty = true; //Used and dirty
|
dirty = true; //Used and dirty
|
||||||
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue