to master merge

This commit is contained in:
jonasty 2022-05-02 16:09:20 +03:00
parent 6571056d18
commit 2beb3298c6
10 changed files with 138 additions and 117 deletions

View File

@ -1,18 +1,5 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-1458936301379465483
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 5
--- !u!21 &2100000
Material:
serializedVersion: 6
@ -135,3 +122,16 @@ Material:
- _WavingTint: {r: 1, g: 1, b: 1, a: 1}
- _Wind: {r: 1, g: 1, b: 4, a: 8}
m_BuildTextureStacks: []
--- !u!114 &132002584372362984
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 5

View File

@ -1,6 +1,6 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-8850970943120936482
--- !u!114 &-6731343359379762165
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}

View File

@ -82,7 +82,7 @@ Material:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
m_BuildTextureStacks: []
--- !u!114 &7435650071506671124
--- !u!114 &2766792793257514549
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}

View File

@ -1,18 +1,5 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-8356627826014067786
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 5
--- !u!21 &2100000
Material:
serializedVersion: 6
@ -178,3 +165,16 @@ Material:
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 1, g: 1, b: 1, a: 1}
m_BuildTextureStacks: []
--- !u!114 &265111258872561219
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 5

View File

@ -1,6 +1,6 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-7070093524437990947
--- !u!114 &-3454129911339181364
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}

View File

@ -1,5 +1,18 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-307200169094690312
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 5
--- !u!21 &2100000
Material:
serializedVersion: 6
@ -173,16 +186,3 @@ Material:
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 1, g: 1, b: 1, a: 1}
m_BuildTextureStacks: []
--- !u!114 &7603444385800986913
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 5

View File

@ -97,7 +97,7 @@ Material:
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 1, g: 1, b: 1, a: 1}
m_BuildTextureStacks: []
--- !u!114 &6004310884688239859
--- !u!114 &4114504498260272113
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}

View File

@ -1,18 +1,5 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-5876665935919361285
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 5
--- !u!21 &2100000
Material:
serializedVersion: 6
@ -93,3 +80,16 @@ Material:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
m_BuildTextureStacks: []
--- !u!114 &8185076140583842307
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 5

View File

@ -140,31 +140,6 @@ AnimatorStateTransition:
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &-3741334239111002070
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: Dead
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 1102835054974116572}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.75
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1102 &-1989803667490188130
AnimatorState:
serializedVersion: 6
@ -242,6 +217,28 @@ AnimatorStateTransition:
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &-661908585856255301
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions: []
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 0}
m_Solo: 0
m_Mute: 0
m_IsExit: 1
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 2
m_HasExitTime: 1
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!91 &9100000
AnimatorController:
m_ObjectHideFlags: 0
@ -275,18 +272,6 @@ AnimatorController:
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
- m_Name: Dead
m_Type: 4
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
- m_Name: DeathComplete
m_Type: 4
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Base Layer
@ -897,8 +882,10 @@ AnimatorState:
m_Name: Die
m_Speed: 1
m_CycleOffset: 0
m_Transitions: []
m_StateMachineBehaviours: []
m_Transitions:
- {fileID: -661908585856255301}
m_StateMachineBehaviours:
- {fileID: 7912422198382985104}
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
@ -1080,7 +1067,7 @@ AnimatorStateMachine:
m_Position: {x: 670, y: 550, z: 0}
- serializedVersion: 1
m_State: {fileID: 1102835054974116572}
m_Position: {x: 300, y: -80, z: 0}
m_Position: {x: 40, y: 380, z: 0}
- serializedVersion: 1
m_State: {fileID: 8194647877007136643}
m_Position: {x: 300, y: 220, z: 0}
@ -1091,14 +1078,13 @@ AnimatorStateMachine:
m_State: {fileID: -6878085496064969341}
m_Position: {x: 300, y: 300, z: 0}
m_ChildStateMachines: []
m_AnyStateTransitions:
- {fileID: -3741334239111002070}
m_AnyStateTransitions: []
m_EntryTransitions: []
m_StateMachineTransitions: {}
m_StateMachineBehaviours: []
m_AnyStatePosition: {x: 60, y: -70, z: 0}
m_AnyStatePosition: {x: 50, y: 20, z: 0}
m_EntryPosition: {x: 100, y: 150, z: 0}
m_ExitPosition: {x: 90, y: 510, z: 0}
m_ExitPosition: {x: 50, y: 440, z: 0}
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
m_DefaultState: {fileID: 1102546605246812244}
--- !u!1101 &4009614032068998235
@ -1151,6 +1137,18 @@ AnimatorStateTransition:
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!114 &7912422198382985104
MonoBehaviour:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: aa7306c35f4c27d4daefb1259633b9d0, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1102 &8194647877007136643
AnimatorState:
serializedVersion: 6

View File

@ -19,8 +19,10 @@ public class SlimeAI : MonoBehaviour
private bool isRotatingRight = false;
private bool isWalking = false;
public UnityEvent onDeathComplete;
private bool isAttacking = false;
private float attackStartTime;
public UnityEvent onDeathComplete;
//[SerializeField]
//private UnityEvent onAttack;
@ -29,14 +31,20 @@ public class SlimeAI : MonoBehaviour
{
animator = GetComponent<Animator>();
player = GameObject.FindWithTag("Player");
HP = 2;
HP = 0;
}
// Update is called once per frame
void Update()
{
playerDistance = Vector3.Distance(player.transform.position, transform.position);
if (HP <= 0)
{
animator.Play("Die");
onDeathComplete.Invoke();
}
if (playerDistance < 1.5) //Attack
{
animator.SetBool("Wandering", false);
@ -44,6 +52,7 @@ public class SlimeAI : MonoBehaviour
animator.SetBool("EnemyInAggroRange", true);
animator.SetBool("EnemyInVisionRange", true);
Rotate();
Attack();
}
else if (playerDistance < 10) //Chase
{
@ -69,12 +78,15 @@ public class SlimeAI : MonoBehaviour
animator.SetBool("EnemyInAggroRange", false);
animator.SetBool("EnemyInVisionRange", false);
}
if (!isWandering)
{
//Idle
StartCoroutine("Wander");
}
Debug.Log(isWandering);
Debug.Log(isRotatingLeft);
Debug.Log(isRotatingRight);
if (isRotatingRight == true)
{
animator.SetBool("Wandering", false);
@ -90,18 +102,6 @@ public class SlimeAI : MonoBehaviour
animator.SetBool("Wandering", true);
transform.position += transform.forward * moveSpeed * Time.deltaTime;
}
if (HP <= 0)
{
animator.SetBool("Dead", true);
}
if (animator.GetBool("Dead"))
{
print("asd");
Destroy(this.gameObject);
onDeathComplete.Invoke();
}
@ -124,6 +124,29 @@ public class SlimeAI : MonoBehaviour
HP -= dmg;
}
void Attack()
{
if (!isAttacking)
{
isAttacking = true;
attackStartTime = Time.time;
StartCoroutine(DelayedAttack());
}
else if (Time.time - attackStartTime > 0.833)
{
isAttacking = false;
attackStartTime = 0.0f;
}
}
IEnumerator DelayedAttack()
{
yield return new WaitForSeconds(0.2f);
Debug.Log("Attack");
//do attack e.g check for player in range/hit collider
}
IEnumerator Wander()
{
int rotTime = Random.Range(1, 3);
@ -154,4 +177,4 @@ public class SlimeAI : MonoBehaviour
isWandering = false;
}
}
}