Пример #1
0
 /// <summary>
 /// 人物受击
 /// </summary>
 /// <param name="Damage"></param>
 public virtual void ToBeAttacked(float Damage, string from, AttackAdditionalFeatures aaf, Vector3 frompos)
 {
     if (curFSM.CurState.GetStateName() == "Dodge")
     {
         Debug.Log("闪避");
         return;
     }
     else if (curFSM.CurState.GetStateName() == "Block")
     {
         if ((aaf.ftype & 8) > 0)
         {
             BUFFtimer.Add((Logic.time, delegate() {
                 DefenceChange(0.7f);
             }));
             BUFFtimer.Add((Logic.time + 2f, delegate() {
                 DefenceChange(0.7f);
             }));
             ToUseSkill(BEATTACKED);
         }
         else
         {
             Debug.Log("格挡");
             //TODO:特效
             int id = Logic.GetNewID();
             //Move()
             MoveContrast(0.4f);
             View.timer.Add((Logic.time, delegate() {
                 View.CreatePlayerEffect(id, curFSM.CurState.GetState().BlockSEName, name, "zhengqianfang", false);
             }));
             View.timer.Add((Logic.time + curFSM.CurState.GetState().BlockSEDuringTime, delegate() {
                 View.RemovePlayerEffect(id);
             }));
             return;
         }
     }
     else
     {
         //curCreatureData.curHP -= Damage;
         ToUseSkill(BEATTACKED);
         //if(curCreatureData.curHP < 0)
         //    curCreatureData.curHP = 0;
     }
     if ((aaf.ftype & 1) > 0)
     {
         //击退
         dir = GetDir(pos, frompos);
         MoveContrast(aaf.BeakBackDis);
     }
     if ((aaf.ftype & 2) > 0)
     {
         //TODO:击飞
         Debug.Log("击飞!!!!!!");
         ToUseSkill(FLOATING);
     }
     if ((aaf.ftype & 4) > 0)
     {
         //减速
         BUFFtimer.Add((Logic.time, delegate() {
             curCreatureData.Speed *= aaf.CutSpeedRatio > 1?0:(1 - aaf.CutSpeedRatio);
         }));
         BUFFtimer.Add((Logic.time + aaf.CutSpeedDuringTime, delegate() {
             curCreatureData.Speed /= aaf.CutSpeedRatio > 1?0:(1 - aaf.CutSpeedRatio);
         }));
     }
     if ((aaf.ftype & 16) > 0)
     {
         //吸血
         Logic.obinfmp[from].HPRecover(Damage * aaf.SuckBloodFromDamgeRatio);
     }
     if ((aaf.ftype & 32) > 0)
     {
         //减蓝
         Logic.obinfmp[from].MPRecover(-aaf.CutMp);
     }
     if ((aaf.ftype & 64) > 0)
     {
         //TODO:镜头震动
         if (name == Client.name)
         {
             View.timer.Add((Logic.time, delegate() {
                 GameObject.Find("MainCamera").GetComponent <ShakeCamera>().timer = 0;
             }));
         }
     }
     if ((aaf.ftype & 128) > 0)
     {
         //破防
         BUFFtimer.Add((Logic.time, delegate() {
             DefenceChange(aaf.CutDefenceRatio);
         }));
         BUFFtimer.Add((Logic.time, delegate() {
             DefenceChange(-aaf.CutDefenceRatio);
         }));
     }
     if ((aaf.ftype & 256) > 0)
     {
     }
     HPRecover(-(Damage * (1 - (curCreatureData.Defence > 100?1:curCreatureData.Defence / 100f)) + 1));
     IfBeAttacked = true;
     Debug.Log("受击态 转换");
     if (UPv < 0)
     {
         UPv = 4;
     }
     else if (UPv > 0)
     {
         UPv += 2;
     }
     if (curFSM.CurState.GetStateName() != "BeAttacked")
     {
         return;
     }
     timer.Clear();
 }
Пример #2
0
    /// <summary>
    /// 进入该状态需要做的操作
    /// </summary>
    public void OnEnter()
    {
        Debug.Log("master name " + StateMasterName + "   " + "state name " + StateData.StateName + " !!!!!!!!!!!!!!!!!!!");
        timer.Clear();
        //播放动画
        //gameObject.GetComponent<Animator>().CrossFade(StateData.SkillAnimationName,0.1f);

        //状态进入需要让视图层做的操作包成事件交给试图层的事件系统
        //特效绑定动画?
        //每一个状态在view层都有对应的资源管理器?

        //特效:
        //是否绑定在某一GameObject下
        //是否定时销毁
        //是否跟随动画销毁

        //特性:
        //产生点
        //绑定人物对应点
        //随动画停止销毁=逻辑层的状态驱动
        //定时销毁=逻辑层的时间驱动

        foreach (var t in StateData.Floats)
        {
            SkillFloatType e = t;
            timer.Add((Logic.time + e.BeginTime, delegate() {
                var ob = Logic.obinfmp[StateMasterName];
                //Debug.Log("e.UPv " + e.UPv);
                if (ob.UPv <= 0)
                {
                    ob.UPv += e.UPv;
                }
                else
                {
                    ob.UPv += e.UPv * 0.2f;
                }
            }));
        }

        //特效事件的发出
        foreach (var t in StateData.SkillSEList)
        {
            SkillSE e = new SkillSE();
            e = t;
            int curID = Logic.GetNewID();
            //FollowStateDestroySEID.Add(curID);
            //特效生成事件加入View层的timer中
            timer.Add((Logic.time + e.SkillSEBeginTime, delegate() {
                View.timer.Add((Logic.time, delegate() {
                    View.CreatePlayerEffect(curID, e.SEName, StateMasterName, e.SELoadPointName, e.IfFollowLoadPoint);
                }));
                if (e.IfFollowAnimationDestroy)
                {
                    //如果特效随动画销毁,就加入状态的特效控制表中
                    FollowStateDestroySEID.Add(curID);
                }
                else
                {
                    //如果特效随时间销毁,就将销毁事件加入视图层的timer中
                    //Debug.Log("remove event " + curID);
                    View.timer.Add((e.SkillSEDuringTime + Logic.time, delegate() {
                        View.RemovePlayerEffect(curID);
                    }));
                }
            }));
        }

        //将动画播放事件加入View层中的timer中
        View.timer.Add((Logic.time, delegate() {
            /*if(StateData.AnimationName=="W_BeAttacked") {
             *  Debug.Log("BeAttcked!!!!!!!!");
             * }*/
            //View.obmp[StateMasterName].GetComponent<Animator>().CrossFade(StateData.AnimationName,0.1f);
            //View.obmp[StateMasterName].GetComponent<Animator>();
            View.obmp[StateMasterName].GetComponent <Animator>().Play(StateData.AnimationName, 0, 0f);
        }));
        //View.EventHandle += delegate() {
        //    View.obmp[StateMasterName].GetComponent<Animator>().CrossFade(StateData.AnimationName,0.1f);
        //};

        //进入状态的时间更新
        StateEnterTime = Logic.time;
    }