Improve misc things

This commit is contained in:
Jens Pitkänen 2020-04-20 23:50:17 +03:00
parent 73d328e2e0
commit 45d8568f3f
10 changed files with 84 additions and 21 deletions

View File

@ -14,6 +14,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
DisplayName: burnt stick
FuelValue: 1
BurnTime: 0.5
FlameEffect: 0.3
SoundEffect: 0.8
Ignitable: 1

View File

@ -14,6 +14,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
DisplayName: stick
FuelValue: 5
BurnTime: 1
FlameEffect: 0.7
SoundEffect: 1.5
Ignitable: 1

View File

@ -5197,7 +5197,7 @@ CapsuleCollider:
m_Material: {fileID: 0}
m_IsTrigger: 1
m_Enabled: 1
m_Radius: 0.07
m_Radius: 0.1
m_Height: 0.6
m_Direction: 1
m_Center: {x: 0.005, y: 0, z: 0.005}
@ -5318,6 +5318,11 @@ PrefabInstance:
propertyPath: m_Materials.Array.data[1]
value:
objectReference: {fileID: 2100000, guid: d5b620399c48df144843bdd86af8973c, type: 2}
- target: {fileID: -1504981713932161579, guid: e44ff149e18c4334b82caa71b1fae7f7,
type: 3}
propertyPath: m_CastShadows
value: 0
objectReference: {fileID: 0}
- target: {fileID: -927199367670048503, guid: e44ff149e18c4334b82caa71b1fae7f7,
type: 3}
propertyPath: m_Name

View File

