Esempio n. 1
0
        void Prepare(FlowAINode node, int depthX, int depthY)
        {
            if (node == null)
            {
                return;
            }

            //準備済みノードならば終了
            if (_prepares.Exists(item => item.node == node))
            {
                return;
            }

            _maxDepthX = Mathf.Max(depthX, _maxDepthX);
            _maxDepthY = Mathf.Max(depthY, _maxDepthY);

            //準備済みリストに追加
            //位置
            Vector2 pos = new Vector2(depthX * _nodeHorizontalSpace, depthY * _nodeVerticalSpace);

            pos += _globalOffset;

            //矩形
            Rect nodeRect = new Rect(Vector2.zero, _nodeSize);

            nodeRect.center = pos;

            Vector2 mousePos = Input.mousePosition;

            mousePos.y = Screen.height - mousePos.y;

            _prepares.Add(new PrepareData(node, depthX, depthY, _targetBasis.currentNode == node, nodeRect.Contains(mousePos), nodeRect));

            //処理ノードかエントリポイントノードならば
            if (node is ProcessNode || node is FlowAIBasis.EntryPointNode)
            {
                //Y方向の深さを1つ掘る
                Prepare(node.GetNextNode(), depthX, depthY + 1);
                return;
            }

            //分岐ノードならば
            else if (node is BranchNode)
            {
                var branch = node as BranchNode;

                //Y方向の深さを1つ掘る
                Prepare(branch.trueNode, depthX, depthY + 1);
                //X方向とY方向の深さを1つ掘る
                Prepare(branch.falseNode, depthX + 1, depthY + 1);
                return;
            }
        }
Esempio n. 2
0
        /// <summary>遷移 Transition</summary>
        /// <param name="localId">遷移先のノードID LocalID of next node</param>
        public void Transition(int localId)
        {
            var node = _nodes.FirstOrDefault(item => item.localId == localId);

            //そのIDのノードが存在しない場合
            if (node == null)
            {
                TFDebug.Log("FlowAIBasis", "[TRNS]この基盤に存在しないローカルID:{0}", localId);
                _isStopped = true;
                return;
            }

            _currentNode = node;
            _currentNode.Processing();

            //終端ノードだった場合
            if (_currentNode.GetNextNode() == null)
            {
                _isStopped = true;
                TFDebug.Log("FlowAIBasis", "[TRNS]終端ノードに到達しました ローカルID:{0}", localId);
                return;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 更新処理
        /// Update.
        /// </summary>
        /// <param name="delta">デルタ Delta time.</param>
        public void Update(float delta)
        {
            //停止中だった場合
            if (_isStopped)
            {
                //	Debug.Log("[UPDT]FlowAIは停止しています");
                return;
            }

            _elapsed += delta;

            //遷移時間を終えた場合
            if (_elapsed >= _currentNode.duration)
            {
                Transition(_currentNode.GetNextNode().localId);
                _elapsed = 0f;
            }
            //遷移中の場合
            else
            {
                //	Debug.LogFormat("[UPDT]遷移中 LID{0} >>> LID{1}", _currentNode.localId, _currentNode.GetNextNode().localId);
            }
        }