コード例 #1
0
ファイル: Rewards.cs プロジェクト: Gillium/spyrun
        public Rewards(Texture2D texture, float number, Hills hills)
        {
            spriteSheet = texture;
            velocity = number;
            this.hills = hills;
            this.texture = texture;

            rand = new Random();

            goldBarSpriteOffset = 562;
            goldBarFrameCount = 2;
            goldBarFrameIndex = 0;
            goldBarFrameWidth = 174;
            goldBarFrameHeight = 91;
            goldBarRadius = 43;

            batterySpriteOffset = 484;
            batteryFrameCount = 4;
            batteryFrameIndex = 0;
            batteryFrameWidth = 74;
            batteryFrameHeight = 61;
            batteryRadius = 20;

            sawSpriteOffset = 660;
            sawFrameCount = 3;
            sawFrameIndex = 0;
            sawFrameWidth = 179;
            sawFrameHeight = 64;
            sawRadius = 20;
        }
コード例 #2
0
ファイル: World.cs プロジェクト: hafewa/Fantasy-Project
    //This function is only temporary as the map will not always be a hills biome,
    //it does however show how one goes about generating terrain
    public void generateMap()
    {
        //Create a new reference to the hills bimoe which stores data on what blocks need to be generated and how
        Biome hills = new Hills();

        //Create a new terrain generator for the hills biome in this world
        TerrainGenerator terrainGenerator = new TerrainGenerator(gameManager, this, hills);

        //Iterate over a 4*4 chunk region to generate 16 chunks
        for (int i = -2; i < 2; i++)
        {
            for (int j = -2; j < 2; j++)
            {
                //Get the location of the current chunk
                ChunkLocation chunkLocation = new ChunkLocation(this, i, 0, j);

                Chunk chunk = loadChunk(terrainGenerator, chunkLocation);
                //renderChunk(chunk);
            }
        }

        MapDisplay1 display = FindObjectOfType <MapDisplay1>();

        display.drawMap(4, 4, getLoadedChunks());
    }
コード例 #3
0
        /// <summary>
        /// The create hills.
        /// </summary>
        /// <remarks></remarks>
        public void createHills()
        {
            // Hold our possible 5 hill points listings
            List <Vector3>[] hillPoints = new List <Vector3> [5];

            for (int x = 0; x < bsp.Spawns.Spawn.Count; x++)
            {
                if (bsp.Spawns.Spawn[x].Type == SpawnInfo.SpawnType.Objective)
                {
                    SpawnInfo.ObjectiveSpawn currObj = (SpawnInfo.ObjectiveSpawn)bsp.Spawns.Spawn[x];
                    string s1 = currObj.ObjectiveType.ToString();
                    if (s1.Substring(0, s1.Length - 1) == "KingOfTheHill_")
                    {
                        int num = int.Parse(s1[s1.Length - 1].ToString()) - 1;
                        if (hillPoints[num] == null)
                        {
                            hillPoints[num] = new List <Vector3>();
                        }

                        hillPoints[num].Add(new Vector3(currObj.X, currObj.Y, currObj.Z));
                    }
                }
            }

            for (int i = 0; i < 5; i++)
            {
                if (hillPoints[i] != null)
                {
                    hillDisplay[i] = Hills.createHillObject(device, hillPoints[i]);
                }
            }

            hillsLoaded = true;
        }
コード例 #4
0
 public void StartHotSeat(hills hill)
 {
     if (ActualCompetition != null)
     {
         Debug.Log("Competition is already started!");
         return;
     }
     ActualCompetition = Instantiate(HotSeatCompetitionPrefab).GetComponent <CompetitionManager>();
     if (ActualCompetition == null)
     {
         Debug.LogError("GameManager cannot acces Competition manager in Hot Seat Competition Prefab!");
     }
     if (ActualCompetition != null)
     {
         ActualCompetition.transform.parent = this.transform;
     }
     CurrentHill = Hills.Find(_hill => _hill.HillName.Equals(hill));
     SceneManager.LoadScene(CurrentHill.HillName.ToString());
 }
