Exemple #1
0
    public BanditArea CreateNewBand(MapData NewMapData, int BandID)
    {
        BanditArea newBand = new BanditArea();

        newBand.Coverage = Random.Range(1, 4);

        CreateInCircle Borders = new CreateInCircle();

        Borders.MapColumn = NewMapData.GenerateIndexes.Columns;
        Borders.MapRow    = NewMapData.GenerateIndexes.Row;

        if (newBand.Coverage == 1)
        {
            int GetRandomTile = Random.Range(0, NewMapData.GenerateIndexes.Columns * NewMapData.GenerateIndexes.Row - 1);
            newBand.Coordinates = NewMapData.Tiles[GetRandomTile].TileID;
        }
        if (newBand.Coverage == 2)
        {
            int GetRandomTile = Random.Range(0, NewMapData.GenerateIndexes.Columns * NewMapData.GenerateIndexes.Row - 1);
            newBand.Coordinates = NewMapData.Tiles[GetRandomTile].TileID;
            Borders.TakeCell    = newBand.Coordinates;
            Borders.GetBorders();
            if (Borders.IdentifyRow == 1)
            {
                newBand.Coordinates += NewMapData.GenerateIndexes.Row;
            }
            if (Borders.IdentifyRow == NewMapData.GenerateIndexes.Row)
            {
                newBand.Coordinates -= NewMapData.GenerateIndexes.Row;
            }
            if (Borders.IdentifyColumn == 1)
            {
                newBand.Coordinates += 1;
            }
            if (Borders.IdentifyColumn == NewMapData.GenerateIndexes.Columns)
            {
                newBand.Coordinates -= 1;
            }
        }
        if (newBand.Coverage == 3)
        {
            int GetRandomTile = Random.Range(0, NewMapData.GenerateIndexes.Columns * NewMapData.GenerateIndexes.Row - 1);
            newBand.Coordinates = NewMapData.Tiles[GetRandomTile].TileID;
            Borders.TakeCell    = newBand.Coordinates;
            Borders.GetBorders();
            if (Borders.IdentifyRow < 3)
            {
                newBand.Coordinates += 2 * NewMapData.GenerateIndexes.Row;
            }
            if (Borders.IdentifyRow > NewMapData.GenerateIndexes.Row - 3)
            {
                newBand.Coordinates -= 2 * NewMapData.GenerateIndexes.Row;
            }
            if (Borders.IdentifyColumn < 3)
            {
                newBand.Coordinates += 2;
            }
            if (Borders.IdentifyColumn > NewMapData.GenerateIndexes.Columns - 3)
            {
                newBand.Coordinates -= 2;
            }
        }

        CreateInCircle circ = new CreateInCircle();

        circ.TakeCell  = newBand.Coordinates;
        circ.Radius    = newBand.Coverage;
        circ.MapRow    = NewMapData.GenerateIndexes.Row;
        circ.MapColumn = NewMapData.GenerateIndexes.Columns;
        circ.TakeRadius();

        bool CheckCollision = false;

        foreach (int cell in circ.FullTiles)
        {
            if (NewMapData.Tiles[cell - 1].Empty == true)
            {
                CheckCollision = true;
            }
            else
            {
                CheckCollision = false;
                break;
            }
        }

        if (CheckCollision == true)
        {
            foreach (MapTileSample Tile in NewMapData.Tiles)
            {
                foreach (int Cell in circ.FullTiles)
                {
                    if (Tile.TileID == Cell)
                    {
                        Tile.Empty = false;
                    }
                }
            }
            int band = Random.Range(1, 4);
            if (band == 1)
            {
                newBand.Clan = "Trumans'";
            }
            if (band == 2)
            {
                newBand.Clan = "Knackers";
            }
            if (band == 3)
            {
                newBand.Clan = "Horde";
            }
            int Populate = 0;
            if (newBand.Coverage == 1)
            {
                Populate           = Random.Range(1, 5);
                newBand.Population = Populate;
            }
            if (newBand.Coverage == 2)
            {
                Populate           = Random.Range(5, 10);
                newBand.Population = Populate;
            }
            if (newBand.Coverage == 3)
            {
                Populate           = Random.Range(10, 15);
                newBand.Population = Populate;
            }
            newBand.NumberOfArea = BandID;
            return(newBand);
        }
        else
        {
            return(null);
        }
    }
