Ejemplo n.º 1
0
    public void ChooseThePathMoreShort()
    {
        if (this != GameManager.managerGame.systemPathfinding.originTile)
        {
            Collider[] collision = Physics.OverlapSphere(transform.position, radiusContact);


            List <TileScript> tilesList = new List <TileScript>();

            foreach (Collider col in collision)
            {
                if (col.gameObject.GetComponent <TileScript>() != null && col.gameObject != this && col.gameObject.GetComponent <TileScript>().isUsedBool&& !col.GetComponent <TileScript>().checkTheCorrectPathBool)
                {
                    tilesList.Add(col.gameObject.GetComponent <TileScript>());
                }
            }

            TileScript moreShortPosition = null;
            float      minimumDistance   = Mathf.NegativeInfinity;


            foreach (TileScript tile in tilesList)
            {
                if (minimumDistance < tile.fCost && tile != this.GetComponent <TileScript>() && !tile.checkTheCorrectPathBool)
                {
                    moreShortPosition = tile;

                    minimumDistance = tile.fCost;
                }
            }



            if (moreShortPosition != null)
            {
                GameManager.managerGame.systemPathfinding.tilesUsedForThePath.Add(this);

                checkTheCorrectPathBool = true;
                moreShortPosition.CorrectPathMaterial();

                moreShortPosition.ChooseThePathMoreShort();
            }
        }
        else
        {
            StartCoroutine(GameManager.managerGame.characterControl.CharacterMovement());
        }
    }
Ejemplo n.º 2
0
 public void ChooseStarterPath()
 {
     m_destTile.ChooseThePathMoreShort();
 }