Ejemplo n.º 1
0
    public static void HostInitialize()
    {
        Tile tile = new Tile();
        //GameData.player.GetFaction = Player.Faction.nature;

        int idIndex = 0;

        GameData.LevelGrid = new HexaGrid(30, 40, tile.Width, tile.Height, true, "levelGrid");
        for (int i = 0; i < LevelGrid.Columns; i++)
        {
            for (int j = 0; j < LevelGrid.Rows; j++)
            {
                if (i > (int)(LevelGrid.Columns * .25) && i < (int)(LevelGrid.Columns * .75))
                {
                    switch (GameWorld.Random.Next(12))
                    {
                    case 0:
                        Forest f = new Forest(new Point(i, j));
                        f.gridPosition = new Point(i, j);
                        f.ID           = f.ID + idIndex.ToString();
                        idIndex++;
                        GameData.LevelGrid.Add(f, i, j);
                        forests.Add(f);
                        GameData.Buildings.Add(f);
                        break;

                    default:
                        int  type = 1 + (int)(GameWorld.Random.NextDouble() * 7);
                        Tile t    = new Tile("environment" + type);
                        t.gridPosition = new Point(i, j);
                        GameData.LevelGrid.Add(t, i, j);
                        break;
                    }
                }
                else
                {
                    int  type = 1 + (int)(GameWorld.Random.NextDouble() * 7);
                    Tile t    = new Tile("environment" + type);
                    t.gridPosition = new Point(i, j);
                    GameData.LevelGrid.Add(t, i, j);
                }
            }
        }
        Mine mine = new Mine();

        mine.gridPosition = new Point(4, 8);
        GameData.LevelGrid.replaceTile((Tile)GameData.LevelGrid.Objects[4, 8], mine, false);
        HumanityBase hBase = new HumanityBase();

        hBase.gridPosition = new Point(2, 11);
        hBase.Position     = GameData.LevelGrid.Objects[2, 11].Position;
        GameData.LevelGrid.Objects[2, 11] = hBase;
        hBase.HasBeenBuiltAction();
        hBase.AddQuadCoTiles();
        GameData.Buildings.Add(hBase);
        GameData.Buildings.Add(mine);
        mine.HasBeenBuiltAction();
        SunlightTree sunlightTree = new SunlightTree();
        NatureBase   nBase        = new NatureBase();

        nBase.gridPosition        = new Point(GameData.LevelGrid.Columns - 2, GameData.LevelGrid.Rows - 11);
        sunlightTree.gridPosition = new Point(GameData.LevelGrid.Columns - 4, GameData.LevelGrid.Rows - 8);
        GameData.LevelGrid.replaceTile((Tile)GameData.LevelGrid.Objects[GameData.LevelGrid.Columns - 4, GameData.LevelGrid.Rows - 8], sunlightTree, false);
        nBase.Position = GameData.LevelGrid.Objects[GameData.LevelGrid.Columns - 2, GameData.LevelGrid.Rows - 11].Position;
        GameData.LevelGrid.Objects[GameData.LevelGrid.Columns - 2, GameData.LevelGrid.Rows - 11] = nBase;
        nBase.AddQuadCoTiles();
        nBase.HasBeenBuiltAction();
        GameData.Buildings.Add(nBase);
        GameData.Buildings.Add(sunlightTree);
        sunlightTree.HasBeenBuiltAction();
        GameData.LevelObjects.Add(GameData.LevelGrid);

        GameWorld.Camera.Bounds = new Rectangle(0 - (int)tile.Sprite.Center.X, -(int)tile.Sprite.Center.Y,
                                                GameData.LevelGrid.GetWidth(), GameData.LevelGrid.GetHeight());
        GameWorld.Camera.Pos = new Vector2(-(int)tile.Sprite.Center.X, -(int)tile.Sprite.Center.Y);
        if (player.GetFaction == Player.Faction.humanity)
        {
            GameWorld.Camera.Pos = new Vector2(0, 0);
        }
        else
        {
            //GameWorld.Camera.Pos = new Vector2(-(int)tile.Sprite.Center.X, -(int)tile.Sprite.Center.Y);
            int y = GameData.LevelGrid.GetHeight();
            int x = GameData.LevelGrid.GetWidth();
            GameWorld.Camera.Pos = new Vector2(3380, 85);
        }

        selectedTile          = new SpriteGameObject("selectedTile", 0, "selectedTile", 1);
        selectedTile.Origin   = selectedTile.Sprite.Center;
        selectedTile.Position = new Vector2(-3000, -3000);
        GameData.LevelObjects.Add(selectedTile);

        if (GameData.Cursor != null)
        {
            GameData.LevelObjects.Remove(GameData.Cursor);
        }
        if (GameData.player.GetFaction == Player.Faction.humanity)
        {
            GameData.Cursor = new Cursor("humanityCursor");
            GameWorld.AssetLoader.PlayMusic("hMusic");
        }
        else
        {
            GameData.Cursor = new Cursor("natureCursor");
            GameWorld.AssetLoader.PlayMusic("nMusic");
        }



        GameData.LevelObjects.Add(GameData.Cursor);



        //naturePlayer = new Player(Player.Faction.nature);
        //GameData.LevelObjects.Add(naturePlayer);
        GameData.LevelObjects.Add(player);
        //ResourceController = new ResourceController(1, 10, 10) ;
        //GameData.LevelObjects.Add(ResourceController)
    }