Exemple #2
0
    public Store CreateNewStore(MapData NewMapData, StoreStack StoresStack, string Type, int StoreID, bool In_Radius)
    {
        if (Type == "Slaves")
        {
            int RandomCell = NewMapData.Tiles[Random.Range(0, NewMapData.GenerateIndexes.Columns * NewMapData.GenerateIndexes.Row - 1)].TileID;

            if (NewMapData.Tiles[RandomCell].Empty == true)
            {
                MapTileSample Tile = NewMapData.Tiles[RandomCell];

                Store      newStore = new Store();
                StorePoint AddStore = new StorePoint();
                newStore.TileID  = Tile.TileID;
                newStore.StoreID = StoreID;
                newStore.Type    = Type;

                AddStore.TypeOfStore = newStore.Type;
                AddStore.StoreID     = newStore.StoreID;
                AddStore.CountOfItem = Random.Range(10, 15);
                for (int Slv = 0; Slv < AddStore.CountOfItem; Slv++)
                {
                    AddStore.SlaveRandomize();
                }
                StoresStack.storePoint.Add(AddStore);

                if (StoreID == 0)
                {
                    NewMapData.GenerateIndexes.PlayerCoords = Tile.Coordinates + new Vector3(0, 0, -5);
                }

                Tile.Empty = false;
                return(newStore);
            }
            else
            {
                return(null);
            }
        }
        if (Type == "Guns")
        {
            CreateInCircle newCirc = new CreateInCircle();
            if (In_Radius == true)
            {
                newCirc.TakeCell  = NewMapData.GenerateIndexes.Stores[StoreID - 1].TileID;
                newCirc.MapColumn = NewMapData.GenerateIndexes.Columns;
                newCirc.MapRow    = NewMapData.GenerateIndexes.Row;
                newCirc.Radius    = 2;
                newCirc.GenerateCell();
                //Debug.Log(newCirc.TargetCell);
                if (NewMapData.Tiles[newCirc.TargetCell - 1].Empty == true)
                {
                    MapTileSample Tile     = NewMapData.Tiles[newCirc.TargetCell - 1];
                    Store         newStore = new Store();
                    StorePoint    AddStore = new StorePoint();
                    newStore.TileID  = Tile.TileID;
                    newStore.StoreID = StoreID;
                    newStore.Type    = Type;

                    AddStore.TypeOfStore = newStore.Type;
                    AddStore.StoreID     = newStore.StoreID;
                    AddStore.CountOfItem = Random.Range(10, 15);
                    for (int Wpn = 0; Wpn < AddStore.CountOfItem; Wpn++)
                    {
                        AddStore.WeaponRandomize();
                    }
                    StoresStack.storePoint.Add(AddStore);

                    Tile.Empty = false;
                    return(newStore);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                int RandCell = Random.Range(0, NewMapData.Tiles.Count);
                if (NewMapData.Tiles[RandCell].Empty == true)
                {
                    MapTileSample Tile     = NewMapData.Tiles[RandCell];
                    Store         newStore = new Store();
                    StorePoint    AddStore = new StorePoint();
                    newStore.TileID  = Tile.TileID;
                    newStore.StoreID = StoreID;
                    newStore.Type    = Type;

                    AddStore.TypeOfStore = newStore.Type;
                    AddStore.StoreID     = newStore.StoreID;
                    AddStore.CountOfItem = Random.Range(10, 15);
                    for (int Wpn = 0; Wpn < AddStore.CountOfItem; Wpn++)
                    {
                        AddStore.WeaponRandomize();
                    }
                    StoresStack.storePoint.Add(AddStore);

                    Tile.Empty = false;
                    return(newStore);
                }
                else
                {
                    return(null);
                }
            }
        }
        if (Type == "Bullets")
        {
            if (In_Radius == true)
            {
                CreateInCircle newCirc = new CreateInCircle();
                newCirc.TakeCell  = NewMapData.GenerateIndexes.Stores[StoreID - 1].TileID;
                newCirc.MapColumn = NewMapData.GenerateIndexes.Columns;
                newCirc.MapRow    = NewMapData.GenerateIndexes.Row;
                newCirc.Radius    = 2;
                newCirc.GenerateCell();
                //Debug.Log(newCirc.TargetCell);
                if (NewMapData.Tiles[newCirc.TargetCell - 1].Empty == true)
                {
                    MapTileSample Tile     = NewMapData.Tiles[newCirc.TargetCell - 1];
                    Store         newStore = new Store();
                    StorePoint    AddStore = new StorePoint();
                    newStore.TileID  = Tile.TileID;
                    newStore.StoreID = StoreID;
                    newStore.Type    = Type;

                    AddStore.TypeOfStore = newStore.Type;
                    AddStore.StoreID     = newStore.StoreID;
                    AddStore.CountOfItem = Random.Range(10, 15);
                    for (int Bul = 0; Bul < AddStore.CountOfItem; Bul++)
                    {
                        AddStore.BulletRandomize();
                    }
                    StoresStack.storePoint.Add(AddStore);

                    Tile.Empty = false;
                    return(newStore);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                int RandCell = Random.Range(0, NewMapData.Tiles.Count);
                if (NewMapData.Tiles[RandCell].Empty == true)
                {
                    MapTileSample Tile     = NewMapData.Tiles[RandCell];
                    Store         newStore = new Store();
                    StorePoint    AddStore = new StorePoint();
                    newStore.TileID  = Tile.TileID;
                    newStore.StoreID = StoreID;
                    newStore.Type    = Type;

                    AddStore.TypeOfStore = newStore.Type;
                    AddStore.StoreID     = newStore.StoreID;
                    AddStore.CountOfItem = Random.Range(10, 15);
                    for (int Bul = 0; Bul < AddStore.CountOfItem; Bul++)
                    {
                        AddStore.BulletRandomize();
                    }
                    StoresStack.storePoint.Add(AddStore);

                    Tile.Empty = false;
                    return(newStore);
                }
                else
                {
                    return(null);
                }
            }
        }
        if (Type == "Stuff")
        {
            if (In_Radius == true)
            {
                CreateInCircle newCirc = new CreateInCircle();
                newCirc.TakeCell  = NewMapData.GenerateIndexes.Stores[StoreID - 1].TileID;
                newCirc.MapColumn = NewMapData.GenerateIndexes.Columns;
                newCirc.MapRow    = NewMapData.GenerateIndexes.Row;
                newCirc.Radius    = 2;
                newCirc.GenerateCell();
                if (NewMapData.Tiles[newCirc.TargetCell - 1].Empty == true)
                {
                    MapTileSample Tile     = NewMapData.Tiles[newCirc.TargetCell - 1];
                    Store         newStore = new Store();
                    StorePoint    AddStore = new StorePoint();
                    newStore.TileID  = Tile.TileID;
                    newStore.StoreID = StoreID;
                    newStore.Type    = Type;

                    AddStore.TypeOfStore = newStore.Type;
                    AddStore.StoreID     = newStore.StoreID;
                    AddStore.CountOfItem = Random.Range(10, 15);
                    for (int Stf = 0; Stf < AddStore.CountOfItem; Stf++)
                    {
                        AddStore.StuffRandomize(Stf);
                    }
                    StoresStack.storePoint.Add(AddStore);

                    Tile.Empty = false;
                    return(newStore);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                int RandCell = Random.Range(0, NewMapData.Tiles.Count);
                if (NewMapData.Tiles[RandCell].Empty == true)
                {
                    MapTileSample Tile     = NewMapData.Tiles[RandCell];
                    Store         newStore = new Store();
                    StorePoint    AddStore = new StorePoint();
                    newStore.TileID  = Tile.TileID;
                    newStore.StoreID = StoreID;
                    newStore.Type    = Type;

                    AddStore.TypeOfStore = newStore.Type;
                    AddStore.StoreID     = newStore.StoreID;
                    AddStore.CountOfItem = Random.Range(10, 15);
                    for (int Stf = 0; Stf < AddStore.CountOfItem; Stf++)
                    {
                        AddStore.StuffRandomize(Stf);
                    }
                    StoresStack.storePoint.Add(AddStore);

                    Tile.Empty = false;
                    return(newStore);
                }
                else
                {
                    return(null);
                }
            }
        }
        if (Type == "Recycling")
        {
            //CreateInCircle newCirc = new CreateInCircle();
            //newCirc.TakeCell = NewMapData.GenerateIndexes.Stores[StoreID - 1].TileID;
            //newCirc.MapColumn = NewMapData.GenerateIndexes.Columns;
            //newCirc.MapRow = NewMapData.GenerateIndexes.Row;
            //newCirc.Radius = 3;
            //newCirc.GenerateCell();
            int RandomCell = NewMapData.Tiles[Random.Range(0, NewMapData.Tiles.Count)].TileID;

            Debug.Log(RandomCell);
            if (NewMapData.Tiles[RandomCell].Empty == true)
            {
                MapTileSample Tile     = NewMapData.Tiles[RandomCell];
                Store         newStore = new Store();
                StorePoint    AddStore = new StorePoint();
                newStore.TileID  = Tile.TileID;
                newStore.StoreID = StoreID;
                newStore.Type    = Type;

                AddStore.TypeOfStore = newStore.Type;
                AddStore.StoreID     = newStore.StoreID;
                StoresStack.storePoint.Add(AddStore);

                Tile.Empty = false;
                return(newStore);
            }
            else
            {
                return(null);
            }
        }
        else
        {
            return(null);
        }
    }