Пример #1
0
        public static void UnsignedOuput(RichTextBox output, MemoryItem variable, string name)
        {
            StringBuilder temp = new StringBuilder(name);

            temp.Append(": " + ((ushort)variable.GetValue()).ToString() + "\n");
            output.Text += temp.ToString();
        }
Пример #2
0
 /// <summary>
 /// Task Priority
 /// </summary>
 public float GetPriority(MoonAI ai)
 {
     if (!PriorityLoaded)
     {
         m_priority     = _Priority.GetValue <float>(ai.Memory);
         PriorityLoaded = true;
     }
     return(m_priority);
 }
Пример #3
0
        public override void OnEnter(MoonAI ai)
        {
            string rbkey = _rigidbodyKey.GetValue <string>(ai.Memory);

            if (!string.IsNullOrEmpty(rbkey))
            {
                rb = ai.Memory.GetValue <Rigidbody>(rbkey);
            }
        }
Пример #4
0
 public override void OnEnter(MoonAI ai)
 {
     Timer    = 0;
     WaitTime = Seconds.GetValue <float>(ai.Memory);
     if (WaitTime < 0)
     {
         WaitTime = 0;
     }
 }
Пример #5
0
        public override void OnEnter(MoonAI ai)
        {
            string gokey = _gameObjectKey.GetValue <string>(ai.Memory);

            if (!string.IsNullOrEmpty(gokey))
            {
                m_gameObject = ai.Memory.GetValue <GameObject>(gokey);
            }
        }
Пример #6
0
        public override void OnEnter(MoonAI ai)
        {
            MoonBT loadedbt = BehaviorTree.GetValue <MoonBT>(ai.Memory);

            if (loadedbt != null && (loadedbt != ai.BehaviorTree) && loadedbt.Root != null)
            {
                Bt = MoonBT.CopyBT(loadedbt);
            }
        }
Пример #7
0
 public override TaskResult OnExecute(MoonAI ai)
 {
     if (rb != null)
     {
         Vector3 f     = force.GetValue <Vector3>(ai.Memory);
         float   delta = (useDeltaTime.GetValue <bool>(ai.Memory)) ? Time.deltaTime : 1;
         rb.AddForce(f * delta, forceMode);
     }
     return(TaskResult.Failure);
 }
Пример #8
0
        public override TaskResult OnExecute(MoonAI ai)
        {
            if (anim != null)
            {
                anim.speed = Speed.GetValue <float>(ai.Memory);
                return(TaskResult.Success);
            }

            return(TaskResult.Failure);
        }
Пример #9
0
        public override TaskResult OnExecute(MoonAI ai)
        {
            float speed = Speed.GetValue <float>(Mem);

            if (Agent != null)
            {
                Agent.speed = speed;
                return(TaskResult.Success);
            }
            return(TaskResult.Failure);
        }
Пример #10
0
        // Called when the task is executed
        public override TaskResult OnExecute(MoonAI ai)
        {
            float Aval = AValue.GetValue <float>(ai.Memory);

            float BVal = BValue.GetValue <float>(ai.Memory);

            string mSaveKey = SaveKey.GetValue <string>(ai.Memory);

            ai.Memory.SetValue(mSaveKey, Compute(Aval, BVal));

            return(TaskResult.Success);
        }
Пример #11
0
        public override TaskResult OnExecute(MoonAI ai)
        {
            string _key = Key.GetValue <string>(ai.Memory);

            if (!string.IsNullOrEmpty(_key))
            {
                object val = Value.GetValue <object>(null);
                ai.Memory.SetValue(_key, val);
                return(TaskResult.Success);
            }
            return(TaskResult.Failure);
        }
Пример #12
0
        public override TaskResult OnExecute(MoonAI ai)
        {
            Vector3 forward = ForwardVector.GetValue <Vector3>(ai.Memory);

            float speed = LookSpeed.GetValue <float>(ai.Memory);

            if (forward != Vector3.zero)
            {
                Quaternion tres = Quaternion.LookRotation(forward);
                ai.transform.rotation = Quaternion.Slerp(ai.transform.rotation, tres, speed * Time.deltaTime);
            }
            return(TaskResult.Success);
        }
Пример #13
0
        public override TaskResult OnExecute(MoonAI ai)
        {
            string _tag = Tag.GetValue <string>(Mem);

            if (!string.IsNullOrEmpty(_tag) && !string.IsNullOrEmpty(Savekey))
            {
                GameObject obj = GameObject.FindGameObjectWithTag(_tag);
                Mem.SetValue(Savekey, obj);
                return(TaskResult.Success);
            }

            return(TaskResult.Failure);
        }
Пример #14
0
        public override TaskResult OnExecute(MoonAI ai)
        {
            string axisName = AxisName.GetValue <string>(ai.Memory);
            string savekey  = SaveKey.GetValue <string>(ai.Memory);

            if (!string.IsNullOrEmpty(axisName) & !string.IsNullOrEmpty(savekey))
            {
                ai.Memory.SetValue(savekey, (Mode == AxisMode.Normal) ? Input.GetAxis(axisName) : Input.GetAxisRaw(axisName));
                return(TaskResult.Success);
            }

            return(TaskResult.Failure);
        }
