void DoSet(Blackboard bb, string name, T value)
        {
            var targetVariable = bb.GetVariable <T>(name);

            if (targetVariable == null)
            {
                targetVariable = (Variable <T>)bb.AddVariable(varName.value, typeof(T));
            }
            if (operation != OperationMethod.Set)
            {
                if (typeof(T) == typeof(float))
                {
                    targetVariable.value = (T)(object)OperationTools.Operate((float)(object)targetVariable.value, (float)(object)value, operation);
                }
                else if (typeof(T) == typeof(int))
                {
                    targetVariable.value = (T)(object)OperationTools.Operate((int)(object)targetVariable.value, (int)(object)value, operation);
                }
                else if (typeof(T) == typeof(Vector3))
                {
                    targetVariable.value = (T)(object)OperationTools.Operate((Vector3)(object)targetVariable.value, (Vector3)(object)value, operation);
                }
                else
                {
                    targetVariable.value = value;
                }
            }
            else
            {
                targetVariable.value = value;
            }
        }
示例#2
0
    public override void Awake()
    {
        blackboard = Owner.GetComponent <Blackboard> ();
        if (blackboard.GetVariable <float> (key) == null)
        {
            blackboard.AddVariable(key, typeof(float));
        }

        if (!cdFirst)
        {
            blackboard.SetValue(key, float.MinValue);
        }
    }
示例#3
0
        /// <summary>
        /// Affirm黑板变量
        /// </summary>
        /// <param name="blackboard"></param>
        static public void AffirmBlackboardVariable(Blackboard blackboard)
        {
            if (blackboard.GetVariable <Transform>("Target") == null)
            {
                blackboard.AddVariable("Target", typeof(Transform));
            }

            if (blackboard.GetVariable <bool>("FriendlyFire") == null)
            {
                blackboard.AddVariable("FriendlyFire", false);
            }

            if (blackboard.GetVariable <bool>(GlobalSymbol.FLAG_TARGET_LOCKED) == null)
            {
                blackboard.AddVariable(GlobalSymbol.FLAG_TARGET_LOCKED, false);
            }

            if (blackboard.GetVariable <List <Transform> >("Candidate Targets") == null)
            {
                // (blackboard.AddVariable ( "Candidate Targets", new List<Transform>() )
                //  as Variable< List<Transform> >).GetValue ().Add ( GameManager.Player );
                (blackboard.AddVariable("Candidate Targets", new List <Transform>())
                 as Variable <List <Transform> >).GetValue().Add(default);