/// <summary> 开始游戏回调 </summary> private void OnBtnBeginGameClick() { if (m_IsSelectRoleView) { RoleCreateRequestProto proto = new RoleCreateRequestProto(); proto.JobId = (byte)m_SelectJobId; proto.RoleName = m_SelectRoleView.IFNickName.text; if (string.IsNullOrEmpty(proto.RoleName)) { TipsUtil.ShowTextTips(1000306); return; } NetWorkSocket.Instance.SendMsg(proto.ToArray()); } else { if (!m_IsHaveRole) { RoleCreateRequestProto proto = new RoleCreateRequestProto(); proto.JobId = (byte)m_SelectJobId; proto.RoleName = m_SelectRoleView.IFNickName.text; if (string.IsNullOrEmpty(proto.RoleName)) { TipsUtil.ShowTextTips(1000306); return; } NetWorkSocket.Instance.SendMsg(proto.ToArray()); } else { EnterGame(); } } }
private void OnAccountLogOnResponse(byte[] buffer) { AccountLogOnResponseProto proto = AccountLogOnResponseProto.GetProto(buffer); if (!proto.IsSuccess) { TipsUtil.ShowTextTips(1000111); } else { //登录成功 //TipsUtil.ShowTextTips("用户编号 = " + proto.UserId); if (m_LogOnWindow != null) { Stat.LogOn(proto.UserId, m_LogOnWindow.IFAccount.text); PlayerPrefsUtil.SetAccountID(proto.UserId); PlayerPrefsUtil.SetAccountUserName(m_LogOnWindow.IFAccount.text); PlayerPrefsUtil.SetAccountPwd(m_LogOnWindow.IFPwd.text); m_LogOnWindow.CloseAndOpenNext(Window.GameServerEnter); } else { Stat.Register(proto.UserId, PlayerPrefsUtil.GetAccountUserName()); WindowManager.Instance.OpenWindow(Window.GameServerEnter); } GlobalInit.Instance.AccountId = proto.UserId; GlobalInit.Instance.AccountUserName = PlayerPrefsUtil.GetAccountUserName(); } }
private void OnGameEnterResponse(byte[] buffer) { GameLevelEnterResponseProto proto = GameLevelEnterResponseProto.GetProto(buffer); Debuger.LogError("proto.Issuccess = " + proto.IsSuccess); if (proto.IsSuccess) { SceneMgr.Instance.LoadToWorldMap(m_WordMapId); } else { TipsUtil.ShowTextTips(string.Format(StringUtil.GetStringById(proto.MsgCode), m_WordMapId)); } }
private void OnRoleCreateResponse(byte[] buffer) { RoleCreateResponseProto proto = RoleCreateResponseProto.GetProto(buffer); if (proto.IsSuccess) { Debuger.Log("创建成功"); LogOnGameServer(); } else { TipsUtil.ShowTextTips(proto.MsgCode); } }
/// <summary> 服务器返回角色信息 </summary> /// <param name="buffer"></param> private void OnRoleInfoResponse(byte[] buffer) { RoleInfoResponseProto proto = RoleInfoResponseProto.GetProto(buffer); if (proto.IsSuccess) { GlobalInit.Instance.PlayerInfo = new RoleInfoMainPlayer(proto); Debuger.LogError("GlobalInit.Instance.PlayerInfo.level = " + GlobalInit.Instance.PlayerInfo.Level); m_LastInWorldMapId = proto.LastInWorldMapId; } else { TipsUtil.ShowTextTips(proto.MsgCode); } }
private void OnPhyAttack() { if (GlobalInit.Instance.SkillSlotsItem != null) { GlobalInit.Instance.SkillSlotsItem = null; } if (GlobalInit.Instance.CurrPlayer.IsRigidity) { //技能施放中 TipsUtil.ShowTextTips(1000503); return; } int[] phyIdArray = JobDBModel.Instance.Get(GlobalInit.Instance.PlayerInfo.JobId).PhyAttackIdArray; int id = UnityEngine.Random.Range(phyIdArray[0], phyIdArray[phyIdArray.Length - 1]); GlobalInit.Instance.CurrPlayer.ToAttack(RoleAttackType.PhyAttack, id); }
/// <summary> 单服点击回调 </summary> /// <param name="index"></param> private void OnRightCallBack(int index) { RightGameServerItem item = m_RightItemList[index]; if (item.ServerState == 0 || item.ServerState > 3) { TipsUtil.ShowTextTips(StringUtil.GetStringById(1000205)); } else { UpdateWin(item); m_GameServerEnterWin.ServerSelectWin.DOPlayBackwards(); //m_GameServerEnterWin.NowServerText.text = item.ServerName; //m_GameServerEnterWin.Status.sprite = AssetBundleManager.Instance.LoadSprite("Login", "YanChi0"+item.ServerState); //m_GameServerEnterWin.ChangeText.text = StringUtil.RichString(1000202); //m_IsShowSelectWin = false; //m_GameServerEnterWin.Logo.SetActive(true); } }
protected virtual void OnUpdate() { if (Input.GetKeyDown(KeyCode.E)) { TipsUtil.ShowExpTips(10000); } if (Input.GetKeyDown(KeyCode.C)) { TipsUtil.ShowCoinTips(10000); } if (Input.GetKeyDown(KeyCode.T)) { TipsUtil.ShowTextTips("世事如棋 乾坤莫测"); } if (Input.GetKeyDown(KeyCode.G)) { TipsUtil.ShowGoldTips(666666); } if (Input.GetKeyDown(KeyCode.B)) { TipsUtil.ShowGoldBindingTips(888888); } }
private void ToSkillAttack(UISkillSlotsItem item) { //if (GlobalInit.Instance.CurrPlayer.IsRigidity) //{ //技能施放中 //TipsUtil.ShowTextTips(1000503); //return; //} if (!item.IsActive) { SceneMgr.Instance.LoadToWorldMap(PlayerCtrl.Instance.LastInWorldMapId); //技能未开启 TipsUtil.ShowTextTips(1000502); return; } if (item.LeftTime > 0) { //技能冷却中 TipsUtil.ShowTextTips(1000501); return; } GlobalInit.Instance.SkillSlotsItem = item; GlobalInit.Instance.CurrPlayer.ToAttack(RoleAttackType.SkillAttack, item.SkillId); }
public void ToAttack(RoleAttackType type, int skillId) { if (m_CurrRoleFSMMgr == null || m_CurrRoleFSMMgr.CurrRoleCtrl.IsRigidity) { if (type == RoleAttackType.SkillAttack) { m_NextSkillId = skillId; } return; } m_NextSkillId = -1; //1.角色类型只有玩家和怪才参与技能数值计算 if (m_CurrRoleCtrl.CurrRoleType == RoleType.MainPlayer || m_CurrRoleCtrl.CurrRoleType == RoleType.Monster) { //2.获取技能信息 SkillEntity skillEntity = SkillDBModel.Instance.Get(skillId); if (skillEntity == null) { return; } int skillLevel = m_CurrRoleCtrl.CurrRoleInfo.GetSkillLevel(skillId); //技能所需魔法值 int spendMP = skillEntity.SpendMP + skillEntity.SpendMPLevelUp * (skillLevel - 1); //3.如果是主角 if (m_CurrRoleCtrl.CurrRoleType == RoleType.MainPlayer && type == RoleAttackType.SkillAttack) { if (GlobalInit.Instance.SkillSlotsItem != null) { if (spendMP > GlobalInit.Instance.PlayerInfo.CurrMP) { TipsUtil.ShowTextTips(1000504); return; } GlobalInit.Instance.PlayerInfo.CurrMP -= spendMP; GlobalInit.Instance.PlayerInfo.SetSkillCDEndTime(skillId); if (m_CurrRoleCtrl.OnMPChange != null) { m_CurrRoleCtrl.OnMPChange(ValueChnageType.Reduce); } GlobalInit.Instance.SkillSlotsItem.AddTimer(); GlobalInit.Instance.SkillSlotsItem = null; } } m_EnemyList.Clear(); //4.找敌人 如果是主角才找敌人 怪找敌人使用AI if (m_CurrRoleCtrl.CurrRoleType == RoleType.MainPlayer) { int attackTargetCount = skillEntity.AttackTargetCount; if (attackTargetCount == 1) { #region ------ 单体攻击 ------ //单体攻击 必须有锁定敌人 if (m_CurrRoleCtrl.LockEnemy != null) { m_EnemyList.Add(m_CurrRoleCtrl.LockEnemy); } else { m_SearchList.Clear(); //没有锁定敌人 //发射射线去找 离当前攻击者最近的 就是锁定敌人 Collider[] searchList = Physics.OverlapSphere(m_CurrRoleCtrl.transform.position, skillEntity.AreaAttackRadius, 1 << LayerMask.NameToLayer("Role")); if (searchList != null && searchList.Length > 0) { for (int i = 0; i < searchList.Length; i++) { if (searchList[i].GetComponent <RoleCtrl>().CurrRoleType != RoleType.MainPlayer) { m_SearchList.Add(searchList[i]); } } } m_SearchList.Sort((c1, c2) => { int ret = 0; if (Vector3.Distance(c1.transform.position, m_CurrRoleCtrl.transform.position) < Vector3.Distance(c2.transform.position, m_CurrRoleCtrl.transform.position)) { ret = -1; } else { ret = 1; } return(ret); }); if (m_SearchList.Count > 0) { m_CurrRoleCtrl.LockEnemy = m_SearchList[0].GetComponent <RoleCtrl>(); m_EnemyList.Add(m_CurrRoleCtrl.LockEnemy); } } #endregion } else { #region ------ 群体攻击 ------ int needAttackCount = attackTargetCount; m_SearchList.Clear(); //没有锁定敌人 //发射射线去找 离当前攻击者最近的 就是锁定敌人 Collider[] searchList = Physics.OverlapSphere(m_CurrRoleCtrl.transform.position, skillEntity.AreaAttackRadius, 1 << LayerMask.NameToLayer("Role")); if (searchList != null && searchList.Length > 0) { for (int i = 0; i < searchList.Length; i++) { if (searchList[i].GetComponent <RoleCtrl>().CurrRoleType != RoleType.MainPlayer) { m_SearchList.Add(searchList[i]); } } } m_SearchList.Sort((c1, c2) => { int ret = 0; if (Vector3.Distance(c1.transform.position, m_CurrRoleCtrl.transform.position) < Vector3.Distance(c2.transform.position, m_CurrRoleCtrl.transform.position)) { ret = -1; } else { ret = 1; } return(ret); }); //群体攻击 如果有锁定敌人 锁定敌人必须是攻击目标之一 if (m_CurrRoleCtrl.LockEnemy != null) { m_EnemyList.Add(m_CurrRoleCtrl.LockEnemy); needAttackCount--; for (int i = 0; i < m_SearchList.Count; i++) { RoleCtrl ctrl = m_SearchList[i].GetComponent <RoleCtrl>(); if (ctrl.CurrRoleInfo.RoleId != m_CurrRoleCtrl.CurrRoleInfo.RoleId) { if ((i + 1) > needAttackCount) { break; } m_EnemyList.Add(m_SearchList[i].GetComponent <RoleCtrl>()); } } } else { if (m_SearchList.Count > 0) { m_CurrRoleCtrl.LockEnemy = m_SearchList[0].GetComponent <RoleCtrl>(); for (int i = 0; i < m_SearchList.Count; i++) { RoleCtrl ctrl = m_SearchList[i].GetComponent <RoleCtrl>(); if ((i + 1) > needAttackCount) { break; } m_EnemyList.Add(ctrl); } } } #endregion } } else if (m_CurrRoleCtrl.CurrRoleType == RoleType.Monster) { if (m_CurrRoleCtrl.LockEnemy != null) { m_EnemyList.Add(m_CurrRoleCtrl.LockEnemy); } } //Debug.Log(m_EnemyList.Count); //5.让敌人受伤 for (int i = 0; i < m_EnemyList.Count; i++) { m_EnemyList[i].ToHurt(CalculateHurtValue(m_EnemyList[i], skillEntity)); } } #region ------ 动画特效相关 ------ RoleAttackInfo info = GetRoleAttackInfo(type, skillId); if (info == null) { return; } GlobalInit.Instance.StartCoroutine(PlayerEffect(info)); //EffectManager.Instance.DestroyEffect(trans, info.EffectLifeTime); //if (info.IsDoCameraShake && CameraCtrl.Instance != null) //{ // CameraCtrl.Instance.CameraShake(info.CameraShakeDelay); //} if (m_RoleStateAttack == null) { m_RoleStateAttack = m_CurrRoleFSMMgr.GetRoleState(RoleState.Attack) as RoleStateAttack; } m_RoleStateAttack.AnimatorCondition = type == RoleAttackType.PhyAttack ? "ToPhyAttack" : "ToSkill"; m_RoleStateAttack.AnimatorConditionValue = info.Index; m_RoleStateAttack.AnimatorCurrState = GameUtil.GetRoleAnimatorState(type, info.Index); #endregion m_CurrRoleFSMMgr.ChangeState(RoleState.Attack); }