Add items, Pickup logic works
This commit is contained in:
72
Assets/SellingPedestal/EmptyCounter.cs
Normal file
72
Assets/SellingPedestal/EmptyCounter.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class EmptyCounter : MonoBehaviour, IObjectParentHolder {
|
||||
|
||||
[SerializeField] private ObjectSO _objectSo;
|
||||
[SerializeField] private Transform _counterObjectHandle;
|
||||
|
||||
[SerializeField] private bool _shouldSpawnOnInteract;
|
||||
|
||||
private Object _currentObject;
|
||||
|
||||
public void Interact() {
|
||||
InteractionBehaviour interactionBehaviour = PlayerController.Instance.InteractionBehaviour;
|
||||
if (_shouldSpawnOnInteract) {
|
||||
if (_currentObject == null) {
|
||||
Transform objectTransform = Instantiate(_objectSo.prefab, _counterObjectHandle);
|
||||
objectTransform.GetComponent<Object>().setObjectParent(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!HasObject()) {
|
||||
//No item on the counter
|
||||
//Check player if he has something
|
||||
if (interactionBehaviour.HasObject()) {
|
||||
Object obj = interactionBehaviour.GetObject();
|
||||
obj.setObjectParent(this);
|
||||
}
|
||||
else {
|
||||
//Player has no item
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
//Item on Counter
|
||||
//Check player if he has something
|
||||
if (interactionBehaviour.HasObject()) {
|
||||
//Player has something
|
||||
}
|
||||
else {
|
||||
//Player has nothing
|
||||
//Take the object
|
||||
GetObject().setObjectParent(interactionBehaviour);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public Transform GetHolderTransform() {
|
||||
return _counterObjectHandle;
|
||||
}
|
||||
|
||||
public void SetObject(Object obj) {
|
||||
this._currentObject = obj;
|
||||
}
|
||||
|
||||
public Object GetObject() {
|
||||
return this._currentObject;
|
||||
}
|
||||
|
||||
public void ClearObject() {
|
||||
this._currentObject = null;
|
||||
}
|
||||
|
||||
public bool HasObject() {
|
||||
return this._currentObject != null;
|
||||
}
|
||||
}
|
||||
11
Assets/SellingPedestal/EmptyCounter.cs.meta
Normal file
11
Assets/SellingPedestal/EmptyCounter.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 35dfc09c0e3a6ba4ca3dcdfba7193aff
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/SellingPedestal/Pedestal.blend
Normal file
BIN
Assets/SellingPedestal/Pedestal.blend
Normal file
Binary file not shown.
109
Assets/SellingPedestal/Pedestal.blend.meta
Normal file
109
Assets/SellingPedestal/Pedestal.blend.meta
Normal file
@@ -0,0 +1,109 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5cddd5128d0f0c745806cf1bcbe74416
|
||||
ModelImporter:
|
||||
serializedVersion: 22200
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
materials:
|
||||
materialImportMode: 2
|
||||
materialName: 0
|
||||
materialSearch: 1
|
||||
materialLocation: 1
|
||||
animations:
|
||||
legacyGenerateAnimations: 4
|
||||
bakeSimulation: 0
|
||||
resampleCurves: 1
|
||||
optimizeGameObjects: 0
|
||||
removeConstantScaleCurves: 0
|
||||
motionNodeName:
|
||||
rigImportErrors:
|
||||
rigImportWarnings:
|
||||
animationImportErrors:
|
||||
animationImportWarnings:
|
||||
animationRetargetingWarnings:
|
||||
animationDoRetargetingWarnings: 0
|
||||
importAnimatedCustomProperties: 0
|
||||
importConstraints: 0
|
||||
animationCompression: 1
|
||||
animationRotationError: 0.5
|
||||
animationPositionError: 0.5
|
||||
animationScaleError: 0.5
|
||||
animationWrapMode: 0
|
||||
extraExposedTransformPaths: []
|
||||
extraUserProperties: []
|
||||
clipAnimations: []
|
||||
isReadable: 0
|
||||
meshes:
|
||||
lODScreenPercentages: []
|
||||
globalScale: 1
|
||||
meshCompression: 0
|
||||
addColliders: 0
|
||||
useSRGBMaterialColor: 1
|
||||
sortHierarchyByName: 1
|
||||
importPhysicalCameras: 1
|
||||
importVisibility: 1
|
||||
importBlendShapes: 1
|
||||
importCameras: 1
|
||||
importLights: 1
|
||||
nodeNameCollisionStrategy: 1
|
||||
fileIdsGeneration: 2
|
||||
swapUVChannels: 0
|
||||
generateSecondaryUV: 0
|
||||
useFileUnits: 1
|
||||
keepQuads: 0
|
||||
weldVertices: 1
|
||||
bakeAxisConversion: 0
|
||||
preserveHierarchy: 0
|
||||
skinWeightsMode: 0
|
||||
maxBonesPerVertex: 4
|
||||
minBoneWeight: 0.001
|
||||
optimizeBones: 1
|
||||
meshOptimizationFlags: -1
|
||||
indexFormat: 0
|
||||
secondaryUVAngleDistortion: 8
|
||||
secondaryUVAreaDistortion: 15.000001
|
||||
secondaryUVHardAngle: 88
|
||||
secondaryUVMarginMethod: 1
|
||||
secondaryUVMinLightmapResolution: 40
|
||||
secondaryUVMinObjectScale: 1
|
||||
secondaryUVPackMargin: 4
|
||||
useFileScale: 1
|
||||
strictVertexDataChecks: 0
|
||||
tangentSpace:
|
||||
normalSmoothAngle: 60
|
||||
normalImportMode: 0
|
||||
tangentImportMode: 3
|
||||
normalCalculationMode: 4
|
||||
legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0
|
||||
blendShapeNormalImportMode: 1
|
||||
normalSmoothingSource: 0
|
||||
referencedClips: []
|
||||
importAnimation: 1
|
||||
humanDescription:
|
||||
serializedVersion: 3
|
||||
human: []
|
||||
skeleton: []
|
||||
armTwist: 0.5
|
||||
foreArmTwist: 0.5
|
||||
upperLegTwist: 0.5
|
||||
legTwist: 0.5
|
||||
armStretch: 0.05
|
||||
legStretch: 0.05
|
||||
feetSpacing: 0
|
||||
globalScale: 1
|
||||
rootMotionBoneName:
|
||||
hasTranslationDoF: 0
|
||||
hasExtraRoot: 0
|
||||
skeletonHasParents: 1
|
||||
lastHumanDescriptionAvatarSource: {instanceID: 0}
|
||||
autoGenerateAvatarMappingIfUnspecified: 1
|
||||
animationType: 2
|
||||
humanoidOversampling: 1
|
||||
avatarSetup: 0
|
||||
addHumanoidExtraRootOnlyWhenUsingAvatar: 1
|
||||
importBlendShapeDeformPercent: 1
|
||||
remapMaterialsIfMaterialImportModeIsNone: 0
|
||||
additionalBone: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
130
Assets/SellingPedestal/SellingPedestal.prefab
Normal file
130
Assets/SellingPedestal/SellingPedestal.prefab
Normal file
@@ -0,0 +1,130 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &1301157404835660967
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1586355533238855113}
|
||||
- component: {fileID: 4132876516117494459}
|
||||
m_Layer: 0
|
||||
m_Name: SellingPedestal
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &1586355533238855113
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1301157404835660967}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 7519754370334350393}
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!65 &4132876516117494459
|
||||
BoxCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1301157404835660967}
|
||||
m_Material: {fileID: 0}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_LayerOverridePriority: 0
|
||||
m_IsTrigger: 0
|
||||
m_ProvidesContacts: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_Size: {x: 1, y: 1, z: 1}
|
||||
m_Center: {x: 0, y: 0.5, z: 0}
|
||||
--- !u!1001 &8057275906215197650
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 1586355533238855113}
|
||||
m_Modifications:
|
||||
- target: {fileID: -8679921383154817045, guid: 5cddd5128d0f0c745806cf1bcbe74416,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 4.656613e-10
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 5cddd5128d0f0c745806cf1bcbe74416,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: -0.000000014901161
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 5cddd5128d0f0c745806cf1bcbe74416,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 5cddd5128d0f0c745806cf1bcbe74416,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 0.7071067
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 5cddd5128d0f0c745806cf1bcbe74416,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: -0.7071068
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 5cddd5128d0f0c745806cf1bcbe74416,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 5cddd5128d0f0c745806cf1bcbe74416,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: -0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 5cddd5128d0f0c745806cf1bcbe74416,
|
||||
type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 5cddd5128d0f0c745806cf1bcbe74416,
|
||||
type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 5cddd5128d0f0c745806cf1bcbe74416,
|
||||
type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 919132149155446097, guid: 5cddd5128d0f0c745806cf1bcbe74416,
|
||||
type: 3}
|
||||
propertyPath: m_Name
|
||||
value: Pedestal
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
m_AddedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 5cddd5128d0f0c745806cf1bcbe74416, type: 3}
|
||||
--- !u!4 &7519754370334350393 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: -8679921383154817045, guid: 5cddd5128d0f0c745806cf1bcbe74416,
|
||||
type: 3}
|
||||
m_PrefabInstance: {fileID: 8057275906215197650}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
7
Assets/SellingPedestal/SellingPedestal.prefab.meta
Normal file
7
Assets/SellingPedestal/SellingPedestal.prefab.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 444f68f9ec6b58f499c51c9615500930
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user