Example #1
0
    static int IsInvoking(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 1)
        {
            FSMBase obj = LuaScriptMgr.GetNetObject <FSMBase>(L, 1);
            bool    o   = obj.IsInvoking();
            LuaScriptMgr.Push(L, o);
            return(1);
        }
        else if (count == 2)
        {
            FSMBase obj  = LuaScriptMgr.GetNetObject <FSMBase>(L, 1);
            string  arg0 = LuaScriptMgr.GetLuaString(L, 2);
            bool    o    = obj.IsInvoking(arg0);
            LuaScriptMgr.Push(L, o);
            return(1);
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: FSMBase.IsInvoking");
        }

        return(0);
    }
Example #2
0
    static int Lua_ToString(IntPtr L)
    {
        FSMBase obj = LuaScriptMgr.GetNetObject <FSMBase>(L, 1);

        LuaScriptMgr.Push(L, obj.ToString());
        return(1);
    }
Example #3
0
    static int GetComponents(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 2)
        {
            FSMBase     obj  = LuaScriptMgr.GetNetObject <FSMBase>(L, 1);
            Type        arg0 = LuaScriptMgr.GetTypeObject(L, 2);
            Component[] o    = obj.GetComponents(arg0);
            LuaScriptMgr.PushArray(L, o);
            return(1);
        }
        else if (count == 3)
        {
            FSMBase          obj  = LuaScriptMgr.GetNetObject <FSMBase>(L, 1);
            Type             arg0 = LuaScriptMgr.GetTypeObject(L, 2);
            List <Component> arg1 = LuaScriptMgr.GetNetObject <List <Component> >(L, 3);
            obj.GetComponents(arg0, arg1);
            return(0);
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: FSMBase.GetComponents");
        }

        return(0);
    }
Example #4
0
 public void UnRegistState(FSMBase _fsmBase)
 {
     if (m_allState.ContainsKey(_fsmBase.state))
     {
         m_allState.Remove(_fsmBase.state);
     }
 }
Example #5
0
 /// <summary>
 /// 绑定
 /// </summary>
 public void BindFsm(FSMState state, FSMBase fsmBase)
 {
     if (!allState.ContainsKey(state))
     {
         allState.Add(state, fsmBase);
     }
 }
Example #6
0
    public override void EnterState(FSMBase fsm)
    {
        base.EnterState(fsm);

        //禁用状态机
        fsm.enabled = false;
    }
Example #7
0
    static int GetComponent(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        Type[] types0 = { typeof(FSMBase), typeof(string) };
        Type[] types1 = { typeof(FSMBase), typeof(Type) };

        if (count == 2 && LuaScriptMgr.CheckTypes(L, types0, 1))
        {
            FSMBase   obj  = LuaScriptMgr.GetNetObject <FSMBase>(L, 1);
            string    arg0 = LuaScriptMgr.GetString(L, 2);
            Component o    = obj.GetComponent(arg0);
            LuaScriptMgr.Push(L, o);
            return(1);
        }
        else if (count == 2 && LuaScriptMgr.CheckTypes(L, types1, 1))
        {
            FSMBase   obj  = LuaScriptMgr.GetNetObject <FSMBase>(L, 1);
            Type      arg0 = LuaScriptMgr.GetTypeObject(L, 2);
            Component o    = obj.GetComponent(arg0);
            LuaScriptMgr.Push(L, o);
            return(1);
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: FSMBase.GetComponent");
        }

        return(0);
    }
Example #8
0
 public void RegistState(FSMBase _fsmBase)
 {
     //没有这个状态就添加
     if (!m_allState.ContainsKey(_fsmBase.state))
     {
         m_allState.Add(_fsmBase.state, _fsmBase);
     }
 }
Example #9
0
    static int StopAllCoroutines(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 1);
        FSMBase obj = LuaScriptMgr.GetNetObject <FSMBase>(L, 1);

        obj.StopAllCoroutines();
        return(0);
    }
Example #10
0
 /// <summary>
 /// 开始运作并进入一个状态
 /// </summary>
 /// <param name="_fsmBase">想要进入的状态</param>
 /// <param name="args">可选参数</param>
 public void Go(FSMBase _fsmBase, params object[] args)
 {
     if (m_curState != null)
     {
         return;
     }
     m_curState = _fsmBase;
     m_curState.OnEnter(args);
 }
Example #11
0
 public override void ActionState(FSMBase fsm)
 {
     base.ActionState(fsm);
     //获取最小值
     Vector3 movement = (fsm.SelectTargetByDistanceMin(fsm.chStatus.scoutDistance).position - fsm.transform.position).normalized;
     //fsm.chMotor.MoveSpeed=followSpeed;
     //Debug.Log(movement);
     //fsm.chMotor.Movement(movement);
 }
    public override void EnterState(FSMBase fsm)
    {
        base.EnterState(fsm);

        fsm.isPatrolComplete = false;

        //播放走路动画
        fsm.anim.SetBool("walk", true);
    }
Example #13
0
 public void AddState(FSMBase tmpBase)
 {
     if (currentState > allState.Length - 1)
     {
         return;
     }
     currentState++;
     allState[currentState] = tmpBase;
 }
Example #14
0
 //添加新动画
 public void AddState(FSMBase tmpBase)
 {
     if (stateCount > allstate.Length)
     {
         return;
     }
     allstate[stateCount] = tmpBase;
     stateCount++;
 }
Example #15
0
    static int GetInstanceID(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 1);
        FSMBase obj = LuaScriptMgr.GetNetObject <FSMBase>(L, 1);
        int     o   = obj.GetInstanceID();

        LuaScriptMgr.Push(L, o);
        return(1);
    }
