Lua向C#逻辑迁移 一期
创建了若干C#文件,替代对应lua文件
This commit is contained in:
		| @ -0,0 +1,32 @@ | ||||
| using UnrealSharp.Attributes; | ||||
| using UnrealSharp.Engine; | ||||
|  | ||||
| namespace Level.GameSettings; | ||||
|  | ||||
| [UClass] | ||||
| public class ABusyLevelGameMode : AGameMode | ||||
| { | ||||
|     [UProperty(PropertyFlags.EditDefaultsOnly)] | ||||
|     public UnrealSharp.TSubclassOf<AActor> GameMapActorClass { get; set; } | ||||
|  | ||||
|     protected override void BeginPlay() | ||||
|     { | ||||
|         base.BeginPlay(); | ||||
|         if (GameMapActorClass.Valid) | ||||
|         { | ||||
|             SpawnActor(GameMapActorClass); | ||||
|         } | ||||
|     } | ||||
|      | ||||
| } | ||||
|  | ||||
| // -- function LevelGameMode:K2_PostLogin(new_player_controller) | ||||
| // --     local new_player_state = new_player_controller.PlayerState | ||||
| // --     local role = new_player_state:CreateRoleRoster(new_player_controller) | ||||
| // --     local new_pos = FVector() | ||||
| // --     new_pos.X = 500 | ||||
| // --     new_pos.Y = 500 | ||||
| // --     new_pos.Z = 50 | ||||
| // --     role:K2_SetActorLocation(new_pos, true, nil, false) | ||||
| // --     new_player_controller:Possess(role) | ||||
| // -- end | ||||
| @ -0,0 +1,17 @@ | ||||
| using UnrealSharp.Attributes; | ||||
| using UnrealSharp.BusyRabbit; | ||||
| using UnrealSharp.Engine; | ||||
|  | ||||
| namespace Level.GameSettings; | ||||
|  | ||||
| [UClass] | ||||
| public class ABusyLevelPlayerState : ALevelPlayerState | ||||
| { | ||||
|     protected override void BeginPlay() | ||||
|     { | ||||
|         base.BeginPlay(); | ||||
|         APlayerController pc = UGameplayStatics.GetPlayerController(0); | ||||
|         var role = CreateRoleRoster(pc) as APawn; | ||||
|         pc.Possess(role); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										54
									
								
								Script/ManagedBusyRabbit/Level/Role/BusyFoxRole.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								Script/ManagedBusyRabbit/Level/Role/BusyFoxRole.cs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,54 @@ | ||||
| // local LevelFoxRole = {} | ||||
| // local Vector2D = require("Utils.Vector2D") | ||||
|  | ||||
| // function LevelFoxRole:ctor() | ||||
|  | ||||
| // end | ||||
|  | ||||
| // function LevelFoxRole:ReceiveBeginPlay() | ||||
| // 	self["SpineAnimationComponent"]:SetAnimation(0, "Idle/Front", true) | ||||
| //     self.last_animation = "Idle/Front" | ||||
|  | ||||
| //     self["SpineBoneFollower"].Target = self | ||||
| //     self["SpineBoneFollower"].BoneName = "tail" | ||||
| //     self["SpineBoneFollower"].UseComponentTransform = true | ||||
| //     self["SpineBoneFollower"].UseScale = true | ||||
|  | ||||
| //     self["TailCollision"]:SetCollisionEnabled(0) | ||||
| // end | ||||
|  | ||||
|  | ||||
| // function LevelFoxRole:OnMoveDirectionChanged(InDirection) | ||||
| //     -- 运动组件更新方向响应函数 | ||||
| //     local cur_animation | ||||
| //     if Vector2D.Equals(InDirection, Vector2D.Zero) then -- Idle的情况 | ||||
| //         local forward_direction = self["MovementComponent"]:GetForwardDirection() | ||||
| //         if(forward_direction.Y >= 0) then | ||||
| //             cur_animation = "Idle/Front" | ||||
| //         else | ||||
| //             cur_animation = "Idle/Back" | ||||
| //         end | ||||
| //     else | ||||
| //         if(InDirection.Y >= 0) then | ||||
| //             cur_animation = "Move/Front" | ||||
| //         else | ||||
| //             cur_animation = "Move/Back" | ||||
| //         end | ||||
| //     end | ||||
| //     if cur_animation ~= self.last_animation then | ||||
| //         self["SpineAnimationComponent"]:SetAnimation(0, cur_animation, true) | ||||
| //         self.last_animation = cur_animation | ||||
| //     end | ||||
|  | ||||
| //     self["SpineAnimationComponent"]:SetTimeScale(1.0) | ||||
| // end | ||||
|  | ||||
|  | ||||
| // function LevelFoxRole:OnMove(location) | ||||
| //     -- 控制器移动相应函数 | ||||
| //     self["MovementComponent"]:MoveTo(location) | ||||
| // end | ||||
|  | ||||
|  | ||||
|  | ||||
| // return Class(nil, nil, LevelFoxRole) | ||||
							
								
								
									
										36
									
								
								Script/ManagedBusyRabbit/Level/Role/BusyRabbitRole.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								Script/ManagedBusyRabbit/Level/Role/BusyRabbitRole.cs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,36 @@ | ||||
| // local LevelRabbitRole = {} | ||||
|  | ||||
| // function LevelRabbitRole:ctor() | ||||
| //     self.last_animation = "back/move" | ||||
| // end | ||||
|  | ||||
| // function LevelRabbitRole:ReceiveBeginPlay() | ||||
| // 	self["SpineAnimationComponent"]:SetSkin("back/move") | ||||
| // 	self["SpineAnimationComponent"]:SetAnimation(0, "animation", true) | ||||
| // end | ||||
|  | ||||
|  | ||||
| // function LevelRabbitRole:OnMove(location) | ||||
| //     -- 控制器移动相应函数 | ||||
| //     self["MovementComponent"]:MoveTo(location) | ||||
| // end | ||||
|  | ||||
|  | ||||
| // function LevelRabbitRole:OnMoveDirectionChanged(InDirection) | ||||
| //     -- 运动组件更新方向响应函数 | ||||
| //     local cur_animation | ||||
| //     if(InDirection.Y >= 0) then | ||||
| //         cur_animation = "front/move" | ||||
| //     else | ||||
| //         cur_animation = "back/move" | ||||
| //     end | ||||
| //     print("LevelRabbitRole:OnMoveDirectionChanged", cur_animation) | ||||
| //     if cur_animation ~= self.last_animation then | ||||
| //         self["SpineAnimationComponent"]:SetSkin(cur_animation) | ||||
| //         self["SpineAnimationComponent"]:SetSlotsToSetupPose() | ||||
| //         self.last_animation = cur_animation | ||||
| //     end | ||||
| // end | ||||
|  | ||||
|  | ||||
| // return Class(nil, nil, LevelRabbitRole) | ||||
		Reference in New Issue
	
	Block a user