AkiraPixelWind/Assets/Scripts/Main/Role/MainRole.cs
2023-01-30 18:16:49 +08:00

242 lines
7.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Axibug;
using Axibug.Event;
using Axibug.Runtime;
using System.Collections.Generic;
using UnityEngine;
namespace Game
{
public class MainRole : RoleBase
{
protected SpriteRenderer mSpriteRenderer;
public SnapshotData mRoleSnapshot;
public S_ROLE_SELF PlayData;
/// <summary>
/// ³õʼ»¯
/// </summary>
/// <param name="data"></param>
public void Init(S_ROLE_SELF data)
{
base.Init(data);
PlayData = data;
mRoleSnapshot = new SnapshotData();
}
protected override void Awake()
{
base.Awake();
mSpriteRenderer = mModelTransfrom.GetComponent<SpriteRenderer>();
}
protected override void OnEnable()
{
base.OnEnable();
AppEntry.Event.Subscribe(MainPlayerOnceAttackEventArgs.EventId, OnMainPlayerInAttackEventArgs);
AppEntry.Event.Subscribe(MainPlayerJumpStateEventArgs.EventId, OnMainPlayerJumpStateEventArgs);
}
protected override void OnDisable()
{
base.OnDisable();
AppEntry.Event.Unsubscribe(MainPlayerOnceAttackEventArgs.EventId, OnMainPlayerInAttackEventArgs);
AppEntry.Event.Unsubscribe(MainPlayerJumpStateEventArgs.EventId, OnMainPlayerJumpStateEventArgs);
}
protected override void FixedUpdate()
{
base.FixedUpdate();
FixedUpdate_FastMoveMode();
}
const int SnapInterval = 3;
int SnapIntervalIndex = 0;
/// <summary>
/// ¿ìÕÕ¸üÐÂÂß¼­
/// </summary>
void Update_Snap()
{
SnapIntervalIndex++;
if (SnapIntervalIndex >= SnapInterval)
{
mRoleSnapshot.AddSnap(mSpriteRenderer.sprite, mBridgeTransfrom.localEulerAngles, transform.position);
SnapIntervalIndex = 0;
}
}
protected override void Update()
{
base.Update();
Update_Snap();
if (Input.GetKeyDown(KeyCode.T))
{
RoleFastShadow fastshadow = GamePlayEntry.EffectMgr.rolegastEftPool.GetAnyHide();
//ÉèÖÃÓ°×Ó
//fastshadow.SetData(mSpriteRenderer.sprite, mBridgeTransfrom.localEulerAngles, transform.position);
}
if (Input.GetKeyDown(KeyCode.G))
{
Anime.SetAnimatorSpeed(1f);
Move_BaseSpeed = 3.5f * 1f;
}
if (Input.GetKeyDown(KeyCode.Y))
{
Anime.SetAnimatorSpeed(1.5f);
Move_BaseSpeed = 3.5f * 1.5f;
}
if (Input.GetKeyDown(KeyCode.U))
{
Anime.SetAnimatorSpeed(2f);
Move_BaseSpeed = 3.5f * 2f;
}
if (Input.GetKeyDown(KeyCode.I))
{
Anime.SetAnimatorSpeed(2.6f);
Move_BaseSpeed = 3.5f * 2.6f;
}
}
public override void MeshChangeMoveState(bool ToMoveState)
{
if (ToMoveState)
{
Anime.StartRun();
}
else
{
Anime.BackToIdle();
}
}
public override void ChangeJumpState(E_JUMP_STEP jumpStep)
{
switch (jumpStep)
{
case E_JUMP_STEP.JumpUp:
Anime.SetOtherAnime("jump");
break;
case E_JUMP_STEP.JumpFall:
Anime.SetOtherAnime("JumptoFall");
break;
case E_JUMP_STEP.None:
Anime.BackToIdle();
break;
}
}
public override void Release()
{
}
#region ¸ßËÙÒÆ¯Ä£Ê½
private bool mIsFastSkillMode = false;
private float LastFastShadowCreateTime = 0;
public bool IsFastSkillMode
{
get { return mIsFastSkillMode; }
set
{
if (mIsFastSkillMode != value)
{
mIsFastSkillMode = value;
if (value)
{
AxibugLog.Debug("¸ßËÙģʽ:¿ª");
//¸Õ¿ªÊ¼¸ßËÙÒÆ¶¯Ä£Ê½
Move_SpeedMultiplier = ConstClass.FastRunSpeedMultiplier;
Anime.SetAnimatorSpeed(ConstClass.FastRunSpeedMultiplier);
AttackBoxAnime.SetBool("KeepAttack", true);
}
else
{
AxibugLog.Debug("¸ßËÙģʽ:¹Ø");
//¸ÕÍ£Ö¹¸ßËÙÒÆ¶¯Ä£Ê½
Move_SpeedMultiplier = 1f;
Anime.SetAnimatorSpeed(1f);
AttackBoxAnime.SetBool("KeepAttack", false);
//Camera.main.fieldOfView = GamePlayEntry.MainPlayer.srcCameraFov;
//ÇåÀíÓ°×Ó
GamePlayEntry.EffectMgr.rolegastEftPool.Hide();
}
}
}
}
public void FixedUpdate_FastMoveMode()
{
if (!IsMove)
{
IsFastSkillMode = false;
}
else
{
//Èç¹û³¬¹ýÒÆ¶¯Ê±¼ä
if(MoveTime > ConstClass.ToFastModeTime
//&& PlayData.skill.hadskillid.Contains(5)//ÅжÏÊÇ·ñÓмÓËÙ¼¼ÄÜ
)
IsFastSkillMode = true;
else
IsFastSkillMode = false;
}
//¸ßËÙģʽ¿ªÓ°×Ó
if (IsFastSkillMode)
{
if (Time.time - LastFastShadowCreateTime > ConstClass.FastModeShadowCreateIntervalTime)
{
LastFastShadowCreateTime = Time.time;
AxibugLog.Debug("´´½¨Ó°×Ó");
//´´½¨Ó°×Ó
GamePlayEntry.EffectMgr.rolegastEftPool.GetAnyHide();
}
float fov = Camera.main.fieldOfView;
fov += 30f * Time.deltaTime;
fov = Mathf.Min(GamePlayEntry.MainPlayer.srcCameraFov + 10f, fov);
Camera.main.fieldOfView = fov;
}
else
{
float fov = Camera.main.fieldOfView;
fov -= 25f * Time.deltaTime;
fov = Mathf.Max(GamePlayEntry.MainPlayer.srcCameraFov, fov);
Camera.main.fieldOfView = fov;
}
}
#endregion
#region ʼþ
private void OnMainPlayerInAttackEventArgs(object sender, LogicEventArgs e)
{
MainPlayerOnceAttackEventArgs msg = (MainPlayerOnceAttackEventArgs)e;
if (msg == null) throw new GameException("MainPlayerOnceAttackEventArgs is null");
if (msg.RoleID == RoleID)
{
AttackStep = msg.Step;
}
}
private void OnMainPlayerJumpStateEventArgs(object sender, LogicEventArgs e)
{
MainPlayerJumpStateEventArgs msg = (MainPlayerJumpStateEventArgs)e;
if (msg == null) throw new GameException("MainPlayerJumpState is null");
if (msg.RoleID == RoleID)
{
JumpStep = msg.Step;
}
}
#endregion
}
}