初始化提交
This commit is contained in:
		
							
								
								
									
										15
									
								
								Content/Lua/GamePlay/Components/InventoryComponent.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								Content/Lua/GamePlay/Components/InventoryComponent.lua
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,15 @@ | ||||
| local InventoryComponent = {} | ||||
|  | ||||
|  | ||||
| function InventoryComponent:ReceiveBeginPlay() | ||||
|     print(self, "InventoryComponent:ReceiveBeginPlay") | ||||
| end | ||||
|  | ||||
| function InventoryComponent:InitItemGrid(grid) | ||||
|     grid.MaxCount = 1 | ||||
| 	grid.CurrentCount = 0 | ||||
| 	grid.Priority = 1 | ||||
|     return grid | ||||
| end | ||||
|  | ||||
| return Class(nil, nil, InventoryComponent) | ||||
							
								
								
									
										59
									
								
								Content/Lua/GamePlay/Components/LevelItemRewardMovement.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										59
									
								
								Content/Lua/GamePlay/Components/LevelItemRewardMovement.lua
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,59 @@ | ||||
| local Movement = {} | ||||
| local RoleUtils = require("GamePlay.Utils.RoleUtils") | ||||
| local Vector2D = require("Utils.Vector2D") | ||||
|  | ||||
| function Movement:ctor() | ||||
|     self.speed = 300.0 | ||||
|     self.accelerate = 300.0 | ||||
|     self.rate = 0.0 | ||||
|     self.direction = Vector2D.New() | ||||
| end | ||||
| function Movement:ReceiveBeginPlay() | ||||
|     self.rate = 0.0 | ||||
|     self.direction = Vector2D.Normalize(self.direction) | ||||
| end | ||||
|  | ||||
| function Movement:SetMoveOriginDirection(vector) | ||||
|     self.direction = Vector2D.Normalize(vector) | ||||
| end | ||||
|  | ||||
| function Movement:SetMoveOriginSpeed(speed, accelerate) | ||||
|     self.speed = speed | ||||
|     self.accelerate = accelerate | ||||
| end | ||||
|  | ||||
| function Movement:ReceiveTick(DeltaSeconds) | ||||
|     local owner = self:GetOwner() | ||||
|     local role = RoleUtils.GetRole(self) | ||||
|  | ||||
|     local role_location = role:K2_GetActorLocation() | ||||
|     local curr_location = owner:K2_GetActorLocation() | ||||
|  | ||||
|     local accelerate_vector = Vector2D.New( | ||||
|         role_location.X - curr_location.X, | ||||
|         role_location.Y - curr_location.Y | ||||
|     ) | ||||
|     accelerate_vector = Vector2D.Normalize(accelerate_vector) | ||||
|  | ||||
|     self.rate = self.rate + DeltaSeconds * 0.1 | ||||
|  | ||||
|     local velocity_vector = Vector2D.Mul(self.direction, self.speed) | ||||
|     local direction_vector= Vector2D.Mul(accelerate_vector, self.speed * self.rate) | ||||
|     self.direction = Vector2D.Normalize(Vector2D.Add(velocity_vector, direction_vector)) | ||||
|     local new_velocity = Vector2D.Mul(self.direction, self.speed) | ||||
|     local new_location = Vector2D.New( | ||||
|         curr_location.X + new_velocity.X * DeltaSeconds, | ||||
|         curr_location.Y + new_velocity.Y * DeltaSeconds | ||||
|     ) | ||||
|     self.speed = self.speed + self.accelerate * DeltaSeconds | ||||
|     owner:K2_SetActorLocation( | ||||
|         Vector2D.ToUnrealEngine3D(new_location, curr_location.Z), | ||||
|         true, nil, false | ||||
|     ) | ||||
| end | ||||
|  | ||||
| function Movement:ReceiveEndPlay() | ||||
|     print("Movement:ReceiveEndPlay  123") | ||||
| end | ||||
|  | ||||
| return Class(nil, nil, Movement) | ||||
		Reference in New Issue
	
	Block a user