add pills to heal self

This commit is contained in:
Kotrba Filip 2020-02-02 10:47:16 +01:00
parent 90c9a49afb
commit 7c4bf94b09
8 changed files with 292 additions and 1 deletions

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: da8b54377c2fbd549a1c8184b7e5645a
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,97 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &8423879596285337014
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4808991200749645733}
- component: {fileID: 4604929225511032211}
- component: {fileID: 7843994914498914666}
- component: {fileID: 5689278253577398147}
m_Layer: 0
m_Name: painkillers 1
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4808991200749645733
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8423879596285337014}
m_LocalRotation: {x: -0.7071068, y: -0, z: -0, w: 0.7071068}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.1, y: 0.100000046, z: 0.100000046}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: -90, y: 0, z: 0}
--- !u!33 &4604929225511032211
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8423879596285337014}
m_Mesh: {fileID: 2534964839176971238, guid: 7bb7d0cda29f61c488d0d6786d32e4ea, type: 3}
--- !u!23 &7843994914498914666
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8423879596285337014}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 1150922412438403536, guid: 7bb7d0cda29f61c488d0d6786d32e4ea, type: 3}
- {fileID: 2100000, guid: eed2d74525424704a913401a05e42534, type: 2}
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: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!64 &5689278253577398147
MeshCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8423879596285337014}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 3
m_Convex: 1
m_CookingOptions: 30
m_Mesh: {fileID: 2534964839176971238, guid: 7bb7d0cda29f61c488d0d6786d32e4ea, type: 3}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: d946f9dd565b97e49919fc8bd91aae4e
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -7644,6 +7644,74 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: f614b02c1b25fce4ba5bee61a982ff4f, type: 3} m_SourcePrefab: {fileID: 100100000, guid: f614b02c1b25fce4ba5bee61a982ff4f, type: 3}
--- !u!1 &1990836489
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1990836491}
- component: {fileID: 1990836490}
- component: {fileID: 1990836492}
m_Layer: 0
m_Name: PillsObject
m_TagString: Interact
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1990836490
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1990836489}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a26079dbac7f3cd4bacb95972241b8cb, type: 3}
m_Name:
m_EditorClassIdentifier:
blockType: 6
health: 30
healthRate: 15
amountModels: []
pills: {fileID: 7646678029089908993}
prefabPills: {fileID: 8423879596285337014, guid: d946f9dd565b97e49919fc8bd91aae4e,
type: 3}
spawnPillsPoint: {x: 0.008133344, y: 1.265739, z: -2.023658}
audioSource: {fileID: 0}
doorSound: {fileID: 0}
--- !u!4 &1990836491
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1990836489}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.008133344, y: 1.265739, z: -2.023658}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 6648769901767351058}
m_Father: {fileID: 0}
m_RootOrder: 33
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!65 &1990836492
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1990836489}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 0.2, y: 0.4, z: 0.2}
m_Center: {x: 0, y: 0.15, z: 0}
--- !u!1 &2079126252 stripped --- !u!1 &2079126252 stripped
GameObject: GameObject:
m_CorrespondingSourceObject: {fileID: 835007492758508419, guid: 5322794fa1699704b8e50a14cef106b1, m_CorrespondingSourceObject: {fileID: 835007492758508419, guid: 5322794fa1699704b8e50a14cef106b1,
@ -7787,6 +7855,76 @@ Transform:
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 25 m_RootOrder: 25
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &2232049265454068919
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 1990836491}
m_Modifications:
- target: {fileID: 4808991200749645733, guid: d946f9dd565b97e49919fc8bd91aae4e,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4808991200749645733, guid: d946f9dd565b97e49919fc8bd91aae4e,
type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4808991200749645733, guid: d946f9dd565b97e49919fc8bd91aae4e,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4808991200749645733, guid: d946f9dd565b97e49919fc8bd91aae4e,
type: 3}
propertyPath: m_LocalRotation.x
value: -0.7071068
objectReference: {fileID: 0}
- target: {fileID: 4808991200749645733, guid: d946f9dd565b97e49919fc8bd91aae4e,
type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4808991200749645733, guid: d946f9dd565b97e49919fc8bd91aae4e,
type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4808991200749645733, guid: d946f9dd565b97e49919fc8bd91aae4e,
type: 3}
propertyPath: m_LocalRotation.w
value: 0.7071068
objectReference: {fileID: 0}
- target: {fileID: 4808991200749645733, guid: d946f9dd565b97e49919fc8bd91aae4e,
type: 3}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4808991200749645733, guid: d946f9dd565b97e49919fc8bd91aae4e,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: -90
objectReference: {fileID: 0}
- target: {fileID: 4808991200749645733, guid: d946f9dd565b97e49919fc8bd91aae4e,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4808991200749645733, guid: d946f9dd565b97e49919fc8bd91aae4e,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8423879596285337014, guid: d946f9dd565b97e49919fc8bd91aae4e,
type: 3}
propertyPath: m_Name
value: painkillers
objectReference: {fileID: 0}
m_RemovedComponents:
- {fileID: 5689278253577398147, guid: d946f9dd565b97e49919fc8bd91aae4e, type: 3}
m_SourcePrefab: {fileID: 100100000, guid: d946f9dd565b97e49919fc8bd91aae4e, type: 3}
--- !u!1001 &2435173729303179787 --- !u!1001 &2435173729303179787
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -8502,6 +8640,18 @@ PrefabInstance:
- {fileID: 4090411522576814766, guid: 5322794fa1699704b8e50a14cef106b1, type: 3} - {fileID: 4090411522576814766, guid: 5322794fa1699704b8e50a14cef106b1, type: 3}
- {fileID: 7851948758291723579, guid: 5322794fa1699704b8e50a14cef106b1, type: 3} - {fileID: 7851948758291723579, guid: 5322794fa1699704b8e50a14cef106b1, type: 3}
m_SourcePrefab: {fileID: 100100000, guid: 5322794fa1699704b8e50a14cef106b1, type: 3} m_SourcePrefab: {fileID: 100100000, guid: 5322794fa1699704b8e50a14cef106b1, type: 3}
--- !u!4 &6648769901767351058 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 4808991200749645733, guid: d946f9dd565b97e49919fc8bd91aae4e,
type: 3}
m_PrefabInstance: {fileID: 2232049265454068919}
m_PrefabAsset: {fileID: 0}
--- !u!1 &7646678029089908993 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 8423879596285337014, guid: d946f9dd565b97e49919fc8bd91aae4e,
type: 3}
m_PrefabInstance: {fileID: 2232049265454068919}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &7985979212702423926 --- !u!1001 &7985979212702423926
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -4,7 +4,7 @@ using UnityEngine;
public class BlockManager : MonoBehaviour public class BlockManager : MonoBehaviour
{ {
public enum BlockType {None, Barricade, Door, Wood, Ammo, FireCamp}; public enum BlockType {None, Barricade, Door, Wood, Ammo, FireCamp, Pills};
public BlockType blockType = BlockType.None; public BlockType blockType = BlockType.None;
public float health = 100; public float health = 100;
public float healthRate = 5; public float healthRate = 5;
@ -13,6 +13,9 @@ public class BlockManager : MonoBehaviour
private PlayerManager player; private PlayerManager player;
private bool action = false; private bool action = false;
public List<GameObject> amountModels = new List<GameObject>(); public List<GameObject> amountModels = new List<GameObject>();
public GameObject pills;
public GameObject prefabPills;
public Vector3 spawnPillsPoint;
public AudioSource audioSource = new AudioSource(); public AudioSource audioSource = new AudioSource();
public AudioClip doorSound; public AudioClip doorSound;
@ -33,6 +36,10 @@ public class BlockManager : MonoBehaviour
{ {
healthTime = healthRate; healthTime = healthRate;
} }
else if (blockType == BlockType.Pills)
{
healthTime = healthRate;
}
} }
// Update is called once per frame // Update is called once per frame
@ -55,6 +62,13 @@ public class BlockManager : MonoBehaviour
healthTime = healthRate + Time.time; healthTime = healthRate + Time.time;
} }
} }
else if (blockType == BlockType.Pills)
{
if (pills == null && healthTime < Time.time) {
pills = Instantiate(prefabPills, spawnPillsPoint, prefabPills.transform.rotation);
this.GetComponent<BoxCollider>().enabled = true;
}
}
viewHealthAs(); viewHealthAs();
} }
@ -132,6 +146,22 @@ public class BlockManager : MonoBehaviour
player.ammo += (player.ammo <= 40 ? 10 : (50 - player.ammo)); player.ammo += (player.ammo <= 40 ? 10 : (50 - player.ammo));
} }
} }
else if (blockType == BlockType.Pills)
{
if (pills != null && player.actualHealth != player.health) {
if (player.actualHealth <= player.health - health)
{
player.actualHealth += health;
}
else
{
player.actualHealth = player.health;
}
Destroy(pills);
this.GetComponent<BoxCollider>().enabled = false;
healthTime = healthRate + Time.time;
}
}
} }
void SpikeHit() void SpikeHit()