예제 #1
0
        public void OnFight_Hit(int id, int to, FightEffectPiece piece)
        {
            /*  Debug.Log(id + "打了" + to);*/

            attackid = to;
            if (piece.beHurtState != null)
            {
                fightFSM.hitcount++;
            }

            hitcount++;

            if (piece.hold)//抓技能
            {
                if (logicchar.idHold < 0)
                {
                    logicchar.Hold(to);
                }
            }
        }
예제 #2
0
        public void OnFight_Parry(int id, int from, FightEffectPiece piece, float posx)
        {
            Debug.Log(id + "被" + from + "打了,但是触发了格挡");
            //攻击功能
            //攻击效果
            bool left      = (posx < GetTransform().position.x); //打我的人在我左边还是右边
            int  firedir   = left ? -1 : 1;
            int  mydir     = this.aniplayer.dir;
            bool bFaceToMe = (left && mydir == -1) || (!left && mydir == 1);

            if (piece.beHurtState == null)
            {
                return;
            }
            foreach (var e in piece.beHurtState.effects)
            {
                string fire  = e.parryfire;
                string sound = e.parrysound;

                if (e.facetome == bFaceToMe)
                {
                    //播放特效
                    if (!string.IsNullOrEmpty(fire) && fire != "")
                    {
                        if (battleField.world.extplayer != null)
                        {
                            battleField.world.extplayer.PlayEffect(fire, piece.firepos, firedir);
                        }
                    }
                    //播放音效
                    if (!string.IsNullOrEmpty(sound) && sound != "")
                    {
                        if (battleField.world.extplayer != null)
                        {
                            battleField.world.extplayer.PlaySoundOnce(sound);
                        }
                    }
                    break;
                }
            }
        }
예제 #3
0
        public bool AddHit(int id, int hash, int hitcount, string prop, int add, BeHurtStateTable attackeffect, Vector3 firepos, bool hold, bool hurtfriend)
        {
            //int hashi = FightEffectPiece.CalcHash(PieceType.Hit, prop, add);
            var eff = (id == AID) ? AEffect : BEffect;

            if (eff.ContainsKey(hash)) //效果不能重复添加
            {
                return(false);
            }
            if (bUsed)
            {
                //if (!eff.ContainsKey(hashi))//用过了,新的效果,clear重来。
                Clear();
            }

            eff[hash] = new FightEffectPiece(PieceType.Hit, hitcount, prop, add, attackeffect, firepos, hold, hurtfriend);
            //Debug.Log("AddHitEffect:" + hitcount + "," + prop + "," + add + "," + enemytostate);
            bInited = true;

            //use 才计算happy
            //happy = id;

            return(false);
        }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id">被击者</param>
        /// <param name="from">攻击者</param>
        /// <param name="piece">攻击效果</param>
        /// <param name="_attackdir">攻击者方向</param>
        public void OnFight_BeHit(int id, int from, FightEffectPiece piece, float posx)
        {
            //UGUIFlyHp.Instance().init(UGUIFlyHp.FlyEffect.DecHp, "- 15", GetTransform().position, id);
            /* Debug.Log(id + "被" + from + "打了");*/
            Debug.Log("idhold:" + fightFSM.charLogic.idHold);
            //判断是否处于抓技
            if (fightFSM.charLogic.idHold != -1)
            {
                var tc = battleField.GetCharactorController(fightFSM.charLogic.idHold) as CharController_Direct;
                if (tc != null)
                {
                    tc.fightFSM.ChangeBlock("stand", 0);
                }
                //中断抓技
                Debug.Log("中断抓技");
                fightFSM.FE_LetGo();
            }
            //攻击功能
            /*   Debug.Log("prop=" + piece.prop.ToLower() + "=" + piece.add);*/
            int v = logicchar.GetParam(piece.prop.ToLower());

            //BattleMainLogic test = new BattleMainLogic();
            ////这个id是英雄
            //if(test.GetCurHeroIndex==id
            v += piece.add;
            logicchar.SetParam(piece.prop.ToLower(), v);
            //攻击效果
            if (piece.beHurtState == null)
            {
                return;
            }


            bool left = (posx < GetTransform().position.x); //打我的人在我左边还是右边

            int firedir = left ? 1 : -1;
            int mydir   = this.aniplayer.dir;
            //面对  ,(mydir =-1 && leftorright==1)  ||  (mydir=1 &&  leftorright==-1);
            //or 背对
            bool bFaceToMe = (left && mydir == -1) || (!left && mydir == 1);

            foreach (var e in piece.beHurtState.effects)
            {
                if (e.onstate == "any" || e.onstate == fightFSM.GetCurStateName)//当前状态符合
                {
                    if (e.facetome == bFaceToMe)
                    {
                        //播放暂停
                        aniplayer.PlayPause(e.enemypauseframe);
                        //攻击者暂停
                        (battleField as BattleField).GetRealChar(from).transform.GetComponent <AniPlayer>().PlayPause(e.mypauseframe);
                        //改变状态
                        fightFSM.ChangeBlockDelay(e.enemytostate, 0);
                        string fire  = e.hitfire;
                        string sound = e.hitsound;
                        //播放特效
                        if (!string.IsNullOrEmpty(fire) && fire != "")
                        {
                            if (battleField.world.extplayer != null)
                            {
                                battleField.world.extplayer.PlayEffect(fire, piece.firepos, firedir);
                            }
                        }
                        //播放音效
                        if (!string.IsNullOrEmpty(sound) && sound != "")
                        {
                            if (battleField.world.extplayer != null)
                            {
                                battleField.world.extplayer.PlaySoundOnce(sound);
                            }
                        }
                        break;
                    }
                }
            }
        }
