コード例 #1
0
    private GameObject SpawnCellObject(GameObject prefab, Vector2Int vector2Int)
    {
        var instance   = Instantiate(prefab, (Vector2)vector2Int, Quaternion.identity);
        var controller = instance.GetComponent <CellObjectController>();
        var cell       = _cellMapController.GetCell(vector2Int);

        controller.Cell = cell;
        cell.CellObjects.Add(controller);
        return(instance);
    }
コード例 #2
0
    public void DropRawItemInFactory(Vector2Int position, int ammount)
    {
        var factory = _cellMapController.GetCell(position).GetCellObject <FactoryController>();

        if (factory == null)
        {
            Debug.LogError("No factory at " + position);
            return;
        }

        factory.AddRawItems(ammount);
    }
コード例 #3
0
ファイル: VillagerController.cs プロジェクト: vikepic/rewild
    private void GoToOrderDestination(Vector2Int position)
    {
        var path = (List <Node>)PathfindingController.Instance.FindPath(
            BitMath.RoundToInt((Vector2)transform.position), position);

        if (path.Count > 0)
        {
            var pos = path.Last();
            _villagerModel.DestinationCell = _cellMapController.GetCell(pos.Position);
            // I'm removing the last node in the path because the villager looks better
            // if it stops right before its destination
            path.RemoveAt(path.Count - 1);
        }

        if (path.Count > 0)
        {
            _villagerModel.CurrentPath = path;
            _villagerStateController.CurrentVillagerState = VillagerState.GetToOrder;
            return;
        }

        _villagerStateController.CurrentVillagerState = VillagerState.ProcessOrder;
    }