Ejemplo n.º 1
0
        public void OnInit(IBattleField battleField)
        {
            this.battleField = battleField as BattleField;
            FB.FFSM.GraphChar_Driver ap = (battleField as BattleField).GetRealChar(idCare);
            var cc = ap.transform.GetComponent <FB.FFSM.com_FightFSM>();

            logicchar = new LogicChar_Driver(battleField, idCare);
            foreach (var p in cc.defaultParam)
            {
                //Debug.LogError("p.name= " + p.name);
                //Debug.LogError("p.value= " + p.value);
                logicchar.SetParam(p.name, p.value);
            }
            graphchar = new GraphChar_Sender(battleField, idCare);
            //Charactor 脱离低级趣味
            aniplayer = ap.transform.GetComponent <FB.PosePlus.AniPlayer>();

            //fps = aniplayer.clips[0].fps;
            fightFSM = new FFSM.FightFSM(this.graphchar, this.logicchar, cc.stateTable, cc.aiStateTable, cc.stateTree, joy);

            if (joy is Input_AI)
            {
                (joy as Input_AI).Init(battleField, this, AiLevel);
            }
        }
Ejemplo n.º 2
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;
                    }
                }
            }
        }