Ejemplo n.º 1
0
    void AjustPosition()
    {
        mapSCR.RemoveCharacterPosition(gameObject, isAlly);
        //mapSCR.RemoveCharacterPosition(gameObject, isAlly, tempCellPos);
        charMng.playerCell = null;
        ShipCell emptyCell = mapSCR.IsRoomEmpty(transform.position, isAlly);

        if (emptyCell != null)
        {
            Vector2 mypos     = new Vector2(transform.position.x, transform.position.y);
            Vector2 mycellpos = new Vector2(emptyCell.position.x, emptyCell.position.y);
            float   distance  = Vector2.Distance(mypos, mycellpos);
            if (distance > 0.1f) // <===
            {
                MoveToNode(emptyCell.position);
            }
            else
            {
                charMng.playerCell = mapSCR.SetCharacterPosition(gameObject, isAlly);
            }
        }

        else
        {
            goalList.Clear();
            StartCoroutine(CalculateAllPath());
            StartCoroutine(UrgentPathCorrect());
        }
    }