角色基类

This commit is contained in:
sin365 2023-01-05 00:28:20 +08:00
parent 81fb6e0f19
commit 3dbe973e8d
20 changed files with 1147 additions and 42 deletions

Binary file not shown.

Binary file not shown.

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: d268a2524403b7d47a51f417c95e3d5e
guid: 1016016d0d135b24a9b513a0f6a1cb03
TrueTypeFontImporter:
externalObjects: {}
serializedVersion: 4
@ -9,9 +9,8 @@ TrueTypeFontImporter:
characterPadding: 1
includeFontData: 1
fontNames:
- STZhongsong
fallbackFontReferences:
- {fileID: 12800000, guid: 71e3074360d836348811af020e1ac258, type: 3}
- IPix
fallbackFontReferences: []
customCharacters:
fontRenderingMode: 0
ascentCalculationMode: 1

View File

@ -0,0 +1,859 @@
//using Axibug;
//using Axibug.Event;
//using Axibug.Resources;
//using Axibug.Runtime;
//using Game.Config;
//using System;
//using System.Collections;
//using System.Collections.Generic;
//using System.Linq;
//using UnityEngine;
//namespace Game
//{
// public class UserMgrComponent : GameComponent
// {
// private Queue<S_ROLE_BASE> temp_RemoveUser = new Queue<S_ROLE_BASE>();//需要移除的玩家列表
// private Queue<Int32> temp_RemoveRequest = new Queue<Int32>();//请求数据列表
// //key:职业+性别 比如ss_w
// private Dictionary<string, Queue<GameObject>> userPool = new Dictionary<string, Queue<GameObject>>();
// private float temp_CheckTime = 0;
// private float temp_RequestTime = 0;
// private S_ROLE_SELF myrole { get { return UserData.role; } }
// private void Start()
// {
// //AppEntry.Event.Subscribe(UserMoveEventArgs.EventId, OnUserMoveEvent);
// //AppEntry.Event.Subscribe(UserPlayerSkillEventArgs.EventId, OnUserPlayerSkill);
// //AppEntry.Event.Subscribe(RoleDeadEventArgs.EventId, OnRoleDead);
// //AppEntry.Event.Subscribe(RoleReviveEventArgs.EventId, OnRoleRevive);
// //AppEntry.Event.Subscribe(RoleLevelupEventArgs.EventId, OnRoleLevelUp);
// //AppEntry.Event.Subscribe(AddRoleBufferEvent.EventId, AddBuffer);
// //AppEntry.Event.Subscribe(RemoveRoleBufferEvent.EventId, RemoveBuffer);
// }
// public GameObject Accquire(string myKey, S_ROLE_BASE role)
// {
// if (!userPool.ContainsKey(myKey))
// return null;
// Queue<GameObject> gos = userPool[myKey];
// if (gos.Count == 0)
// return null;
// GameObject go = gos.Dequeue();
// go.SetActive(true);
// //role.userview.go = go;
// role.userview.rolePrefabGo = go;
// return go;
// }
// public void Release(S_ROLE_BASE role)
// {
// string strJob = Common.GetStrJob((byte)role.innate.job);
// string strSex = Common.GetStrSex(role.innate.sex);
// string myKey = $"{strJob}_{strSex}";
// // 清理玩家信息条
// BattleEntitysInfoCtrl.Instance.DisposeUserInfo(role.mem.userindex);
// Queue<GameObject> gos = null;
// if (userPool.ContainsKey(myKey))
// gos = userPool[myKey];
// else
// {
// gos = new Queue<GameObject>();
// userPool.Add(myKey, gos);
// }
// if(role.userview.go != null)
// {
// /*
// gos.Enqueue(role.userview.go);
// role.userview.go.SetActive(false);
// role.userview.go = null;
// */
// gos.Enqueue(role.userview.rolePrefabGo);
// role.userview.go.SetActive(false);
// }
// role.userview.Release();
// AppEntry.Event.FireNow(null, CharReleaseEventArgs.Create(role.dataSet.GetCharIndex(), E_NODE_TYPE.N_ROLE));
// }
// public void CreateMainPlayer(S_ROLE_SELF myrole)
// {
// if (myrole == null)
// return;
// //初始化便捷数据类
// MainPlayerDataSet mainDataSet = new MainPlayerDataSet();
// mainDataSet.Init(myrole);
// myrole.dataSet = mainDataSet;
// CreateRole((byte)myrole.innate.job, myrole, true);
// }
// public void CreateRole(byte job, S_ROLE_BASE role, bool isMainPlayer=false)
// {
// if (!isMainPlayer)
// {
// //产生时,标记角色格子占据
// HotfixEntry.Map.SetRoleCell(role.mem.userindex, (int)role.status.pos.x, (int)role.status.pos.z, E_NODE_TYPE.N_ROLE);
// }
// //RoleTop.transform.localRotation = Quaternion.EulerRotation(60, 0, 0);
// string strJob = Common.GetStrJob(job);
// string strSex = Common.GetStrSex(role.innate.sex);
// string myKey = $"{strJob}_{strSex}";
// //@Test 测试模型用
// string path = Utility.Path.GetPlayerPath(myKey, myKey+"_Test");
// //还没写完, 待测试
// GameObject go = Accquire(myKey, role);
// if(go == null)
// {
// //ch
// GameObject RoleTop = new GameObject();
// if (isMainPlayer)
// {
// RoleTop.transform.parent = HotfixEntry.MainPlayer.transform;
// RoleTop.transform.localPosition = Vector3.zero;
// }
// else
// RoleTop.transform.parent = HotfixEntry.UserMgr.transform;
// HotfixEntry.Resources.Clone(path, CreateCallback, RoleTop.transform, role, myKey.ToLower());
// return;
// }
// role.userview.go = go;
// role.userview.ResetGameObject(go);
// }
// protected void CreateCallback(UnityEngine.Object obj, CallbackType err, object userData)
// {
// if (err != CallbackType.Success)
// {
// Log.Error("创建角色失败");
// return;
// }
// if (userData == null)
// return;
// S_ROLE_BASE role = (S_ROLE_BASE)userData;
// if (role as S_ROLE_SELF != null)
// HotfixEntry.MainPlayer.myView.InitGameObject(obj as GameObject);
// else
// {
// role.userview.InitGameObject(obj as GameObject);
// }
// }
// /// <summary>
// /// 主角色换装
// /// </summary>
// /// <param name="roleView"></param>
// /// <param name="job"></param>
// /// <param name="SubJob">二级职业,如DZ_M_DD刀盾模型中末尾的"DD"</param>
// public void MainPlayerChangeEquipment(byte job,string SubJob)
// {
// MyView myview = HotfixEntry.MainPlayer.myView;
// ChangeEquipment(myview, myview.myrole,job,SubJob);
// }
// protected void ChangeEquipmentCallback(UnityEngine.Object obj, CallbackType err, object userData)
// {
// if (err != CallbackType.Success)
// {
// Log.Error("创建角色失败");
// return;
// }
// if (userData == null)
// return;
// S_ROLE_BASE role = (S_ROLE_BASE)userData;
// GameObject Oldobj = role.characterview.rolePrefabGo.gameObject;
// GameObject Newobj = (obj as GameObject);
// role.characterview.rolePrefabGo = Newobj;
// //重置Movement而不是创建
// if (role as S_ROLE_SELF != null)
// {
// HotfixEntry.MainPlayer.myView.InitMovement(obj as GameObject);
// }
// else
// role.userview.InitMovement(obj as GameObject);
// Newobj.transform.localPosition = Oldobj.transform.localPosition;
// Newobj.transform.localRotation = Oldobj.transform.localRotation;
// //完全替换后再销毁原角色,保证时序靠后
// Destroy(Oldobj);
// }
// //角色移动
// private void OnUserMoveEvent(object sender, LogicEventArgs e)
// {
// UserMoveEventArgs move = (UserMoveEventArgs)e;
// if (move == null)
// throw new GameException("UserMoveEventArgs is null");
// var role = UserData.findRoleData(move.userIndex);
// if(role == null)
// throw new GameException("the role is null");
// role.userview.StartMove(move.speed, role.status.face);
// //更新下玩家的大格子
// HotfixEntry.Map.UpdateUserBC(role);
// }
// //角色播放技能
// private void OnUserPlayerSkill(object sender, LogicEventArgs e)
// {
// UserPlayerSkillEventArgs skill = (UserPlayerSkillEventArgs)e;
// if (skill == null)
// throw new GameException("UserPlayerSkillEventArgs is null");
// int clientId = ConstClass.GetClientSkillID(skill.skillid, skill.skilllevel);
// SkillData script = HotfixEntry.Luban.GetSkill(clientId);
// if (script == null)
// throw new GameException($"the skillid:[{clientId}] is null");
// Transform source = null;
// Transform target = null;
// Vector3 targetPos = Vector3.zero;
// CellNode cell = null;
// switch (skill.lock_type)
// {
// case (byte)Lock_Type.LOCK_PLAYER:
// {
// var role = UserData.findRoleData(skill.lockIndex);
// if (role == null || role.userview == null)
// throw new GameException($"the lockIndex:{skill.lockIndex} is null");
// cell = role.userview.CurCell;
// target = role.userview.rolePrefabGo.transform;
// targetPos = role.userview.rolePrefabGo.transform.position;
// }
// break;
// case (byte)Lock_Type.LOCK_MONSTER:
// {
// var robot = RobotData.findRobotData(skill.lockIndex);
// if (robot == null || robot.data == null)
// throw new GameException($"the lockIndex:{skill.lockIndex} is null");
// cell = robot.view.CurCell;
// target = robot.view.rolePrefabGo.transform;
// targetPos = robot.view.rolePrefabGo.transform.position;
// }
// break;
// }
// if (cell == null)
// return;
// //修改特效发送source和taget的位置
// if (skill.userIndex == myrole.mem.userindex)
// {
// HotfixEntry.MainPlayer.myView.Attack(cell, script.Motion);
// myrole.move.state = 1;
// source = HotfixEntry.MainPlayer.myView.rolePrefabGo.transform;
// }
// else
// {
// S_ROLE_BASE role = UserData.findRoleData(skill.userIndex);
// if (role == null)
// throw new GameException("the role is null");
// role.userview.Attack(role.userview.CurCell, script.Motion, false);
// source = role.userview.rolePrefabGo.transform;
// }
// //播放技能特效
// string path = string.Empty;
// //如果有技能动作,则播放
// if (!string.IsNullOrEmpty(script.BindEffect) && script.BindEffect != "0")
// {
// path = Utility.Path.GetPrefabPath("Effects", script.BindEffect);
// HotfixEntry.EffectMgr.PlayAttackEffect(path, source);
// }
// if (!string.IsNullOrEmpty(script.WorldEffect) && script.WorldEffect != "0")
// {
// path = Utility.Path.GetPrefabPath("Effects", script.WorldEffect);
// HotfixEntry.EffectMgr.PlayWorldEffect(path, targetPos);
// }
// if (!string.IsNullOrEmpty(script.BallisticEffect) && script.BallisticEffect != "0")
// {
// path = Utility.Path.GetPrefabPath("Effects", script.BallisticEffect);
// StartCoroutine(DelayPlayerEffect(script.EffectDelayTime, path, source, target));
// }
// Log.Debug($"播放技能ID={clientId} 动作={script.Motion}, 绑定特效={script.BindEffect}, 世界特效={script.WorldEffect}, 弹道特效={script.BallisticEffect}, 被击特效={script.HitEffect}");
// }
// IEnumerator DelayPlayerEffect(int delay, string path, Transform source, Transform target)
// {
// yield return new WaitForSeconds(delay / 1000.0f);
// HotfixEntry.EffectMgr.PlayBallisticEffect(path, source, target);
// }
// //角色死亡
// public void OnRoleDead(object sender, LogicEventArgs e)
// {
// RoleDeadEventArgs dead = (RoleDeadEventArgs)e;
// if (dead == null)
// throw new GameException("RoleDeadEventArgs is null");
// S_ROLE_BASE role = null;
// if (dead.roleIndex == myrole.mem.userindex)
// {
// role = myrole;
// //HotfixEntry.MainPlayer.myView.SetAnimation("Dead", true);
// myrole.myView.movement.characterAnimator.PlayDead();
// HotfixEntry.UI.OpenUI<DeathPanelUI>();
// }
// else
// {
// role = UserData.findRoleData(dead.roleIndex);
// if (role == null)
// throw new GameException("the role is null");
// //role.userview.SetAnimation("Dead", true);
// role.userview.movement.characterAnimator.PlayDead();
// HotfixEntry.Map.ClearRoleCellData(dead.roleIndex, E_NODE_TYPE.N_ROLE);
// }
// switch ((Lock_Type)role.tmp.lockData.lock_type)
// {
// case Lock_Type.LOCK_PLAYER://玩家
// {
// var lockRole = UserData.findRoleData(role.tmp.lockData.lock_index);
// if (lockRole == null || lockRole.userview == null || lockRole.userview.go == null)
// return;
// lockRole.userview.SetSublightOff();
// }
// break;
// case Lock_Type.LOCK_MONSTER://怪物
// {
// var lockRobot = RobotData.findRobotData(role.tmp.lockData.lock_index);
// if (lockRobot == null || lockRobot.view == null || lockRobot.view.go == null)
// return;
// lockRobot.view.SetSublightOff();
// }
// break;
// }
// role.tmp.lockData.lock_state = 0;
// role.tmp.lockData.lock_index = -1;
// }
// //角色复活
// public void OnRoleRevive(object sender, LogicEventArgs e)
// {
// RoleReviveEventArgs revive = (RoleReviveEventArgs)e;
// if (revive == null)
// throw new GameException("RoleReviveEventArgs is null");
// //传送
// if (revive.userIndex == myrole.mem.userindex)
// {
// myrole.myView.movement.characterAnimator.DeadToIdle();
// AppEntry.Event.Fire(null, BattleRoleMovingEventArgs.Create(myrole.myDataSet.GetCharIndex(),E_NODE_TYPE.N_MAINPLAYER));
// HotfixEntry.MainPlayer.myView.TeleportingToPos(revive.pos);
// myrole.status.state = (int)CharacterState.Living;
// return;
// }
// S_ROLE_BASE role = UserData.findRoleData(revive.userIndex);
// if (role == null)
// throw new GameException("the role is null");
// role.userview.movement.characterAnimator.DeadToIdle();
// role.userview.TeleportingToPos(revive.pos);
// role.status.state = (int)CharacterState.Living;
// }
// //角色升级
// public void OnRoleLevelUp(object sender, LogicEventArgs e)
// {
// RoleLevelupEventArgs msg = (RoleLevelupEventArgs)e;
// if (msg == null)
// throw new GameException("RoleLevelupEventArgs is null");
// S_ROLE_BASE role = null;
// if (msg.roleIndex == myrole.mem.userindex)
// {
// //如果升级的是自己
// role = myrole;
// }
// else
// {
// role = UserData.findRoleData(msg.roleIndex);
// if (role == null)
// throw new GameException("the role is null");
// }
// role.exp.level = msg.currentLevel;
// Log.Warning($"角色提升到{role.exp.level}级");
// }
// //角色播放buff
// public void AddBuffer(object sender, LogicEventArgs e)
// {
// //播放特效
// AddRoleBufferEvent msg = (AddRoleBufferEvent)e;
// if (msg == null)
// throw new GameException("AddRoleBufferEvent is null");
// if (msg.roleIndex != myrole.mem.userindex)
// return;
// AppEntry.Event.Fire(this, AddBufferIconEvent.Create(msg.buffId));
// }
// //角色删除buff
// public void RemoveBuffer(object sender, LogicEventArgs e)
// {
// //删除特效
// RemoveRoleBufferEvent msg = (RemoveRoleBufferEvent)e;
// if (msg == null)
// throw new GameException("AddRoleBufferEvent is null");
// if (msg.roleIndex != myrole.mem.userindex)
// return;
// AppEntry.Event.Fire(this, RemoveBufferIconEvent.Create(msg.buffId));
// }
// // Update is called once per frame
// void Update()
// {
// #region
// if (Input.GetKeyDown(KeyCode.O))
// {
// CaoCaoLog.Debug("测试换装到,DD");
// MainPlayerChangeEquipment((byte)eJob.Warrior, "DD");
// }
// if (Input.GetKeyDown(KeyCode.P))
// {
// CaoCaoLog.Debug("测试换装到,KD");
// MainPlayerChangeEquipment((byte)eJob.Warrior, "KD");
// }
// if (Input.GetKeyDown(KeyCode.U))
// {
// CaoCaoLog.Debug("测试升级");
// UIMgr.Instance.OpenUI<TipShowLevelUpUI>();
// }
// if (Input.GetKeyDown(KeyCode.Y))
// {
// HotfixEntry.UI.OpenUI<AttrPointTipsUI>();
// }
// if (Input.GetKeyDown(KeyCode.T))
// {
// HotfixEntry.UI.OpenUI<TaskMainUI>();
// }
// //if (Input.GetKeyDown(KeyCode.M))
// //{
// // if (!HotfixEntry.UI.IsOpen<FullMapUI>())
// // HotfixEntry.UI.OpenUI<FullMapUI>();
// //}
// #endregion
// if (HotfixEntry.MainPlayer.myView == null)
// return;
// if (!UserData.role.isEntryWorld)
// return;
// //1、同步自己的移动 三大策略发送移动数据
// SyncMove();
// UserBuffManager.renderBuff();
// UpdateUserCell();
// //2、更新其他玩家显示 200毫秒检查一次
// float ftime = Time.time - temp_CheckTime;
// if (ftime > 0.2f)
// {
// temp_CheckTime = Time.time;
// UpdateUserRect();
// return;
// }
// //3、更新其他玩家信息
// foreach (var r in UserData.onlines)
// {
// var role = r.Value;
// if (role.userview == null)
// continue;
// if (role.userview.go == null)
// continue;
// if (role.status.state == (int)CharacterState.Dead)
// continue;
// role.userview.Update();
// }
// //4、排队申请其他玩家和怪物数据 节约服务器性能 把峰值平摊在逐帧
// float ftime2 = Time.time - temp_RequestTime;
// if (ftime2 > 0.05f)
// {
// temp_RequestTime = Time.time;
// UpdateRequestRoleData();
// UpdateRequestRobotData();
// }
// }
// private void UpdateUserCell()
// {
// int[] keys = UserData.onlines.Keys.ToArray();
// for (int i = 0; i < keys.Length; i++)
// {
// S_ROLE_BASE user = UserData.onlines[keys[i]];
// if (user.mem.userindex != HotfixEntry.MainPlayer.myDataSet.GetCharIndex() && user.status.state < (byte)CharacterState.Dead && user.life.curHP > 0)
// {
// //产生时,标记角色格子占据
// HotfixEntry.Map.SetRoleCell(keys[i], user.userview.go.transform.position, E_NODE_TYPE.N_ROLE);
// }
// }
// }
// //更新请求玩家数据列表或者怪物数据列表
// private void UpdateRequestRoleData()
// {
// if (UserData.requestRoleDatas.Count == 0)
// return;
// Int32 count = 0;
// foreach (var r in UserData.requestRoleDatas)
// {
// int index = r.Value;
// temp_RemoveRequest.Enqueue(index);
// ++count;
// if (count >= UserData.MAX_REQUEST_ROLE_COUNT)
// break;
// }
// //清理玩家
// while (temp_RemoveRequest.Count > 0)
// {
// Int32 userindex = temp_RemoveRequest.Dequeue();
// //移除其他玩家
// UserData.removeRequestRoledata(userindex);
// //发送请求其他玩家详细数据
// AppEntryWorld.send_700(userindex);
// //var entryWorld = HotfixEntry.Resources.m_Assembly.GetType("Game.HotFix.AppEntryWorld");
// //var start = entryWorld.GetMethod("send_700");
// //start?.Invoke(null, new object[] { userindex });
// //AppEntryWorld.send_700(userindex);
// }
// temp_RemoveRequest.Clear();
// }
// //更新请求玩家数据列表或者怪物数据列表
// private void UpdateRequestRobotData()
// {
// if (UserData.requestRobotDatas.Count == 0)
// return;
// Int32 count = 0;
// foreach (var r in UserData.requestRobotDatas)
// {
// int index = r.Value;
// temp_RemoveRequest.Enqueue(index);
// ++count;
// if (count >= UserData.MAX_REQUEST_ROBOT_COUNT)
// break;
// }
// //清理玩家
// while (temp_RemoveRequest.Count > 0)
// {
// Int32 robotindex = temp_RemoveRequest.Dequeue();
// //移除其他玩家
// UserData.removeRequestRobotdata(robotindex);
// //var app = HotfixEntry.Resources.m_Assembly.GetType("Game.HotFix.AppRobot");
// //var method = app.GetMethod("send_8000");
// //method?.Invoke(null, new object[] { robotindex });
// //发送请求怪物详细数据
// AppRobot.send_8000(robotindex);
// }
// temp_RemoveRequest.Clear();
// }
// //玩家离开世界
// public void LeaveWorld(S_ROLE_BASE role)
// {
// if (role == null)
// return;
// //释放角色,清楚角色格子占据数据
// HotfixEntry.Map.ClearRoleCellData(role.mem.userindex, E_NODE_TYPE.N_ROLE);
// //0、清理锁定
// ClearLock(role, null);
// //1、释放显示资源
// if (role.userview != null)
// {
// //role.userview.Release();
// Release(role);
// UserData.pushUserView(role.userview);
// role.userview = null;
// //清除便捷数据类
// UserData.pushRoleDataSet(role.dataSet);
// role.dataSet = null;
// }
// //2、释放数据
// UserData.removeRoleData(role.mem.userindex);//从玩家数据中移除
// UserData.pushRoleData(role);//放回对象回收池 重复利用
// }
// public void ClearLock(S_ROLE_BASE role, S_ROBOT_BASE robot)
// {
// bool islock = false;
// if (role == null && robot == null)
// {
// islock = true;
// }
// else
// {
// switch ((Lock_Type)UserData.role.tmp.lockData.lock_type)
// {
// case Lock_Type.LOCK_PLAYER:
// if (role != null)
// if (role.mem.userindex == UserData.role.tmp.lockData.lock_index)
// islock = true;
// break;
// case Lock_Type.LOCK_MONSTER:
// if (robot != null)
// if (robot.data.robotindex == UserData.role.tmp.lockData.lock_index)
// islock = true;
// break;
// }
// }
// if (!islock)
// return;
// if (UserData.role.tmp.lockData.lock_type > 0)
// {
// //FGUIManager.GetFUI(FGUIType.BattlePanel).GetComponent<UIBattleComponent>().HideSelectObjInfo();
// //GameObject.Destroy(MyUserData.lockeffect);
// }
// UserData.role.tmp.lockData.Init();
// }
// //同步移动 状态同步
// //三种策略 1、状态发送变化 2、方向发生了变化 3、距离发生了变化
// public void SyncMove()
// {
// float face = HotfixEntry.MainPlayer.myView.movement.CurRotate;
// //1、状态发生变化
// if (myrole.move.state != myrole.move.oldstate)
// {
// myrole.move.oldstate = myrole.move.state;
// SendMove();
// return;
// }
// if (myrole.move.state == 0)
// return;
// //2、验证距离
// float ftime = Time.time - myrole.move.syncTime;
// if (ftime > 0.2f)
// {
// //距离格子中心点0.2才算
// Vector3 centerPos = HotfixEntry.Map.GetPosByCell(HotfixEntry.MainPlayer.myView.movement.CurCell.X, HotfixEntry.MainPlayer.myView.movement.CurCell.Y);
// float centerDis = Vector3.Distance(HotfixEntry.MainPlayer.myView.Pos, centerPos);
// if (centerDis >= 0.2f)
// return;
// Vector3 tPos = new Vector3(HotfixEntry.MainPlayer.myView.movement.CurCell.X, 0, HotfixEntry.MainPlayer.myView.movement.CurCell.Y);
// float distance = Vector3.Distance(myrole.move.pos, tPos);
// if (distance >= 0.8f)
// {
// SendMove();
// return;
// }
// }
// else if (ftime > 0.1f)
// {
// //3、角度发生了变化
// float angle = Math.Abs(myrole.move.face - face);
// if (angle >= 5)
// {
// SendMove();
// return;
// }
// }
// }
// public void SendMove()
// {
// float face = HotfixEntry.MainPlayer.myView.movement.CurRotate;
// myrole.move.syncTime = Time.time;
// myrole.move.face = face;
// //发送数据
// if (myrole.move.state == 0)
// AppMove.send_1000(face, 0, myrole.status.pos, myrole.status.pos);
// else
// {
// myrole.move.pos = new Vector3(HotfixEntry.MainPlayer.myView.movement.CurCell.X, 0, HotfixEntry.MainPlayer.myView.movement.CurCell.Y);
// //Log.Debug($"发送路径:起始点:[{myrole.status.pos}], 结束点:[{myrole.move.pos}]");
// AppMove.send_1000(face, HotfixEntry.MainPlayer.myView.movement.speed, myrole.status.pos, myrole.move.pos);
// myrole.status.pos = new Vector3(HotfixEntry.MainPlayer.myView.movement.CurCell.X, 0, HotfixEntry.MainPlayer.myView.movement.CurCell.Y);
// }
// HotfixEntry.Map.UpdateUserBC(myrole);
// }
// //更新删除玩家显示
// //玩家三大策略 1、收到服务器玩家离开信息删除ok 2、不在主控玩家九宫格范围删除 3、心跳包时间超时删除
// private void UpdateUserRect()
// {
// foreach (var r in UserData.onlines)
// {
// var role = r.Value;
// if (role.userview == null)
// continue;
// if (role.userview.go == null)
// continue;
// role.userview.Update();
// //1、验证大格子是不是在主控玩家九宫格区域内
// if (!myrole.bc.edge.IsRect(role.bc.grid_big.row, role.bc.grid_big.col))
// {
// //需要删除
// temp_RemoveUser.Enqueue(role);
// Debug.Log("玩家不在九宫格范围..." + role.mem.userId);
// continue;
// }
// //2、心跳时间验证 超过60秒 认为这个玩家是个死链接 删除
// float ftime = Time.time - role.tmp.heartTime;
// if (ftime > 60)
// {
// //需要删除
// temp_RemoveUser.Enqueue(role);
// Debug.Log("玩家hearttime...删除" + role.mem.userId);
// continue;
// }
// }
// //清理玩家
// while (temp_RemoveUser.Count > 0)
// {
// var role = temp_RemoveUser.Dequeue();
// //移除其他玩家
// if (UserData.onlines.ContainsKey(role.mem.userindex))
// {
// UserData.onlines.Remove(role.mem.userindex);
// }
// //玩家离开世界
// LeaveWorld(role);
// }
// temp_RemoveUser.Clear();
// }
// public List<S_ROLE_BASE> GetRoleListInRadius(int cellNum, int curRobotIndex = -1)
// {
// CellNode cur = HotfixEntry.MainPlayer.myView.CurCell;
// List<S_ROLE_BASE> roles = new List<S_ROLE_BASE>();
// foreach (var r in UserData.onlines)
// {
// var role = r.Value;
// if (role.userview == null)
// continue;
// var roleCell = role.userview.CurCell;
// float count = Vector2Int.Distance(new Vector2Int(cur.X, cur.Y), new Vector2Int(roleCell.X, roleCell.Y));
// //超过距离,过滤
// if (count > cellNum)
// continue;
// //当前已选中怪,过滤, 并且取消选中状态
// if (role.mem.userindex == curRobotIndex)
// continue;
// roles.Add(role);
// }
// return roles;
// }
// public void SetAllSublightOff()
// {
// foreach (var r in UserData.onlines)
// {
// var role = r.Value;
// if (role.userview == null)
// continue;
// role.userview.SetSublightOff();
// }
// }
// }
//}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 43144cb712dca51408ee7f9be700a154
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -3,6 +3,29 @@ using UnityEngine;
namespace Game
{
//主控玩家角色数据
public class S_ROLE_SELF : S_ROLE_DATA_BASE
{
public S_ROLE_ECON econ;//经济
public S_ROLE_MOVE move;
public S_ROLE_SELF(int RoleID)
{
RoleType = E_NODE_TYPE.N_MAINPLAYER;
move = new S_ROLE_MOVE();
econ = new S_ROLE_ECON();
}
override public void Init()
{
base.Init();
exp.Init();
move.Init();
econ.Init();
}
}
//½ÇÉ«¾­Ñé
public class S_ROLE_EXP
{
@ -20,13 +43,9 @@ namespace Game
public class S_ROLE_ECON
{
public long gold;//½ð±Ò
public long vcoin;//元宝
public long silverCoin;//银币
public void Init()
{
gold = 0;
vcoin = 0;
silverCoin = 0;
}
}
@ -173,25 +192,4 @@ namespace Game
pos.x = 0; pos.y = 0; pos.z = 0;
}
}
//主控玩家角色数据
public class S_ROLE_SELF : S_ROLE_BASE
{
public S_ROLE_ECON econ;//经济
public S_ROLE_MOVE move;
public S_ROLE_SELF()
{
move = new S_ROLE_MOVE();
econ = new S_ROLE_ECON();
}
override public void Init()
{
base.Init();
exp.Init();
move.Init();
econ.Init();
}
}
}
}