Example #16
0
    static int GetType(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 1);
        FSMBase obj = LuaScriptMgr.GetNetObject <FSMBase>(L, 1);
        Type    o   = obj.GetType();

        LuaScriptMgr.Push(L, o);
        return(1);
    }
Example #17
0
    static int ToString(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 1);
        FSMBase obj = LuaScriptMgr.GetNetObject <FSMBase>(L, 1);
        string  o   = obj.ToString();

        LuaScriptMgr.Push(L, o);
        return(1);
    }
Example #18
0
    static int GetComponentInParent(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 2);
        FSMBase   obj  = LuaScriptMgr.GetNetObject <FSMBase>(L, 1);
        Type      arg0 = LuaScriptMgr.GetTypeObject(L, 2);
        Component o    = obj.GetComponentInParent(arg0);

        LuaScriptMgr.Push(L, o);
        return(1);
    }
Example #19
0
    static int Equals(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 2);
        FSMBase obj  = LuaScriptMgr.GetNetObject <FSMBase>(L, 1);
        object  arg0 = LuaScriptMgr.GetVarObject(L, 2);
        bool    o    = obj.Equals(arg0);

        LuaScriptMgr.Push(L, o);
        return(1);
    }
Example #20
0
    static int CompareTag(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 2);
        FSMBase obj  = LuaScriptMgr.GetNetObject <FSMBase>(L, 1);
        string  arg0 = LuaScriptMgr.GetLuaString(L, 2);
        bool    o    = obj.CompareTag(arg0);

        LuaScriptMgr.Push(L, o);
        return(1);
    }
Example #21
0
    static int Invoke(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 3);
        FSMBase obj  = LuaScriptMgr.GetNetObject <FSMBase>(L, 1);
        string  arg0 = LuaScriptMgr.GetLuaString(L, 2);
        float   arg1 = (float)LuaScriptMgr.GetNumber(L, 3);

        obj.Invoke(arg0, arg1);
        return(0);
    }
Example #22
0
    static int StartCoroutine_Auto(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 2);
        FSMBase     obj  = LuaScriptMgr.GetNetObject <FSMBase>(L, 1);
        IEnumerator arg0 = LuaScriptMgr.GetNetObject <IEnumerator>(L, 2);
        Coroutine   o    = obj.StartCoroutine_Auto(arg0);

        LuaScriptMgr.PushObject(L, o);
        return(1);
    }
Example #23
0
 /// <summary>
 /// 注册状态
 /// </summary>
 /// <param name="name"></param>
 /// <param name="fsm"></param>
 /// <returns></returns>
 public bool RegisterState(FSMBase fsm)
 {
     if (IsContainState(fsm.Name))
     {
         return(false);
     }
     Fsms.Add(fsm.Name, fsm);
     fsm.ownerMgr = this;
     return(true);
 }
    public override void ActionState(FSMBase fsm)
    {
        base.ActionState(fsm);

        if (atkTime <= Time.time)
        {
            fsm.skillSystem.UseRandomSkill();

            atkTime = Time.time + fsm.chStatus.attackInterval;
        }
    }
Example #25
0
 /// <summary>
 /// 设置根节点
 /// </summary>
 /// <param name="root"></param>
 /// <returns></returns>
 public bool SetRoot(FSMBase root)
 {
     if (RootState != null)
     {
         return(false);
     }
     RootState = root;
     RegisterState(root);
     MoveState(root.Name);
     return(true);
 }
Example #26
0
        public override void OnUpdate(FSMBase _fsm)
        {
            HeroFSM fsm = (HeroFSM)_fsm;

            // 没血了就死
            if (fsm.parameter.hp <= 0)
            {
                fsm.Destroy();
            }

            return;
        }
Example #27
0
 public void AddState(FSMBase tempBase)
 {
     if (count <= allFSM.Length)
     {
         allFSM[count] = tempBase;
         count++;
     }
     else
     {
         Debug.LogError("动画已达上限!!!");
     }
 }
Example #28
0
        public override void HandleInput(FSMBase _fsm)
        {
            HeroFSM fsm = (HeroFSM)_fsm;

            float x_Input = Input.GetAxisRaw("Horizontal");

            // 如果没速度了,该站立了
            if (Vector3.Dot(fsm.parameter.rb.velocity, new Vector3(1 * fsm.parameter.transform.localScale.x, 0, 0)) == 0)
            {
                fsm.TransactionState(HeroStates.idleState);
            }
        }
Example #29
0
    void Awake()
    {
        instance = this;
        anim = gameObject.GetComponentInChildren<Animator>();
        camTr = GameObject.FindGameObjectWithTag("MainCamera").transform;
        playerTr = GameObject.Find("Luna_Head_Point").transform;
        fsmBase = GetComponent<FSMBase>();

        idle = GetComponent<WahleIdle>();
        move = GetComponent<WahleMove>();
        attack = GetComponent<WahleAttack>();
    }
    private void LoopPatrolling(FSMBase fsm)
    {
        // a - b - c - a - b - c -...
        if (Vector3.Distance(fsm.transform.position, fsm.wayPoints[index].position) < 0.1)
        {
            if (index == fsm.wayPoints.Length - 1)
            {
                index = (index + 1) % fsm.wayPoints.Length;
            }
        }

        fsm.MoveToTarget(fsm.wayPoints[index].position, 0, fsm.walkSpeed);
    }
Example #31
0
    //检测当前状态条件
    public void Reason(FSMBase fsm)
    {
        for (int i = 0; i < Triggers.Count; i++)
        {
            if (Triggers[i].HandleTrigger(fsm))
            {
                FSMStateID stateID = map[Triggers[i].TriggerID];
                fsm.ChangeActiveState(stateID);

                return;
            }
        }
    }