public IEnumerable <T> Traversing(WalkOrder order)
        {
            _orderList = new List <Node <T> >();
            Action <Node <T> > traversing;

            switch (order)
            {
            case WalkOrder.Post:
                traversing = new Action <Node <T> >(PostOrderTraversing);
                break;

            case WalkOrder.Pre:
                traversing = new Action <Node <T> >(PreOrderTraversing);
                break;

            case WalkOrder.In:
                traversing = new Action <Node <T> >(InOrderTraversing);
                break;

            default:
                traversing = new Action <Node <T> >(InOrderTraversing);
                break;
            }

            return(Walk(traversing));
        }
Beispiel #2
0
        IEnumerator Indicator(List <Vector3> way, int spendVigor, WalkOrder walkOrder)
        {
            // start
            _enemy.activeState = ActiveState.Moving;
            _cameraController.transform.rotation = _cameraController.currentClock.ClockwiseRotation;
            yield return(null);

            if (way == null)
            {
                print("No Way");
                _enemy.activeState = ActiveState.NotAnything;
                _cameraController.useKeyboardInput   = true;
                _cameraController.useScreenEdgeInput = true;
            }

            _animator.SetBool(Running, true);

            // do
            if (way != null)
            {
                foreach (var destination in way)
                {
                    MoveUnit(destination);
                    while (_enemy.activeState == ActiveState.Moving)
                    {
                        yield return(null);
                    }
                }
            }

            if (walkOrder == WalkOrder.Rush)
            {
                yield return(_waiting);
            }

            _animator.SetBool(Running, false);

            // end
            _board.ResetBoard();
            _enemy.activeState = ActiveState.NotAnything;
            _gameManager.Marked();
            _enemy.currentVigor -= spendVigor;
        }
Beispiel #3
0
        // start
        public void IndicateUnit(List <TileNode> way, AreaOrder areaOrder, WalkOrder walkOrder)
        {
            int spendVigor;

            if (areaOrder == AreaOrder.Base)
            {
                spendVigor = _enemy.enemyAi.halfVigor;
            }
            else if (areaOrder == AreaOrder.Double)
            {
                spendVigor = _enemy.enemyAi.fullVigor;
            }
            else
            {
                spendVigor = _enemy.enemyAi.halfVigor;
            }
            way.Reverse();
            StartCoroutine(Indicator(MakeTransform(way), spendVigor, walkOrder));
        }
Beispiel #4
0
        private bool MovingSkill(TileNode endNode, List <TileNode> allNodeList, AreaOrder areaOrder, WalkOrder walkOrder)
        {
            if (endNode == null)
            {
                print("EndNode : " + endNode);
                return(false);
            }

            var enemy = enemyAi.currentEnemy;

            if (enemy == null)
            {
                print("Enemy : " + enemy);
                return(false);
            }

            var startNode = allNodeList.Find(i => i.Coordinate == GameUtility.Coordinate(enemy.transform.position));

            if (startNode == null)
            {
                print("StartNode : " + startNode);
                return(false);
            }

            var way = _board.PathFinding.GreedPathFinding(startNode, endNode, _board.NodeList);

            if (way == null)
            {
                return(false);
            }

            enemy.enemyMove.IndicateUnit(way, areaOrder, walkOrder);
            return(true);
        }
Beispiel #5
0
        public bool UnitWalk(AreaOrder areaOrder, WalkOrder walkOrder, TileNode endNode)
        {
            TileNode newNode = endNode;

            if (walkOrder == WalkOrder.Random)
            {
                var areaList = new List <TileNode>();

                if (areaOrder == AreaOrder.Base)
                {
                    moveBaseArea.SetActive(true);
                }
                else if (areaOrder == AreaOrder.Double)
                {
                    moveDoubleArea.SetActive(true);
                }
                else
                {
                    print("Wrong order for RandomWalk");
                }

                foreach (var node in _board.NodeList)
                {
                    if (Physics.CheckBox(node.transform.position, GameUtility.Box, Quaternion.identity, LayerMask.GetMask("Obstacle", "Player", "Enemy")))
                    {
                        continue;
                    }
                    if (areaOrder == AreaOrder.Base)
                    {
                        if (Physics.CheckBox(node.transform.position, GameUtility.Box, Quaternion.identity, LayerMask.GetMask("MoveBaseArea")))
                        {
                            node.tileStyle = TileStyle.OneArea;
                            areaList.Add(node);
                        }
                    }
                    else if (areaOrder == AreaOrder.Double)
                    {
                        if (Physics.CheckBox(node.transform.position, GameUtility.Box, Quaternion.identity, LayerMask.GetMask("MoveDoubleArea")))
                        {
                            node.tileStyle = TileStyle.TwoArea;
                            areaList.Add(node);
                        }
                    }
                }

                int randomNumber = Random.Range(0, areaList.Count - 1);
                newNode = areaList[randomNumber];

                if (areaOrder == AreaOrder.Base)
                {
                    moveBaseArea.SetActive(false);
                }
                else if (areaOrder == AreaOrder.Double)
                {
                    moveDoubleArea.SetActive(false);
                }
            }

            else if (walkOrder == WalkOrder.Base || walkOrder == WalkOrder.Rush)
            {
                newNode = endNode;
            }

            var canMove = MovingSkill(newNode, _board.NodeList, areaOrder, walkOrder);

            return(canMove);
        }