ajout event animation, ajout classe Root qui sert de transition entre la classe Entity et l'animator.
This commit is contained in:
parent
5238cb2e8a
commit
e44264d66f
@ -2066,4 +2066,11 @@ AnimationClip:
|
|||||||
script: {fileID: 0}
|
script: {fileID: 0}
|
||||||
m_HasGenericRootTransform: 1
|
m_HasGenericRootTransform: 1
|
||||||
m_HasMotionFloatCurves: 0
|
m_HasMotionFloatCurves: 0
|
||||||
m_Events: []
|
m_Events:
|
||||||
|
- time: 0.6166667
|
||||||
|
functionName: ShotProjectile
|
||||||
|
data:
|
||||||
|
objectReferenceParameter: {fileID: 0}
|
||||||
|
floatParameter: 0
|
||||||
|
intParameter: 0
|
||||||
|
messageOptions: 0
|
||||||
|
|||||||
@ -4962,4 +4962,11 @@ AnimationClip:
|
|||||||
script: {fileID: 0}
|
script: {fileID: 0}
|
||||||
m_HasGenericRootTransform: 1
|
m_HasGenericRootTransform: 1
|
||||||
m_HasMotionFloatCurves: 0
|
m_HasMotionFloatCurves: 0
|
||||||
m_Events: []
|
m_Events:
|
||||||
|
- time: 0.65
|
||||||
|
functionName: Attack
|
||||||
|
data:
|
||||||
|
objectReferenceParameter: {fileID: 0}
|
||||||
|
floatParameter: 0
|
||||||
|
intParameter: 0
|
||||||
|
messageOptions: 0
|
||||||
|
|||||||
@ -497,6 +497,7 @@ GameObject:
|
|||||||
- component: {fileID: 4594931196062474192}
|
- component: {fileID: 4594931196062474192}
|
||||||
- component: {fileID: 3579562406765713002}
|
- component: {fileID: 3579562406765713002}
|
||||||
- component: {fileID: 2002611158446544964}
|
- component: {fileID: 2002611158446544964}
|
||||||
|
- component: {fileID: 7161153261079215068}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: root
|
m_Name: root
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@ -562,6 +563,19 @@ SortingGroup:
|
|||||||
m_SortingLayerID: 0
|
m_SortingLayerID: 0
|
||||||
m_SortingLayer: 0
|
m_SortingLayer: 0
|
||||||
m_SortingOrder: 2
|
m_SortingOrder: 2
|
||||||
|
--- !u!114 &7161153261079215068
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1531129202202440418}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: c0fbd934c179894458914437255781c4, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
_entity: {fileID: 313037212318601125}
|
||||||
--- !u!1 &1776168629768863343
|
--- !u!1 &1776168629768863343
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@ -527,7 +527,6 @@ MonoBehaviour:
|
|||||||
_speed: 0
|
_speed: 0
|
||||||
_attack_damage: 10
|
_attack_damage: 10
|
||||||
_attack_speed: 2
|
_attack_speed: 2
|
||||||
_arrow: {fileID: 6962989255644195630, guid: 869a03bba705e8d4485aa73daad773dc, type: 3}
|
|
||||||
--- !u!1 &6962989255710846697
|
--- !u!1 &6962989255710846697
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -686,6 +685,7 @@ GameObject:
|
|||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 6962989255883535387}
|
- component: {fileID: 6962989255883535387}
|
||||||
- component: {fileID: 6962989255883535384}
|
- component: {fileID: 6962989255883535384}
|
||||||
|
- component: {fileID: 8020346774049635274}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: root
|
m_Name: root
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@ -735,6 +735,20 @@ Animator:
|
|||||||
m_AllowConstantClipSamplingOptimization: 1
|
m_AllowConstantClipSamplingOptimization: 1
|
||||||
m_KeepAnimatorStateOnDisable: 0
|
m_KeepAnimatorStateOnDisable: 0
|
||||||
m_WriteDefaultValuesOnDisable: 0
|
m_WriteDefaultValuesOnDisable: 0
|
||||||
|
--- !u!114 &8020346774049635274
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 6962989255883535386}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: c0fbd934c179894458914437255781c4, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
_entity: {fileID: 5998513223176943995}
|
||||||
|
_projectile: {fileID: 6962989255644195630, guid: 869a03bba705e8d4485aa73daad773dc, type: 3}
|
||||||
--- !u!1 &6962989255885988245
|
--- !u!1 &6962989255885988245
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@ -685,6 +685,7 @@ GameObject:
|
|||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 6962989255883535387}
|
- component: {fileID: 6962989255883535387}
|
||||||
- component: {fileID: 6962989255883535384}
|
- component: {fileID: 6962989255883535384}
|
||||||
|
- component: {fileID: 5665233094155356672}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: root
|
m_Name: root
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@ -734,6 +735,19 @@ Animator:
|
|||||||
m_AllowConstantClipSamplingOptimization: 1
|
m_AllowConstantClipSamplingOptimization: 1
|
||||||
m_KeepAnimatorStateOnDisable: 0
|
m_KeepAnimatorStateOnDisable: 0
|
||||||
m_WriteDefaultValuesOnDisable: 0
|
m_WriteDefaultValuesOnDisable: 0
|
||||||
|
--- !u!114 &5665233094155356672
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 6962989255883535386}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: c0fbd934c179894458914437255781c4, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
_entity: {fileID: 8585520847943034727}
|
||||||
--- !u!1 &6962989255885988245
|
--- !u!1 &6962989255885988245
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@ -24,13 +24,7 @@ public class Ally : Entity
|
|||||||
//Attack Cooldown
|
//Attack Cooldown
|
||||||
if(AttackSpeed < AttackSpeedWait) {
|
if(AttackSpeed < AttackSpeedWait) {
|
||||||
|
|
||||||
Enemy.Hit(AttackDamage);
|
Animation.PlayAttackAnim();
|
||||||
|
|
||||||
//Kill if no hp
|
|
||||||
if(Enemy.Hp <= 0) {
|
|
||||||
IsEnemyDetected = false;
|
|
||||||
Enemy.Death();
|
|
||||||
}
|
|
||||||
|
|
||||||
AttackSpeedWait = 0f;
|
AttackSpeedWait = 0f;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,17 +5,9 @@ using UnityEngine;
|
|||||||
public class Archer : Ally
|
public class Archer : Ally
|
||||||
{
|
{
|
||||||
|
|
||||||
[SerializeField]
|
|
||||||
private GameObject _arrow;
|
|
||||||
|
|
||||||
private Rigidbody2D _rigidbodyAlly;
|
|
||||||
private Rigidbody2D _rigidbodyOpponent;
|
|
||||||
|
|
||||||
public override void Start()
|
public override void Start()
|
||||||
{
|
{
|
||||||
base.Start();
|
base.Start();
|
||||||
|
|
||||||
_rigidbodyAlly = GetComponent<Rigidbody2D>();
|
|
||||||
Animation = gameObject.AddComponent<AnimationEntity>();
|
Animation = gameObject.AddComponent<AnimationEntity>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,7 +15,6 @@ public class Archer : Ally
|
|||||||
{
|
{
|
||||||
|
|
||||||
if(IsEnemyDetected) {
|
if(IsEnemyDetected) {
|
||||||
_rigidbodyOpponent = Enemy.GetComponent<Rigidbody2D>();
|
|
||||||
AttackEnemy();
|
AttackEnemy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,14 +28,7 @@ public class Archer : Ally
|
|||||||
|
|
||||||
Animation.PlayAttackAnim();
|
Animation.PlayAttackAnim();
|
||||||
|
|
||||||
GameObject _newArrow = Instantiate(_arrow, _rigidbodyAlly.position, Quaternion.identity);
|
|
||||||
|
|
||||||
//Warning : the Speed of the arrow is equal to the speed of this unit, if this unit need to move, use an other variable !
|
|
||||||
_newArrow.GetComponent<Projectile>().Damage = AttackDamage;
|
|
||||||
_newArrow.GetComponent<Projectile>().EnemySpeed = Enemy.Speed;
|
|
||||||
_newArrow.GetComponent<Projectile>().VectorStart = _rigidbodyAlly.position;
|
|
||||||
_newArrow.GetComponent<Projectile>().VectorEnd = _rigidbodyOpponent.position;
|
|
||||||
_newArrow.GetComponent<Projectile>().Target = Enemy;
|
|
||||||
|
|
||||||
AttackSpeedWait = 0f;
|
AttackSpeedWait = 0f;
|
||||||
|
|
||||||
|
|||||||
@ -36,13 +36,6 @@ public class Opponent : Entity
|
|||||||
{
|
{
|
||||||
Animation.PlayAttackAnim();
|
Animation.PlayAttackAnim();
|
||||||
|
|
||||||
Enemy.Hit(AttackDamage);
|
|
||||||
|
|
||||||
//Kill if no hp
|
|
||||||
if(Enemy.Hp <= 0) {
|
|
||||||
Enemy.Death();
|
|
||||||
}
|
|
||||||
|
|
||||||
AttackSpeedWait = 0f;
|
AttackSpeedWait = 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
37
Assets/Scripts/Root.cs
Normal file
37
Assets/Scripts/Root.cs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class Root : MonoBehaviour
|
||||||
|
{
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
private Entity _entity;
|
||||||
|
[SerializeField]
|
||||||
|
private GameObject _projectile;
|
||||||
|
|
||||||
|
void Attack() {
|
||||||
|
_entity.Enemy.Hit( _entity.AttackDamage);
|
||||||
|
if(_entity.Enemy.Hp <= 0) {
|
||||||
|
_entity.Enemy.Death();
|
||||||
|
_entity.IsEnemyDetected = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShotProjectile() {
|
||||||
|
Rigidbody2D _rigidbodyAlly;
|
||||||
|
Rigidbody2D _rigidbodyOpponent;
|
||||||
|
_rigidbodyAlly = _entity.GetComponent<Rigidbody2D>();
|
||||||
|
_rigidbodyOpponent = _entity.Enemy.GetComponent<Rigidbody2D>();
|
||||||
|
|
||||||
|
GameObject _newArrow = Instantiate(_projectile, _rigidbodyAlly.position, Quaternion.identity);
|
||||||
|
|
||||||
|
//Warning : the Speed of the arrow is equal to the speed of this unit, if this unit need to move, use an other variable !
|
||||||
|
_newArrow.GetComponent<Projectile>().Damage = _entity.AttackDamage;
|
||||||
|
_newArrow.GetComponent<Projectile>().EnemySpeed = _entity.Enemy.Speed;
|
||||||
|
_newArrow.GetComponent<Projectile>().VectorStart = _rigidbodyAlly.position;
|
||||||
|
_newArrow.GetComponent<Projectile>().VectorEnd = _rigidbodyOpponent.position;
|
||||||
|
_newArrow.GetComponent<Projectile>().Target = _entity.Enemy;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Scripts/Root.cs.meta
Normal file
11
Assets/Scripts/Root.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c0fbd934c179894458914437255781c4
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Loading…
x
Reference in New Issue
Block a user