コード例 #5
0
        private void LoadMap(Bytemap bitmap)
        {
            _tiles = new ITile[WIDTH, HEIGHT];

            for (int x = 0; x < WIDTH; x++)
            {
                for (int y = 0; y < HEIGHT; y++)
                {
                    ITile tile;
                    bool  special = TileIsSpecial(x, y);
                    switch (bitmap[x, y])
                    {
                    case 2: tile = new Forest(x, y, special); break;

                    case 3: tile = new Swamp(x, y, special); break;

                    case 6: tile = new Plains(x, y, special); break;

                    case 7: tile = new Tundra(x, y, special); break;

                    case 9: tile = new River(x, y); break;

                    case 10: tile = new Grassland(x, y); break;

                    case 11: tile = new Jungle(x, y, special); break;

                    case 12: tile = new Hills(x, y, special); break;

                    case 13: tile = new Mountains(x, y, special); break;

                    case 14: tile = new Desert(x, y, special); break;

                    case 15: tile = new Arctic(x, y, special); break;

                    default: tile = new Ocean(x, y, special); break;
                    }
                    _tiles[x, y] = tile;
                }
            }
        }
コード例 #6
0
        // Display the current map
        public override string ToString()
        {
            string s = "";

            for (int y = 0; y < Rows; y++)
            {
                for (int x = 0; x < Cols; x++)
                {
                    Coordinates pos = new Coordinates(x, y);
                    char        c   = '_';
                    if (MyAnts.ContainsKey(pos))
                    {
                        c = 'a';
                    }
                    else if (Walls.Contains(pos))
                    {
                        c = '#';
                    }
                    else if (Enemies.Contains(pos))
                    {
                        c = 'e';
                    }
                    else if (Food.Contains(pos))
                    {
                        c = '.';
                    }
                    else if (Hills.Contains(pos))
                    {
                        c = '*';
                    }
                    s += c;
                }
                s += "\n";
            }
            return(s);
        }
コード例 #7
0
        public void ChangeTileType(int x, int y, Terrain type)
        {
            bool special  = TileIsSpecial(x, y);
            bool road     = _tiles[x, y].Road;
            bool railRoad = _tiles[x, y].RailRoad;

            switch (type)
            {
            case Terrain.Forest: _tiles[x, y] = new Forest(x, y, special); break;

            case Terrain.Swamp: _tiles[x, y] = new Swamp(x, y, special); break;

            case Terrain.Plains: _tiles[x, y] = new Plains(x, y, special); break;

            case Terrain.Tundra: _tiles[x, y] = new Tundra(x, y, special); break;

            case Terrain.River: _tiles[x, y] = new River(x, y); break;

            case Terrain.Grassland1:
            case Terrain.Grassland2: _tiles[x, y] = new Grassland(x, y); break;

            case Terrain.Jungle: _tiles[x, y] = new Jungle(x, y, special); break;

            case Terrain.Hills: _tiles[x, y] = new Hills(x, y, special); break;

            case Terrain.Mountains: _tiles[x, y] = new Mountains(x, y, special); break;

            case Terrain.Desert: _tiles[x, y] = new Desert(x, y, special); break;

            case Terrain.Arctic: _tiles[x, y] = new Arctic(x, y, special); break;

            case Terrain.Ocean: _tiles[x, y] = new Ocean(x, y, special); break;
            }
            _tiles[x, y].Road     = road;
            _tiles[x, y].RailRoad = railRoad;
        }
コード例 #8
0
        private void MergeElevationAndLatitude(int[,] elevation, int[,] latitude)
        {
            Log("Map: Stage 3 - Merge elevation and latitude into the map");

            // merge elevation and latitude into the map
            for (int y = 0; y < HEIGHT; y++)
            {
                for (int x = 0; x < WIDTH; x++)
                {
                    bool special = TileIsSpecial(x, y);
                    switch (elevation[x, y])
                    {
                    case 0: _tiles[x, y] = new Ocean(x, y, special); break;

                    case 1:
                    {
                        switch (latitude[x, y])
                        {
                        case 0: _tiles[x, y] = new Desert(x, y, special); break;

                        case 1: _tiles[x, y] = new Plains(x, y, special); break;

                        case 2: _tiles[x, y] = new Tundra(x, y, special); break;

                        case 3: _tiles[x, y] = new Arctic(x, y, special); break;
                        }
                    }
                    break;

                    case 2: _tiles[x, y] = new Hills(x, y, special); break;

                    default: _tiles[x, y] = new Mountains(x, y, special); break;
                    }
                }
            }
        }
コード例 #9
0
 public void AddHill(int col, int row)
 {
     Hills.Add(new Coordinates(col, row));
 }
