public bool NavToRandom(ShipRuntime targetShip)
    {
        this.targetShip = targetShip;
        // Enter this state from a cell pos, no previous path exists (idle roam from absolute cell pos)
        curPath = null;

        bool success = false;

        Vector2Int pos = targetShip.GetRandomNavigateableCellPos(out success, WallState.Down);

        if (!success)
        {
            return(false);
        }

        if (!Navigate(
                targetShip,
                new Vector2Int(Mathf.RoundToInt(transform.localPosition.x / 3.2f), Mathf.RoundToInt(transform.localPosition.y / 3.2f)),
                pos))
        {
            return(false);
        }

        return(true);
    }
    public void Init(ShipRuntime targetShip)
    {
        this.targetShip = targetShip;
        transform.SetParent(targetShip.transform);

        bool       success = false;
        Vector2Int pos     = targetShip.GetRandomNavigateableCellPos(out success, WallState.Down);

        if (success)
        {
            transform.localPosition = new Vector3(pos.x, pos.y, 0) * 3.2f;
        }

        // Idle job
        jobController.SetIdleJob(new JobPlayerCrewIdle("Idle", new object[] { jobController, navigationController, targetShip }));
    }
Esempio n. 3
0
    public void NavToRandom(ShipRuntime targetShip)
    {
        bool       success = false;
        Vector2Int pos     = targetShip.GetRandomNavigateableCellPos(out success);

        if (success)
        {
            Navigate(
                targetShip,
                new Vector2Int(Mathf.RoundToInt(transform.localPosition.x / 3.2f), Mathf.RoundToInt(transform.localPosition.y / 3.2f)),
                pos);
        }
        else
        {
            StartCoroutine("DelaySearch");
        }
    }