View File

@ -1,27 +1,29 @@
namespace Game
{
//玩家角色数据
public class S_ROLE_BASE
public class S_ROLE_DATA_BASE
{
public E_NODE_TYPE RoleType;
//玩家数据
public S_ROLE_INNATE innate;//先天属性
public S_ROLE_STATUS status;//状态
public S_ROLE_LIFE life;//生命
public S_ROLE_EXP exp;//经验
public S_ROLE_BATTLEATTR_1ST battleattr1st;//1级战斗属性
public S_ROLE_BATTLEATTR battleattr;
//public S_ROLE_BATTLEATTR_1ST battleattr1st;//1¼¶Õ½¶·ÊôÐÔ
//public S_ROLE_BATTLEATTR battleattr;
public bool isEntryWorld;
public S_ROLE_BASE()
public S_ROLE_DATA_BASE()
{
innate = new S_ROLE_INNATE();
status = new S_ROLE_STATUS();
life = new S_ROLE_LIFE();
exp = new S_ROLE_EXP();
battleattr1st = new S_ROLE_BATTLEATTR_1ST();
battleattr = new S_ROLE_BATTLEATTR();
//battleattr1st = new S_ROLE_BATTLEATTR_1ST();
//battleattr = new S_ROLE_BATTLEATTR();
isEntryWorld = false;
}
@ -30,10 +32,8 @@ namespace Game
{
status.Init();
life.Init();
exp.Init();
battleattr1st.Init();
//exp.Init();
//battleattr1st.Init();
}
}
}
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 863450b96fdef644d89f32a174fcf8b9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 92dd00f3d5b6be043b7e9496acfaeddb
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,80 @@
using Game;
using Game.HotFix;
using System.Collections.Generic;
using UnityEngine;
namespace Game
{
public class CharacterMachine : ICharMachineBase //是否使用其他基类或是否使用MonoBehaviour 靠外部驱动,按需修改
{
private Animator _animator;
public bool IsAttacking()
{
AnimatorStateInfo stateInfo = _animator.GetCurrentAnimatorStateInfo(0);
if (stateInfo.IsName("Idle01"))
return false;
if (stateInfo.IsName("Run"))
return false;
if (stateInfo.IsName("Hit"))
return false;
return true;
}
#region
public void InitMachine(Transform trans)
{
_animator = trans.GetComponent<Animator>();
}
public void ReleazeMachine()
{
_animator = null;
}
public void Update_Logic()
{ }
public void StartRun()
{
_animator.SetInteger("Speed", 1);
}
public void BackToIdle()
{
_animator.SetInteger("Speed", 0);
}
public void DeadToIdle()
{
_animator.SetBool("Dead", false);
}
public void SetAttack(string anim)
{
_animator.SetBool(anim, true);
}
public void SetOtherAnime(string anim)
{
_animator.Play(anim);
}
public void PlayDead()
{
_animator.SetBool("Dead", true);
}
public void StartHit()
{
_animator.SetBool("Hit", true);
}
#endregion
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 42d4639d3c8bb9543868f68d9315a75a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,24 @@
using Axibug;
using System.Collections.Generic;
using UnityEngine;
namespace Game
{
public interface ICharMachineBase
{
/// <summary>
/// ´«ÈëÓж¯»­»úµÄ²ã¼¶
/// </summary>
/// <param name="trans"></param>
public abstract void InitMachine(Transform trans);
public abstract void ReleazeMachine();
public abstract void Update_Logic();
public abstract void SetAttack(string anim);
public abstract void SetOtherAnime(string anim);
public abstract void PlayDead();
public abstract void StartHit();
public abstract void StartRun();
public abstract void BackToIdle();
public abstract void DeadToIdle();
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 899a62e98309e3b4cb500fa3faa9e2a4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,24 @@
using Axibug;
using Axibug.Runtime;
using System.Collections.Generic;
using UnityEngine;
namespace Game
{
public abstract class MainRole : RoleBase
{
/// <summary>
/// ³õʼ»¯
/// </summary>
/// <param name="data"></param>
public void Init(S_ROLE_SELF data)
{
base.Init(data);
}
public override void Release()
{
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 89233ed8a4aa86247be5d5a1de5e66f9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,45 @@
using Axibug;
using Axibug.Runtime;
using System;
using System.Collections.Generic;
using UnityEngine;
namespace Game
{
public abstract class RoleBase : MonoBehaviour
{
protected E_NODE_TYPE mRoleType => mData.RoleType;
protected Int64 mRoleID => mData.innate.roleid;
/// <summary>
/// ¶¯»­¿ØÖÆÆ÷
/// </summary>
protected ICharMachineBase Anime;
protected S_ROLE_DATA_BASE mData;
/// <summary>
/// ³õʼ»¯
/// </summary>
/// <param name="data"></param>
public virtual void Init(S_ROLE_DATA_BASE data)
{
mData = data;
if (mRoleType == E_NODE_TYPE.N_MAINPLAYER)
{
Anime = new CharacterMachine();
Anime.InitMachine(transform.Find("Model"));
}
else if (mRoleType == E_NODE_TYPE.N_MONSTER)
{
}
else if (mRoleType == E_NODE_TYPE.N_NPC)
{
}
}
public abstract void Release();
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 16d753beef6b04247956d321f0cc9a9b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -115,7 +115,7 @@
<Compile Include="Assets\Scripts\Main\UI\UIYYControl\UITimer.cs" />
<Compile Include="Assets\Scripts\Main\UI\Native\NativeConfirmUI.cs" />
<Compile Include="Assets\Scripts\Main\Procedure\ProcedureSplash.cs" />
<Compile Include="Assets\Scripts\Main\Definition\DataStruct\Role\S_ROLE_BASE.cs" />
<Compile Include="Assets\Scripts\Main\Definition\DataStruct\Role\S_ROLE_DATA_BASE.cs" />
<Compile Include="Assets\Scripts\Main\UI\UIYYControl\UIPolygon.cs" />
<Compile Include="Assets\Scripts\Main\Base\AppEntry.cs" />
<Compile Include="Assets\Scripts\Main\BuiltinData\BuiltinDataComponent.cs" />
@ -124,6 +124,11 @@
<Compile Include="Assets\Scripts\Main\CustomsComponent\InputComponent.cs" />
<Compile Include="Assets\Scripts\Main\UI\UIMgr\UIAutoAdjustWidth.cs" />
<Compile Include="Assets\Scripts\Main\Procedure\ProcedureInitSystem.cs" />
<Compile Include="Assets\Scripts\Main\CustomsComponent\UserMgrComponent.cs" />
<Compile Include="Assets\Scripts\Main\Role\RoleBase.cs" />
<Compile Include="Assets\Scripts\Main\Role\CharacterMachine\ICharMachineBase.cs" />
<Compile Include="Assets\Scripts\Main\Role\CharacterMachine\CharacterMachine.cs" />
<Compile Include="Assets\Scripts\Main\Role\MainRole.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Assets\Scripts\Main\Game.asmdef" />