//----------------------------------------------------------------------------------- // 查找技能 //----------------------------------------------------------------------------------- public CSkill FindSkillByTypeID(uint dwTypeID) { CSkill pSkill = null; m_mapSkill.TryGetValue(dwTypeID, out pSkill); return(pSkill); }
private void CalSkillEffect(CSceneEntity pBeAtcker, CSkill pSkill) { if (pBeAtcker != null) { pBeAtcker.OnBeAttacked(m_pOwner, pSkill, false, false, false); } }
public void CalculateDmg(CSceneEntity pBeAtcker, CSkill pSkill, string strActEff) { bool bCrit = false; if (!CalculateBlock(pBeAtcker, pSkill)) { pBeAtcker.OnBeAttacked(m_pOwner, pSkill, false, true, false); return; } /* * if (!CalculateHit ( pBeAtcker, pSkill) ) * { * // miss 了 * pBeAtcker.OnBeAttacked( m_pOwner, pSkill, false, false, false ); * return ; * } */ if (strActEff != "") { CalActionEffect(pBeAtcker, strActEff); } CalSkillEffect(pBeAtcker, pSkill); float fDmg = CalculateBaseDmg(pBeAtcker, pSkill); pBeAtcker.ChangeHP(m_pOwner, pSkill, -(int)fDmg, bCrit); }
public void Enter(CSkill pSkill) { m_pSkill = pSkill; m_bClose = false; m_SegIndex++; if (m_SegIndex > 3) { m_SegIndex = 1; } m_StepSeg = (NormalizeSeg)m_SegIndex; if (m_StepSeg == NormalizeSeg.NATK_Seg0) { m_CtrlSkelton.PlayTrack(ACTID.ACT_DoubleHit01); } if (m_StepSeg == NormalizeSeg.NATK_Seg1) { m_CtrlSkelton.PlayTrack(ACTID.ACT_DoubleHit02); } if (m_StepSeg == NormalizeSeg.NATK_Seg2) { m_CtrlSkelton.PlayTrack(ACTID.ACT_DoubleHit03); } }
//--------------------------------------------------------------------------------- // 被攻击 //--------------------------------------------------------------------------------- public virtual void OnBeAttacked(CSceneEntity pSrc, CSkill pSkill, bool bHited, bool bBlock, bool bCrited) { if (CNGUISys.Inst != null && gameObject.transform.tag == "Player") { //if( CNGUISys.Inst.m_CombatUI != null ) // CNGUISys.Inst.m_CombatUI.SendMessage( "ShowBeAttackEffect" ); } }
public CNormBehavior( ) { m_pSkill = null; m_pOwner = null; m_bClose = true; m_SegIndex = 0; m_StepSeg = NormalizeSeg.NATK_Null; m_CtrlSkelton = null; }
public void Enter(CSkill pSkill) { m_pSkill = pSkill; if (pSkill.GetProto().ActID > 0 && m_CtrlSkelton != null) { ACTID eActID = (ACTID)pSkill.GetProto().ActID; m_CtrlSkelton.PlayTrack(eActID); } }
public override void update( ) { foreach (var item in m_mapSkill) { CSkill pSkill = item.Value; if (pSkill != null) { pSkill.UpdateCD(); } } }
private void InitSkill( ) { if (m_pProto.dwNormalSkill > 0) { m_pMeleeSkill = AddSkill(m_pProto.dwNormalSkill); } if (m_pProto.dwLongDisSkill > 0) { m_pRangedSkill = AddSkill(m_pProto.dwLongDisSkill); } }
public override void OnDead(CSceneEntity pKiller, CSkill pSkill) { if (IsInState(EState.ES_Dead)) { return; } //SetState (EState.ES_Dead); if (pKiller != null) { pKiller.OnKill(this); } }
//----------------------------------------------------------------------------------- // 增加技能 //----------------------------------------------------------------------------------- public CSkill AddSkill(uint dwTypeID) { CSkill newSkill = null; m_mapSkill.TryGetValue(dwTypeID, out newSkill); if (newSkill == null) { newSkill = new CSkill(); newSkill.Init(dwTypeID); m_mapSkill.Add(dwTypeID, newSkill); } return(newSkill); }
public IHttpActionResult AddSkills(CSkill Skill) { try { Skill Sk = new Skill(); Sk.SkillName = Skill.SkillName; skillObj.InsertModel(Sk); skillObj.Save(); if (true) { return(Ok("Skill Insert Successfully")); } } catch (Exception ex) { var error = ex.Message; return(null); } }
private float CalculateBaseDmg(CSceneEntity bBaker, CSkill pSkill) { float fBaseDmg = 1.0f; float fMinWeaponDmg = m_pOwner.GetAttValue(ERoleAttribute.ERA_WeaponDmgMin); float fMaxWeaponDmg = m_pOwner.GetAttValue(ERoleAttribute.ERA_WeaponDmgMax); float fWeaponDmg = UnityEngine.Random.Range(fMinWeaponDmg, fMaxWeaponDmg); int nSkillDmg = 0; nSkillDmg = pSkill.GetDmg(); if (pSkill.GetDmgType() == ESkillDmgType.ESDGT_Physical) { if (nSkillDmg > 100000) { fBaseDmg = fWeaponDmg * ((float)(nSkillDmg - 100000) / 100000.0f); } else { fBaseDmg = fWeaponDmg + nSkillDmg; } fBaseDmg = fBaseDmg * (1.0f + (float)m_pOwner.GetAttValue(ERoleAttribute.ERA_ExAttack) / 100.0f); } if (pSkill.GetDmgType() == ESkillDmgType.ESDGT_Energy) { if (nSkillDmg > 100000) { fBaseDmg = fWeaponDmg * ((float)(nSkillDmg - 100000) / 100000.0f); } else { fBaseDmg = fWeaponDmg + nSkillDmg; } fBaseDmg = fBaseDmg * (1.0f + (float)m_pOwner.GetAttValue(ERoleAttribute.ERA_InAttack) / 100.0f); } return(fBaseDmg); }
//-------------------------------------------------------------------------------- // 根据英雄身上的技能,初始化技能快捷栏 //-------------------------------------------------------------------------------- private void InitSkillShortcut() { if (m_Hero == null) { return; } int i = 0; foreach (var item in m_Hero.m_mapSkill) { CSkill pEntity = item.Value; if (pEntity == null) { continue; } tagSkillProto pProto = pEntity.GetProto(); if (pProto == null) { continue; } if (pProto.eType == ESkillType.ESUT_Norm) { Transform bg = m_NoralizeAttack.transform.Find("Background"); bg.GetComponent <UISprite>().spriteName = pProto.strIcon; m_dwNormSkillID = pEntity.GetID(); m_map2ID.Add(m_NoralizeAttack, pEntity.GetID()); continue; } else { UnityEngine.GameObject ctrl = m_listSkill[i]; Transform bg = ctrl.transform.Find("Background"); bg.GetComponent <UISprite>().spriteName = pProto.strIcon; m_map2ID.Add(ctrl, pEntity.GetID()); } i++; } }
private bool CalculateBlock(CSceneEntity bBaker, CSkill pSkill) { float fBlock = 20.0f; if (fBlock < 0.0f) { fBlock = 0.0f; } if (fBlock > 1.0f) { fBlock = 1.0f; } float fradom = UnityEngine.Random.Range(0, 100); if (fradom < fBlock * 100) { return(true); } return(false); }
private bool CalculateCritRate(CSceneEntity bBaker, CSkill pSkill) { float fCrit = 2.0f * (m_pOwner.GetAttValue(ERoleAttribute.ERA_Crit_Rate) * m_pOwner.m_nLevel - m_pOwner.GetAttValue(ERoleAttribute.ERA_Technique) * bBaker.m_nLevel) / (m_pOwner.m_nLevel + bBaker.m_nLevel) * 1000.0f; if (fCrit < 0.01f) { fCrit = 0.01f; } else if (fCrit > 0.3f) { fCrit = 0.3f; } float fradom = UnityEngine.Random.Range(0, 100); if (fradom < fCrit * 100) { return(true); } return(false); }
private void CaleSkillCost(CSkill pSkill) { if (pSkill == null) { return; } ESkillCostType eType = pSkill.GetCostType(); if (eType == ESkillCostType.ESCT_HP) { int nHP = pSkill.GetSkillCost(); m_pOwner.ChangeHP(m_pOwner, pSkill, -nHP, false); } if (eType == ESkillCostType.ESCT_MP) { int nMP = pSkill.GetSkillCost(); m_pOwner.ChangeMP(-nMP); } }
public override void Enter(uint dwParam) { uint dwSkillID = dwParam; m_pSkill = m_pOwner.FindSkillByTypeID(dwSkillID); if (m_pSkill == null) { return; } if (m_pSkill.GetProto().eType == ESkillType.ESUT_Norm) { m_step = EStep.EStep_NorAttack; m_norAttack.Enter(m_pSkill); } else { m_step = EStep.EStep_Attack; m_actAttack.Enter(m_pSkill); } }
private bool CalculateHit(CSceneEntity bBaker, CSkill pSkill) { float fHit = 0.0f; fHit = 0.9f * (1.0f - (float)(bBaker.GetAttValue(ERoleAttribute.ERA_Dodge) - m_pOwner.GetAttValue(ERoleAttribute.ERA_HitRate))) / 10000.0f; if (fHit < 0.0f) { fHit = 0.0f; } if (fHit > 1.0f) { fHit = 1.0f; } float fradom = UnityEngine.Random.Range(0, 100); if (fradom < fHit * 100) { return(true); } return(false); }
//--------------------------------------------------------------------------------- // 游戏物体 HP 改变 //--------------------------------------------------------------------------------- public void ChangeHP(CSceneEntity pSrc, CSkill pSkill, int nValue, bool bCrit) { if (0 == nValue) { return; } ModAttValue(ERoleAttribute.ERA_HP, nValue); // 如果是见血事件 if (nValue < 0) { if (GetAttValue(ERoleAttribute.ERA_HP) <= 0) { SetAttValue(ERoleAttribute.ERA_HP, 0, false); OnDead(pSrc, pSkill); } ShowHPEffect(-nValue); } OnAttChangeEvent(); }
public void LoadMySkills(XHERO hero) { try { if (conn.State == ConnectionState.Open) { MySqlCommand cmd = new MySqlCommand(); cmd.Connection = conn; cmd.CommandText = "select * from u_heroskill WHERE heroIndex = @id and heroSocketNum = @order;"; cmd.Parameters.AddWithValue("@id", hero.zs_data.ID_IDX); cmd.Parameters.AddWithValue("@order", hero.zs_data.HERO_ORDER); MySqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { CSkill skill = new CSkill(hero); skill.skillID = reader.GetByte(2); skill.skillLevel = reader.GetByte(3); skill.skillPoint = reader.GetUInt16(4); skill.learningDate = reader.GetDateTime(5); hero.AddSkill(skill); Console.WriteLine("skill adicionada!"); } } else { reader.Close(); } reader.Close(); } } catch { } }
public override void OnBeAttacked(CSceneEntity pSrc, CSkill pSkill, bool bHited, bool bBlock, bool bCrited) { }
public bool LoadFromFile(string file) { LuaState ls = new LuaState(); TextAsset luaContent = (TextAsset)Resources.Load(file); if (luaContent == null) { Debug.LogError("LifeObj Init Error. Failed to Load File. File:" + file); return(false); } ls.DoString(luaContent.text); m_path = file; LuaTable role = (LuaTable)ls["Role"]; if (role == null) { Debug.LogError("LifeObj Init Error. Can not find LifeObj Info in lua. File:" + m_path); return(false); } if (role["Name"] == null || role["Name"].GetType().ToString() != "System.String") { Debug.LogError("LifeObj Init Error. Can not find name in LifeObj Info. File:" + m_path); return(false); } string name = (string)role["Name"]; m_szName = name; if (role["HP"] == null || role["HP"].GetType().ToString() != "System.Double") { Debug.LogError("LifeObj Init Error. Can not find HP in LifeObj Info. File:" + m_path); return(false); } int HPMax = Convert.ToInt32((double)role["HP"]); m_nHPMax = HPMax; if (role["SP"] == null || role["SP"].GetType().ToString() != "System.Double") { Debug.LogError("LifeObj Init Error. Can not find SP in LifeObj Info. File:" + m_path); return(false); } int SPMax = Convert.ToInt32((double)role["SP"]); m_nSPMax = SPMax; if (role["SPSpeed"] == null || role["SPSpeed"].GetType().ToString() != "System.Double") { Debug.LogError("LifeObj Init Error. Can not find SPSpeed in LifeObj Info. File:" + m_path); return(false); } double SPSpeed = (double)role["SPSpeed"]; m_fSPSpeed = (float)SPSpeed; if (role["Defense"] == null || role["Defense"].GetType().ToString() != "System.Double") { Debug.LogError("LifeObj Init Error. Can not find defense in LifeObj Info. File:" + m_path); return(false); } int defense = Convert.ToInt32((double)role["Defense"]); m_nDefense = defense; LuaTable CDTimers = (LuaTable)role["CDTimers"]; if (CDTimers == null || CDTimers.Values.Count == 0) { Debug.LogError("LifeObj Init Error. Can not find CDTimers in LifeObj Info. File:" + m_path); return(false); } int nTimerCnt = CDTimers.Values.Count; for (int i = 0; i < nTimerCnt; i++) { LuaTable timerInfo = (LuaTable)CDTimers[i + 1]; if (timerInfo == null || timerInfo.Values.Count != 2 || timerInfo["id"] == null || timerInfo["id"].GetType().ToString() != "System.Double" || timerInfo["CD"] == null || timerInfo["CD"].GetType().ToString() != "System.Double") { Debug.LogError("LifeObj Init Error. TimerInfo[" + i + "] is invalid. File:" + m_path); return(false); } int id = Convert.ToInt32((double)timerInfo["id"]); double CD = (double)timerInfo["CD"]; if (id == 0) { Debug.LogError("LifeObj Init Error. Group ID of TimerInfo[" + i + "] is invalid. File:" + m_path); return(false); } CDTimer timer = new CDTimer(id, (float)CD); m_CDTimer.Add(id, timer); } LuaTable SkillsTable = (LuaTable)role["Skill"]; if (SkillsTable == null || SkillsTable.Values.Count == 0) { Debug.LogError("LifeObj Init Error. Can not find Skill in LifeObj Info. File:" + m_path); return(false); } int nSkillCnt = SkillsTable.Values.Count; m_SkillList = new CSkill[nSkillCnt]; for (int i = 0; i < nSkillCnt; i++) { LuaTable SkillTable = (LuaTable)SkillsTable[i + 1]; if (SkillTable == null) { Debug.LogError("Skill Info is null. Index:" + (i + 1) + ", File:" + m_path); return(false); } m_SkillList[i] = new CSkill(this); if (m_SkillList[i].LoadFromLua(SkillTable) == false) { Debug.LogError("Skill Info is invalid. Index:" + (i + 1) + ", File:" + m_path); return(false); } } return(true); }
//--------------------------------------------------------------------------------- // 怪物死亡 //--------------------------------------------------------------------------------- public virtual void OnDead(CSceneEntity pKiller, CSkill pSkill) { }