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.
		
		
		
		
		
			
		
			
	
	
		
			189 lines
		
	
	
		
			5.9 KiB
		
	
	
	
		
			C#
		
	
		
		
			
		
	
	
			189 lines
		
	
	
		
			5.9 KiB
		
	
	
	
		
			C#
		
	
| 
											2 years ago
										 | using System.Collections.Generic; | ||
|  | using UnityEngine; | ||
|  | using Bolt; | ||
|  | 
 | ||
|  | namespace Game | ||
|  | { | ||
|  |     [UnitTitle("删除实体")] | ||
|  |     [UnitSubtitle("NodeDestroyEntity")] | ||
|  |     [UnitCategory("Game-Entity")] | ||
|  |     public class NodeDestroyEntity : NodeDefault | ||
|  |     { | ||
|  |         public ValueInput entity; | ||
|  |         protected override void Def() | ||
|  |         { | ||
|  |             entity = ValueInput<int>("entity"); | ||
|  |         } | ||
|  |         protected override void Run(Flow flow) | ||
|  |         { | ||
|  |             Util.DestroyEntity(flow.GetValue<int>(entity)); | ||
|  |         } | ||
|  |     } | ||
|  | 
 | ||
|  |     [UnitTitle("实体位置")] | ||
|  |     [UnitSubtitle("NodeEntityPosition")] | ||
|  |     [UnitCategory("Game-Entity")] | ||
|  |     public class NodeEntityPosition : NodeDefault | ||
|  |     { | ||
|  |         public ValueInput entity; | ||
|  |         public ValueOutput pos; | ||
|  |         protected override void Def() | ||
|  |         { | ||
|  |             entity = ValueInput<int>("entity"); | ||
|  |             pos = ValueOutput<Vector3>("pos"); | ||
|  |         } | ||
|  |         protected override void Run(Flow flow) | ||
|  |         { | ||
|  |             var e = flow.GetValue<int>(entity); | ||
|  |             var p = Util.EntityLogicPos(e); | ||
|  |             flow.SetValue(pos, p); | ||
|  |         } | ||
|  |     } | ||
|  |     [UnitTitle("实体距离")] | ||
|  |     [UnitSubtitle("NodeEntityDistance")] | ||
|  |     [UnitCategory("Game-Entity")] | ||
|  |     public class NodeEntityDistance : NodeDefault | ||
|  |     { | ||
|  |         public ValueInput entity1; | ||
|  |         public ValueInput entity2; | ||
|  |         public ValueOutput distance; | ||
|  |         protected override void Def() | ||
|  |         { | ||
|  |             entity1 = ValueInput<int>("entity1"); | ||
|  |             entity2 = ValueInput<int>("entity2"); | ||
|  |             distance = ValueOutput<float>("distance"); | ||
|  |         } | ||
|  |         protected override void Run(Flow flow) | ||
|  |         { | ||
|  |             var e1 = flow.GetValue<int>(entity1); | ||
|  |             var e2 = flow.GetValue<int>(entity2); | ||
|  |             var dist = Util.EntityDistance(e1, e2); | ||
|  |             flow.SetValue(distance, dist); | ||
|  |         } | ||
|  |     } | ||
|  |     [UnitTitle("实体偏移向量(1->2)")] | ||
|  |     [UnitSubtitle("NodeEntityOffset")] | ||
|  |     [UnitCategory("Game-Entity")] | ||
|  |     public class NodeEntityOffset : NodeDefault | ||
|  |     { | ||
|  |         public ValueInput entity1; | ||
|  |         public ValueInput entity2; | ||
|  |         public ValueOutput offset; | ||
|  |         protected override void Def() | ||
|  |         { | ||
|  |             entity1 = ValueInput<int>("entity1"); | ||
|  |             entity2 = ValueInput<int>("entity2"); | ||
|  |             offset = ValueOutput<Vector3>("offset"); | ||
|  |         } | ||
|  |         protected override void Run(Flow flow) | ||
|  |         { | ||
|  |             var e1 = flow.GetValue<int>(entity1); | ||
|  |             var e2 = flow.GetValue<int>(entity2); | ||
|  |             var dist = Util.EntityOffset(e1, e2); | ||
|  |             flow.SetValue(offset, dist); | ||
|  |         } | ||
|  |     } | ||
|  |     [UnitTitle("实体是否浮空")] | ||
|  |     [UnitSubtitle("NodeEntityInAir")] | ||
|  |     [UnitCategory("Game-Entity")] | ||
|  |     public class NodeEntityInAir : NodeDefault | ||
|  |     { | ||
|  |         public ValueInput entity; | ||
|  |         public ValueOutput inAir; | ||
|  |         protected override void Def() | ||
|  |         { | ||
|  |             entity = ValueInput<int>("entity"); | ||
|  |             inAir = ValueOutput<bool>("inAir"); | ||
|  |         } | ||
|  |         protected override void Run(Flow flow) | ||
|  |         { | ||
|  |             var e = flow.GetValue<int>(entity); | ||
|  |             var b = Util.EntityInAir(e); | ||
|  |             flow.SetValue(inAir, b); | ||
|  |         } | ||
|  |     } | ||
|  |     [UnitTitle("移动")] | ||
|  |     [UnitSubtitle("NodeEntityMove")] | ||
|  |     [UnitCategory("Game-Entity")] | ||
|  |     public class NodeEntityMove : NodeDefault | ||
|  |     { | ||
|  |         public ValueInput direction { get; private set; } | ||
|  |         protected override void Def() | ||
|  |         { | ||
|  |             direction = ValueInput<Vector3>("direction"); | ||
|  |         } | ||
|  |         protected override void Run(Flow flow) | ||
|  |         { | ||
|  |             var e = data.Entity; | ||
|  |             var d = flow.GetValue<Vector3>(direction); | ||
|  |             d = new Vector3(d.x, 0, d.z); | ||
|  |             Util.EntityMove(e, d); | ||
|  |         } | ||
|  |     } | ||
|  |     [UnitTitle("停止移动")] | ||
|  |     [UnitSubtitle("NodeEntityStop")] | ||
|  |     [UnitCategory("Game-Entity")] | ||
|  |     public class NodeEntityStop : NodeDefault | ||
|  |     { | ||
|  |         protected override void Run(Flow flow) | ||
|  |         { | ||
|  |             var e = data.Entity; | ||
|  |             Util.EntityStopMove(e); | ||
|  |         } | ||
|  |     } | ||
|  |     [UnitTitle("获取主角")] | ||
|  |     [UnitSubtitle("NodeGetMaster")] | ||
|  |     [UnitCategory("Game-Entity")] | ||
|  |     public class NodeGetMaster : NodeDefault | ||
|  |     { | ||
|  |         public ValueOutput master { get; private set; } | ||
|  |         protected override void Def() | ||
|  |         { | ||
|  |             master = ValueOutput<int>("master"); | ||
|  |         } | ||
|  |         protected override void Run(Flow flow) | ||
|  |         { | ||
|  |             flow.SetValue(master, Util.GetMasterID()); | ||
|  |         } | ||
|  |     } | ||
|  |     [UnitTitle("获取所有敌人")] | ||
|  |     [UnitSubtitle("NodeGetAllEnemies")] | ||
|  |     [UnitCategory("Game-Entity")] | ||
|  |     public class NodeGetAllEnemies : NodeDefault | ||
|  |     { | ||
|  |         public ValueOutput list { get; private set; } | ||
|  |         protected override void Def() | ||
|  |         { | ||
|  |             list = ValueOutput<List<int>>("list"); | ||
|  |         } | ||
|  |         protected override void Run(Flow flow) | ||
|  |         { | ||
|  |             flow.SetValue(list, Util.GetAllEnemies()); | ||
|  |         } | ||
|  |     } | ||
|  |     [UnitTitle("按照实体距离排序")] | ||
|  |     [UnitSubtitle("NodeSortByDistance")] | ||
|  |     [UnitCategory("Game-Entity")] | ||
|  |     public class NodeSortByDistance : NodeDefault | ||
|  |     { | ||
|  |         public ValueInput entity { get; private set; } | ||
|  |         public ValueInput list { get; private set; } | ||
|  |         public ValueOutput result { get; private set; } | ||
|  |         protected override void Def() | ||
|  |         { | ||
|  |             entity = ValueInput<int>("entity"); | ||
|  |             list = ValueInput<List<int>>("list"); | ||
|  |             result = ValueOutput<List<int>>("list"); | ||
|  |         } | ||
|  |         protected override void Run(Flow flow) | ||
|  |         { | ||
|  |             var e = flow.GetValue<int>(entity); | ||
|  |             var l = flow.GetValue<List<int>>(list); | ||
|  |             l.Sort((left, right) => | ||
|  |             { | ||
|  |                 return (int)((Util.EntityDistance(e, left) - Util.EntityDistance(e, right)) * 10); | ||
|  |             }); | ||
|  |             flow.SetValue(result, l); | ||
|  |         } | ||
|  |     } | ||
|  | } |