예제 #1
0
파일: ItemData.cs 프로젝트: Team-on/LD48
    public bool IsCanUseItemWhileInHotbar()
    {
        switch (itemSO.metaType)
        {
        case ItemSO.ItemMetaType.BuildableForeground:
            if (!GameManager.Instance.SelectedCell || GameManager.Instance.SelectedCell.foregroud != Cell.CellContentForegroud.None)
            {
                return(false);
            }

            PlacebleBlock placebleBlock = GameManager.Instance.GetItemPlacable(itemSO.type);
            return(placebleBlock.isCanPlaceOnPlayerPos || !GameManager.Instance.SelectedCell.IsPlayerInside());

        case ItemSO.ItemMetaType.MiningTool:
            return(GameManager.Instance.SelectedCell && (
                       (GameManager.Instance.SelectedCell.foregroud != Cell.CellContentForegroud.None && itemSO.miningForce >= GameManager.Instance.SelectedCell.foregroundBlock.neededForceToBroke) ||
                       (GameManager.Instance.SelectedCell.ore != Cell.CellContentOre.None && itemSO.miningForce >= GameManager.Instance.SelectedCell.oreBlock.neededForceToBroke)
                       ));

        default:
            Debug.LogError("Unsupported ItemMetaType for using");
            break;
        }

        return(false);
    }
예제 #2
0
파일: ItemData.cs 프로젝트: Team-on/LD48
    public bool UseItemWhileInHotbar()
    {
        switch (itemSO.metaType)
        {
        case ItemSO.ItemMetaType.BuildableForeground:
            if (!GameManager.Instance.SelectedCell || GameManager.Instance.SelectedCell.foregroud != Cell.CellContentForegroud.None)
            {
                return(false);
            }

            PlacebleBlock placebleBlock = GameManager.Instance.GetItemPlacable(itemSO.type);

            if (placebleBlock.isCanPlaceOnPlayerPos || !GameManager.Instance.SelectedCell.IsPlayerInside())
            {
                GameManager.Instance.SelectedCell.foregroud = placebleBlock.foregroud;
                GameManager.Instance.SelectedCell.RecreateVisualAfterChangeType();

                --count;
                if (count <= 0)
                {
                    itemSO = null;
                }

                return(true);
            }
            break;

        case ItemSO.ItemMetaType.MiningTool:
            if (!GameManager.Instance.SelectedCell)
            {
                return(false);
            }

            if (
                (GameManager.Instance.SelectedCell.foregroud != Cell.CellContentForegroud.None && itemSO.miningForce >= GameManager.Instance.SelectedCell.foregroundBlock.neededForceToBroke) ||
                (GameManager.Instance.SelectedCell.ore != Cell.CellContentOre.None && itemSO.miningForce >= GameManager.Instance.SelectedCell.oreBlock.neededForceToBroke)
                )
            {
                GameManager.Instance.SelectedCell.Mine(Time.deltaTime, itemSO.miningForce);
            }
            break;

        default:
            Debug.LogError("Unsupported ItemMetaType for using");
            break;
        }

        return(false);
    }
예제 #3
0
파일: Cell.cs 프로젝트: Team-on/LD48
    void CreateAllVisuals()
    {
        gameObject.transform.localScale = new Vector3(1, 1, 1.0f);

        if (foregroundBlock != null && foregroud != foregroundBlock.foregroud)
        {
            Destroy(foregroundBlock.gameObject);
            foregroundBlock = null;
        }

        if (backgroundBlock != null && background != backgroundBlock.background)
        {
            Destroy(backgroundBlock.gameObject);
            backgroundBlock = null;
        }

        if (oreBlock != null && ore != oreBlock.ore)
        {
            Destroy(oreBlock.gameObject);
            oreBlock = null;
        }

        if (foregroundBlock == null && foregroud != CellContentForegroud.None)
        {
            foregroundBlock        = Instantiate(GameManager.Instance.GetCellForeground(foregroud), gameObject.transform.position, Quaternion.identity, gameObject.transform).GetComponent <PlacebleBlock>();
            foregroundBlock.MyCell = this;
        }

        if (backgroundBlock == null && background != CellContentBackground.None)
        {
            backgroundBlock        = Instantiate(GameManager.Instance.GetCellBackground(background), gameObject.transform.position, Quaternion.identity, gameObject.transform).GetComponent <PlacebleBlock>();
            backgroundBlock.MyCell = this;
        }

        if (oreBlock == null && ore != CellContentOre.None)
        {
            oreBlock        = Instantiate(GameManager.Instance.GetCellOre(ore), gameObject.transform.position, Quaternion.identity, gameObject.transform).GetComponent <PlacebleBlock>();
            oreBlock.MyCell = this;
        }
    }