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>
        /// 1、人物控制器更新
        /// 2、里面控制这人物状态机的更新
        /// 3、摇杆更新
        /// </summary>
        /// <param name="delta"></param>
        public void OnUpdate(float delta)
        {
            if (fightFSM != null)
            {
                fightFSM.Update();
                if (Death)
                {
                    //怪物死亡之后,三秒钟销毁怪物
                    deathTimer += delta;
                    if (deathTimer >= 15f)
                    {
                        (battleField as BattleField).Cmd_Char_Death(idCare);
                        fightFSM  = null;
                        aniplayer = null;
                        graphchar = null;
                        logicchar = null;
                    }
                    return;
                }
            }
            else
            {
                return;  //死亡了直接return;
            }

            if (iLife > -1)
            {
                iLife--;
                if (iLife == -1)
                {
                    Death = true;
                }
            }
            timer += Time.deltaTime;
            if (hitcount > lastcount)
            {
                lastcount = hitcount;
                timer     = 0;
            }
            if (timer > intervaltime)
            {
                hitcount = lastcount = 0;
            }
            var ap = (battleField as BattleField).GetRealChar(idCare);

            if (ap == null)
            {
                return;
            }
            var cc = ap.transform.GetComponent <FB.FFSM.com_FightFSM>();

            cc.Hp = this.logicchar.GetParam("hp");
            //更新方向
            if (attackDir != aniplayer.dir)
            {
                attackDir = aniplayer.dir;
            }
            if (cc.Hp <= 0)
            {
                if (fightFSM.isCanDeath)
                {
                    Death = true;
                }
                else
                {
                    Debug.Log("该状态下不能死亡!");
                }
            }
            if (joy != null)
            {
                joy.SetCharDir(aniplayer.chardir);
                joy.Update();
            }
        }