@ -1,5 +1,19 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!136 &5232873284161183228
CapsuleCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4234420637803406081}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
m_Radius: 0.3
m_Height: 3.3
m_Direction: 1
m_Center: {x: 0.02, y: 1.35, z: -0.15}
--- !u!1 &6700814859666117554
GameObject:
m_ObjectHideFlags: 0
@ -135,6 +149,12 @@ PrefabInstance:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 69199c2062afc1f41908440ccbf9b84f, type: 3}
--- !u!1 &4234420637803406081 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: -927199367670048503, guid: 69199c2062afc1f41908440ccbf9b84f,
type: 3}
m_PrefabInstance: {fileID: 5323890504769059336}
m_PrefabAsset: {fileID: 0}
--- !u!4 &907746880502108434 stripped
Transform:
m_CorrespondingSourceObject: {fileID: -4216859302048453862, guid: 69199c2062afc1f41908440ccbf9b84f,

View File

@ -31,6 +31,20 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!136 &6706357655407235765
CapsuleCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6126701630107862393}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
m_Radius: 0.4
m_Height: 3.4
m_Direction: 1
m_Center: {x: 0, y: 1.3, z: 0}
--- !u!1001 &2749315332302543984
PrefabInstance:
m_ObjectHideFlags: 0
@ -135,6 +149,12 @@ PrefabInstance:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 5e924ac251896824783ca38373727892, type: 3}
--- !u!1 &6126701630107862393 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: -927199367670048503, guid: 5e924ac251896824783ca38373727892,
type: 3}
m_PrefabInstance: {fileID: 2749315332302543984}
m_PrefabAsset: {fileID: 0}
--- !u!4 &7159935559873607530 stripped
Transform:
m_CorrespondingSourceObject: {fileID: -4216859302048453862, guid: 5e924ac251896824783ca38373727892,

View File

@ -41,7 +41,7 @@ CapsuleCollider:
m_Material: {fileID: 0}
m_IsTrigger: 1
m_Enabled: 1
m_Radius: 0.07
m_Radius: 0.1
m_Height: 0.6
m_Direction: 1
m_Center: {x: 0.005, y: 0, z: 0.005}
@ -268,6 +268,11 @@ PrefabInstance:
propertyPath: m_Materials.Array.data[0]
value:
objectReference: {fileID: 2100000, guid: 80996928df7a0d847bbb7a283c52976b, type: 2}
- target: {fileID: -1504981713932161579, guid: 88768e5e916bdea47b890bb833348313,
type: 3}
propertyPath: m_CastShadows
value: 0
objectReference: {fileID: 0}
- target: {fileID: -927199367670048503, guid: 88768e5e916bdea47b890bb833348313,
type: 3}
propertyPath: m_Name

View File

@ -1061,7 +1061,7 @@ MonoBehaviour:
- {fileID: 11400000, guid: 1e8a50f126551b144b536b2643d4f38c, type: 2}
- {fileID: 11400000, guid: a7ecdd1c4aa8e1b4d998c7c2b94b237c, type: 2}
- {fileID: 11400000, guid: 0247f0f621e470f419aa3b48a8ab69d8, type: 2}
Cooldown: 2
Cooldown: 5
AmbientNoiseCooldown: 0
Roll: 0
--- !u!1 &6215241420411417389

View File

@ -6,6 +6,7 @@ using UnityEngine;
public class BurnQuality : ScriptableObject {
public string DisplayName;
public float FuelValue;
public float BurnTime;
public float FlameEffect;
public float SoundEffect;
public bool Ignitable;

View File

@ -31,7 +31,7 @@ public class Campfire : MonoBehaviour {
private float LastRandomVarianceChange = 0;
private List<Item> LogQueue = new List<Item>();
private float LastLogBurned = 0;
private float NextLogTime = 0;
private void Awake() {
EnoughFuelColor = DynamicLight.color;
@ -39,10 +39,12 @@ public class Campfire : MonoBehaviour {
}
private void Update() {
if (LogQueue.Count > 0 && Time.time - LastLogBurned > LogBurningCooldown) {
LastLogBurned = Time.time;
if (LogQueue.Count > 0 && Time.time > NextLogTime) {
if (BurnLog(LogQueue[0])) {
LogQueue.RemoveAt(0);
if (LogQueue.Count > 0) {
NextLogTime = Time.time + LogQueue[0].Quality.BurnTime;
}
}
}
@ -78,6 +80,9 @@ public class Campfire : MonoBehaviour {
if (Burnable != null && !LogQueue.Contains(Burnable)) {
Flame.AddFuelEffect += Burnable.Quality.FlameEffect;
Sfx.ActiveBurn += Burnable.Quality.SoundEffect;
if (LogQueue.Count == 0) {
NextLogTime = Time.time + Burnable.Quality.BurnTime;
}
LogQueue.Add(Burnable);
}
}

View File

@ -23,13 +23,15 @@ public class ItemGrabber : MonoBehaviour {
public Torch Torch;
public GameObject NextTorch;
private Item LookedAtItem = null;
private float LastItemHitTime = -1;
private void Start() {
PrimaryIndicator.alpha = 0;
SecondaryIndicator.alpha = 0;
}
private void Update() {
Item Item = null;
Campfire Campfire = null;
RaycastHit Hit;
Vector3 From = CameraTransform.position;
@ -41,21 +43,24 @@ public class ItemGrabber : MonoBehaviour {
if (Physics.Raycast(From, Direction, out Hit, Distance, ItemLayer) &&
Hit.collider.attachedRigidbody != null) {
Item = Hit.collider.attachedRigidbody.GetComponent<Item>();
LookedAtItem = Hit.collider.attachedRigidbody.GetComponent<Item>();
LastItemHitTime = Time.time;
} else if (Time.time - LastItemHitTime > 0.1f) {
LookedAtItem = null;
}
if (Item != null && Input.GetButtonDown("Grab")) {
Item.PickUp(HandTransform);
GrabbedItems.Add(Item);
if (Physics.Raycast(From, Direction, out Hit, Distance * 2f, 1 << LayerMask.NameToLayer("Campfire")) &&
Hit.collider.attachedRigidbody != null) {
Campfire = Hit.collider.attachedRigidbody.GetComponent<Campfire>();
CanIgniteTorch |= Campfire != null && TorchableItem != null;
}
if (Campfire == null && LookedAtItem != null && Input.GetButtonDown("Grab")) {
LookedAtItem.PickUp(HandTransform);
GrabbedItems.Add(LookedAtItem);
}
if (GrabbedItems.Count > 0) {
if (Physics.Raycast(From, Direction, out Hit, Distance * 2f, 1 << LayerMask.NameToLayer("Campfire")) &&
Hit.collider.attachedRigidbody != null) {
Campfire = Hit.collider.attachedRigidbody.GetComponent<Campfire>();
CanIgniteTorch |= Campfire != null && TorchableItem != null;
}
if (CanIgniteTorch && Input.GetButtonDown("Ignite")) {
if (Torch == null) {
NextTorch = TorchableItem.gameObject;
@ -70,7 +75,7 @@ public class ItemGrabber : MonoBehaviour {
}
}
if (Input.GetButtonDown("Grab") && Item == null && ThrowableItem != null) {
if (Input.GetButtonDown("Grab") && (LookedAtItem == null || Campfire != null) && ThrowableItem != null) {
Vector3 DropPosition;
if (Campfire != null) {
DropPosition = Campfire.transform.position + Vector3.up * 0.7f;
@ -113,12 +118,12 @@ public class ItemGrabber : MonoBehaviour {
}
PrimaryIndicator.alpha = Mathf.Lerp(PrimaryIndicator.alpha,
Item != null || Campfire != null || ThrowableItem != null ? 1 : 0,
LookedAtItem != null || Campfire != null || ThrowableItem != null ? 1 : 0,
10f * Time.deltaTime);
if (Campfire != null && ThrowableItem != null) {
PrimaryText.text = $"Burn {ThrowableItem.Quality.DisplayName}";
} else if (Item != null) {
PrimaryText.text = $"Take {Item.Quality.DisplayName}";
} else if (LookedAtItem != null && Campfire == null) {
PrimaryText.text = $"Take {LookedAtItem.Quality.DisplayName}";
} else if (ThrowableItem != null) {
PrimaryText.text = $"Throw {ThrowableItem.Quality.DisplayName}";
}