You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			45 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			C#
		
	
			
		
		
	
	
			45 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			C#
		
	
| namespace Game
 | |
| {
 | |
|     public partial class AIEntityBase<T> where T : new()
 | |
|     {
 | |
|         protected void MoveTo()
 | |
|         {
 | |
|             _moveTo("向前移动", true, 0.6f, 45, 0);
 | |
|         }
 | |
| 
 | |
|         protected void MoveAroundTo()
 | |
|         {
 | |
|             _moveTo("向前环绕", true, 1, 180, 90);
 | |
|         }
 | |
| 
 | |
|         protected void MoveAround()
 | |
|         {
 | |
|             _moveTo("横向环绕", true, 1, 180, 120);
 | |
|         }
 | |
| 
 | |
|         private void _moveTo(string name, bool toward, float randChance, float randAngle, float forbidAngle)
 | |
|         {
 | |
|             Do(name, () =>
 | |
|             {
 | |
|                 var target = Util.GetEntity(_entity.Target());
 | |
|                 var dir = target.Pos() - _entity.Pos();
 | |
|                 if (GameRandom.Roll(randChance))
 | |
|                 {
 | |
|                     dir = GameRandom.RandomDir(dir, randAngle, forbidAngle);
 | |
|                 }
 | |
| 
 | |
|                 Util.EntityMove(_entity.ID(), dir);
 | |
|                 return ETaskStatus.Success;
 | |
|             });
 | |
|         }
 | |
| 
 | |
|         private void _stop()
 | |
|         {
 | |
|             Do($"停止移动", () =>
 | |
|             {
 | |
|                 Util.EntityStopMove(_entity.ID());
 | |
|                 return ETaskStatus.Success;
 | |
|             });
 | |
|         }
 | |
|     }
 | |
| } |