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;
|
2023-01-07 23:24:18 +08:00
|
|
|
|
using Axibug;
|
|
|
|
|
using Axibug.Event;
|
2023-01-02 23:28:14 +08:00
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
2023-01-09 23:13:17 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Fov TODO<44><4F><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public float srcCameraFov;
|
|
|
|
|
|
2023-01-05 18:32:58 +08:00
|
|
|
|
//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;
|
2023-01-09 00:17:20 +08:00
|
|
|
|
AppEntry.Event.Subscribe(MainPlayerOnceAttackEventArgs.EventId, OnMainPlayerInAttackEventArgs);
|
2023-01-07 23:24:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnDisable()
|
|
|
|
|
{
|
2023-01-09 00:17:20 +08:00
|
|
|
|
AppEntry.Event.Unsubscribe(MainPlayerOnceAttackEventArgs.EventId, OnMainPlayerInAttackEventArgs);
|
2023-01-05 18:32:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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-07 23:24:18 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ű<F0B6AFBD>
|
|
|
|
|
MainCamNode.gameObject.AddComponent<CameraShake>();
|
|
|
|
|
|
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;
|
2023-01-09 23:13:17 +08:00
|
|
|
|
MainCamNode.localPosition = Vector3.zero;
|
|
|
|
|
MainCamNode.localEulerAngles = Vector3.zero;
|
2023-01-06 00:14:59 +08:00
|
|
|
|
//<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-09 23:13:17 +08:00
|
|
|
|
|
|
|
|
|
srcCameraFov = Camera.main.fieldOfView;
|
2023-01-05 18:32:58 +08:00
|
|
|
|
}
|
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;
|
2023-01-07 23:24:18 +08:00
|
|
|
|
|
2023-01-05 18:32:58 +08:00
|
|
|
|
Player.InputV2 = GamePlayEntry.Input.InputV2;
|
2023-01-07 23:24:18 +08:00
|
|
|
|
|
2023-01-09 00:17:20 +08:00
|
|
|
|
if (GamePlayEntry.Input.Attack
|
|
|
|
|
&&
|
|
|
|
|
Player.AttackStep != E_ONCEATTACK_STEP.InAttack
|
|
|
|
|
)
|
2023-01-07 23:24:18 +08:00
|
|
|
|
{
|
|
|
|
|
//AxibugLog.Debug("DoAttack");
|
|
|
|
|
DoNextMotionAnimeName();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void DoNextMotionAnimeName()
|
|
|
|
|
{
|
|
|
|
|
Player.Anime.BackToIdle();
|
|
|
|
|
string AnimeName;
|
|
|
|
|
string AtkBoxAnimeName;
|
|
|
|
|
//<2F>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
|
|
|
|
|
bool IsEndMotion = false;
|
2023-01-12 23:49:16 +08:00
|
|
|
|
|
2023-01-07 23:24:18 +08:00
|
|
|
|
//һ<><D2BB>Ҳû<D2B2><C3BB><EFBFBD><EFBFBD>
|
2023-01-12 23:49:16 +08:00
|
|
|
|
if (GamePlayEntry.Input.mInputMotionData.CheckHistoryLastMotion(E_MOTION_TYPE.Attack_2))
|
2023-01-07 23:24:18 +08:00
|
|
|
|
{
|
2023-01-12 23:49:16 +08:00
|
|
|
|
AnimeName = "Attack_3";
|
2023-01-07 23:24:18 +08:00
|
|
|
|
AtkBoxAnimeName = "HorizontalCut_Down";
|
2023-01-12 23:49:16 +08:00
|
|
|
|
GamePlayEntry.Input.mInputMotionData.AddMontionKey(E_MOTION_TYPE.Attack_3);
|
|
|
|
|
IsEndMotion = true;
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2023-01-07 23:24:18 +08:00
|
|
|
|
}
|
2023-01-12 23:49:16 +08:00
|
|
|
|
else if(GamePlayEntry.Input.mInputMotionData.CheckHistoryLastMotion(E_MOTION_TYPE.Attack_1))
|
2023-01-07 23:24:18 +08:00
|
|
|
|
{
|
2023-01-12 23:49:16 +08:00
|
|
|
|
AnimeName = "Attack_2";
|
2023-01-07 23:24:18 +08:00
|
|
|
|
AtkBoxAnimeName = "HorizontalCut_Up";
|
|
|
|
|
GamePlayEntry.Input.mInputMotionData.AddMontionKey(E_MOTION_TYPE.Attack_2);
|
2023-01-12 23:49:16 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
AnimeName = "Attack_1";
|
|
|
|
|
AtkBoxAnimeName = "HorizontalCut_Down";
|
|
|
|
|
GamePlayEntry.Input.mInputMotionData.AddMontionKey(E_MOTION_TYPE.Attack_1);
|
2023-01-07 23:24:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Player.Anime.SetAttack(AnimeName);
|
|
|
|
|
Player.DoAtkBox(AtkBoxAnimeName);
|
|
|
|
|
|
|
|
|
|
if(IsEndMotion)
|
|
|
|
|
GamePlayEntry.Input.mInputMotionData.ClearHistoryMotion();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region <EFBFBD>¼<EFBFBD>
|
|
|
|
|
|
|
|
|
|
private void OnMainPlayerInAttackEventArgs(object sender, LogicEventArgs e)
|
|
|
|
|
{
|
2023-01-09 00:17:20 +08:00
|
|
|
|
MainPlayerOnceAttackEventArgs msg = (MainPlayerOnceAttackEventArgs)e;
|
|
|
|
|
if (msg == null) throw new GameException("MainPlayerOnceAttackEventArgs is null");
|
|
|
|
|
if (msg.RoleID == Player.RoleID)
|
|
|
|
|
{
|
|
|
|
|
Player.AttackStep = msg.Step;
|
|
|
|
|
}
|
2023-01-02 23:28:14 +08:00
|
|
|
|
}
|
2023-01-05 18:32:58 +08:00
|
|
|
|
|
2023-01-07 23:24:18 +08:00
|
|
|
|
#endregion
|
2023-01-02 23:28:14 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|