• PlayMaker 不支持过渡条件


    Unity Animator 自带也支持过渡条件,  我看了下PlayMaker没有这个概念.  最近研究下PlayMaker,图形化编程的确很爽. 但是PlayMaker 始于与给一些策划进行流程设置. 用它来全程做游戏我感觉会的.

    image

    image

    在Playmaker上自己封装的条件类

    using HutongGames.PlayMaker;
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    
    public class CondFloat : BaseCond
    {
        [UIHint(UIHint.FsmFloat)]
        public FsmFloat mVal1;
        public ECondition mCondition;
        [UIHint(UIHint.FsmFloat)]
        public FsmFloat mVal2;
    
    
        public override bool Condition()
        {
            if (mCondition == ECondition.Equal)
                return mVal1.Value == mVal2.Value;
            if (mCondition == ECondition.Less)
                return mVal1.Value < mVal2.Value;
            if (mCondition == ECondition.Greater)
                return mVal1.Value > mVal2.Value;
    
            return false;
        }
    }
    
    public class CondBool : BaseCond
    {
        [UIHint(UIHint.FsmBool)]
        public FsmBool mVal1;
        public override bool Condition()
        {
            return mVal1.Value;
        }
    }
    
    public class CondString : BaseCond
    {
        [UIHint(UIHint.FsmString)]
        public FsmString mVal1;
        [UIHint(UIHint.FsmString)]
        public FsmString mVal2;
    
    
        public override bool Condition()
        {
            return mVal1.Equals(mVal2);
        }
    }
    
    public class CondMethod : BaseCond
    {
        [UIHint(UIHint.Method)]
        public FsmString mVal1;
        [UIHint(UIHint.Method)]
        public FsmString mVal2;
        
        public override bool Condition()
        {
            return mVal1.Equals(mVal2);
        }
    }
    [SerializeField]
    public class BaseCond
    {
        public string mEventName;
    
        public string GetEventName()
        {
            return mEventName;
        }
    
        public virtual bool Condition()
        {
            return false;
        }
    
    }
    public enum ECondition
    {
        Less,
        Equal,
        Greater
    }
    using HutongGames.PlayMaker;
    using HutongGames.PlayMaker.Actions;
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    
    
    [ActionCategory(ActionCategory.Debug)]
    [HutongGames.PlayMaker.Tooltip("发送事件")]
    public class SendMethod : FsmStateAction
    {
        public string mMethodName;
    
        public override void OnEnter()
        {
            this.Finish();
        }
    }
    using HutongGames.PlayMaker;
    using HutongGames.PlayMaker.Actions;
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    
    public abstract class CondAction : SendMethod
    {
        public abstract BaseCond Condition { get;}
    
        public override void OnEnter()
        {
            bool l = Condition.Condition();
            string s = Condition.GetEventName();
    
            if (l)
            {
                this.Fsm.Event(s);
                Debug.Log("发送事件");
            }
            this.Finish();
        }
    }
    using HutongGames.PlayMaker;
    using HutongGames.PlayMaker.Actions;
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using System;
    
    public class CondActionBool : CondAction
    {
        public CondBool mCondition;
    
        public override BaseCond Condition
        {
            get
            {
                return mCondition;
            }
        }
    
    
    }

    代码浏览

    image

    代码地址: https://gitee.com/PFSchool/UFrame.git    ScriptTools文件夹下

  • 相关阅读:
    【luogu3768】简单的数学题 欧拉函数(欧拉反演)+杜教筛
    【codeforces666E】Forensic Examination 广义后缀自动机+树上倍增+线段树合并
    【bzoj5073】[Lydsy1710月赛]小A的咒语 后缀数组+倍增RMQ+贪心+dp
    【bzoj4596】[Shoi2016]黑暗前的幻想乡 容斥原理+矩阵树定理
    窗体的呈现、用户控件的呈现
    WPF和js交互 WebBrowser数据交互
    字符串string 转换为 Base64String
    静态资源加载过程及时序
    if else 与 if else if 的区分与使用总结
    复杂耗时逻辑处理——子线程
  • 原文地址:https://www.cnblogs.com/plateFace/p/8548335.html
Copyright © 2020-2023  润新知