Commit 3c1a7b98 authored by czy's avatar czy

添加boss动画管理器

parent 062757c0
......@@ -368,7 +368,7 @@ public class BattleUI : MonoBehaviour
//设置战斗UI状态
public void SetBattleObjState(bool bool_)
{
print("显示m_battleObj:"+bool_);
//print("显示m_battleObj:"+bool_);
m_battleObj.SetActive(bool_);
//m_successResultObj.SetActive(bool_);
//m_successResultMaskObj.SetActive(!bool_);
......@@ -502,7 +502,7 @@ public class BattleUI : MonoBehaviour
}
public void UpdateScore2(string name,string text)
{
print("name:" + name + ",text" + text);
//print("name:" + name + ",text" + text);
switch (name)
{
case "Player":
......
......@@ -36,7 +36,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
......
......@@ -22354,4 +22354,11 @@ AnimationClip:
script: {fileID: 0}
m_HasGenericRootTransform: 0
m_HasMotionFloatCurves: 0
m_Events: []
m_Events:
- time: 0
functionName: ChangeAttackType
data:
objectReferenceParameter: {fileID: 0}
floatParameter: 0
intParameter: 0
messageOptions: 0
......@@ -11,26 +11,31 @@ AnimatorStateMachine:
m_ChildStates:
- serializedVersion: 1
m_State: {fileID: -7856523028850394630}
m_Position: {x: -180, y: 200, z: 0}
m_Position: {x: -30, y: 550, z: 0}
- serializedVersion: 1
m_State: {fileID: 4471307210666310047}
m_Position: {x: -220, y: 320, z: 0}
m_Position: {x: -270, y: 340, z: 0}
- serializedVersion: 1
m_State: {fileID: -340101015679708446}
m_Position: {x: 30, y: 460, z: 0}
m_Position: {x: -580, y: 350, z: 0}
- serializedVersion: 1
m_State: {fileID: -5355840141299690807}
m_Position: {x: 30, y: 330, z: 0}
m_Position: {x: -440, y: 500, z: 0}
- serializedVersion: 1
m_State: {fileID: 5730630131191024332}
m_Position: {x: -30, y: 350, z: 0}
m_ChildStateMachines: []
m_AnyStateTransitions: []
m_AnyStateTransitions:
- {fileID: -988131835395953829}
- {fileID: 8973507764031670339}
m_EntryTransitions: []
m_StateMachineTransitions: {}
m_StateMachineBehaviours: []
m_AnyStatePosition: {x: 50, y: 20, z: 0}
m_EntryPosition: {x: 50, y: 120, z: 0}
m_ExitPosition: {x: 80, y: 620, z: 0}
m_AnyStatePosition: {x: -430, y: 200, z: 0}
m_EntryPosition: {x: -10, y: 120, z: 0}
m_ExitPosition: {x: -420, y: 610, z: 0}
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
m_DefaultState: {fileID: -5355840141299690807}
m_DefaultState: {fileID: 5730630131191024332}
--- !u!1102 &-7856523028850394630
AnimatorState:
serializedVersion: 5
......@@ -42,7 +47,7 @@ AnimatorState:
m_Speed: 1
m_CycleOffset: 0
m_Transitions:
- {fileID: 9215743797728680209}
- {fileID: -1429333520268681619}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
......@@ -58,6 +63,56 @@ AnimatorState:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1101 &-6201182350460217250
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 2
m_ConditionEvent: LegSweep
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: -7856523028850394630}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.89285713
m_HasExitTime: 1
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &-5535950680375300128
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 3
m_ConditionEvent: MoveSpeed
m_EventTreshold: 0.2
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: -7856523028850394630}
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 &-5355840141299690807
AnimatorState:
serializedVersion: 5
......@@ -69,9 +124,7 @@ AnimatorState:
m_Speed: 1
m_CycleOffset: 0
m_Transitions:
- {fileID: -1573847190218674684}
- {fileID: 8852921774420047574}
- {fileID: 6084528436147092541}
- {fileID: -4809412122287805464}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
......@@ -86,8 +139,30 @@ AnimatorState:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1101 &-1573847190218674684
m_TimeParameter: MoveSpeed
--- !u!1101 &-4809412122287805464
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: 0.75
m_HasExitTime: 1
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &-1429333520268681619
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
......@@ -95,11 +170,36 @@ AnimatorStateTransition:
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 3
- m_ConditionMode: 4
m_ConditionEvent: MoveSpeed
m_EventTreshold: 0.2
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: -7856523028850394630}
m_DstState: {fileID: 5730630131191024332}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.6428572
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &-988131835395953829
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: HurricaneKick
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 4471307210666310047}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
......@@ -124,6 +224,7 @@ AnimatorState:
m_CycleOffset: 0
m_Transitions:
- {fileID: 4032888935653943640}
- {fileID: -6201182350460217250}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
......@@ -179,6 +280,31 @@ AnimatorController:
m_IKPass: 0
m_SyncedLayerAffectsTiming: 0
m_Controller: {fileID: 9100000}
--- !u!1101 &2335692240658299194
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 2
m_ConditionEvent: HurricaneKick
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: -7856523028850394630}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.8636364
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &4032888935653943640
AnimatorStateTransition:
m_ObjectHideFlags: 1
......@@ -193,7 +319,7 @@ AnimatorStateTransition:
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: -5355840141299690807}
m_Solo: 0
m_Mute: 0
m_Mute: 1
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
......@@ -216,6 +342,7 @@ AnimatorState:
m_CycleOffset: 0
m_Transitions:
- {fileID: 6957880257579340654}
- {fileID: 2335692240658299194}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
......@@ -231,31 +358,33 @@ AnimatorState:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1101 &6084528436147092541
AnimatorStateTransition:
m_ObjectHideFlags: 1
--- !u!1102 &5730630131191024332
AnimatorState:
serializedVersion: 5
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: HurricaneKick
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 4471307210666310047}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.18607777
m_TransitionOffset: 0
m_ExitTime: 0.7942538
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
m_Name: Idle2
m_Speed: 1
m_CycleOffset: 0
m_Transitions:
- {fileID: -5535950680375300128}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400000, guid: 5ee8ce777d6cb89459716b5e56ad39a5, type: 2}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1101 &6957880257579340654
AnimatorStateTransition:
m_ObjectHideFlags: 1
......@@ -270,43 +399,40 @@ AnimatorStateTransition:
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: -5355840141299690807}
m_Solo: 0
m_Mute: 0
m_Mute: 1
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.03374338
m_TransitionOffset: 0
m_ExitTime: 0.9815945
m_HasExitTime: 1
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &8852921774420047574
--- !u!1101 &7648654103078084003
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: LegSweep
m_EventTreshold: 0
m_Conditions: []
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: -340101015679708446}
m_DstState: {fileID: 0}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
m_IsExit: 1
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.75
m_HasExitTime: 0
m_HasExitTime: 1
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &9215743797728680209
--- !u!1101 &8973507764031670339
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
......@@ -314,18 +440,18 @@ AnimatorStateTransition:
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 4
m_ConditionEvent: MoveSpeed
m_EventTreshold: 0.2
- m_ConditionMode: 1
m_ConditionEvent: LegSweep
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: -5355840141299690807}
m_DstState: {fileID: -340101015679708446}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.6428572
m_ExitTime: 0.75
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
......
......@@ -262,17 +262,17 @@ PrefabInstance:
- target: {fileID: -4216859302048453862, guid: 092b5adfc35664b43a5e216c3aba0c4d,
type: 3}
propertyPath: m_LocalScale.x
value: 1
value: 0.8
objectReference: {fileID: 0}
- target: {fileID: -4216859302048453862, guid: 092b5adfc35664b43a5e216c3aba0c4d,
type: 3}
propertyPath: m_LocalScale.y
value: 1
value: 0.8
objectReference: {fileID: 0}
- target: {fileID: -4216859302048453862, guid: 092b5adfc35664b43a5e216c3aba0c4d,
type: 3}
propertyPath: m_LocalScale.z
value: 1
value: 0.8
objectReference: {fileID: 0}
- target: {fileID: -927199367670048503, guid: 092b5adfc35664b43a5e216c3aba0c4d,
type: 3}
......@@ -2386,8 +2386,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 88224c51f1a97cf40895dff846d2a5b3, type: 3}
m_Name:
m_EditorClassIdentifier:
foodNumber: 20
timeSpan: 10
foodNumber: 100
timeSpan: 2
foodPoint:
- {fileID: 1752813316}
- {fileID: 1547259537}
......@@ -6945,6 +6945,7 @@ GameObject:
- component: {fileID: 557966604}
- component: {fileID: 557966602}
- component: {fileID: 557966603}
- component: {fileID: 557966605}
m_Layer: 0
m_Name: Boss
m_TagString: Boss
......@@ -7015,7 +7016,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
VSpeed: 10
life: 30
life: 300
scale: 1
MinScale: 0.2
targetList:
......@@ -7025,9 +7026,27 @@ MonoBehaviour:
MoveSpeed: 0
BirthplacePos: {fileID: 225105685}
EnemyNumber: 0
Timer1: 0
HurricaneKickDuration: 1.5
CurrentHurricaneKickDuration: 0
HurricaneKickCoolingTime: 5
CurrentHurricaneKickCoolingTime: 0
isDeltaTime: 0
LegSweepDuration: 2
CurrentLegSweepDuration: 0
isDeltaTime2: 0
bossState: 0
--- !u!114 &557966605
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 557966600}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 17ab4b61d0b362349828e661a3b978a3, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &560627449 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 5957448836295836418, guid: 15d49ef1e12d35a46b7c6fb953021b43,
......@@ -18506,8 +18525,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 88224c51f1a97cf40895dff846d2a5b3, type: 3}
m_Name:
m_EditorClassIdentifier:
foodNumber: 20
timeSpan: 10
foodNumber: 100
timeSpan: 2
foodPoint:
- {fileID: 297527856}
- {fileID: 1128247090}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public enum BossAnimationState
{
LegSweep=1,
HurricaneKick=2,
NotAttack=3
}
public class BossAnimationManager : MonoBehaviour
{
private Animator animator;
void Start()
{
animator = GetComponentInChildren<Animator>();
}
public void ChangeAnimatorState(BossAnimationState state)
{
print(gameObject.name + ",ChangeAnimatorState:" + state);
switch (state)
{
case BossAnimationState.LegSweep:
animator.SetBool("HurricaneKick", false);
animator.SetBool("LegSweep", true);
animator.SetFloat("MoveSpeed", 0);
break;
case BossAnimationState.HurricaneKick:
animator.SetBool("HurricaneKick", true);
animator.SetBool("LegSweep", false);
animator.SetFloat("MoveSpeed", 0) ;
break;
case BossAnimationState.NotAttack:
animator.SetBool("HurricaneKick", false);
animator.SetBool("LegSweep", false);
break;
default:
animator.SetBool("HurricaneKick", false);
animator.SetBool("LegSweep", false);
Debug.LogError(state);
break;
}
}
}
fileFormatVersion: 2
guid: 17ab4b61d0b362349828e661a3b978a3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -60,7 +60,7 @@ public class BossAttack : MonoBehaviour
public void ChangeAttackType(int i)
{
attackType = (AttackType)i;
//print("改变boss攻击状态为:"+attackType);
print("改变boss攻击状态为:"+attackType);
}
......
......@@ -7,6 +7,7 @@ public class BossMove : MonoBehaviour
[Header("控制移动")]
[Tooltip("控制向前的速度。")]
public float VSpeed = 10.0f;
[Header("生命和缩放")]
public int life = 30;
private int MaxLife;
public float scale = 1;
......@@ -29,20 +30,48 @@ public class BossMove : MonoBehaviour
private float timer = 0.0f;
public GameObject BirthplacePos;//出生点
private BossAttack bossAttack;
[Header("附近敌人个数")]
public int EnemyNumber = 0;
public float Timer1 = 5;
[Header("旋风腿")]
[Tooltip("旋风腿持续时间")]
public float HurricaneKickDuration = 3;
public float CurrentHurricaneKickDuration=0;
[Tooltip("旋风腿冷却时间")]
public float HurricaneKickCoolingTime =5;
public float CurrentHurricaneKickCoolingTime=0;
[Tooltip("旋风腿技能是否处于冷却中")]
public bool isDeltaTime = false;
private bool isAttacking=false;
[Header("扫腿")]
[Tooltip("扫腿冷却时间")]
public float LegSweepDuration = 2;
public float CurrentLegSweepDuration = 0;
[Tooltip("扫腿技能是否处于冷却中")]
public bool isDeltaTime2 = false;
private bool LegSweepIsFinsh = false;
private bool HurricaneKickIsFinsh = false;
private bool IsCanRotate = true;
private bool IsCanMove = true;
private bool isHurricaneKick = false;
public enum BossState
{
Sleep=0, //睡着
GotoTarget=1, //朝着目标点移动
GoBackToSleep=2 //返回碎觉点
GoBackToSleep=2, //返回碎觉点
LegSweep=3,
HurricaneKick=4,
Attack
}
public BossState bossState= BossState.Sleep;
private BossAnimationManager bossAnimationManager;
......@@ -54,6 +83,10 @@ public class BossMove : MonoBehaviour
//获取animator组件
animator = GetComponentInChildren<Animator>();
bossAttack = GetComponentInChildren<BossAttack>();
bossAnimationManager = GetComponentInChildren<BossAnimationManager>();
}
......@@ -106,15 +139,35 @@ public class BossMove : MonoBehaviour
{
//print("游戏是否开始:"+ BattleCtrl.instance.isStartBattle);
//print("游戏是否结束:"+ BattleCtrl.instance.isEndBattle);
//----技能冷却--------------------------------------------------------------
if (isDeltaTime)
{
Timer1 += Time.deltaTime;
if (Timer1 > 5)
//旋风腿处于冷却中
CurrentHurricaneKickCoolingTime += Time.deltaTime;
if (CurrentHurricaneKickCoolingTime > HurricaneKickCoolingTime)
{
Timer1 = 5;
//冷却完成,可以使用技能,重置技能持续时间。
CurrentHurricaneKickDuration = 0;
//重置冷却时间
CurrentHurricaneKickCoolingTime = 0;
//旋风腿退出冷却时间。
isDeltaTime = false;
}
}
if (isDeltaTime2)
{
//扫腿处于冷却中。
CurrentLegSweepDuration += Time.deltaTime;
if (CurrentLegSweepDuration >= LegSweepDuration)
{
CurrentLegSweepDuration = 0;
isDeltaTime2 = false;
}
}
//---------------------------------------------------------------------------
if (!BattleCtrl.instance.isStartBattle)
{
return;
......@@ -132,9 +185,10 @@ public class BossMove : MonoBehaviour
switch (bossState)
{
case BossState.Sleep:
targetObj = null;
break;
case BossState.GotoTarget:
IsCanMove = true;
IsCanRotate = true;
timer += Time.deltaTime;
if (targetObj == null || timer >= 1)
{
......@@ -142,20 +196,9 @@ public class BossMove : MonoBehaviour
timer = 0;
targetObj = GetTargetObj();
}
break;
case BossState.GoBackToSleep:
targetObj = BirthplacePos;
if(Vector3.Distance(new Vector3(transform.position.x,0, transform.position.z), new Vector3(BirthplacePos.transform.position.x,0, BirthplacePos.transform.position.z)) < 0.2f)
{
bossState = BossState.Sleep;
targetObj = null;
}
break;
default:Debug.LogError(bossState);
break;
}
if (targetObj != null)
{
animator.SetBool("LegSweep", false);
animator.SetBool("HurricaneKick", false);
//Boss目标为Player 或者 Competitor,追击目标
Vector3 speed = Vector3.zero;
Vector3 pos1 = new Vector3(transform.position.x, 0, transform.position.z);
Vector3 pos2 = new Vector3(targetObj.transform.position.x, 0, targetObj.transform.position.z);
......@@ -165,48 +208,108 @@ public class BossMove : MonoBehaviour
if (Vector3.Distance(pos1, pos2) < 10f)
{
//敌人进入攻击范围
bossState = BossState.Attack;
}
break;
case BossState.Attack:
IsCanMove = false;
IsCanRotate = false;
//动画播放完成判断距离
LegSweepIsFinsh = !animator.GetCurrentAnimatorStateInfo(0).IsName("Leg Sweep");
HurricaneKickIsFinsh = !animator.GetCurrentAnimatorStateInfo(0).IsName("Hurricane Kick");
float dic = GetHorizontalDistance(transform.position, targetObj.transform.position);
if (LegSweepIsFinsh && HurricaneKickIsFinsh && dic >= 10)
{
//目标退出攻击范围
print("目标退出攻击范围");
bossState = BossState.GotoTarget;
}
//print("boss附近敌人个数:"+ EnemyNumber+"技能是否不能使用:"+ isDeltaTime);
if (EnemyNumber >= 2&& !isDeltaTime)
if (EnemyNumber >= 2)
{
Timer1 -= Time.deltaTime;
if (Timer1 <= 0) isDeltaTime = true; //旋转5秒等待5秒
//print("11111111111111");
animator.SetBool("HurricaneKick", true);
animator.SetBool("LegSweep", false);
isHurricaneKick = true;
}
if (isHurricaneKick && !isDeltaTime && !animator.GetCurrentAnimatorStateInfo(0).IsName("Leg Sweep"))
{
//附近有2个人就触发,技能好了就等待,当前播放的动画不是扫腿就开始播放旋风腿。
print("旋风腿");
CurrentHurricaneKickDuration += Time.deltaTime;//旋风腿持续时间减少
if (CurrentHurricaneKickDuration >= HurricaneKickDuration)
{
//技能使用完成,进入冷却
isDeltaTime = true;
isHurricaneKick = false;
//重新计时冷却时间
CurrentHurricaneKickCoolingTime = 0;
CurrentHurricaneKickDuration = 0;
}
//HurricaneKickTime -= Time.deltaTime;
//if (HurricaneKickTime <= 0)
//{
// isDeltaTime = true; //旋转5秒等待5秒
// isHurricaneKick = false;
//}
bossAnimationManager.ChangeAnimatorState(BossAnimationState.HurricaneKick);
bossAttack.attackType = AttackType.HurricaneKick;
}
else
else if (dic < 10 && !isDeltaTime2)
{
//print("2222222222222");
isAttacking = true;
animator.SetBool("HurricaneKick", false);
animator.SetBool("LegSweep", true);
print("扫腿");
IsCanRotate = true;
//注意的是,技能一开始使用,就进入了冷却计时。所以当前技能释放完成到下一次释放技能时间间隔会小于冷却时间。
isDeltaTime2 = true;
bossAnimationManager.ChangeAnimatorState(BossAnimationState.LegSweep);
bossAttack.attackType = AttackType.LegSweep;
}
}
else
{
isAttacking = false;
animator.SetBool("LegSweep", false);
animator.SetBool("HurricaneKick", false);
//bossAttack.attackType = AttackType.Null;
}
print("追击目标");
bossAnimationManager.ChangeAnimatorState(BossAnimationState.NotAttack);
}
else
break;
case BossState.GoBackToSleep:
targetObj = BirthplacePos;
//Boss目标为出生点
speed = Vector3.zero;
pos1 = new Vector3(transform.position.x, 0, transform.position.z);
pos2 = new Vector3(targetObj.transform.position.x, 0, targetObj.transform.position.z);
speed = (pos2 - pos1).normalized * VSpeed;
xDelta = speed.x * Time.deltaTime;
zDelta = speed.z * Time.deltaTime;
if (Vector3.Distance(pos1, pos2) < 0.2f)
{
//boss回到出生点
bossState = BossState.Sleep;
targetObj = null;
}
break;
default:Debug.LogError(bossState);
break;
}
//控制移动
if (targetObj == null)
{
xDelta = 0;
zDelta = 0;
}
Move();
}
public void Move()
if (targetObj!= null&&IsCanRotate)
{
//是否可以旋转
print("Boss旋转");
Vector3 speed = Vector3.zero;
Vector3 pos1 = new Vector3(transform.position.x, 0, transform.position.z);
Vector3 pos2 = new Vector3(targetObj.transform.position.x, 0, targetObj.transform.position.z);
speed = (pos2 - pos1).normalized * VSpeed;
xDelta = speed.x * Time.deltaTime;
zDelta = speed.z * Time.deltaTime;
float angle = Vector3.Angle(Vector3.forward, new Vector3(xDelta, 0, zDelta));
if (xDelta < 0)
......@@ -214,28 +317,49 @@ public class BossMove : MonoBehaviour
angle = -Mathf.Abs(angle);
}
transform.localEulerAngles = new Vector3(0, angle, 0);
if (isAttacking)
{
}
else
if (IsCanMove)
{
//print("isAttacking:" + isAttacking+"Boss开始移动:" + new Vector3(xDelta, yDelta, zDelta));
//是否可以移动
characterController.Move(new Vector3(xDelta, yDelta, zDelta));//移动
}
//移动
MoveSpeed = new Vector3(xDelta,0,zDelta).magnitude;
MoveSpeed = new Vector3(xDelta / Time.deltaTime, 0, zDelta / Time.deltaTime).magnitude;
//是否在地面
Grounded = characterController.isGrounded;
animator.SetFloat("MoveSpeed", MoveSpeed);
animator.SetBool("Grounded", Grounded);
}
public string GetCurrentAnimatorName()
{
string name=null;
List<string> names = new List<string>() { "Leg Sweep", "Hurricane Kick", "Idle", "Idle2", "Running" };
foreach (string item in names)
{
if (animator.GetCurrentAnimatorStateInfo(0).IsName(item))
{
name = item;
return name;
}
}
Debug.LogError("Boss没有动画状态。");
return name;
}
/// <summary>
/// 获取pos1和pos2的水平距离
/// </summary>
/// <param name="pos1"></param>
/// <param name="pos2"></param>
/// <returns></returns>
public float GetHorizontalDistance(Vector3 pos1, Vector3 pos2)
{
float dic;
pos1 = new Vector3(pos1.x, 0, pos1.z);
pos2 = new Vector3(pos2.x, 0, pos2.z);
dic = Vector3.Distance(pos1, pos2);
return dic;
}
//唤醒boss
public void AwakeBoss(GameObject obj)
......
......@@ -104,10 +104,10 @@ public class PlayerMove : MonoBehaviour
{
if (hit.gameObject== targetWall)
{
print("Player碰到墙:"+ scale);
//print("Player碰到墙:"+ scale);
if (scale>1)
{
print("推墙");
//print("推墙");
hit.gameObject.GetComponent<Rigidbody>().AddForce(new Vector3(0, 0, 100));
scale -= reduceStep;
ReduceIsPlayChangeModeEffect();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment