Example #1
0
    public void CreatingEdge()
    {
        Debug.Log("Ribs start");
        GraphNav = new Graph(ListHexagonControls);
        for (int i = 0; i < ListHexagonControls.Count; i++)
        {
            ListHexagonControls[i].Data.CreateNewList();
        }

        for (int i = 0; i < GraphNav.Length - 1; i++)
        {
            for (int j = i + 1; j < GraphNav.Length; j++)
            {
                bool IsElevation;

                Vector2 StartPosition = GraphNav[i].NodeHexagon.transform.position;
                Vector2 direction     = GraphNav[j].NodeHexagon.transform.position;

                bool NoRibs = false;

                if (GraphNav[i].NodeHexagon.TypeHexagon <= 0 ||
                    (GraphNav[i].NodeHexagon.TypeHexagon == 3 && GraphNav[j].NodeHexagon.gameObject.layer != 10))
                {
                    IsElevation = false;
                    if (!NavStatic.CollisionCheck(StartPosition, direction, IsElevation, null, null))
                    {
                        NoRibs = true;
                    }
                }
                else
                {
                    IsElevation = true;
                    if (!NavStatic.CollisionCheckElevation(StartPosition, direction, IsElevation, null, null))
                    {
                        NoRibs = true;
                    }
                }

                if (!NoRibs)
                {
                    float magnitude = (GraphNav[i].NodeHexagon.transform.position - GraphNav[j].NodeHexagon.transform.position).magnitude;
                    GraphNav[i].Connect(GraphNav[j], magnitude, null);

                    GraphNav[i].NodeHexagon.Data.SaveTheWay(GraphNav[j].NodeHexagon, new List <HexagonControl>()
                    {
                        GraphNav[i].NodeHexagon, GraphNav[j].NodeHexagon
                    });
                    GraphNav[j].NodeHexagon.Data.SaveTheWay(GraphNav[i].NodeHexagon, new List <HexagonControl>()
                    {
                        GraphNav[j].NodeHexagon, GraphNav[i].NodeHexagon
                    });
                }
                else
                {
                    GraphNav[i].ListUnrelated.Add(GraphNav[j]);
                }
            }
        }
        Debug.Log("Ribs completed");
    }
Example #2
0
    private void WayBypass(HexagonControl hexagonFinish, IMove EnemyTarget, IMove Collision)
    {
        List <HexagonControl> Way;

        Way = new List <HexagonControl>()
        {
            Control.HexagonMain(), hexagonFinish
        };

        if (Way != null)
        {
            Way = NavStatic.PathCheckBypassFly(Way, Collision, EnemyTarget, this);

            if (Way.Count > 0)
            {
                _wayList.Clear();

                _wayList.AddRange(Way);
                _isMove = true;
            }
            else
            {
                StartCoroutine(StopBypass());
            }
        }
    }
Example #3
0
    private void Way(HexagonControl hexagonFinish, IMove EnemyTarget)
    {
        List <HexagonControl> Way;

        Way = Control.HexagonMain().GetWay(hexagonFinish);

        if (Way != null)
        {
            if (_isClever)
            {
                Way = NavStatic.PathCheck(Way, EnemyTarget, this);
            }
            else
            {
                Way.Remove(Way[0]);
            }

            _wayList.AddRange(Way);
            _isMove = true;
        }
    }