reworked interactions, fixed health depleting from testing
This commit is contained in:
parent
661aa6704b
commit
f57389e8a4
@ -166,6 +166,8 @@ MonoBehaviour:
|
||||
m_GameObject: {fileID: 4918528717594724652}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 87ac36bb4d63c7b4f901ce681578ca4b, type: 3}
|
||||
m_Script: {fileID: 11500000, guid: 502dfdd16cfb094a89708a6d31f80af2, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
clip: {fileID: 0}
|
||||
isEnemy: 1
|
||||
|
||||
@ -13,6 +13,7 @@ GameObject:
|
||||
- component: {fileID: 6365990307743021963}
|
||||
- component: {fileID: 6952935615892918535}
|
||||
- component: {fileID: 2329328608366088264}
|
||||
- component: {fileID: 3373736657539295389}
|
||||
m_Layer: 0
|
||||
m_Name: Rock_1
|
||||
m_TagString: Object:Stone
|
||||
@ -134,3 +135,16 @@ Rigidbody:
|
||||
m_Interpolate: 0
|
||||
m_Constraints: 122
|
||||
m_CollisionDetection: 0
|
||||
--- !u!114 &3373736657539295389
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4852758362040146526}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4fc88a9ab15a9238baf100c2fd070aa7, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
clip: {fileID: 7400000, guid: dfe6f42559279b9f2a43256075839781, type: 2}
|
||||
|
||||
@ -13,6 +13,7 @@ GameObject:
|
||||
- component: {fileID: 3216712892522360414}
|
||||
- component: {fileID: 1477549268999423186}
|
||||
- component: {fileID: 3850889906121968706}
|
||||
- component: {fileID: 3470364473752288912}
|
||||
m_Layer: 0
|
||||
m_Name: Rock_2
|
||||
m_TagString: Object:Stone
|
||||
@ -134,3 +135,16 @@ Rigidbody:
|
||||
m_Interpolate: 0
|
||||
m_Constraints: 122
|
||||
m_CollisionDetection: 0
|
||||
--- !u!114 &3470364473752288912
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4009596908532748171}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4fc88a9ab15a9238baf100c2fd070aa7, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
clip: {fileID: 7400000, guid: dfe6f42559279b9f2a43256075839781, type: 2}
|
||||
|
||||
@ -211,9 +211,10 @@ MonoBehaviour:
|
||||
m_GameObject: {fileID: 4972404453844040047}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: cc3c1c0815bce34498b5dc8b199d0118, type: 3}
|
||||
m_Script: {fileID: 11500000, guid: 2fe18bcd2d3d0d752ae519027875df8f, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
clip: {fileID: 0}
|
||||
--- !u!64 &-3685426353244344161
|
||||
MeshCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@ -295,9 +295,10 @@ MonoBehaviour:
|
||||
m_GameObject: {fileID: 7422307534756093511}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: cc3c1c0815bce34498b5dc8b199d0118, type: 3}
|
||||
m_Script: {fileID: 11500000, guid: 2fe18bcd2d3d0d752ae519027875df8f, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
clip: {fileID: 0}
|
||||
--- !u!64 &2645811048282726494
|
||||
MeshCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@ -306,9 +306,10 @@ MonoBehaviour:
|
||||
m_GameObject: {fileID: 9127354857402186281}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: cc3c1c0815bce34498b5dc8b199d0118, type: 3}
|
||||
m_Script: {fileID: 11500000, guid: 2fe18bcd2d3d0d752ae519027875df8f, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
clip: {fileID: 0}
|
||||
--- !u!64 &-1326613566692478026
|
||||
MeshCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@ -295,9 +295,10 @@ MonoBehaviour:
|
||||
m_GameObject: {fileID: 8445085162624319281}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: cc3c1c0815bce34498b5dc8b199d0118, type: 3}
|
||||
m_Script: {fileID: 11500000, guid: 2fe18bcd2d3d0d752ae519027875df8f, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
clip: {fileID: 0}
|
||||
--- !u!64 &3048554505669354710
|
||||
MeshCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@ -129,9 +129,10 @@ MonoBehaviour:
|
||||
m_GameObject: {fileID: 1452497377981145769}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: cc3c1c0815bce34498b5dc8b199d0118, type: 3}
|
||||
m_Script: {fileID: 11500000, guid: 2fe18bcd2d3d0d752ae519027875df8f, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
clip: {fileID: 0}
|
||||
--- !u!64 &3661858136180210843
|
||||
MeshCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@ -129,9 +129,10 @@ MonoBehaviour:
|
||||
m_GameObject: {fileID: 419805594404797990}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: cc3c1c0815bce34498b5dc8b199d0118, type: 3}
|
||||
m_Script: {fileID: 11500000, guid: 2fe18bcd2d3d0d752ae519027875df8f, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
clip: {fileID: 0}
|
||||
--- !u!64 &-4696269184063814604
|
||||
MeshCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@ -297,9 +297,10 @@ MonoBehaviour:
|
||||
m_GameObject: {fileID: 7815009759384241731}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: cc3c1c0815bce34498b5dc8b199d0118, type: 3}
|
||||
m_Script: {fileID: 11500000, guid: 2fe18bcd2d3d0d752ae519027875df8f, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
clip: {fileID: 0}
|
||||
--- !u!64 &6523941094505267678
|
||||
MeshCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@ -15,6 +15,7 @@ GameObject:
|
||||
- component: {fileID: 1658981204574654673}
|
||||
- component: {fileID: 6099884091545410372}
|
||||
- component: {fileID: 645566918292761053}
|
||||
- component: {fileID: 3674917119847316386}
|
||||
m_Layer: 0
|
||||
m_Name: Tree_1
|
||||
m_TagString: Object:Tree
|
||||
@ -4992,3 +4993,16 @@ ParticleSystemRenderer:
|
||||
m_MeshWeighting2: 1
|
||||
m_MeshWeighting3: 1
|
||||
m_MaskInteraction: 0
|
||||
--- !u!114 &3674917119847316386
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8867824946895199964}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 9d069bae9082b7b60a2a05060a98424e, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
clip: {fileID: 7400000, guid: 4522681ee7a4e1196af04c3f4fc704d6, type: 2}
|
||||
|
||||
@ -13,6 +13,7 @@ GameObject:
|
||||
- component: {fileID: 7366098166761564472}
|
||||
- component: {fileID: 6781544929942635444}
|
||||
- component: {fileID: 8075644600998223849}
|
||||
- component: {fileID: 1343859431540429002}
|
||||
m_Layer: 0
|
||||
m_Name: Tree_2
|
||||
m_TagString: Object:Tree
|
||||
@ -135,3 +136,16 @@ Rigidbody:
|
||||
m_Interpolate: 0
|
||||
m_Constraints: 122
|
||||
m_CollisionDetection: 0
|
||||
--- !u!114 &1343859431540429002
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 9023347993894783213}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 9d069bae9082b7b60a2a05060a98424e, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
clip: {fileID: 7400000, guid: 4522681ee7a4e1196af04c3f4fc704d6, type: 2}
|
||||
|
||||
@ -94,6 +94,7 @@ GameObject:
|
||||
- component: {fileID: 4848850860749154617}
|
||||
- component: {fileID: -2572412590075727139}
|
||||
- component: {fileID: 4483093259101442725}
|
||||
- component: {fileID: 5418233419134080367}
|
||||
m_Layer: 0
|
||||
m_Name: copperOre
|
||||
m_TagString: Object:Ore
|
||||
@ -167,6 +168,19 @@ MeshCollider:
|
||||
m_Convex: 1
|
||||
m_CookingOptions: 30
|
||||
m_Mesh: {fileID: -5266056624350073623, guid: 21b8842f73b5b16dc87c1cb1b0afe0ce, type: 3}
|
||||
--- !u!114 &5418233419134080367
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5188503590062044035}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: ab6955d1e578ef1b88f1ee3b6fa83051, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
clip: {fileID: 7400000, guid: dfe6f42559279b9f2a43256075839781, type: 2}
|
||||
--- !u!1 &8310517336631356992
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@ -94,6 +94,7 @@ GameObject:
|
||||
- component: {fileID: 5321737818351179594}
|
||||
- component: {fileID: 8145716631555738662}
|
||||
- component: {fileID: 7075289032286914303}
|
||||
- component: {fileID: 7599337776987165547}
|
||||
m_Layer: 0
|
||||
m_Name: goldOre
|
||||
m_TagString: Object:Ore
|
||||
@ -167,6 +168,19 @@ MeshCollider:
|
||||
m_Convex: 1
|
||||
m_CookingOptions: 30
|
||||
m_Mesh: {fileID: -5266056624350073623, guid: 21b8842f73b5b16dc87c1cb1b0afe0ce, type: 3}
|
||||
--- !u!114 &7599337776987165547
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4796699693279464944}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: ab6955d1e578ef1b88f1ee3b6fa83051, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
clip: {fileID: 7400000, guid: dfe6f42559279b9f2a43256075839781, type: 2}
|
||||
--- !u!1 &8774396427657433139
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@ -94,6 +94,7 @@ GameObject:
|
||||
- component: {fileID: 6744453271754949240}
|
||||
- component: {fileID: 215655860811652073}
|
||||
- component: {fileID: 6576777228973474439}
|
||||
- component: {fileID: 6437085144792087181}
|
||||
m_Layer: 0
|
||||
m_Name: ironOre
|
||||
m_TagString: Object:Ore
|
||||
@ -167,6 +168,19 @@ MeshCollider:
|
||||
m_Convex: 1
|
||||
m_CookingOptions: 30
|
||||
m_Mesh: {fileID: -5266056624350073623, guid: 21b8842f73b5b16dc87c1cb1b0afe0ce, type: 3}
|
||||
--- !u!114 &6437085144792087181
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6256287307790063810}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: ab6955d1e578ef1b88f1ee3b6fa83051, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
clip: {fileID: 7400000, guid: dfe6f42559279b9f2a43256075839781, type: 2}
|
||||
--- !u!1 &7892395422436754689
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@ -61,7 +61,7 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 0.27058825, g: 0.4117647, b: 0.5647059, a: 1}
|
||||
m_Color: {r: 0.24313726, g: 0.53333336, b: 0.35686275, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
|
||||
@ -94,6 +94,7 @@ GameObject:
|
||||
- component: {fileID: 6024848534698070052}
|
||||
- component: {fileID: 70974923766122465}
|
||||
- component: {fileID: 6135128249415564205}
|
||||
- component: {fileID: 8624121310591208666}
|
||||
m_Layer: 0
|
||||
m_Name: tinOre
|
||||
m_TagString: Object:Ore
|
||||
@ -167,6 +168,19 @@ MeshCollider:
|
||||
m_Convex: 1
|
||||
m_CookingOptions: 30
|
||||
m_Mesh: {fileID: -5266056624350073623, guid: 21b8842f73b5b16dc87c1cb1b0afe0ce, type: 3}
|
||||
--- !u!114 &8624121310591208666
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6401690393767201438}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: ab6955d1e578ef1b88f1ee3b6fa83051, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
clip: {fileID: 7400000, guid: dfe6f42559279b9f2a43256075839781, type: 2}
|
||||
--- !u!1 &7170566803458479965
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@ -13187,7 +13187,7 @@ MonoBehaviour:
|
||||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: 800x600
|
||||
m_Text: German
|
||||
--- !u!222 &722907595
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@ -6,6 +6,7 @@ using UnityEngine.EventSystems;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.UI;
|
||||
using Assets.Scripts.Player;
|
||||
using Assets.Scripts.InteractableObjects;
|
||||
|
||||
public class Controls : MonoBehaviour
|
||||
{
|
||||
@ -141,22 +142,17 @@ public class Controls : MonoBehaviour
|
||||
fight.GetComponent<Fight>().startFight(worldGen.GetComponent<WorldGenerator>().getCurrentTile(), target, player);
|
||||
break;
|
||||
case "Tree":
|
||||
StartCoroutine(playAnimation(target, "Chopping"));
|
||||
player.GetComponent<PlayerGameObject>().getPlayer().getStat("TreeCount").changeAmount(1);
|
||||
GameObject.Find("Inventory").GetComponent<Inventory>().addItem(new Item("Wood"));
|
||||
break;
|
||||
case "Stone":
|
||||
StartCoroutine(playAnimation(target, "Mining"));
|
||||
GameObject.Find("Inventory").GetComponent<Inventory>().addItem(new Item("Rock"));
|
||||
break;
|
||||
case "NPC":
|
||||
target.GetComponent<NPC>().interact();
|
||||
break;
|
||||
case "Door":
|
||||
target.GetComponent<Door>().interact();
|
||||
break;
|
||||
case "Chest":
|
||||
target.GetComponent<Chest>().interact();
|
||||
break;
|
||||
case "Ore":
|
||||
if (target.name.ToLower().Contains("iron"))
|
||||
@ -176,44 +172,13 @@ public class Controls : MonoBehaviour
|
||||
GameObject.Find("Inventory").GetComponent<Inventory>().addItem(new Item("Tin ore"));
|
||||
}
|
||||
player.GetComponent<PlayerGameObject>().getPlayer().getStat("OreCount").changeAmount(1);
|
||||
StartCoroutine(playAnimation(target, "Mining"));
|
||||
break;
|
||||
}
|
||||
target.GetComponent<InteractableObject>().OnInteraction(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator playParticle(GameObject target)
|
||||
{
|
||||
Vector3 playerPos = player.transform.position;
|
||||
playerPos.y = target.transform.position.y;
|
||||
Quaternion newRotation = Quaternion.LookRotation(playerPos - target.transform.position, target.transform.TransformDirection(Vector3.up));
|
||||
ParticleSystem particleSystem = target.GetComponent<ParticleSystem>();
|
||||
ParticleSystem.ShapeModule shape = particleSystem.shape;
|
||||
shape.rotation = newRotation.eulerAngles;
|
||||
particleSystem.Play();
|
||||
yield return new WaitUntil(() => !particleSystem.isPlaying);
|
||||
Destroy(target);
|
||||
}
|
||||
|
||||
IEnumerator playAnimation(GameObject target, string key)
|
||||
{
|
||||
player.GetComponent<Animator>().Play(key);
|
||||
Animator animator = player.GetComponent<Animator>();
|
||||
AnimationClip[] clips = animator.runtimeAnimatorController.animationClips;
|
||||
float length = 0;
|
||||
foreach (AnimationClip clip in clips)
|
||||
{
|
||||
if (clip.name.ToLower() == key.ToLower())
|
||||
{
|
||||
length = clip.length;
|
||||
break;
|
||||
}
|
||||
}
|
||||
yield return new WaitForSeconds(length);
|
||||
Destroy(target);
|
||||
}
|
||||
|
||||
public void OnInventory()
|
||||
{
|
||||
uihandler.switchInventory();
|
||||
|
||||
@ -5,6 +5,7 @@ using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
using Assets.Scripts.Player;
|
||||
using Assets.Scripts.InteractableObjects;
|
||||
|
||||
public class Fight : MonoBehaviour
|
||||
{
|
||||
|
||||
@ -7,6 +7,7 @@ using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.Localization.Settings;
|
||||
using UnityEngine.UI;
|
||||
using Assets.Scripts.InteractableObjects;
|
||||
|
||||
namespace Assets.Scripts
|
||||
{
|
||||
|
||||
8
Assets/Scripts/InteractableObjects.meta
Normal file
8
Assets/Scripts/InteractableObjects.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: abcb4e1f5010a0bde9b4bdc47563e496
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -4,24 +4,13 @@ using UnityEngine;
|
||||
using System;
|
||||
using Assets.Scripts.Player;
|
||||
|
||||
namespace Assets.Scripts
|
||||
namespace Assets.Scripts.InteractableObjects
|
||||
{
|
||||
public class Chest : MonoBehaviour
|
||||
public class Chest : InteractableObject
|
||||
{
|
||||
bool gotItem = false;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void interact(){
|
||||
public override void handleInteraction(GameObject player){
|
||||
if (gotItem)
|
||||
{
|
||||
GameObject.Find("UIHandler").GetComponent<UIHandler>().showMessage("ERROR;"+TextHandler.getText("alreadyLooted"));
|
||||
@ -30,7 +19,7 @@ namespace Assets.Scripts
|
||||
{
|
||||
gameObject.transform.Find("Lid").GetComponent<Animator>().Play("ChestOpen");
|
||||
Item item;
|
||||
int luck = GameObject.Find("Player").GetComponent<PlayerGameObject>().getPlayerStat("Luck").getAmount();
|
||||
int luck = player.GetComponent<PlayerGameObject>().getPlayerStat("Luck").getAmount();
|
||||
int type = new System.Random().Next(3);
|
||||
switch (type)
|
||||
{
|
||||
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 542700d30d7f9c98a910fb33e30c4174
|
||||
guid: 3a68095ee650a0b5eaefd210c9641289
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@ -4,26 +4,14 @@ using UnityEngine;
|
||||
using System;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Assets.Scripts
|
||||
namespace Assets.Scripts.InteractableObjects
|
||||
{
|
||||
public class Door : MonoBehaviour
|
||||
public class Door : InteractableObject
|
||||
{
|
||||
public bool hasInteracted = false;
|
||||
bool isOpen = false;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void interact()
|
||||
public override void handleInteraction(GameObject player)
|
||||
{
|
||||
if (hasInteracted)
|
||||
{
|
||||
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 14e8c3bbd04c0574da570d1bc8d00649
|
||||
guid: 5ae65e9f2852fc2fbb96d7c9ec9cafe0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@ -6,17 +6,15 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.Scripts
|
||||
namespace Assets.Scripts.InteractableObjects
|
||||
{
|
||||
public class Enemy : MonoBehaviour
|
||||
public class Enemy : InteractableObject
|
||||
{
|
||||
string enemyname;
|
||||
System.Random rand = new System.Random();
|
||||
BasicSlime slime;
|
||||
SlimeFactory factory = new SlimeFactory();
|
||||
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
enemyname = gameObject.name;
|
||||
@ -28,10 +26,9 @@ namespace Assets.Scripts
|
||||
renameEnemy();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
public override void handleInteraction(GameObject player)
|
||||
{
|
||||
|
||||
keepAlive = true;
|
||||
}
|
||||
|
||||
private void renameEnemy()
|
||||
@ -115,7 +112,7 @@ namespace Assets.Scripts
|
||||
|
||||
public bool takeDamage(int amount)
|
||||
{
|
||||
return slime.takeDamage(amount,rand);
|
||||
return slime.takeDamage(amount, rand);
|
||||
}
|
||||
|
||||
public int getExperience()
|
||||
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cc3c1c0815bce34498b5dc8b199d0118
|
||||
guid: 2fe18bcd2d3d0d752ae519027875df8f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
70
Assets/Scripts/InteractableObjects/InteractableObject.cs
Normal file
70
Assets/Scripts/InteractableObjects/InteractableObject.cs
Normal file
@ -0,0 +1,70 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.Scripts.InteractableObjects
|
||||
{
|
||||
public abstract class InteractableObject : MonoBehaviour
|
||||
{
|
||||
public AnimationClip clip;
|
||||
private bool particlePlayed;
|
||||
private bool animationPlayed;
|
||||
public bool keepAlive;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
particlePlayed = false;
|
||||
animationPlayed = false;
|
||||
keepAlive = false;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
destroyObject();
|
||||
}
|
||||
|
||||
public void OnInteraction(GameObject player)
|
||||
{
|
||||
StartCoroutine(playParticle(player));
|
||||
StartCoroutine(playAnimation(player));
|
||||
handleInteraction(player);
|
||||
}
|
||||
|
||||
public abstract void handleInteraction(GameObject player);
|
||||
|
||||
IEnumerator playParticle(GameObject player)
|
||||
{
|
||||
if (GetComponent<ParticleSystem>() != null)
|
||||
{
|
||||
Vector3 playerPos = player.transform.position;
|
||||
playerPos.y = transform.position.y;
|
||||
Quaternion newRotation = Quaternion.LookRotation(playerPos - transform.position, transform.TransformDirection(Vector3.up));
|
||||
ParticleSystem particleSystem = GetComponent<ParticleSystem>();
|
||||
ParticleSystem.ShapeModule shape = particleSystem.shape;
|
||||
shape.rotation = newRotation.eulerAngles;
|
||||
particleSystem.Play();
|
||||
yield return new WaitUntil(() => !particleSystem.isPlaying);
|
||||
}
|
||||
particlePlayed = true;
|
||||
}
|
||||
|
||||
IEnumerator playAnimation(GameObject player)
|
||||
{
|
||||
if (clip != null)
|
||||
{
|
||||
player.GetComponent<Animator>().Play(clip.name);
|
||||
yield return new WaitForSeconds(clip.length);
|
||||
}
|
||||
animationPlayed = true;
|
||||
}
|
||||
|
||||
public void destroyObject()
|
||||
{
|
||||
if (particlePlayed && animationPlayed && !keepAlive)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4e98ea4e0e891353aa6bdff9dfb8ead8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -2,25 +2,15 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.Scripts
|
||||
namespace Assets.Scripts.InteractableObjects
|
||||
{
|
||||
public class NPC : MonoBehaviour
|
||||
public class NPC : InteractableObject
|
||||
{
|
||||
bool hasQuest = true;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void interact()
|
||||
|
||||
public override void handleInteraction(GameObject player)
|
||||
{
|
||||
keepAlive = true;
|
||||
if (hasQuest)
|
||||
{
|
||||
GameObject.Find("UIHandler").GetComponent<UIHandler>().showMessage("SUCCESS;"+TextHandler.getText("gotQuest"));
|
||||
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 87ac36bb4d63c7b4f901ce681578ca4b
|
||||
guid: 502dfdd16cfb094a89708a6d31f80af2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
14
Assets/Scripts/InteractableObjects/Ore.cs
Normal file
14
Assets/Scripts/InteractableObjects/Ore.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.Scripts.InteractableObjects
|
||||
{
|
||||
public class Ore : InteractableObject
|
||||
{
|
||||
public override void handleInteraction(GameObject player)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/InteractableObjects/Ore.cs.meta
Normal file
11
Assets/Scripts/InteractableObjects/Ore.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ab6955d1e578ef1b88f1ee3b6fa83051
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
14
Assets/Scripts/InteractableObjects/Stone.cs
Normal file
14
Assets/Scripts/InteractableObjects/Stone.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.Scripts.InteractableObjects
|
||||
{
|
||||
public class Stone : InteractableObject
|
||||
{
|
||||
public override void handleInteraction(GameObject player)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/InteractableObjects/Stone.cs.meta
Normal file
11
Assets/Scripts/InteractableObjects/Stone.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4fc88a9ab15a9238baf100c2fd070aa7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
14
Assets/Scripts/InteractableObjects/Tree.cs
Normal file
14
Assets/Scripts/InteractableObjects/Tree.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.Scripts.InteractableObjects
|
||||
{
|
||||
public class Tree : InteractableObject
|
||||
{
|
||||
public override void handleInteraction(GameObject player)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/InteractableObjects/Tree.cs.meta
Normal file
11
Assets/Scripts/InteractableObjects/Tree.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9d069bae9082b7b60a2a05060a98424e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -2,6 +2,7 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using Assets.Scripts.InteractableObjects;
|
||||
|
||||
namespace Assets.Scripts.Player
|
||||
{
|
||||
|
||||
@ -9,6 +9,7 @@ using Assets.Scripts.Classes;
|
||||
using Assets.Scripts.Races;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using UnityEngine.InputSystem;
|
||||
using Assets.Scripts.InteractableObjects;
|
||||
|
||||
namespace Assets.Scripts.Player
|
||||
{
|
||||
@ -88,7 +89,7 @@ namespace Assets.Scripts.Player
|
||||
{
|
||||
now = DateTime.Now;
|
||||
player.regainSecondary(inventory.getEquipmentBonus()["MPR"], inventory.getEquipmentBonus()["MP"]);
|
||||
player.healPlayer(/*4 - difficulty * 2*/-20, inventory.getEquipmentBonus()["HP"]);
|
||||
player.healPlayer(4 - difficulty * 2, inventory.getEquipmentBonus()["HP"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ using Newtonsoft.Json.Linq;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Assets.Scripts.InteractableObjects;
|
||||
|
||||
namespace Assets.Scripts
|
||||
{
|
||||
|
||||
@ -5,6 +5,7 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using Assets.Scripts.InteractableObjects;
|
||||
|
||||
public class Tile : MonoBehaviour
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user