コード例 #10
0
        public void ComputeMoves(GameActionsMessage msg)
        {
            // Next ants positions
            Dictionary <Coordinates, Ant> updated = new Dictionary <Coordinates, Ant>();

            Random rand = new Random();

            foreach (KeyValuePair <Coordinates, Ant> pair in MyAnts)
            {
                Ant          ant = pair.Value;
                Coordinates  pos = pair.Key;
                AntDirection move;
                Coordinates  next;
                if (ant.HasFood)
                {
                    if (ant.History.Count > 0 && !Hills.Contains(pos))
                    {
                        // Walk back
                        move = ant.History.Pop().Reverse();
                        next = pos.ApplyDirection(move).Normalize(this);
                        // If the path is blocked, don't move (and put the move back on the history for next round)
                        if (!Enemies.Contains(next) && !updated.ContainsKey(next))
                        {
                            msg.AddMove(pos.Col, pos.Row, move.ToString());
                            updated.Add(next, ant);
                        }
                        else
                        {
                            ant.History.Push(move.Reverse());
                        }
                        continue;
                    }
                    else
                    {
                        ant.HasFood = false;
                    }
                }
                move = GetNearbyFood(pos);
                // If there is accessible food, go there
                if (move == AntDirection.U)
                {
                    List <AntDirection> remaining = new List <AntDirection>()
                    {
                        AntDirection.N, AntDirection.S, AntDirection.E, AntDirection.W
                    };
                    int index;
                    // First move to try : continue the same way or not ? 50% chance
                    if (ant.History.Count > 0 && rand.NextDouble() < 0.5)
                    {
                        move = ant.History.Peek();
                        remaining.Remove(move);
                    }
                    else
                    {
                        index = rand.Next(4);
                        move  = remaining[index];
                        remaining.RemoveAt(index);
                    }
                    int size = remaining.Count;
                    do
                    {
                        Coordinates result = pos.ApplyDirection(move).Normalize(this);
                        if (!Walls.Contains(result) && !MyAnts.ContainsKey(result) && !updated.ContainsKey(result))
                        {
                            break;
                        }
                        if (size > 0)
                        {
                            index = rand.Next(size);
                            move  = remaining[index];
                            remaining.RemoveAt(index);
                        }
                        else
                        {
                            move = AntDirection.U;
                        }
                        size--;
                    } while (size >= 0);
                }
                else
                {
                    ant.HasFood = true;
                }
                next = pos.ApplyDirection(move).Normalize(this);
                if (move != AntDirection.U && !updated.ContainsKey(next))
                {
                    ant.History.Push(move);
                    msg.AddMove(pos.Col, pos.Row, move.ToString());
                    updated.Add(next, ant);
                }
            }

            MyAnts = updated;
        }
コード例 #11
0
ファイル: Hills.cs プロジェクト: ChromeWheels/CasterWars
	/**
	 * Called when the script is loaded, before the game starts
	 */
	void Awake () {
		S = this;
	}
コード例 #12
0
        private void GenerateRectangleIsland(Rectangle island)
        {
            var random   = new Random();
            int distance = 1;
            var tiles    = _world.GetTilesInRectangle(island);

            foreach (var tile in tiles)
            {
                //
                if (tile.Y > _world.Height - 5)
                {
                    var winter = new Tundra(tile.X, tile.Y, tile.Cell);
                    _world.SetTileProperty(winter, tile.X, tile.Y, true, true, false);
                }
                else if (tile.Y > _world.Height - 10)
                {
                    var desert = new Dessert(tile.X, tile.Y, tile.Cell);
                    _world.SetTileProperty(desert, tile.X, tile.Y, true, true, false);
                }
                else if (tile.Y < 5)
                {
                    var winter = new Tundra(tile.X, tile.Y, tile.Cell);
                    _world.SetTileProperty(winter, tile.X, tile.Y, true, true, false);
                }
                else if (tile.Y < 10)
                {
                    var desert = new Dessert(tile.X, tile.Y, tile.Cell);
                    _world.SetTileProperty(desert, tile.X, tile.Y, true, true, false);
                }
                else
                {
                    var tileType = random.Next(0, 99);
                    if (tileType < 30)
                    {
                        var plains = new Plains(tile.X, tile.Y, tile.Cell);
                        _world.SetTileProperty(plains, tile.X, tile.Y, true, true, false);
                    }
                    else if (tileType < 50)
                    {
                        var Forest = new Plains(tile.X, tile.Y, tile.Cell);
                        _world.SetTileProperty(Forest, tile.X, tile.Y, true, true, false);
                    }
                    else if (tileType < 65)
                    {
                        var hill = new Hills(tile.X, tile.Y, tile.Cell);
                        _world.SetTileProperty(hill, tile.X, tile.Y, true, true, false);
                    }
                    else if (tileType < 75)
                    {
                        var mountain = new Mountain(tile.X, tile.Y, tile.Cell);
                        _world.SetTileProperty(mountain, tile.X, tile.Y, true, true, false);
                    }
                    else if (tileType < 90)
                    {
                        var marsh = new Marsh(tile.X, tile.Y, tile.Cell);
                        _world.SetTileProperty(marsh, tile.X, tile.Y, true, true, false);
                    }
                    else
                    {
                        var plain = new Plains(tile.X, tile.Y, tile.Cell);
                        _world.SetTileProperty(plain, tile.X, tile.Y, true, true, false);
                    }
                }
            }

            var beachTiles =
                _world.GetTilesAlongLine(island.Left - distance, island.Top - distance, island.Right, island.Top - distance).ToList();

            beachTiles.
            AddRange(_world.GetTilesAlongLine(island.Left - distance, island.Bottom, island.Right, island.Bottom));
            beachTiles.
            AddRange(_world.GetTilesAlongLine(island.Left - distance, island.Top - distance, island.Left - distance, island.Bottom));
            beachTiles.
            AddRange(_world.GetTilesAlongLine(island.Right, island.Top - distance, island.Right, island.Bottom));
            foreach (var t in beachTiles)
            {
                var coast = new Coast(t.X, t.Y, t.Cell);
                _world.SetTileProperty(coast, t.X, t.Y, true, true, false);
            }
        }
