Ajout Consumable
This commit is contained in:
parent
80704e1ba3
commit
16248cdf16
6 changed files with 220 additions and 11 deletions
|
@ -136,6 +136,7 @@ GameObject:
|
||||||
- component: {fileID: 107140167}
|
- component: {fileID: 107140167}
|
||||||
- component: {fileID: 107140166}
|
- component: {fileID: 107140166}
|
||||||
- component: {fileID: 107140169}
|
- component: {fileID: 107140169}
|
||||||
|
- component: {fileID: 107140170}
|
||||||
m_Layer: 8
|
m_Layer: 8
|
||||||
m_Name: Oldman
|
m_Name: Oldman
|
||||||
m_TagString: Client
|
m_TagString: Client
|
||||||
|
@ -254,6 +255,20 @@ BoxCollider2D:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Size: {x: 0.44506907, y: 0.50397205}
|
m_Size: {x: 0.44506907, y: 0.50397205}
|
||||||
m_EdgeRadius: 0
|
m_EdgeRadius: 0
|
||||||
|
--- !u!114 &107140170
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 107140165}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 2dfbc8fb0a162ab4da4ff5cb76650e03, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
consumeTime: 3
|
||||||
|
waitingTime: 10
|
||||||
--- !u!1 &519420028
|
--- !u!1 &519420028
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -351,7 +366,7 @@ GameObject:
|
||||||
- component: {fileID: 698542428}
|
- component: {fileID: 698542428}
|
||||||
m_Layer: 8
|
m_Layer: 8
|
||||||
m_Name: Chicken
|
m_Name: Chicken
|
||||||
m_TagString: Grabable
|
m_TagString: Mug
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
|
@ -460,7 +475,130 @@ MonoBehaviour:
|
||||||
m_Script: {fileID: 11500000, guid: 06f2e18c7d91f7f4d99cd5e5c7d12b45, type: 3}
|
m_Script: {fileID: 11500000, guid: 06f2e18c7d91f7f4d99cd5e5c7d12b45, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
|
size: 2
|
||||||
|
--- !u!1 &1163880821
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 1163880824}
|
||||||
|
- component: {fileID: 1163880823}
|
||||||
|
- component: {fileID: 1163880825}
|
||||||
|
- component: {fileID: 1163880822}
|
||||||
|
m_Layer: 8
|
||||||
|
m_Name: Mug
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!114 &1163880822
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1163880821}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 06f2e18c7d91f7f4d99cd5e5c7d12b45, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
size: 1
|
size: 1
|
||||||
|
--- !u!212 &1163880823
|
||||||
|
SpriteRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1163880821}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_CastShadows: 0
|
||||||
|
m_ReceiveShadows: 0
|
||||||
|
m_DynamicOccludee: 1
|
||||||
|
m_MotionVectors: 1
|
||||||
|
m_LightProbeUsage: 1
|
||||||
|
m_ReflectionProbeUsage: 1
|
||||||
|
m_RayTracingMode: 0
|
||||||
|
m_RayTraceProcedural: 0
|
||||||
|
m_RenderingLayerMask: 1
|
||||||
|
m_RendererPriority: 0
|
||||||
|
m_Materials:
|
||||||
|
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
|
m_StaticBatchInfo:
|
||||||
|
firstSubMesh: 0
|
||||||
|
subMeshCount: 0
|
||||||
|
m_StaticBatchRoot: {fileID: 0}
|
||||||
|
m_ProbeAnchor: {fileID: 0}
|
||||||
|
m_LightProbeVolumeOverride: {fileID: 0}
|
||||||
|
m_ScaleInLightmap: 1
|
||||||
|
m_ReceiveGI: 1
|
||||||
|
m_PreserveUVs: 0
|
||||||
|
m_IgnoreNormalsForChartDetection: 0
|
||||||
|
m_ImportantGI: 0
|
||||||
|
m_StitchLightmapSeams: 1
|
||||||
|
m_SelectedEditorRenderState: 0
|
||||||
|
m_MinimumChartSize: 4
|
||||||
|
m_AutoUVMaxDistance: 0.5
|
||||||
|
m_AutoUVMaxAngle: 89
|
||||||
|
m_LightmapParameters: {fileID: 0}
|
||||||
|
m_SortingLayerID: 0
|
||||||
|
m_SortingLayer: 0
|
||||||
|
m_SortingOrder: 0
|
||||||
|
m_Sprite: {fileID: 21300000, guid: 17d59b2d4d882c04480a40119a442279, type: 3}
|
||||||
|
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
m_FlipX: 0
|
||||||
|
m_FlipY: 0
|
||||||
|
m_DrawMode: 0
|
||||||
|
m_Size: {x: 0.25, y: 0.25}
|
||||||
|
m_AdaptiveModeThreshold: 0.5
|
||||||
|
m_SpriteTileMode: 0
|
||||||
|
m_WasSpriteAssigned: 1
|
||||||
|
m_MaskInteraction: 0
|
||||||
|
m_SpriteSortPoint: 0
|
||||||
|
--- !u!4 &1163880824
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1163880821}
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: -0.04852522, y: -0.33456293, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_RootOrder: 4
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!61 &1163880825
|
||||||
|
BoxCollider2D:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1163880821}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_Density: 1
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_IsTrigger: 1
|
||||||
|
m_UsedByEffector: 0
|
||||||
|
m_UsedByComposite: 0
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
m_SpriteTilingProperty:
|
||||||
|
border: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
pivot: {x: 0.5, y: 0.5}
|
||||||
|
oldSize: {x: 0.25, y: 0.25}
|
||||||
|
newSize: {x: 0.25, y: 0.25}
|
||||||
|
adaptiveTilingThreshold: 0.5
|
||||||
|
drawMode: 0
|
||||||
|
adaptiveTiling: 0
|
||||||
|
m_AutoTiling: 0
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Size: {x: 0.25, y: 0.25}
|
||||||
|
m_EdgeRadius: 0
|
||||||
--- !u!1001 &5841415791122168402
|
--- !u!1001 &5841415791122168402
|
||||||
PrefabInstance:
|
PrefabInstance:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
|
@ -9,13 +9,22 @@ public class Client_controller : MonoBehaviour
|
||||||
public float waitingTime = 10.0f; //Patience after ordering
|
public float waitingTime = 10.0f; //Patience after ordering
|
||||||
GameObject currentMug;
|
GameObject currentMug;
|
||||||
|
|
||||||
public bool use(GameObject new_mug)
|
public bool use(GameObject object_used)
|
||||||
{
|
{
|
||||||
if(new_mug != null && new_mug.tag=="Mug")
|
if(object_used != null && object_used.tag=="Mug")
|
||||||
{
|
{
|
||||||
Debug.Log(gameObject.name+" take "+new_mug.name);
|
Mug mug = object_used.GetComponent<Mug>();
|
||||||
currentMug = new_mug;
|
if (mug.content != null)
|
||||||
return true; //Object taken from tavernkeeper
|
{
|
||||||
|
Debug.Log(gameObject.name+" take "+object_used.name+ " of "+mug.content.Type);
|
||||||
|
currentMug = object_used;
|
||||||
|
return true; //Object taken from tavernkeeper
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.Log("Display order (or something else) of "+gameObject.name);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
43
Assets/Scripts/Consumable.cs
Normal file
43
Assets/Scripts/Consumable.cs
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
|
||||||
|
//Represents consumable : sprite and informations
|
||||||
|
public class Consumable //: MonoBehaviour
|
||||||
|
{
|
||||||
|
private HashSet<string> allowed_types = new HashSet<string>(new [] {"beer", "pression", "vodka"});
|
||||||
|
private string _type;
|
||||||
|
private int _value;
|
||||||
|
private Sprite _sprite;
|
||||||
|
|
||||||
|
//Read-only accessors
|
||||||
|
public string Type
|
||||||
|
{
|
||||||
|
get{ return _type;}
|
||||||
|
// set{}
|
||||||
|
}
|
||||||
|
public int Value
|
||||||
|
{
|
||||||
|
get{ return _value;}
|
||||||
|
// set{}
|
||||||
|
}
|
||||||
|
public Sprite Sprite
|
||||||
|
{
|
||||||
|
get{ return _sprite;}
|
||||||
|
// set{}
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO : Handle sprite = null
|
||||||
|
public Consumable(string type, int value, Sprite sprite)
|
||||||
|
{
|
||||||
|
if(!allowed_types.Contains(type))
|
||||||
|
{
|
||||||
|
throw new Exception("Invalid consumable type :"+type);
|
||||||
|
}
|
||||||
|
_type=type;
|
||||||
|
_value=value;
|
||||||
|
_sprite=sprite;
|
||||||
|
}
|
||||||
|
}
|
11
Assets/Scripts/Consumable.cs.meta
Normal file
11
Assets/Scripts/Consumable.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9c77f9c8f1c84464ab5cd7c2f07e14ad
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -6,8 +6,8 @@ using UnityEngine;
|
||||||
public class Mug : MonoBehaviour, IGrabable
|
public class Mug : MonoBehaviour, IGrabable
|
||||||
{
|
{
|
||||||
public int size = 1; //Size (1 or 2 hands) of the object
|
public int size = 1; //Size (1 or 2 hands) of the object
|
||||||
bool dirty = false;
|
// bool dirty = false;
|
||||||
int content = 1;
|
public Consumable content= null; //new Consumable("beer",1,null);
|
||||||
|
|
||||||
public void use()
|
public void use()
|
||||||
{
|
{
|
||||||
|
@ -23,13 +23,20 @@ public class Mug : MonoBehaviour, IGrabable
|
||||||
gameObject.transform.position = position;
|
gameObject.transform.position = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fill(int new_content)
|
public void fill(Consumable new_content)
|
||||||
{
|
{
|
||||||
content = new_content;
|
if(content is null)
|
||||||
|
{
|
||||||
|
content = new_content;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.Log(gameObject.name+" cannot be filled (already full) with "+new_content.Type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public void consume()
|
public void consume()
|
||||||
{
|
{
|
||||||
content=0;
|
content=null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
|
|
|
@ -6,6 +6,7 @@ TagManager:
|
||||||
tags:
|
tags:
|
||||||
- Client
|
- Client
|
||||||
- Grabable
|
- Grabable
|
||||||
|
- Mug
|
||||||
layers:
|
layers:
|
||||||
- Default
|
- Default
|
||||||
- TransparentFX
|
- TransparentFX
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue