コード例 #1
0
    private void DigP1(ViewTile tile)
    {
        if (!_world.P1Action.CanUseAction(PlayerActionType.Dig))
        {
            return;
        }

        var tileP1 = _world.P1Plain.Tiles[(int)tile.worldPosition.x, (int)tile.worldPosition.y];
        var tileP2 = _world.P2Plain.Tiles[(int)tile.worldPosition.x, (int)tile.worldPosition.y];

        switch (tileP1.TileType)
        {
        case TileType.Mine:
            break;

        case TileType.Field:
            audioSource.PlayOneShot(DigSFX);
            tileP1.Dig();
            tileP2.Raise();
            _worldCreator.MakeMineP1(tile);
            _worldCreator.MakeMountainP2(tile);
            _world.P1Action.UseAction(PlayerActionType.Dig);
            if (tileP2.TowerActive)
            {
                tileP2.DestoryTower();
                _world.P2Resources.RemoveResource(tileP2.ResourceType);
            }

            break;

        case TileType.Mountain:
            tileP1.Dig();
            audioSource.PlayOneShot(DigSFX);
            _world.P1Action.UseAction(PlayerActionType.Dig);
            if (tileP2.TileType == TileType.Mine)
            {
                tileP2.Raise();
                if (tileP2.TowerActive)
                {
                    _world.P2Resources.RemoveResource(tileP2.ResourceType);
                }
                _worldCreator.MakePlainP2(tile);
                _worldCreator.ViewTilesMultiArrayPlayerTwo[(int)tile.worldPosition.x, (int)tile.worldPosition.y].RemoveHoleSprite();
            }
            _worldCreator.MakePlainP1(tile);
            tile.RemoveMountain();

            break;

        default:
            break;
        }
    }