Merge branch 'master' into perf-build

This commit is contained in:
Jens Pitkänen 2020-04-23 14:39:21 +03:00
commit 7ff005a514
2 changed files with 11 additions and 8 deletions

View File

@ -67,10 +67,12 @@ public class ItemGrabber : MonoBehaviour {
CanIgniteTorch |= Campfire != null && TorchableItem != null; CanIgniteTorch |= Campfire != null && TorchableItem != null;
} }
bool JustPickedUpCasette = false;
if (Casette != null && Input.GetButtonDown("Grab")) { if (Casette != null && Input.GetButtonDown("Grab")) {
Casette.Play(PreviousCasette); Casette.Play(PreviousCasette);
PreviousCasette = Casette; PreviousCasette = Casette;
Casette = null; Casette = null;
JustPickedUpCasette = true;
} else if (Campfire == null && LookedAtItem != null && Input.GetButtonDown("Grab")) { } else if (Campfire == null && LookedAtItem != null && Input.GetButtonDown("Grab")) {
LookedAtItem.PickUp(HandTransform); LookedAtItem.PickUp(HandTransform);
GrabbedItems.Add(LookedAtItem); GrabbedItems.Add(LookedAtItem);
@ -91,7 +93,7 @@ public class ItemGrabber : MonoBehaviour {
} }
} }
if (Input.GetButtonDown("Grab") && (LookedAtItem == null || Campfire != null) && ThrowableItem != null) { if (Input.GetButtonDown("Grab") && (LookedAtItem == null || Campfire != null) && ThrowableItem != null && !JustPickedUpCasette) {
Vector3 DropPosition; Vector3 DropPosition;
if (Campfire != null) { if (Campfire != null) {
DropPosition = Campfire.transform.position + Vector3.up * 0.7f; DropPosition = Campfire.transform.position + Vector3.up * 0.7f;
@ -133,9 +135,7 @@ public class ItemGrabber : MonoBehaviour {
} }
} }
PrimaryIndicator.alpha = Mathf.Lerp(PrimaryIndicator.alpha, float PrimaryIndicatorTargetAlpha = 1;
Casette != null || LookedAtItem != null || Campfire != null || ThrowableItem != null ? 1 : 0,
10f * Time.deltaTime);
if (Casette != null) { if (Casette != null) {
PrimaryText.text = Casette.DisplayPrompt; PrimaryText.text = Casette.DisplayPrompt;
} else if (Campfire != null && ThrowableItem != null) { } else if (Campfire != null && ThrowableItem != null) {
@ -144,12 +144,15 @@ public class ItemGrabber : MonoBehaviour {
PrimaryText.text = $"Take {LookedAtItem.Quality.DisplayName}"; PrimaryText.text = $"Take {LookedAtItem.Quality.DisplayName}";
} else if (ThrowableItem != null) { } else if (ThrowableItem != null) {
PrimaryText.text = $"Throw {ThrowableItem.Quality.DisplayName}"; PrimaryText.text = $"Throw {ThrowableItem.Quality.DisplayName}";
} else {
PrimaryIndicatorTargetAlpha = 0;
} }
PrimaryIndicator.alpha = Mathf.Lerp(PrimaryIndicator.alpha, PrimaryIndicatorTargetAlpha, 10f * Time.deltaTime);
SecondaryIndicator.alpha = Mathf.Lerp(SecondaryIndicator.alpha, CanIgniteTorch ? 1 : 0, 10f * Time.deltaTime);
if (CanIgniteTorch) { if (CanIgniteTorch) {
SecondaryText.text = $"Ignite {TorchableItem.Quality.DisplayName}"; SecondaryText.text = $"Ignite {TorchableItem.Quality.DisplayName}";
} }
SecondaryIndicator.alpha = Mathf.Lerp(SecondaryIndicator.alpha, CanIgniteTorch ? 1 : 0, 10f * Time.deltaTime);
} }
private Item GetTorchableItem() { private Item GetTorchableItem() {

View File

@ -52,11 +52,11 @@ public class StickSpawner : MonoBehaviour {
LastSpawnedWasCasette = false; LastSpawnedWasCasette = false;
} }
CanSpawnNew = false; CanSpawnNew = false;
var Stick = GameObject.Instantiate(SpawnedThing, transform.position + Vector3.up * 2, Random.rotation); var Spawned = GameObject.Instantiate(SpawnedThing, transform.position + Vector3.up * 2, Random.rotation);
if (LastSpawnedWasCasette) { if (LastSpawnedWasCasette) {
SpawnedCasette = Spawned.GetComponent<CasettePickup>();
} else { } else {
SpawnedStick = Stick.GetComponent<Item>(); SpawnedStick = Spawned.GetComponent<Item>();
} }
} }