AkiraPixelWind/Assets/Scripts/Main/CustomsComponent/MainPlayerComponent.cs

78 lines
1.7 KiB
C#
Raw Normal View History

2023-01-02 23:28:14 +08:00
using Axibug.Runtime;
using Bright.Serialization;
using System.IO;
using Game.Config;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using static Axibug.Utility;
using UnityEditor;
using Axibug.Resources;
namespace Game
{
public class MainPlayerComponent : GameComponent
{
2023-01-06 00:14:59 +08:00
public Transform MainCamNode;
2023-01-02 23:28:14 +08:00
public Transform CamPos;
2023-01-05 18:32:58 +08:00
public MainRole Player;
//Rigidbody mRigidbody;
2023-01-02 23:28:14 +08:00
public bool bLoadFinish { get; private set; } = false;
2023-01-05 18:32:58 +08:00
public bool InGame = false;
2023-01-02 23:28:14 +08:00
private void OnEnable()
{
2023-01-06 00:14:59 +08:00
MainCamNode = transform.Find("MainCamNode");
CamPos = MainCamNode.Find("CamPos");
2023-01-05 18:32:58 +08:00
InGame = false;
}
public void ReSetMainPlayer()
{
Player = null;
2023-01-02 23:28:14 +08:00
}
2023-01-05 18:32:58 +08:00
2023-01-02 23:28:14 +08:00
void Start()
{
}
2023-01-05 18:32:58 +08:00
void Update()
{
Update_MoveForInput();
}
2023-01-02 23:28:14 +08:00
public void LoadPlayer()
{
bLoadFinish = false;
2023-01-05 18:32:58 +08:00
Player = GamePlayEntry.RoleMgr.CreateMainRole();
2023-01-02 23:28:14 +08:00
2023-01-05 18:32:58 +08:00
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
SetMainCamera();
2023-01-02 23:28:14 +08:00
bLoadFinish = true;
}
2023-01-05 18:32:58 +08:00
public void SetMainCamera()
{
2023-01-06 00:14:59 +08:00
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Node<64>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
MainCamNode.parent = Player.transform;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD>MainCamNode<64><65>CamPos<6F><73>
2023-01-05 18:32:58 +08:00
Camera.main.transform.parent = CamPos;
Camera.main.transform.localPosition = Vector3.zero;
Camera.main.transform.localEulerAngles = Vector3.zero;
}
2023-01-02 23:28:14 +08:00
2023-01-05 18:32:58 +08:00
public void Update_MoveForInput()
2023-01-02 23:28:14 +08:00
{
2023-01-05 18:32:58 +08:00
if (!Player) return;
Player.InputV2 = GamePlayEntry.Input.InputV2;
2023-01-02 23:28:14 +08:00
}
2023-01-05 18:32:58 +08:00
2023-01-02 23:28:14 +08:00
}
}