aboutsummaryrefslogtreecommitdiffstats
path: root/Assets
diff options
context:
space:
mode:
Diffstat (limited to 'Assets')
-rw-r--r--Assets/Animations/Enemies/Zombie/Attack.anim2
-rw-r--r--Assets/Animations/Enemies/Zombie/Zombie.controller73
-rw-r--r--Assets/Scenes/Jungle.unity16
-rw-r--r--Assets/Scripts/Actors/Enemy.cs24
4 files changed, 103 insertions, 12 deletions
diff --git a/Assets/Animations/Enemies/Zombie/Attack.anim b/Assets/Animations/Enemies/Zombie/Attack.anim
index 43658a5..33cb5f7 100644
--- a/Assets/Animations/Enemies/Zombie/Attack.anim
+++ b/Assets/Animations/Enemies/Zombie/Attack.anim
@@ -69,7 +69,7 @@ AnimationClip:
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
- m_LoopTime: 1
+ m_LoopTime: 0
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0
diff --git a/Assets/Animations/Enemies/Zombie/Zombie.controller b/Assets/Animations/Enemies/Zombie/Zombie.controller
index 7cc8d1f..d7c2a97 100644
--- a/Assets/Animations/Enemies/Zombie/Zombie.controller
+++ b/Assets/Animations/Enemies/Zombie/Zombie.controller
@@ -1,5 +1,27 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
+--- !u!1101 &-8824451288058899808
+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: 5416144975737678020}
+ m_Solo: 0
+ m_Mute: 0
+ m_IsExit: 0
+ serializedVersion: 3
+ m_TransitionDuration: 0.25
+ m_TransitionOffset: 0
+ m_ExitTime: 0.25
+ m_HasExitTime: 1
+ m_HasFixedDuration: 1
+ m_InterruptionSource: 0
+ m_OrderedInterruption: 1
+ m_CanTransitionToSelf: 1
--- !u!1102 &-2461426347161001773
AnimatorState:
serializedVersion: 6
@@ -8,9 +30,10 @@ AnimatorState:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Attack
- m_Speed: 1
+ m_Speed: 0.5
m_CycleOffset: 0
- m_Transitions: []
+ m_Transitions:
+ - {fileID: -8824451288058899808}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
@@ -67,7 +90,19 @@ AnimatorController:
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
- m_Controller: {fileID: 0}
+ m_Controller: {fileID: 9100000}
+ - m_Name: attack
+ m_Type: 9
+ m_DefaultFloat: 0
+ m_DefaultInt: 0
+ m_DefaultBool: 0
+ m_Controller: {fileID: 9100000}
+ - m_Name: airborn
+ m_Type: 4
+ m_DefaultFloat: 0
+ m_DefaultInt: 0
+ m_DefaultBool: 0
+ m_Controller: {fileID: 9100000}
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Base Layer
@@ -92,7 +127,7 @@ AnimatorStateMachine:
m_ChildStates:
- serializedVersion: 1
m_State: {fileID: -2461426347161001773}
- m_Position: {x: 290, y: -30, z: 0}
+ m_Position: {x: 470, y: 10, z: 0}
- serializedVersion: 1
m_State: {fileID: 5416144975737678020}
m_Position: {x: 320, y: 120, z: 0}
@@ -100,11 +135,12 @@ AnimatorStateMachine:
m_State: {fileID: -1887222890965656619}
m_Position: {x: 440, y: 270, z: 0}
m_ChildStateMachines: []
- m_AnyStateTransitions: []
+ m_AnyStateTransitions:
+ - {fileID: 5673627202155167741}
m_EntryTransitions: []
m_StateMachineTransitions: {}
m_StateMachineBehaviours: []
- m_AnyStatePosition: {x: 40, y: -30, z: 0}
+ m_AnyStatePosition: {x: 140, y: -10, z: 0}
m_EntryPosition: {x: 90, y: 80, z: 0}
m_ExitPosition: {x: 800, y: 120, z: 0}
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
@@ -161,6 +197,31 @@ AnimatorState:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
+--- !u!1101 &5673627202155167741
+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: attack
+ m_EventTreshold: 0
+ m_DstStateMachine: {fileID: 0}
+ m_DstState: {fileID: -2461426347161001773}
+ 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!1101 &9190035719620373905
AnimatorStateTransition:
m_ObjectHideFlags: 1
diff --git a/Assets/Scenes/Jungle.unity b/Assets/Scenes/Jungle.unity
index d385757..8cf717f 100644
--- a/Assets/Scenes/Jungle.unity
+++ b/Assets/Scenes/Jungle.unity
@@ -325005,10 +325005,6 @@ PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- - target: {fileID: -849362167687110816, guid: be3f47d037eef1240b8271b5e1da25ba, type: 3}
- propertyPath: m_IsTrigger
- value: 0
- objectReference: {fileID: 0}
- target: {fileID: 199732719703436395, guid: be3f47d037eef1240b8271b5e1da25ba, type: 3}
propertyPath: m_RootOrder
value: 9
@@ -325053,6 +325049,18 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
+ - target: {fileID: 514569869678374215, guid: be3f47d037eef1240b8271b5e1da25ba, type: 3}
+ propertyPath: m_Size.x
+ value: 1.198549
+ objectReference: {fileID: 0}
+ - target: {fileID: 514569869678374215, guid: be3f47d037eef1240b8271b5e1da25ba, type: 3}
+ propertyPath: m_Enabled
+ value: 1
+ objectReference: {fileID: 0}
+ - target: {fileID: 514569869678374215, guid: be3f47d037eef1240b8271b5e1da25ba, type: 3}
+ propertyPath: m_Offset.x
+ value: -0.030214876
+ objectReference: {fileID: 0}
- target: {fileID: 4799600927363337844, guid: be3f47d037eef1240b8271b5e1da25ba, type: 3}
propertyPath: m_Name
value: Zombie
diff --git a/Assets/Scripts/Actors/Enemy.cs b/Assets/Scripts/Actors/Enemy.cs
index 6862298..3db479f 100644
--- a/Assets/Scripts/Actors/Enemy.cs
+++ b/Assets/Scripts/Actors/Enemy.cs
@@ -1,11 +1,14 @@
using UnityEngine;
+using System.Collections;
namespace MontanaJohns.Actors
{
[RequireComponent(typeof(Rigidbody2D))]
public class Enemy : Actor
{
- GameObject player;
+ protected GameObject player;
+ protected float attackRate = 0.5f;
+ protected float nextAttackTime = 0f;
protected override void Awake()
{
@@ -16,12 +19,31 @@ namespace MontanaJohns.Actors
// Update is called once per frame
void Update()
{
+ MoveTowardsPlayer();
+ Attack();
+ CheckHealth();
+ }
+
+ void MoveTowardsPlayer()
+ {
if (player.transform.position.x < transform.position.x) Move(-stats.speedMultiplier * 0.5f);
else Move(stats.speedMultiplier * 0.5f);
+ }
+ void CheckHealth()
+ {
if (health <= 0) Destroy(gameObject);
}
+ void Attack()
+ {
+ if (Mathf.Abs(player.transform.position.x - transform.position.x) <= 3 && Time.time >= nextAttackTime) {
+ _animator.SetTrigger("attack");
+ player.GetComponent<Actor>().TakeDamage(1);
+ nextAttackTime = Time.time + 1f / attackRate;
+ }
+ }
+
private void OnCollisionEnter2D(Collision2D other)
{
if (other.gameObject.tag == "Projectile")