Started working on WkurwHandler

This commit is contained in:
Ignis 2021-08-28 13:59:39 +02:00
parent 7549940ca0
commit 022af83238
5 changed files with 139 additions and 43 deletions

View file

@ -1525,6 +1525,52 @@ Mesh:
offset: 0
size: 0
path:
--- !u!1 &1449662312
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1449662314}
- component: {fileID: 1449662313}
m_Layer: 0
m_Name: WkurwHandler
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1449662313
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1449662312}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 38918a99291c1d74db80e6685fdc39c9, type: 3}
m_Name:
m_EditorClassIdentifier:
health: 100
anger: 0
fear: 0
--- !u!4 &1449662314
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1449662312}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -10.344179, y: 7.2330303, z: -0.9402442}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 7
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1472737031
GameObject:
m_ObjectHideFlags: 0
@ -1537,7 +1583,7 @@ GameObject:
- component: {fileID: 1472737035}
- component: {fileID: 1472737034}
- component: {fileID: 1472737033}
m_Layer: 3
m_Layer: 6
m_Name: Cube
m_TagString: Untagged
m_Icon: {fileID: 0}
@ -1820,7 +1866,7 @@ GameObject:
- component: {fileID: 1729498776}
- component: {fileID: 1729498775}
- component: {fileID: 1729498773}
m_Layer: 3
m_Layer: 6
m_Name: Robber
m_TagString: Robber
m_Icon: {fileID: 0}
@ -2253,14 +2299,20 @@ MonoBehaviour:
trapActivationReachRangeDebugColor: {r: 1, g: 0.28652775, b: 0, a: 0.3764706}
showInteractionReach: 1
trapInteractionReachRangeDebugColor: {r: 0, g: 0.21038437, b: 1, a: 1}
isSet: 1
isActivated: 0
isSet: 0
wasUsed: 0
playerInRange: 0
robberInRange: 0
inputReferences: {fileID: 1945878217}
unsetMaterial: {fileID: 2100000, guid: 79f64ed6f5d6d374d91c3a0af4070258, type: 2}
setMaterial: {fileID: 2100000, guid: 5a26de236ce89e94b963be8fa2b7ade6, type: 2}
trapType: Pinns
player:
serializedVersion: 2
m_Bits: 8
robber:
serializedVersion: 2
m_Bits: 64
trapType: Pins
linkAllOffsets: 1
masterOffset: {x: 0.5, y: 0.5, z: -0.5}
trapInteractionRadiusOffset: {x: 0.5, y: 0.5, z: -0.5}
@ -2271,8 +2323,6 @@ MonoBehaviour:
trapRange: 5
hasActivationDelay: 0
trapActivationDelay: 0
isRechargable: 0
rechargeTime: 0
requieresPlayer: 0
--- !u!114 &1945878217
MonoBehaviour:

View file

@ -19,7 +19,7 @@ public class Trap : MonoBehaviour
public Color trapInteractionReachRangeDebugColor;
public bool isSet;
public bool isActivated;
public bool wasUsed;
public bool playerInRange;
public bool robberInRange;
public PlayerControls dobberControls;
@ -35,7 +35,7 @@ public class Trap : MonoBehaviour
[Dropdown("trapTypes")]
public string trapType;
private string[] trapTypes = new string[] { "Pinns", "Rope", "Ladder", "Bear Trap", "Bannana Peal" };
private string[] trapTypes = new string[] { "Pins", "Rope", "Ladder", "Bear Trap", "Bannana Peel" };
public bool linkAllOffsets;
@ -57,10 +57,6 @@ public class Trap : MonoBehaviour
[ShowIf("hasActivationDelay")]
public float trapActivationDelay;
public bool isRechargable;
[ShowIf("isRechargable")]
public float rechargeTime;
public bool requieresPlayer;
@ -117,15 +113,43 @@ public class Trap : MonoBehaviour
playerInRange = false;
}
if (Physics.CheckSphere(transform.position + trapInteractionRadiusOffset, trapInteractionRadius, player))
if (Physics.CheckSphere(transform.position + trapInteractionRadiusOffset, trapInteractionRadius, robber))
{
playerInRange = true;
robberInRange = true;
// private string[] trapTypes = new string[] { "Pins", "Rope", "Ladder", "Bear Trap", "Bannana Peel" };
switch (trapType)
{
case "Pins":
break;
case "Rope":
break;
case "Ladder":
break;
case "Bear Trap":
break;
case "Bannana Peel":
break;
default:
Debug.LogError("Unknown trap type. Make sure it's added to the switch statement in FixedUpdate, and not just the context menu. And make sure there aren't any types *looks at nimfer*", this);
break;
}
}
else
{
playerInRange = false;
robberInRange = false;
}
}
@ -134,13 +158,13 @@ public class Trap : MonoBehaviour
{
interacted = inputReferences.playerControls.DobberControls.Interact.ReadValue<float>();
if (playerInRange)
if (playerInRange && !isSet)
{
switch (interacted)
{
case 1:
Debug.Log("trap collected");
isSet = false;
Debug.Log("Trap set.");
isSet = true;
GetComponent<MeshRenderer>().sharedMaterial = setMaterial;
break;
case 0:
@ -149,33 +173,13 @@ public class Trap : MonoBehaviour
}
}
if (robberInRange)
if (robberInRange && isSet)
{
isActivated = true;
Debug.Log("The robber has set off the trap.");
GetComponent<MeshRenderer>().sharedMaterial = unsetMaterial;
isSet = false;
wasUsed = true;
}
}
void OnTriggerStay(Collider other)
{
if (other.tag == "Player")
{
playerInRange = true;
}
else
{
playerInRange = false;
}
if (other.tag == "Robber" && isSet)
{
robberInRange = true;
}
else
{
robberInRange = false;
}
}
}

View file

@ -0,0 +1,31 @@
using NaughtyAttributes;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WkurwHandler : MonoBehaviour
{
[ProgressBar("Health", 100, EColor.Red)]
public int health = 100;
[ProgressBar("Anger", 100, EColor.Yellow)]
public int anger = 50;
[ProgressBar("Fear", 100, EColor.Blue)]
public int fear = 35;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 38918a99291c1d74db80e6685fdc39c9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -13,7 +13,7 @@ TagManager:
- Player
- Water
- UI
-
- Robber
-
-
-