Add Workshop (+tag)
This commit is contained in:
parent
16248cdf16
commit
538f05aa15
6 changed files with 114 additions and 15 deletions
|
@ -366,7 +366,7 @@ GameObject:
|
||||||
- component: {fileID: 698542428}
|
- component: {fileID: 698542428}
|
||||||
m_Layer: 8
|
m_Layer: 8
|
||||||
m_Name: Chicken
|
m_Name: Chicken
|
||||||
m_TagString: Mug
|
m_TagString: Workshop
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
|
@ -381,7 +381,7 @@ BoxCollider2D:
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
m_Density: 1
|
m_Density: 1
|
||||||
m_Material: {fileID: 0}
|
m_Material: {fileID: 0}
|
||||||
m_IsTrigger: 1
|
m_IsTrigger: 0
|
||||||
m_UsedByEffector: 0
|
m_UsedByEffector: 0
|
||||||
m_UsedByComposite: 0
|
m_UsedByComposite: 0
|
||||||
m_Offset: {x: -0.045565188, y: 0.14445162}
|
m_Offset: {x: -0.045565188, y: 0.14445162}
|
||||||
|
@ -472,10 +472,13 @@ MonoBehaviour:
|
||||||
m_GameObject: {fileID: 698542424}
|
m_GameObject: {fileID: 698542424}
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
m_EditorHideFlags: 0
|
m_EditorHideFlags: 0
|
||||||
m_Script: {fileID: 11500000, guid: 06f2e18c7d91f7f4d99cd5e5c7d12b45, type: 3}
|
m_Script: {fileID: 11500000, guid: 5e4020837a3c5214f90b5688a1e4faa2, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
size: 2
|
product_name: beer
|
||||||
|
product_value: 1
|
||||||
|
product_sprite: {fileID: 21300000, guid: 17d59b2d4d882c04480a40119a442279, type: 3}
|
||||||
|
prepTime: 2
|
||||||
--- !u!1 &1163880821
|
--- !u!1 &1163880821
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -490,7 +493,7 @@ GameObject:
|
||||||
- component: {fileID: 1163880822}
|
- component: {fileID: 1163880822}
|
||||||
m_Layer: 8
|
m_Layer: 8
|
||||||
m_Name: Mug
|
m_Name: Mug
|
||||||
m_TagString: Untagged
|
m_TagString: Mug
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
|
@ -611,6 +614,11 @@ PrefabInstance:
|
||||||
propertyPath: m_Name
|
propertyPath: m_Name
|
||||||
value: Tavernkeeper
|
value: Tavernkeeper
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 5841415790350674203, guid: dc287deb81f09d8419a5051e1d177e74,
|
||||||
|
type: 3}
|
||||||
|
propertyPath: m_TagString
|
||||||
|
value: Untagged
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 5841415790350674204, guid: dc287deb81f09d8419a5051e1d177e74,
|
- target: {fileID: 5841415790350674204, guid: dc287deb81f09d8419a5051e1d177e74,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_Constraints
|
propertyPath: m_Constraints
|
||||||
|
@ -671,5 +679,10 @@ PrefabInstance:
|
||||||
propertyPath: m_LocalEulerAnglesHint.z
|
propertyPath: m_LocalEulerAnglesHint.z
|
||||||
value: 0
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 5841415790350674207, guid: dc287deb81f09d8419a5051e1d177e74,
|
||||||
|
type: 3}
|
||||||
|
propertyPath: action_dist
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
m_RemovedComponents: []
|
m_RemovedComponents: []
|
||||||
m_SourcePrefab: {fileID: 100100000, guid: dc287deb81f09d8419a5051e1d177e74, type: 3}
|
m_SourcePrefab: {fileID: 100100000, guid: dc287deb81f09d8419a5051e1d177e74, type: 3}
|
||||||
|
|
|
@ -7,18 +7,21 @@ public class Client_controller : MonoBehaviour
|
||||||
{
|
{
|
||||||
public float consumeTime = 3.0f; //Time to consume currentMug
|
public float consumeTime = 3.0f; //Time to consume currentMug
|
||||||
public float waitingTime = 10.0f; //Patience after ordering
|
public float waitingTime = 10.0f; //Patience after ordering
|
||||||
GameObject currentMug;
|
GameObject currentMug = null;
|
||||||
|
|
||||||
|
//Return wether the object is taken from tavernkeeper
|
||||||
public bool use(GameObject object_used)
|
public bool use(GameObject object_used)
|
||||||
|
{
|
||||||
|
if(currentMug is null) //No mug in hand
|
||||||
{
|
{
|
||||||
if(object_used != null && object_used.tag=="Mug")
|
if(object_used != null && object_used.tag=="Mug")
|
||||||
{
|
{
|
||||||
Mug mug = object_used.GetComponent<Mug>();
|
Mug mug = object_used.GetComponent<Mug>();
|
||||||
if (mug.content != null)
|
if (mug!= null && mug.content != null)
|
||||||
{
|
{
|
||||||
Debug.Log(gameObject.name+" take "+object_used.name+ " of "+mug.content.Type);
|
Debug.Log(gameObject.name+" take "+object_used.name+ " of "+mug.content.Type);
|
||||||
currentMug = object_used;
|
currentMug = object_used;
|
||||||
return true; //Object taken from tavernkeeper
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -29,7 +32,13 @@ public class Client_controller : MonoBehaviour
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Log("Display order (or something else) of "+gameObject.name);
|
Debug.Log("Display order (or something else) of "+gameObject.name);
|
||||||
return false; //Object not taken from tavernkeeper
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.Log(gameObject.name+" already consumming "+currentMug.name);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,6 +80,7 @@ public class Tavernkeeper_controller : MonoBehaviour
|
||||||
}
|
}
|
||||||
|
|
||||||
//Handle action with hands
|
//Handle action with hands
|
||||||
|
//TODO : Factoriser actions des IGrabable et actions des Clients/Workshop
|
||||||
void handAction(string hand)
|
void handAction(string hand)
|
||||||
{
|
{
|
||||||
// Test collision of ray from tavernkeeper center (A verifier) at action_dist unit distance on Interactions layer
|
// Test collision of ray from tavernkeeper center (A verifier) at action_dist unit distance on Interactions layer
|
||||||
|
@ -119,6 +120,20 @@ public class Tavernkeeper_controller : MonoBehaviour
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(hit_object.tag == "Workshop")
|
||||||
|
{
|
||||||
|
// Debug.Log("Give "+ hand_container[hand].name+" to "+hit_object.name);
|
||||||
|
Workshop workshop = hit_object.GetComponent<Workshop>();
|
||||||
|
if(workshop!=null)
|
||||||
|
{
|
||||||
|
if(workshop.use(hand_container[hand])) //Interactions w/ object in hands
|
||||||
|
{
|
||||||
|
//Object taken by workshop
|
||||||
|
// Destroy(hand_container[hand]);
|
||||||
|
hand_container[hand]=null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Full hand : drop
|
//Full hand : drop
|
||||||
|
|
51
Assets/Scripts/Workshop.cs
Normal file
51
Assets/Scripts/Workshop.cs
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
[RequireComponent(typeof(Collider2D))]
|
||||||
|
public class Workshop : MonoBehaviour
|
||||||
|
{
|
||||||
|
public string product_name;
|
||||||
|
public int product_value;
|
||||||
|
public Sprite product_sprite;
|
||||||
|
public float prepTime = 2.0f;
|
||||||
|
protected int _stock = 5;
|
||||||
|
|
||||||
|
//Return wether the object is taken from tavernkeeper
|
||||||
|
public bool use(GameObject object_used)
|
||||||
|
{
|
||||||
|
if(object_used != null && object_used.tag=="Mug")
|
||||||
|
{
|
||||||
|
Mug mug = object_used.GetComponent<Mug>();
|
||||||
|
if (mug!= null && mug.content is null && _stock>0)
|
||||||
|
{
|
||||||
|
Debug.Log(gameObject.name+" fill "+object_used.name+ " with "+product_name);
|
||||||
|
mug.fill(new Consumable(product_name,product_value,product_sprite));
|
||||||
|
_stock--;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.Log(object_used.name+" cannot be filled with "+product_name+ " -stock:"+_stock);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.Log("Display order (or something else) of "+gameObject.name);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start is called before the first frame update
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
11
Assets/Scripts/Workshop.cs.meta
Normal file
11
Assets/Scripts/Workshop.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5e4020837a3c5214f90b5688a1e4faa2
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -5,8 +5,8 @@ TagManager:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
tags:
|
tags:
|
||||||
- Client
|
- Client
|
||||||
- Grabable
|
|
||||||
- Mug
|
- Mug
|
||||||
|
- Workshop
|
||||||
layers:
|
layers:
|
||||||
- Default
|
- Default
|
||||||
- TransparentFX
|
- TransparentFX
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue