| 
									
										
										
										
											2025-01-02 19:19:36 +08:00
										 |  |  | /* | 
					
						
							|  |  |  | 文件名:NpcObjectClass.nut | 
					
						
							|  |  |  | 路径:User/Object/ActiveObject/NpcObjectClass.nut | 
					
						
							|  |  |  | 创建日期:2024-12-28	11:11 | 
					
						
							|  |  |  | 文件用途:NPC类 | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | class GameObject.NPC extends GameObject.BaseClass { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     //ID | 
					
						
							|  |  |  |     Id = 0; | 
					
						
							|  |  |  |     //信息 | 
					
						
							|  |  |  |     Info = null; | 
					
						
							|  |  |  |     //Ani动画 | 
					
						
							|  |  |  |     Ani = null; | 
					
						
							|  |  |  |     //名字 | 
					
						
							|  |  |  |     Name = null; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     //识别高度 | 
					
						
							|  |  |  |     IdentifyHeight = 0; | 
					
						
							|  |  |  |     //识别宽度 | 
					
						
							|  |  |  |     IdentifyWidth = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     //是否悬停 | 
					
						
							|  |  |  |     IsHover = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function _typeof() { | 
					
						
							|  |  |  |         return "npc"; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     //初始化装配 | 
					
						
							|  |  |  |     function InitAssembly(IndexKey, SetKey, Func) { | 
					
						
							|  |  |  |         if (Info.rawin(IndexKey)) { | 
					
						
							|  |  |  |             this[SetKey] = Func(Info[IndexKey]); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     constructor(Id) { | 
					
						
							|  |  |  |         this.Id = Id; | 
					
						
							|  |  |  |         base.constructor(); | 
					
						
							|  |  |  |         Info = AssetManager.GetNpc(Id); | 
					
						
							|  |  |  |         if (Info) { | 
					
						
							|  |  |  |             //构造Ani | 
					
						
							|  |  |  |             InitAssembly("field_animation", "Ani", function(Data) { | 
					
						
							|  |  |  |                 local Ani = Animation(Data); | 
					
						
							|  |  |  |                 Addchild(Ani); | 
					
						
							|  |  |  |                 local Size = Ani.GetSize(); | 
					
						
							|  |  |  |                 IdentifyHeight = Size.h; | 
					
						
							|  |  |  |                 IdentifyWidth = Size.w; | 
					
						
							|  |  |  |                 return Ani; | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  |             //构造名字 | 
					
						
							|  |  |  |             InitAssembly("name", "Name", function(Data) { | 
					
						
							|  |  |  |                 //创建名字对象 | 
					
						
							|  |  |  |                 local NameObj = FontAssetManager.GenerateNormal(Data, true, { | 
					
						
							|  |  |  |                     color = sq_RGBA(242, 209, 175, 255), | 
					
						
							|  |  |  |                 }); | 
					
						
							|  |  |  |                 local Height = Ani ? Ani.GetSize().h : 0; | 
					
						
							|  |  |  |                 NameObj.SetPosition(0 - (NameObj.GetSize().w / 2), -Height - 25); | 
					
						
							|  |  |  |                 NameObj.SetZOrder(80000); | 
					
						
							|  |  |  |                 Addchild(NameObj); | 
					
						
							|  |  |  |                 return NameObj; | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function OnMouseLogic(MouseState, Wheel, MousePos_X, MousePos_Y) { | 
					
						
							|  |  |  |         //悬停事件 | 
					
						
							|  |  |  |         if (!IsHover) { | 
					
						
							|  |  |  |             IsHover = true; | 
					
						
							|  |  |  |             //设置Ani描边 | 
					
						
							|  |  |  |             Ani.SetOutline(true, sq_RGBA(155, 255, 0, 250)); | 
					
						
							|  |  |  |             //设置鼠标 | 
					
						
							| 
									
										
										
										
											2025-01-03 19:49:49 +08:00
										 |  |  |             Yosin_Cursor.ChangeActive(120, 4); | 
					
						
							| 
									
										
										
										
											2025-01-02 19:19:36 +08:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function OutMouseLogic() { | 
					
						
							|  |  |  |         //悬停事件 | 
					
						
							|  |  |  |         if (IsHover) { | 
					
						
							|  |  |  |             IsHover = false; | 
					
						
							|  |  |  |             Ani.SetOutline(false); | 
					
						
							|  |  |  |             //设置鼠标 | 
					
						
							|  |  |  |             Yosin_Cursor.Change(0); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-03 19:49:49 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-02 19:19:36 +08:00
										 |  |  | } |