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.
		
		
		
		
		
			
		
			
				
	
	
		
			52 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			C#
		
	
			
		
		
	
	
			52 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			C#
		
	
| using Entitas;
 | |
| using UnityEngine;
 | |
| using Game;
 | |
| public class BulletSystem : IExecuteSystem, IInitializeSystem
 | |
| {
 | |
|     private IGroup<GameEntity> _entities;
 | |
|     public void Initialize()
 | |
|     {
 | |
|         _entities = Util.GetGroup(GameMatcher.Bullet);
 | |
|     }
 | |
|     public void Execute()
 | |
|     {
 | |
|         foreach (var entity in _entities)
 | |
|         {
 | |
|             if (Util.IsPause(entity))
 | |
|             {
 | |
|                 continue;
 | |
|             }
 | |
|             UpdateBulletViewRot(entity);    // 更新子弹旋转
 | |
|             // UpdateBullet(entity);
 | |
|             UpdateBulletAlive(entity); //子弹销毁
 | |
|         }
 | |
|     }
 | |
|     public void UpdateBulletAlive(GameEntity entity)
 | |
|     {
 | |
|         if (!entity.timeline.IsRunning)
 | |
|         {
 | |
|             //时间轴跑完
 | |
|             Util.DestroyEntity(entity);
 | |
|         }
 | |
|         if (entity.move.IsAgainstWall)
 | |
|         {
 | |
|             //击中墙壁
 | |
|             Util.DestroyEntity(entity);
 | |
|         }
 | |
|         if (entity.skill.HitSet.Count > 0)
 | |
|         {
 | |
|             //命中
 | |
|             Util.DestroyEntity(entity);
 | |
|         }
 | |
|     }
 | |
|     public void UpdateBulletViewRot(GameEntity entity)
 | |
|     {
 | |
|         var view = entity.view;
 | |
|         var dir = entity.move.MoveDir;
 | |
|         if (dir.magnitude > 0)
 | |
|         {
 | |
|             var rot = Quaternion.FromToRotation(Vector3.right, dir);
 | |
|             view.TransformView.localRotation = rot;
 | |
|         }
 | |
|     }
 | |
| } |