Пример #15
0
        public override TaskResult OnExecute(MoonAI ai)
        {
            string savek = SaveKey.GetValue <string>(ai.Memory);

            if (!string.IsNullOrEmpty(savek) && m_gameObject != null)
            {
                ai.Memory.SetValue(savek, m_gameObject.transform.position);

                return(TaskResult.Success);
            }

            return(TaskResult.Failure);
        }
Пример #16
0
        public override TaskResult OnExecute(MoonAI ai)
        {
            Animator anim = ai.GetComponent <Animator>();

            string _param = Parameter.GetValue <string>(ai.Memory);

            if (anim != null && !string.IsNullOrEmpty(_param))
            {
                anim.SetTrigger(_param);
                return(TaskResult.Success);
            }

            return(TaskResult.Failure);
        }
Пример #17
0
        public override TaskResult OnExecute(MoonAI ai)
        {
            string _name = GameObjectName.GetValue <string>(ai.Memory);
            string _key  = SaveKey.GetValue <string>(ai.Memory);

            if (!string.IsNullOrEmpty(_name) & !string.IsNullOrEmpty(_key))
            {
                GameObject found = GameObject.Find(_name);

                ai.Memory.SetValue(_key, found);

                return(TaskResult.Success);
            }
            return(TaskResult.Failure);
        }
Пример #18
0
        public override TaskResult OnExecute(MoonAI ai)
        {
            string btnName = ButtunName.GetValue <string>(ai.Memory);

            if (!string.IsNullOrEmpty(btnName) && ((Mode == ButtunMode.Hold && Input.GetButton(btnName)) || (Mode == ButtunMode.Down &&
                                                                                                             Input.GetButtonDown(btnName)) || (Mode == ButtunMode.Up && Input.GetButtonUp(btnName))))
            {
                Task child = Childs[0];
                if (child != null)
                {
                    return(child.Execute(ai));
                }
            }
            return(TaskResult.Failure);
        }
Пример #19
0
        public override TaskResult OnExecute(MoonAI ai)
        {
            NavMeshHit hit;

            Vector3 Point = point.GetValue <Vector3>(ai.Memory);

            if (NavMesh.SamplePosition(Point, out hit, 1.0f, NavMesh.AllAreas))
            {
                if (Childs.Length > 0)
                {
                    return(Childs[0].Execute(ai));
                }
            }

            return(TaskResult.Failure);
        }
Пример #20
0
        public override TaskResult OnExecute(MoonAI ai)
        {
            string key = GameObjectKey.GetValue <string>(ai.Memory);

            if (!string.IsNullOrEmpty(key))
            {
                GameObject go = ai.Memory.GetValue <GameObject>(key);
                if (!go)
                {
                    go = ai.gameObject;
                }
                go.SetActive(Active.GetValue <bool>(ai.Memory));
                return(TaskResult.Success);
            }
            return(TaskResult.Failure);
        }
Пример #21
0
 public override void OnEnter(MoonAI ai)
 {
     index   = 0;
     mChilds = Childs;
     if (Shuffle.GetValue <bool>(ai.Memory))
     {
         for (int i = 0; i < Childs.Length; i++)
         {
             Task curr        = Childs[i];
             int  randomindex = Random.Range(0, Childs.Length);
             Task randomT     = Childs[randomindex];
             mChilds[i]           = randomT;
             mChilds[randomindex] = curr;
         }
     }
 }
Пример #22
0
        public override TaskResult OnExecute(MoonAI ai)
        {
            string k = ObjectKey.GetValue <string>(Mem);

            if (!string.IsNullOrEmpty(k))
            {
                Object obj = Mem.GetValue <Object>(k) as Object;

                if (obj != null)
                {
                    Destroy(obj);
                }
                return(TaskResult.Success);
            }

            return(TaskResult.Failure);
        }
Пример #23
0
        public override TaskResult OnExecute(MoonAI ai)
        {
            string savek = SaveKey.GetValue <string>(ai.Memory);

            if (!string.IsNullOrEmpty(savek))
            {
                Vector3 a = A.GetValue <Vector3>(ai.Memory);

                Vector3 b = B.GetValue <Vector3>(ai.Memory);

                Vector3 result = Vector3.zero;

                switch (Mode)
                {
                case VectorMathMode.Add:

                    result = a + b;

                    break;

                case VectorMathMode.Substract:

                    result = a - b;

                    break;

                case VectorMathMode.Multiply:

                    result = Vector3.Scale(a, b);

                    break;

                case VectorMathMode.Cross:

                    result = Vector3.Cross(a, b);

                    break;
                }

                ai.Memory.SetValue(savek, result);

                return(TaskResult.Success);
            }

            return(TaskResult.Failure);
        }
