/// <summary> 增加武将Buff</summary> /// <param name="role">武将</param> /// <param name="round">影响回合数</param> /// <param name="type">技能类型</param> /// <param name="values">技能效果值</param> /// <param name="flag">true:增加 false:减少</param> private void AddRoleBuff(FightRole role, int round, int type, double values, bool flag) { if (round < 0) { return; } switch (round) { case 0: { var roleAtt = new FightRoleBuff { id = role.id, round = 0, type = type, values = -values, state = 0 }; list_buff.Add(roleAtt); break; } case 99999: { role.foreverBuffVos.Add(new BuffVo { type = type, buffValue = values }); return; } default: { var roleAtt = new FightRoleBuff { id = role.id, round = Round + (round - 1), type = type, values = -values, state = 0 }; list_buff.Add(roleAtt); break; } } role.buffVos2.Add(new BuffVo { type = type, buffValue = flag ? values : -values }); #if DEBUG XTrace.WriteLine(string.Format("{0} {1} {2} - {3}", "增加 武将 " + role.id + " BUFF ", " 类型 " + type, " 过期回合数 " + (Round + (round - 1)), " 效果值 " + values)); #endif }
void Attack(FightRole A, FightRole D) { if (!A.isAttackComplete) { if (A.RoleObj.transform.position != A.atkPoslPos) { A.RoleObj.transform.position = A.atkPoslPos; //角色移动到攻击位 } } else { Formula.Attack(A.roleInfo, D.roleInfo); // A.isDamgea = true; A.isAtking = false; A.RoleObj.transform.position = A.initialPos; A.isAttackComplete = false; A.isAct = false; A.atkCount++; return; } if (!A.isAtking)//触发攻击动作 { A.role_Animator.SetTrigger("Attack"); A.isAtking = true; } }
/// <summary> 是否释放奥义</summary> /// <param name="attackrole">武将vo</param> private bool IsMystery(FightRole attackrole) { if (attackrole.mystery == null) { return(false); } var role = list_role_hp.FirstOrDefault(m => m.id == attackrole.id); //初始时武将状态 if (role == null) { return(false); } double hpcount = Convert.ToDouble(attackrole.hp) / Convert.ToDouble(role.hp); var probability = attackrole.mystery_probability; if (hpcount <= 0.5) { probability = probability + (60 - (hpcount * 100)); } #if DEBUG probability = 60; #endif return(IsTrue(probability) && SkillParsing(attackrole.mystery, (int)SkillType.MYSTERY)); }
/// <summary>出手</summary> private bool Shot(FightRole attackrole) { #if DEBUG XTrace.WriteLine(string.Format("{0} {1}", "出手武将", "验证")); #endif if (StateVerification(attackrole, (int)FightingSkillType.DIZZINESS)) { return(true); //验证武将是否眩晕 } if (StateVerification(attackrole, (int)FightingSkillType.SEAL)) //验证武将是否封印 { #if DEBUG XTrace.WriteLine(string.Format("{0} {1}", "出手武将", "被封印")); #endif goto attack; //跳过秘技验证 进行普通攻击 } if (IsMystery(attackrole)) //是否释放奥义 { goto Yin; } if (IsSkill(attackrole)) //是否释放秘技 { goto Yin; //跳过普通攻击 进行印验证 } attack: if (!NormalAttack(attackrole)) //普通攻击 { return(false); } Yin: //UpdateBuff(); //将上次出手武将新Buff改为旧Buff IsYin(); //是否释放印技能 return(true); }
/// <summary> 单体普通攻击 增加气力值</summary> /// <param name="attackrole">攻击武将</param> private bool NormalAttack(FightRole attackrole) { var flag = false; if (attackrole.angerCount < 8) { attackrole.angerCount = attackrole.angerCount + 1; //普通攻击气力加1 } attackrole.damage = 0; //修改攻击方属性 var defenserole = GetFrontRole(GetMatrix(false)); //最先受击战斗武将Vo if (defenserole == null) { return(false); } if (IsDuck(defenserole)) { return(true); } var number = DamageCount(attackrole, defenserole, ref flag); ByEffect(attackrole, defenserole, number, flag); return(true); }
/// <summary>不加气力普通攻击操作</summary> /// <param name="attackrole">当前攻击武将</param> /// <param name="flag">范围类型:true 全体 false:单体</param> private void Attack(FightRole attackrole, bool flag) { var movesvo = move.CloneDeepEntity(); if (attackrole == null) { return; } var list = GetRoleOrRoleAll(GetMatrix(false), flag); if (!list.Any()) { return; } foreach (var item in list) { var iscrit = false; if (!IsTrue(attackrole.IgnoreDuck)) { if (IsDuck(item)) { continue; } } else { #if DEBUG XTrace.WriteLine(string.Format("{0} {1} {2}", "技能成功--> 被打方Id", item.id, "无视闪避触发成功 直接不计算闪避率进行攻击")); #endif } var number = DamageCount(attackrole, item, ref iscrit); if (flag) { number = Convert.ToInt64(number * 0.3); //群攻增加0.3系数 } item.hp = item.hp - number; movesvo.hitIds.Add(Convert.ToDouble(item.id)); //普通受击武将 if (iscrit) { var roleAtt = new FightRoleBuff { id = item.id, round = 0, type = (int)FightingSkillType.CRIT, values = 0, state = 0 }; list_buff.Add(roleAtt); item.buffVos2.Add(new BuffVo { type = (int)FightingSkillType.CRIT, buffValue = -number }); } else { item.damage = number; } } BuildMovesVo(movesvo, (int)SkillType.COMMON); }
/// <summary>是否释放秘技</summary> /// <param name="attackrole">武将vo</param> private bool IsSkill(FightRole attackrole) { #if DEBUG //attackrole.cheatCode = new SkillVo() //{ // baseId = 16152012, // level = 1, //}; //attackrole.cheatCode = null; #endif return(attackrole.cheatCode != null && SkillParsing(attackrole.cheatCode, (int)SkillType.CHEATCODE)); }
/// <summary> 移除武将身上Buff值 </summary> private void RemoveRoleBuffValues(FightRole role, int type, double values) { var l = new List <FightRole> { role }; var skillEffects = new FightSkillEffects { type = type, values = values, round = -100 }; //round是负数表示恢复属性影响值 if (type != (int)FightingSkillType.DIZZINESS && type != (int)FightingSkillType.SEAL) { EffectType(l, skillEffects); } }
/// <summary>伤害计算</summary> /// <param name="attackrole">攻击武将</param> /// <param name="defenserole">防守武将</param> /// <param name="flag">是否暴击</param> private Int64 DamageCount(FightRole attackrole, FightRole defenserole, ref bool flag) { //A属性 = A基础属性+A装备属性+A生活技能属性+A称号属性 //A总攻击 = A武力*1.5+A装备攻击力+A效果之增加攻击力-A效果之减少攻击力 //B总防御 = B装备防御力+B效果之增加防御力-B效果之减少防御力 //A会心几率 = A魅力/25 *0.01 +A效果之会心几率 //A会心效果 = 150% + (A政务/15)*0.01 +A效果之会心效果 //B闪避几率 = (B智谋/28)*0.01 +B效果之会心效果 //A伤害加成 = A效果之增加伤害+A装备增加伤害 //B减伤 = B装备减伤 + B效果之减伤 //B生命 = B基础生命+B装备生命+B技能生命 //攻击伤害 = (A总攻击-B总防御)*(1-B减伤)*(100% + A会心成功值*(A会心效果-100%))*(100% + A伤害加成) var A0 = attackrole.attack; //A总攻击 var A1 = defenserole.defense; //B总防御 var A2 = attackrole.critProbability; //A会心几率 flag = IsTrue(A2); //是否暴击 var A3 = flag ? 1.5 + (attackrole.critAddition / 100) : 1.0; //A会心效果 var A5 = A0 - A1; //A总攻击-B总防御 var A6 = A5 > 0 ? A5 : 1; //A总攻击-B总防御 var A7 = 1 + (attackrole.hurtIncrease / 100); var A10 = (A6) * ((100 - defenserole.hurtReduce) / 100) * A3 * A7; double number = 1; var n = Round - 21; if (n >= 0) { var b = n / 10; if (b == 0) { number = number + 1; } if (b > 0) { number = number + (1 + n * 0.5); } } var count = A10 * number; if (dic_vocation.ContainsKey(attackrole.user_id)) { count = count * dic_vocation[attackrole.user_id]; } return(count < 0 ? 1 : Convert.ToInt64(count)); }
/// <summary> 移除武将身上指定类型的旧Buff 用于替换Buff时用</summary> /// <param name="role">要操作的武将</param> /// <param name="type">要移除的类型</param> private void RemoveRoleBuff(FightRole role, int type) { var model = list_buff.FirstOrDefault(m => m.id == role.id && m.type == type && m.state == 1); if (model == null) { return; } var buff = role.buffVos.FirstOrDefault(m => m.type == type); if (buff == null) { return; } list_buff.Remove(model); role.buffVos.Remove(buff); RemoveRoleBuffValues(role, type, model.values); }
/// <summary> 武将状态验证 </summary> /// <param name="role">当前武将</param> /// <param name="type">状态类型</param> /// <returns>true:有特殊状态 否则false</returns> private bool StateVerification(FightRole role, int type) { if (role.buffVos2.FirstOrDefault(m => m.type == type) == null) { return(false); } if (type != (int)FightingSkillType.DIZZINESS) { return(true); } var movesvo = move.CloneDeepEntity(); BuildMovesVo(movesvo, (int)SkillType.COMMON); #if DEBUG XTrace.WriteLine(string.Format("{0} {1}", "出手武将", "被眩晕")); #endif return(true); }
public bool ValidateSquadRoleHeadEquiped(string arg) { int roleIdx = int.Parse(arg); FightRole fightRole = MainPlayer.Instance.SquadInfo[roleIdx]; foreach (EquipInfo info in MainPlayer.Instance.EquipInfo) { if (info.pos == fightRole.status) { foreach (EquipmentSlot slot in info.slot_info) { if (slot.id == EquipmentSlotID.ESID_HEAD) { return(slot.equipment_uuid != 0); } } } } return(false); }
void Start() { fm = GetModel <FightModel>(); gm = GetModel <GameModel>(); mm = GetModel <MapModel>(); isend = false; isescape = false; m_Player = (GameObject)Instantiate(Resources.Load("Prefab/Role/Player_kongshou"), playerInitialPos, Quaternion.Euler(0, 180, 0)); if (fm.targetType == 2) { m_Target = (GameObject)Instantiate(Resources.Load("Prefab/Role/Monster/Player"), targetInitialPos, Quaternion.identity); } else if (fm.targetType == 1) { m_Target = (GameObject)Instantiate(Resources.Load("Prefab/Role/NPC/Player"), targetInitialPos, Quaternion.identity); } //p_Animator = m_Player.GetComponent<Animator>(); // t_Animator = m_Target.GetComponent<Animator>(); p_AttackRate = fm.targetRole.speed; t_AttackRate = gm.player.Speed; //初始化战斗对象 p_fightRole = m_Player.GetComponent <FightRole>(); p_fightRole.InitFightRole(gm.player, playerInitialPos, playerAtkPos, p_AttackRate); t_fightRole = m_Target.GetComponent <FightRole>(); t_fightRole.InitFightRole(fm.targetRole, targetInitialPos, targetAtkPos, t_AttackRate); //初始化血条 float v1 = (float)gm.player.Hp / gm.player.MaxHp; playerBlood.value = v1; float v2 = (float)fm.targetRole.Hp / fm.targetRole.maxHp; targetBlood.value = v2; gm.player.HpChange += Player_HpChange; fm.targetRole.HpChange += TargetRole_HpChange; //StartCoroutine("Fight"); }
/// <summary> 对相应的武将进行影响 </summary> /// <param name="attackrole">攻击武将</param> /// <param name="defenserole">防守武将</param> /// <param name="number">造成的伤害</param> /// <param name="flag">是否暴击</param> private void ByEffect(FightRole attackrole, FightRole defenserole, Int64 number, bool flag) { var movesvo = move.CloneDeepEntity(); movesvo.hitIds.Add(Convert.ToDouble(defenserole.id)); //防守武将id加入受击武将id defenserole.hp = defenserole.hp - number; //修改防守方属性 if (flag) { var roleAtt = new FightRoleBuff { id = defenserole.id, round = 0, type = (int)FightingSkillType.CRIT, values = 0, state = 0 }; list_buff.Add(roleAtt); defenserole.buffVos2.Add(new BuffVo { type = (int)FightingSkillType.CRIT, buffValue = -number }); } else { defenserole.damage = number; } BuildMovesVo(movesvo, (int)SkillType.COMMON); }
/// <summary>是否闪避 </summary> private bool IsDuck(FightRole defenserole) { if (!IsTrue(defenserole.dodgeProbability)) { return(false); } var movesvo = move.CloneDeepEntity(); var roleAtt = new FightRoleBuff { id = defenserole.id, round = 0, type = (int)FightingSkillType.DODGE, values = 0, state = 0 }; list_buff.Add(roleAtt); defenserole.buffVos2.Add(new BuffVo { type = (int)FightingSkillType.DODGE }); movesvo.hitIds.Add(defenserole.id); BuildMovesVo(movesvo, (int)SkillType.COMMON); #if DEBUG XTrace.WriteLine(string.Format("{0} {1} {2}", "被打方Id", defenserole.id, "触发闪避 ")); #endif return(true); }
/// <summary>RoleFight实体转换RoleFightVo </summary> /// <param name="model">战斗武将实体</param> /// <returns>前端RoleFightVo</returns> public static RoleFightVo ToFightRoleFightVo(FightRole model) { return(new RoleFightVo { id = model.id, baseId = model.baseId, monsterType = model.monsterType, mystery = model.mystery != null?Convert.ToInt32(model.mystery.baseId) : 0, cheatCode = model.cheatCode != null?Convert.ToInt32(model.cheatCode.baseId) : 0, damage = model.damage, hp = model.hp, initHp = model.initHp, attack = Convert.ToInt32(model.attack), defense = Convert.ToInt32(model.defense), hurtIncrease = model.hurtIncrease, hurtReduce = model.hurtReduce, critProbability = model.critProbability, critAddition = model.critAddition, dodgeProbability = model.dodgeProbability, angerCount = model.angerCount, buffVos = model.buffVos, buffVos2 = model.buffVos2, }); }
/// <summary> 回合计数 </summary> public bool RoundCount(FightRole role, MovesVo movesvo) { if (!dic_round.ContainsKey(role.id)) { InitRound(); //InitRound方法只会在第一次出手时有效 } //UpdateBuff();//将上次出手武将新Buff改为旧Buff 预防不是当前回合出手 var values = dic_round[role.id] + 1; if (values <= Round) { dic_round[role.id] = values; } else { if (!IsAttack) { return(false); } UpdateRound(); if (dic_round.ContainsValue(Round - 1)) { return(false); } #if DEBUG XTrace.WriteLine("{0}", "回合结束"); XTrace.WriteLine(string.Format("{0} {1}", "开始回合数", values)); #endif dic_round[role.id] = values; RemoveBuff(true); } movesvo.times = Round = values; return(true); }
/// <summary> 增加武将Buff</summary> /// <param name="role">武将</param> /// <param name="round">影响回合数</param> /// <param name="type">技能类型</param> /// <param name="flag">true:增加 false:减少</param> private void AddRoleBuff(FightRole role, int round, int type, bool flag) { AddRoleBuff(role, round, type, 0, flag); }
public void EnterGame() { if (respInfo == null) { Debug.LogError("Enter game failed with empty info"); return; } MainPlayer.Instance.AccountID = respInfo.acc_id; MainPlayer.Instance.CreateStep = respInfo.create_step; MainPlayer.Instance.SetBaseInfo(respInfo.info); Debug.Log("EnterGame, create_step:" + respInfo.create_step); Debug.Log("EnterGame, loadedLevel:" + Application.loadedLevel); if (Application.loadedLevelName == GlobalConst.SCENE_STARTUP) // scene startup { GameSystem.Instance.mClient.Reset(); if (respInfo.create_step == 1) //进入基础操作练习 { PractiseData practise = GameSystem.Instance.PractiseConfig.GetConfig(20001); GameSystem.Instance.mClient.CreateMatch(practise, 0ul); GameMatch_Practise match = GameSystem.Instance.mClient.mCurMatch as GameMatch_Practise; match.onBehaviourCreated = () => { PractiseBehaviourGuide behaviour = match.practise_behaviour as PractiseBehaviourGuide; behaviour.onOver = () => { CreateStepIn req = new CreateStepIn(); req.acc_id = respInfo.acc_id; GameSystem.Instance.mNetworkManager.m_platConn.SendPack(0, req, MsgID.CreateStepInID); }; }; } else { MainPlayer.Instance.HpRestoreTime = DateTime.Now + new TimeSpan(0, 0, (int)respInfo.hp_restore_remain); //老玩家,进入大厅界面 LuaTable tScene = LuaScriptMgr.Instance.GetLuaTable("Scene"); tScene.Set("targetUI", "UIHall"); tScene.Set("subID", null); tScene.Set("params", null); SceneManager.Instance.ChangeScene(GlobalConst.SCENE_HALL); } } else { GameMatch curMatch = GameSystem.Instance.mClient.mCurMatch; if (curMatch == null) { GameSystem.Instance.mClient.Reset(); } else // In match, resend EnterGameReq { Debug.Log("EnterGame, Curr league type:" + curMatch.GetConfig().leagueType); if (curMatch.GetConfig().leagueType == GameMatch.LeagueType.eQualifying) { GameSystem.Instance.mClient.Reset(); LuaTable tScene = LuaScriptMgr.Instance.GetLuaTable("Scene"); tScene.Set("targetUI", "UIQualifying"); tScene.Set("subID", null); tScene.Set("params", null); SceneManager.Instance.ChangeScene(GlobalConst.SCENE_MATCH); } else if (curMatch.GetConfig().leagueType == GameMatch.LeagueType.ePVP) { LuaScriptMgr.Instance.CallLuaFunction("jumpToUI", new object[] { "UIHall", null, null }); } else if (curMatch.GetConfig().leagueType == GameMatch.LeagueType.eQualifyingNewer) { LuaTable tQualifyingNewer = LuaScriptMgr.Instance.GetLuaTable("QualifyingNewer"); tQualifyingNewer.Set("inBackToLadder", false); tQualifyingNewer.Set("isJoinLadder", false); tQualifyingNewer.Set("isWinShowIncStarAnim", false); LuaScriptMgr.Instance.CallLuaFunction("jumpToUI", new object[] { "UIHall", null, null }); } else if (curMatch.leagueType == GameMatch.LeagueType.eRegular1V1 || curMatch.leagueType == GameMatch.LeagueType.eQualifyingNew || curMatch.leagueType == GameMatch.LeagueType.ePractise1vs1) { MatchStateOver over = curMatch.m_stateMachine.m_curState as MatchStateOver; if (over == null) { GameSystem.Instance.mClient.Reset(); if (curMatch.leagueType == GameMatch.LeagueType.eRegular1V1) { SceneManager.Instance.ChangeScene(GlobalConst.SCENE_HALL); } else if (curMatch.leagueType == GameMatch.LeagueType.eQualifyingNew) { LuaScriptMgr.Instance.CallLuaFunction("jumpToUI", new object[] { "UIHall", null, null }); } } else { if (curMatch.m_stateMachine.m_curState.m_eState != MatchState.State.eOver || (over != null && !over.matchResultSent) ) { Debug.Log("Resend cached EnterGameReq from new"); MatchType type = GameMatch_PVP.ToMatchType(curMatch.leagueType, curMatch.m_config.type); if (curMatch.leagueType == GameMatch.LeagueType.ePractise1vs1) { EnterGameReq req = new EnterGameReq(); req.acc_id = MainPlayer.Instance.AccountID; req.type = type; req.game_mode = fogs.proto.msg.GameMode.GM_Practice1On1; req.practice_pve = new BeginPracticePve(); req.practice_pve.id = 1; req.practice_pve.fight_list = new FightRoleInfo(); req.practice_pve.fight_list.game_mode = fogs.proto.msg.GameMode.GM_Practice1On1; FightRole fr = new FightRole(); fr.role_id = curMatch.mainRole.m_id; fr.status = FightStatus.FS_MAIN; req.practice_pve.fight_list.fighters.Add(fr); over.SendEnterGamePractise1vs1(req); } else { over.SendEnterGame(type); } } } } else if (PlatNetwork.Instance.cachedEnterGameReq != null) { if (curMatch.m_stateMachine.m_curState.m_eState != MatchState.State.eOver || !(curMatch.m_stateMachine.m_curState as MatchStateOver).matchResultSent) { Debug.Log("Resend cached EnterGameReq"); LuaHelper.SendPlatMsgFromLua((uint)MsgID.EnterGameReqID, PlatNetwork.Instance.cachedEnterGameReq); } } } } if (respInfo.create_step >= GameSystem.Instance.CommonConfig.GetUInt("gMaxCreateStep")) { // after renaming step( the last step), mark as login. MainPlayer.Instance.AddCreateNewRoleLog(true); } else { MainPlayer.Instance.AddCreateNewRoleLog(false); } }