예제 #5
0
        public void Use(IBattleField battleField)
        {
            if (bUsed || !bInited)
            {
                return;
            }
            //Debug.Log("Use FightEvent");
            bUsed = true;
            FightEffectPiece finalA = null;

            foreach (FightEffectPiece eff in AEffect.Values)
            {
                if (eff.type == PieceType.Hit)
                {
                    finalA = eff;
                }
            }
            FightEffectPiece finalB = null;

            foreach (FightEffectPiece eff in BEffect.Values)
            {
                if (eff.type == PieceType.Hit)
                {
                    finalB = eff;
                }
            }
            happy = -1;
            if (finalA != null && finalB != null)
            {//互杀
                var ccB = battleField.GetCharactorController(BID);
                var ccA = battleField.GetCharactorController(AID);

                if (!finalA.hurtfiend)
                {
                    if (ccB.idSide == ccA.idSide)
                    {
                        finalA = null;                          //同阵营不伤害
                    }
                }
                if (!finalB.hurtfiend)
                {
                    if (ccB.idSide == ccA.idSide)
                    {
                        finalB = null;                          //同阵营不伤害
                    }
                }
                if (finalA != null && finalB != null)
                {
                    //互杀
                    ccA.OnFight_Parry(AID, BID, finalB, (ccB as CharController_Direct).GetTransform().position.x);
                    ccB.OnFight_Parry(BID, AID, finalA, (ccA as CharController_Direct).GetTransform().position.x);
                    return;
                }
            }
            if (finalA != null)
            {
                happy = AID;
                //Debug.Log("A 打 B A=" + happy);
                var ccB = battleField.GetCharactorController(BID);
                var ccA = battleField.GetCharactorController(AID);
                if (!finalA.hurtfiend)
                {
                    if (ccB.idSide == ccA.idSide)
                    {
                        return;                          //同阵营不伤害
                    }
                }
                if (BParry)
                {
                    ccB.OnFight_Parry(BID, AID, finalA, (ccA as CharController_Direct).GetTransform().position.x);
                }
                else
                {
                    ccB.OnFight_BeHit(BID, AID, finalA, (ccA as CharController_Direct).GetTransform().position.x);
                    ccA.OnFight_Hit(AID, BID, finalA);
                }
            }
            if (finalB != null)
            {
                happy = BID;
                //Debug.Log("B 打 A B=" + happy);
                var ccB = battleField.GetCharactorController(BID);
                var ccA = battleField.GetCharactorController(AID);

                if (!finalB.hurtfiend)
                {
                    if (ccB.idSide == ccA.idSide)
                    {
                        return;                          //同阵营不伤害
                    }
                }
                if (AParry)
                {
                    ccA.OnFight_Parry(AID, BID, finalB, (ccB as CharController_Direct).GetTransform().position.x);
                }
                else
                {
                    ccA.OnFight_BeHit(AID, BID, finalB, (ccB as CharController_Direct).GetTransform().position.x);
                    ccB.OnFight_Hit(BID, AID, finalB);
                }
            }
        }