override public void _Do( cUnitData Atker , cUnitData Defer , ref List<cHitResult> list ){ if (Atker != null) { // ( int nBuffID , int nCastIdent , int nSkillID , int nTargetId ) //pData.Buffs.AddBuff( res.Value1 , res.Value2, res.SkillID, res.Value3 ); list.Add( new cHitResult( cHitResult._TYPE._ADDBUFF , Atker.n_Ident , nTarBuffID , Atker.n_Ident, nSkillID ,Defer.n_Ident ) ); } }
void OnEnable() { pUnitData = GameDataManager.Instance.GetUnitDateByIdent( nCharIdent ); if (pUnitData == null) { OnCloseClick( this.gameObject ); return ; } int nCharId = pUnitData.n_CharID; //CHARS chars = data.cCharData; // change face UITexture tex = FaceObj.GetComponent<UITexture>(); if (tex != null) { string url = "Art/char/" + pUnitData.cCharData.s_FILENAME + "_L"; //Texture2D tex = Resources.LoadAssetAtPath(url, typeof(Texture2D)) as Texture2D; Texture t = Resources.Load(url, typeof(Texture)) as Texture; tex.mainTexture = t; } // name MyTool.SetLabelText( NameObj , pUnitData.cCharData.s_NAME ); ReloadData(); }
public bool Check( cUnitData data_I , cUnitData data_E , int nSkillID , int nBuffID ){ if (CondLst == null) return false; foreach( List<cTextFunc> funcList in CondLst ) { if(CheckCond( data_I ,data_E ,funcList ,nSkillID,nBuffID ) == true ){ return true; // any one passed. all passed } } return false; }
cUnitData Owner; // owner public cBuffs( cUnitData unit ){ Pool = new Dictionary< int , cBuffData > (); RemoveList = new List< int >(); Owner = unit; }
public void DelUnit( cUnitData unit ) { if( unit != null ) UnitPool.Remove( unit.n_Ident ); }
public void DoCastEffect( cUnitData atker , cUnitData defer , ref List<cHitResult> pool ){ AttrEffect ( atker , defer , CastPool ,CastCond , CastCondEffectPool ); DoEffect ( atker , defer , CastPool , CastCond , CastCondEffectPool , ref pool ); }
override public void _Attr( cUnitData Atker , cUnitData Defer, ref cAttrData attr ){ if ((Atker != null) && ( Defer != null)) { float fDelt = Defer.GetBaseMar() - Atker.GetBaseMar(); fDelt *=fValue; // this is final attr.f_MAR += fDelt; } }
override public void _Do( cUnitData Atker , cUnitData Defer , ref List<cHitResult> list ){ if (Defer != null) { // list.Add( new cHitResult( cHitResult._TYPE._ADDBUFF ,Defer.n_Ident , nBuffID ) ); list.Add( new cHitResult( cHitResult._TYPE._ADDBUFF , Defer.n_Ident , nTarBuffID, Atker.n_Ident, nSkillID ,Defer.n_Ident ) ); } }
override public void _Attr( cUnitData Atker , cUnitData Defer, ref cAttrData attr ){ if ((Atker != null)) { attr.n_SP += iValue; } }
override public void _Attr( cUnitData Atker , cUnitData Defer, ref cAttrData attr ){ if ((Atker != null) && ( Defer != null)) { float fDelt = Defer.GetBaseAttack() - Atker.GetBaseAttack(); fDelt *=fValue; // this is final attr.n_ATK += (int)fDelt; } }
// public void SetData( cUnitData data , _SKILL_TYPE eType ) { if ( eType != _SKILL_TYPE._SKILL && eType != _SKILL_TYPE._ABILITY ) { return ; // don't change data } ClearData (); eSkillType = eType; // nOpIdent = data.n_Ident; nOpCharID = data.n_CharID; pData = data; DataTable pTable = ConstDataManager.Instance.GetTable < SKILL > (); if (pTable == null) return; List< SKILL > sklLst = new List< SKILL > (); if (eType == _SKILL_TYPE._SKILL) { foreach( KeyValuePair< int , cSkillData > pair in pData.SkillPool ){ SKILL skl = pair.Value.skill; if( skl.n_SCHOOL == 0 ) // == 0 is ability continue; if( skl.n_PASSIVE == 1 ) continue; sklLst.Add( skl ); } // int ISch = pData.nActSch [0]; // int ESch = pData.nActSch [1]; // int ELv = pData.GetSchoolLv (ESch); // // foreach( SKILL skl in pTable ) // { // if( skl.n_SCHOOL == 0 ) // == 0 is ability // continue; // // if( skl.n_PASSIVE == 1 ) // continue; // // // normal // if( skl.n_SCHOOL != ESch ) // continue; // // // cheat code for god // if( Config.GOD ){ // sklLst.Add( skl ); // continue; // } // // if( skl.n_LEVEL_LEARN > ELv ) // continue; // // sklLst.Add( skl ); // } } else if (eType == _SKILL_TYPE._ABILITY ) { int CLv = pData.n_Lv; foreach( KeyValuePair< int , int > pair in pData.AbilityPool ) { SKILL skl = ConstDataManager.Instance.GetRow< SKILL >( pair.Key ) ; if( skl == null ) continue; if( skl.n_SCHOOL > 0 ) // > 0 is school continue; if( skl.n_PASSIVE == 1 ) continue; if( Config.GOD ){ sklLst.Add( skl ); continue; } if( CLv < pair.Value ) continue; sklLst.Add( skl ); } // foreach( SKILL skl in pTable ) // { // if( skl.n_SCHOOL > 0 ) // > 0 is school // continue; // if( skl.n_PASSIVE == 1 ) // continue; // // if( Config.GOD ){ // sklLst.Add( skl ); // continue; // } // // check char have this ability // // if( pData.AbilityPool.ContainsKey( skl.n_ID ) == false ){ // continue; // } // // if( skl.n_LEVEL_LEARN > CLv ) // continue; // // sklLst.Add( skl ); // } } // Create UI item foreach( SKILL skl in sklLst ) { // add this skill GameObject go = ResourcesManager.CreatePrefabGameObj( SkillGrid , "Prefab/Item_Skill" ); if( go == null ) continue; Item_Skill item = go.GetComponent<Item_Skill> (); item.SetItemData( MyTool.GetSkillName( skl.n_ID ) , skl.n_RANGE , skl.n_MP ); item.SetScrollView( ScrollView ); // UIEventListener.Get(go).onClick += OnSkillClick; // for trig next line UIEventListener.Get(go).onPress += OnSkillPress; // sklPool.Add( go , skl ); } // default to 1 st skill SetSkill (null); //foreach (KeyValuePair<GameObject , SKILL> pair in sklPool) { // SetSkill( pair.Value ); // set to first // break; //} // for grid re pos UIGrid grid = SkillGrid.GetComponent<UIGrid>(); grid.repositionNow = true; // need this for second pop to re pos //CastNote.SetActive( false ); }
//------------------ // Stage Run //----------------- public void ParserScript( CTextLine line ,cUnitData data_I=null , cUnitData data_E=null ) { List<cTextFunc> funcList =line.GetFuncList(); foreach( cTextFunc func in funcList ) { if( func.sFunc == "POPCHAR" ) { StagePopUnitEvent evt = new StagePopUnitEvent (); evt.eCamp = _CAMP._PLAYER; evt.nCharID = func.I( 0 ); evt.nX = func.I( 1 ); evt.nY = func.I( 2 ); evt.nValue1 = func.I( 3 ); // pop num GameEventManager.DispatchEvent ( evt ); } else if( func.sFunc == "POPMOB" ) { StagePopUnitEvent evt = new StagePopUnitEvent (); evt.eCamp = _CAMP._ENEMY; evt.nCharID = func.I( 0 ); evt.nX = func.I( 1 ); evt.nY = func.I( 2 ); evt.nValue1 = func.I( 3 ); // pop num //test code GameEventManager.DispatchEvent ( evt ); } else if( func.sFunc == "POP" ) { StagePopUnitEvent evt = new StagePopUnitEvent (); evt.eCamp = (_CAMP)func.I( 0 ); evt.nCharID = func.I( 1 ); evt.nX = func.I( 2 ); evt.nY = func.I( 3 ); evt.nValue1 = func.I( 4 ); // pop num GameEventManager.DispatchEvent ( evt ); } else if( func.sFunc == "POPGROUP" ) { StagePopGroupEvent evt = new StagePopGroupEvent (); //evt.eCamp = (_CAMP)func.I( 0 ); evt.nLeaderCharID = func.I( 0 ); evt.nCharID = func.I( 1 ); evt.stX = func.I( 2 ); evt.stY = func.I( 3 ); evt.edX = func.I( 4 ); evt.edY = func.I( 5 ); evt.nPopType = func.I( 6 ); // pop num GameEventManager.DispatchEvent ( evt ); } else if( func.sFunc == "TALK" ) // open talkui { #if UNITY_EDITOR // return ; #endif int nID = func.I( 0 ); GameSystem.TalkEvent( nID ); } else if( func.sFunc == "BGM" ) { int nID = func.I( 0 ); // change bgm GameSystem.PlayBGM ( nID ); } else if( func.sFunc == "SAY" ) { TalkSayEvent evt = new TalkSayEvent(); //evt.nType = func.I(0); evt.nChar = func.I(0); evt.nSayID = func.I(1); //Say( func.I(0), func.I(1) ); GameEventManager.DispatchEvent ( evt ); } else if( func.sFunc == "SETCHAR" ) { TalkSetCharEvent evt = new TalkSetCharEvent(); evt.nType = func.I(0); evt.nChar = func.I(1); //Say( func.I(0), func.I(1) ); GameEventManager.DispatchEvent ( evt ); } else if( func.sFunc == "CHANGEBACK") { } else if( func.sFunc == "SAYEND") { TalkSayEndEvent evt = new TalkSayEndEvent(); //evt.nType = func.I(0); evt.nChar = func.I(0); GameEventManager.DispatchEvent ( evt ); // CloseBox( func.I(0), func.I(1) ); } // stage event else if( func.sFunc == "STAGEBGM") { GameEventManager.DispatchEvent ( new StageBGMEvent() ); } else if( func.sFunc == "ATTACK") // pop a group of mob { StageBattleAttackEvent evt = new StageBattleAttackEvent(); evt.nAtkCharID = func.I(0); evt.nDefCharID = func.I(1); evt.nAtkSkillID = func.I(2); GameEventManager.DispatchEvent ( evt ); } else if( func.sFunc == "MOVETOUNIT") // pop a group of mob { StageMoveToUnitEvent evt = new StageMoveToUnitEvent(); evt.nAtkCharID = func.I(0); evt.nDefCharID = func.I(1); //evt.nAtkSkillID = func.I(2); GameEventManager.DispatchEvent ( evt ); } else if( func.sFunc == "DELUNIT") { StageDelUnitEvent evt = new StageDelUnitEvent (); //evt.eCamp = (_CAMP)func.I( 0 ); evt.nCharID = func.I( 0 ); GameEventManager.DispatchEvent ( evt ); } else if( func.sFunc == "WIN") { PanelManager.Instance.OpenUI( Panel_Win.Name ); //Panel_StageUI.Instance.bIsStageEnd = true; } else if( func.sFunc == "LOST") { PanelManager.Instance.OpenUI( Panel_Lost.Name ); //Panel_StageUI.Instance.bIsStageEnd = true; } else { Debug.LogError( string.Format( "Error-Can't find script func '{0}'" , func.sFunc ) ); } } }
public void GetAffectPool( cUnitData Atker , int nDefer , int SkillID , int nTarX , int nTarY , ref List< cUnitData> pool ) { // don't push defer to affect pool SKILL skl = ConstDataManager.Instance.GetRow< SKILL > ( SkillID ); if (skl == null) { return; } if (skl.n_AREA == 0) return; List < iVec2 > lst = MyTool.GetAOEPool ( nTarX ,nTarY,skl.n_AREA ,Atker.n_X , Atker.n_Y ); if( pool == null ){ pool = new List< cUnitData > (); } // 0→對自己施展 // 1→需要敵方目標 // 2→需要友方目標 // 3→MAP敵方 // 4→MAP我方 // 5-MAP-all bool bCanPK = false; bool bAll = false; if ((skl.n_TARGET == 1) || (skl.n_TARGET == 3)) { bCanPK = true; } else if( skl.n_TARGET == 5 ){ bAll = true; } // check if have affect foreach (iVec2 v in lst) { cUnitData pUnit = GameDataManager.Instance.GetUnitDateByPos( v.X , v.Y ); if( pUnit != null ){ // defer don't add . he have a spec process if( pUnit.n_Ident == nDefer ) continue; if( bAll == true ){ // all is no need check pool.Add( pUnit ); continue; } if( CanPK( Atker.eCampID , pUnit.eCampID ) == bCanPK ){ pool.Add( pUnit ); } } } }
// cal result of castout hit public List<cHitResult> CalSkillHitResult( cUnitData pAtker , cUnitData pDefer , int nSkillID ) { //cUnitData pAtker = GameDataManager.Instance.GetUnitDateByIdent( nAtker ); //Panel_StageUI.Instance.GetUnitByIdent( nAtker ); if ( (pAtker == null) || (pDefer == null) ) return null; List<cHitResult> resPool = new List<cHitResult> (); //resPool.Add ( new cHitResult( cHitResult._TYPE._HIT ,pAtker ) ); // not a really hit // SKILL Skill = pAtker.FightAttr.SkillData.skill; // if (Skill.n_TARGET == 0 ) { // self cast a buff // hit result // MyTool.DoSkillEffect( pAtker , pAtker.FightAttr.HitPool , Skill.s_CAST_TRIG , pAtker.FightAttr.HitEffPool , ref resPool ); pAtker.DoHitEffect(pDefer , ref resPool ); if (pDefer != null) { pDefer.DoBeHitEffect( pAtker , ref resPool ); } // MyScript.Instance.RunSkillEffect ( pAtker , null , pAtker.FightAttr.Skill.s_HIT_EFFECT , ref resPool ); // bad frame work //} return resPool; }
public void CalDropResult( cUnitData Atker , cUnitData Defer , ref int nExp , ref int nMoney ) { if( Atker == null ) return ; int exp = 1; // base exp int money = 0; if( Defer != null ){ int nDiffLv = Defer.n_Lv-Atker.n_Lv; if( nDiffLv > 3 ){ exp +=3; } else if( nDiffLv > -3 ){ exp +=1; } // // kill if( Defer.IsStates( _UNITSTATE._DEAD ) ){ exp = (exp*4)+20; money = 1000; // check drop item if( Defer.cCharData.n_ITEM_DROP > 0 ){ nDropItemPool.Add( Defer.cCharData.n_ITEM_DROP ); } } } nExp += exp ; nMoney += money; }
public virtual void _Hit( cUnitData Atker , cUnitData Defer , ref List<cHitResult> list ){ } // BUFF 專用.命中後 額外效果 public virtual void _BeHit( cUnitData Atker , cUnitData Defer , ref List<cHitResult> list ){ } // BUFF 專用.受擊後 額外效果
override public void _Attr( cUnitData Atker , cUnitData Defer, ref cAttrData attr ){ attr.n_MOV += nValue; }
override public void _Attr( cUnitData Atker , cUnitData Defer, ref cAttrData attr ){ attr.fMpCostRate += fValue; }
override public void _Attr( cUnitData Atker , cUnitData Defer, ref cAttrData attr ){ attr.f_MAR += fValue; }
private bool CheckCond( cUnitData data_I , cUnitData data_E , List<cTextFunc> funcList, int nSkillID, int nBuffID ) { if (funcList == null) return false; foreach( cTextFunc func in funcList ) { if( func.sFunc == "GO" ) { return true; // always true } else if( func.sFunc == "NULL" || func.sFunc == "0" ) { return false; // always fail } if( func.sFunc == "HP_I" ) { return false; // always fail } else if( func.sFunc == "HP_E" ) { return false; // always fail } else if( func.sFunc == "MAR_I" ) { float f1 = data_I.GetMar(); float f2 = 0.0f; if( func.S( 1 ) == "E" ) { if( data_E != null ){ f2 = data_E.GetMar(); }else{ return false; // no enemy is false } } else{ f2 = func.F( 1 ); } if( MyScript.Instance.ConditionFloat( f1 , func.S(0) ,f2 ) == false ){ return false; // always fail } } else if( func.sFunc == "MAR_E" ) { return false; // always fail } else if( func.sFunc == "BUFF_I" ) { return false; // always fail } else if( func.sFunc == "BUFF_E" ) { return false; // always fail } else if( func.sFunc == "SCHOOL_I" ) { return false; } else if( func.sFunc == "SCHOOL_E" ) { return false; } else if( func.sFunc == "SKILL_I" ) { return false; } else if( func.sFunc == "SKILL_E" ) { return false; } else if( func.sFunc == "RANGE_E" ) { return false; } // Fight stat check else if( func.sFunc == "FST_ATKER" ) { return data_I.IsStates( _UNITSTATE._ATKER ); } else if( func.sFunc == "FST_DEFER" ) { return data_I.IsStates( _UNITSTATE._ATKER )==false; } else if( func.sFunc == "FST_DAMAGE" ) { return data_I.IsStates( _UNITSTATE._DAMAGE ); } else if( func.sFunc == "FST_KILL" ) { return data_I.IsStates( _UNITSTATE._KILL ); } else if( func.sFunc == "FST_DEAD" ) { return data_I.IsStates( _UNITSTATE._DEAD ); } else if( func.sFunc == "FST_DODGE" ) { return data_I.IsStates( _UNITSTATE._DODGE ); } else{ Debug.LogError( string.Format( "Error-Can't find script cond func '{0}'" , func.sFunc ) ); } } return true; }
public void AttrEffect( cUnitData atker , cUnitData defer , List< cEffect > effPool , cEffectCondition EffCond, List< cEffect > CondEffPool ) { if (atker == null || effPool == null ) return; cAttrData attr = atker.FightAttr; //cUnitData defer = GameDataManager.Instance.GetUnitDateByIdent ( atker.FightAttr.TarIdent ); // normal eff foreach( cEffect eft in effPool ) { eft._Attr(atker , defer , ref attr ) ; } if ( EffCond == null || CondEffPool == null) return; //cond eff //if (MyScript.Instance.CheckSkillCond (strCond, atker, defer) == true) if( EffCond.Check( atker , defer , nID, 0 ) == true ) { foreach( cEffect eft in CondEffPool ) { eft._Attr(atker , defer ,ref attr ) ; } } }
public virtual void _Attr( cUnitData Atker , cUnitData Defer, ref cAttrData attr ){ }
public void CreateChar( int nCharID , int x , int y ) { CharID = nCharID; pUnitData = GameDataManager.Instance.CreateChar( nCharID ); if( pUnitData == null ) return; SetXY( x , y ); CHARS charData = ConstDataManager.Instance.GetRow<CHARS>( nCharID ); if( charData == null) return; // change face string url = "Art/char/" + charData.s_FILENAME +"_S"; UITexture face = FaceObj.GetComponent<UITexture>(); if( face != null ) { face.mainTexture = Resources.Load <Texture>( url ) ; } }
// SKill public virtual void _Do( cUnitData Atker , cUnitData Defer , ref List<cHitResult> list ){ } // casr/ hit event will run this
public Dictionary< int , cUnitData > UnitPool; // add event id public cUnitData CreateChar( int nCharID ) { cUnitData unit = new cUnitData(); unit.n_Ident = GenerSerialNO( ); unit.n_CharID = nCharID; CHARS cdata = ConstDataManager.Instance.GetRow< CHARS > (nCharID); if (cdata == null) { Debug.LogErrorFormat( "CreateChar with null data {0}" , nCharID ); } unit.SetContData( cdata ); UnitPool.Add( unit.n_Ident , unit ); return unit; }
public virtual void _Do( cUnitData Atker , cUnitData Defer , ref List<cHitResult> list ){ } // casr/ hit event will run this public virtual void _Cast( cUnitData Atker , cUnitData Defer , ref List<cHitResult> list){ } // hit a target
public void DoBeHitEffect( cUnitData tarunit , ref List< cHitResult > resPool ) { if (FightAttr.SkillData != null) { FightAttr.SkillData.DoHitEffect (this, tarunit, ref resPool); } Buffs.OnBeHit (tarunit, ref resPool); // MyTool.DoSkillEffect ( this , tarunit , FightAttr.SkillData.HitPool , FightAttr.SkillData.HitCond , FightAttr.SkillData.CastCondEffectPool , ref resPool ); // if (FightAttr.Skill == null) // return; // // MyTool.DoSkillEffect ( this , FightAttr.HitPool , FightAttr.Skill.s_HIT_TRIG , FightAttr.HitEffPool , ref resPool ); }
public void OnBeHit( cUnitData unit_e , ref List< cHitResult > resPool ) { if (Pool.Count == 0) return; // normal hit foreach( KeyValuePair< int , cBuffData > pair in Pool ) { // normal foreach( cEffect eft in pair.Value.EffectPool ) { if( eft != null ) { eft._BeHit( Owner , unit_e , ref resPool ); } } // condition cUnitData unit = null ; if( pair.Value.nTargetIdent > 0 ){ unit = GameDataManager.Instance.GetUnitDateByIdent ( pair.Value.nTargetIdent ); } else { unit = unit_e; } if( pair.Value.Condition.Check( Owner , unit , pair.Value.nSkillID , pair.Value.nID ) ) { foreach( cEffect eft in pair.Value.ConditionEffectPool ) { if( eft != null ) { eft._BeHit( Owner , unit , ref resPool ); } } } } }