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

78 lines
1.7 KiB
C#

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
{
public Transform MainCamNode;
public Transform CamPos;
public MainRole Player;
//Rigidbody mRigidbody;
public bool bLoadFinish { get; private set; } = false;
public bool InGame = false;
private void OnEnable()
{
MainCamNode = transform.Find("MainCamNode");
CamPos = MainCamNode.Find("CamPos");
InGame = false;
}
public void ReSetMainPlayer()
{
Player = null;
}
void Start()
{
}
void Update()
{
Update_MoveForInput();
}
public void LoadPlayer()
{
bLoadFinish = false;
Player = GamePlayEntry.RoleMgr.CreateMainRole();
//摄像机
SetMainCamera();
bLoadFinish = true;
}
public void SetMainCamera()
{
//把摄像机Node挂到玩家下
MainCamNode.parent = Player.transform;
//把主摄像机挂到MainCamNode的CamPos下
Camera.main.transform.parent = CamPos;
Camera.main.transform.localPosition = Vector3.zero;
Camera.main.transform.localEulerAngles = Vector3.zero;
}
public void Update_MoveForInput()
{
if (!Player) return;
Player.InputV2 = GamePlayEntry.Input.InputV2;
}
}
}