コード例 #13
0
        private void AgeAdjustments()
        {
            Log("Map: Stage 5 - Age adjustments");

            int x         = 0;
            int y         = 0;
            int ageRepeat = (int)(((float)800 * (1 + _age) / (80 * 50)) * (WIDTH * HEIGHT));

            for (int i = 0; i < ageRepeat; i++)
            {
                if (i % 2 == 0)
                {
                    x = Common.Random.Next(WIDTH);
                    y = Common.Random.Next(HEIGHT);
                }
                else
                {
                    switch (Common.Random.Next(8))
                    {
                    case 0: { x--; y--; break; }

                    case 1: { y--; break; }

                    case 2: { x++; y--; break; }

                    case 3: { x--; break; }

                    case 4: { x++; break; }

                    case 5: { x--; y++; break; }

                    case 6: { y++; break; }

                    default: { x++; y++; break; }
                    }
                    if (x < 0)
                    {
                        x = 1;
                    }
                    if (y < 0)
                    {
                        y = 1;
                    }
                    if (x >= WIDTH)
                    {
                        x = WIDTH - 2;
                    }
                    if (y >= HEIGHT)
                    {
                        y = HEIGHT - 2;
                    }
                }

                bool special = TileIsSpecial(x, y);
                switch (_tiles[x, y].Type)
                {
                case Terrain.Forest: _tiles[x, y] = new Jungle(x, y, special); break;

                case Terrain.Swamp: _tiles[x, y] = new Grassland(x, y); break;

                case Terrain.Plains: _tiles[x, y] = new Hills(x, y, special); break;

                case Terrain.Tundra: _tiles[x, y] = new Hills(x, y, special); break;

                case Terrain.River: _tiles[x, y] = new Forest(x, y, special); break;

                case Terrain.Grassland1:
                case Terrain.Grassland2: _tiles[x, y] = new Forest(x, y, special); break;

                case Terrain.Jungle: _tiles[x, y] = new Swamp(x, y, special); break;

                case Terrain.Hills: _tiles[x, y] = new Mountains(x, y, special); break;

                case Terrain.Mountains:
                    if ((x == 0 || _tiles[x - 1, y - 1].Type != Terrain.Ocean) &&
                        (y == 0 || _tiles[x + 1, y - 1].Type != Terrain.Ocean) &&
                        (x == (WIDTH - 1) || _tiles[x + 1, y + 1].Type != Terrain.Ocean) &&
                        (y == (HEIGHT - 1) || _tiles[x - 1, y + 1].Type != Terrain.Ocean))
                    {
                        _tiles[x, y] = new Ocean(x, y, special);
                    }
                    break;

                case Terrain.Desert: _tiles[x, y] = new Plains(x, y, special); break;

                case Terrain.Arctic: _tiles[x, y] = new Mountains(x, y, special); break;
                }
            }
        }