Пример #1
0
    private void CreateRandomTile(TileTypeEnum tileType, Action <List <ResourceModel> > callback)
    {
        LootDropTable <ResourceModel, ResourceTypesEnum> lootDropTable = new LootDropTable <ResourceModel, ResourceTypesEnum>();

        List <BucketObjectModel <ResourceTypesEnum> > lootObjectModel = new List <BucketObjectModel <ResourceTypesEnum> >();

        List <ResourceModel> resources = null;

        foreach (TileCreateModel tileCreateModel in GameModel.Tiles)
        {
            if (tileCreateModel.Type == tileType)
            {
                foreach (ResourceCreateModel resource in tileCreateModel.Resources)
                {
                    BucketObjectModel <ResourceTypesEnum> bucketObject = new BucketObjectModel <ResourceTypesEnum>(resource.Type, resource.Weight, resource.Count);
                    lootObjectModel.Add(bucketObject);
                }

                resources = lootDropTable.GetLoot(lootObjectModel, tileCreateModel.MinDrop, tileCreateModel.MaxDrop);
                break;
            }
        }


        if (resources != null)
        {
            callback.Invoke(resources);
        }

        else
        {
            Debug.LogError("resources == NULL");
        }
    }
Пример #2
0
    private void CreateRandomTile(Action <TileModel> callback)
    {
        LootDropTable <TileModel, TileTypeEnum> lootDropTable = new LootDropTable <TileModel, TileTypeEnum>();

        List <BucketObjectModel <TileTypeEnum> > lootObjectModel = new List <BucketObjectModel <TileTypeEnum> >();

        foreach (TileCreateModel tileCreateModel in GameModel.Tiles)
        {
            BucketObjectModel <TileTypeEnum> bucketObject = new BucketObjectModel <TileTypeEnum>(tileCreateModel.Type, tileCreateModel.Weight, 1);
            lootObjectModel.Add(bucketObject);
        }

        List <TileModel> tileModels = lootDropTable.GetLoot(lootObjectModel, 1, 1);

        if (tileModels != null && tileModels.Count > 0)
        {
            callback.Invoke(tileModels[0]);
            //Debug.Log(tileModels[0].TileType);
        }
        else
        {
            Debug.LogError("Tile == NULL");
        }
    }