Пример #24
0
        public override TaskResult OnExecute(MoonAI ai)
        {
            object msg = Message.GetValue <object>(ai.Memory);

            if (Type == MessageType.Info)
            {
                Debug.Log(msg);
            }
            else if (Type == MessageType.Warning)
            {
                Debug.LogWarning(msg);
            }
            else if (Type == MessageType.Error)
            {
                Debug.LogError(msg);
            }

            return(TaskResult.Success);
        }
Пример #25
0
        public override void OnEnter(MoonAI ai)
        {
            Index         = 0;
            m_saveKey     = TargetPointSaveKey.GetValue <string>(ai.Memory);
            m_currdistkey = CurrentDistanceSaveKey.GetValue <string>(ai.Memory);
            string pathkey = PatrolPathKey.GetValue <string>(ai.Memory);

            if (!string.IsNullOrEmpty(pathkey) && Path == null)
            {
                GameObject Pathgo = ai.Memory.GetValue <GameObject>(pathkey);
                if (Pathgo != null && Pathgo.scene.IsValid())
                {
                    var _path = Pathgo.GetComponent <MoonPath>();
                    if (_path != null)
                    {
                        Path = _path.Waypoints.ToArray();
                    }
                }
            }
            m_NextWaypoint = NextWayPointDistance.GetValue <float>(ai.Memory);
        }
Пример #26
0
        public override TaskResult OnExecute(MoonAI ai)
        {
            TargetPos = (TargetGo != null) ? TargetGo.transform.position : Target.GetValue <Vector3>(ai.Memory);

            Vector3 m_dir    = (TargetPos - ai.transform.position);
            float   stopdist = StopDistance.GetValue <float>(ai.Memory);

            if (agent != null)
            {
                agent.speed            = speed;
                agent.stoppingDistance = stopdist;

                NavMeshHit h;
                if (NavMesh.SamplePosition(TargetPos, out h, 1.0f, NavMesh.AllAreas))
                {
                    agent.destination = TargetPos;
                }
                else
                {
                    return(TaskResult.Failure);
                }

                if (m_dir.magnitude <= stopdist)
                {
                    agent.velocity = Vector3.Lerp(agent.velocity, Vector3.zero, agent.acceleration);
                    return(TaskResult.Success);
                }

                return(TaskResult.Running);
            }
            else
            {
                Vector3 desiredVelocity = m_dir.normalized * speed;
                Vector3 Steering        = desiredVelocity - velocity;
                velocity = Vector3.ClampMagnitude(velocity + Steering, speed);
                ai.transform.position += velocity;

                return((m_dir.magnitude <= stopdist) ? TaskResult.Success : TaskResult.Running);
            }
        }
Пример #27
0
        public override void OnEnter(MoonAI ai)
        {
            DetectSomething = false;
            Running         = false;

            DetectSelf  = _DetectSelf.GetValue <bool>(ai.Memory);
            SearchTag   = _SearchTag.GetValue <string>(ai.Memory);
            SaveName    = _SaveName.GetValue <string>(ai.Memory);
            ResetOnExit = _ResetOnExitSensor.GetValue <bool>(ai.Memory);

            string SensorName = _SensorName.GetValue <string>(ai.Memory);

            if (!string.IsNullOrEmpty(SensorName))
            {
                if (!ai.GetComponent <MoonPerception>())
                {
                    Debug.LogError("[MoonBehavior] No MoonPerception component detected! aborting.");
                    return;
                }
                Vision = ai.GetComponent <MoonPerception>().GetSensor(SensorName) as VisualSensor;
            }
        }
Пример #28
0
        public override TaskResult OnExecute(MoonAI ai)
        {
            Ray r = Camera.main.ScreenPointToRay(Input.mousePosition);

            RaycastHit hit;

            float raydist = RayDistance.GetValue <float>(ai.Memory);

            LayerMask mask = Mask.GetValue <LayerMask>(ai.Memory);

            string savek = SaveKey.GetValue <string>(ai.Memory);

            if (!string.IsNullOrEmpty(savek))
            {
                if (Physics.Raycast(r.origin, r.direction, out hit, raydist, mask))
                {
                    ai.Memory.SetValue(savek, hit.point);
                }

                return(TaskResult.Success);
            }

            return(TaskResult.Failure);
        }
Пример #29
0
        public override TaskResult OnExecute(MoonAI ai)
        {
            if (TargetGo != null)
            {
                Vector3 dir = (TargetGo.transform.position - ai.transform.position);

                if (dir != Vector3.zero)
                {
                    Quaternion tr = Quaternion.LookRotation(dir);
                    ai.transform.rotation = Quaternion.Slerp(ai.transform.rotation, tr, LookSpeed.GetValue <float>(ai.Memory)
                                                             * Time.deltaTime);
                }
                return(TaskResult.Success);
            }
            return(TaskResult.Failure);
        }
Пример #30
0
        public override void OnEnter(MoonAI ai)
        {
            string key = TargetKey.GetValue <string>(ai.Memory);

            TargetGo = ai.Memory.GetValue <GameObject>(key);
        }