| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  | using System; | 
					
						
							|  |  |  |  | using System.Collections; | 
					
						
							|  |  |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  |  | using UnityEngine; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | public class SoldierStateRun : BaseState<SoldierUnit> | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     public override void EnterState(Type pLastState) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         base.EnterState(pLastState); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         if (mMaster.AtkType == AttackType.Near) | 
					
						
							|  |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-09-09 14:35:49 +00:00
										 |  |  |  |             mMaster.ClearDeadAtkTarget(); | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  |             if (mMaster.HasAttackableTarget) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 ChangeState(typeof(SoldierStateAttack)); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 mMaster.SetACTrigger(SoldierACTrigger.TriggerRun); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         else if (mMaster.AtkType == AttackType.Far) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             mMaster.ShootTarget = mMaster.AgainstGroup.GetNearestTarget(mMaster.transform.position, mMaster.AtkDistance); | 
					
						
							|  |  |  |  |             if (mMaster.ShootTarget != null && !mMaster.ShootTarget.IsDead) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 ChangeState(typeof(SoldierStateShoot)); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 mMaster.SetACTrigger(SoldierACTrigger.TriggerRun); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     public override void ExecuteState(float pDeltaTime) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         base.ExecuteState(pDeltaTime); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         if (mMaster.AtkType == AttackType.Near) | 
					
						
							|  |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-09-09 14:35:49 +00:00
										 |  |  |  |             mMaster.ClearDeadAtkTarget(); | 
					
						
							| 
									
										
										
										
											2022-05-23 13:39:59 +00:00
										 |  |  |  |             if (mMaster.HasAttackableTarget) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 ChangeState(typeof(SoldierStateAttack)); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 if (mMaster.MoveTarget != null && !mMaster.MoveTarget.IsDead) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     mMaster.MoveToTarget(pDeltaTime); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 else | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     ChangeState(typeof(SoldierStateIdle)); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         else if (mMaster.AtkType == AttackType.Far) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             mMaster.ShootTarget = mMaster.AgainstGroup.GetNearestTarget(mMaster.transform.position, mMaster.AtkDistance); | 
					
						
							|  |  |  |  |             if (mMaster.ShootTarget != null && !mMaster.ShootTarget.IsDead) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 ChangeState(typeof(SoldierStateShoot)); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 if (mMaster.MoveTarget != null && !mMaster.MoveTarget.IsDead) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     mMaster.MoveToTarget(pDeltaTime); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 else | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     ChangeState(typeof(SoldierStateIdle)); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     public override void ExitState(Type pNextState) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         base.ExitState(pNextState); | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | } |