Ejemplo n.º 1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // Create title and gameover screens
            introScreen = new GameScreen(this, Content.Load<Texture2D>("textures/titleScreen"), 10.0f);
            gameoverScreen = new GameOverGameScreen(this, Content.Load<Texture2D>("textures/gameoverScreen"), 3.0f);

            // Create main game related stuff
            world = new World();
            world.Load();
            // load textures
            playerTexture = Content.Load<Texture2D>("textures/playerTexture");
            backgroundTexture = Content.Load<Texture2D>("Background/Background_1");
            backgroundTexture2 = Content.Load<Texture2D>("Background/Background_2");
            backgroundTexture3 = Content.Load<Texture2D>("Background/Background_3");
            this.black = Content.Load<Texture2D>("black");
            this.noise = Content.Load<Texture2D>("noise");

            this.parallaxCollection = new ParallaxCollection(this);

            // create map panel
            mapPanel = new MapPanel(this, Content.Load<Texture2D>("textures/centerBar"),
                                    Content.Load<Texture2D>("textures/darkBar"),
                                    Content.Load<Texture2D>("textures/mapIcons"));

            // create players
            players = new List<PlayerSprite>();
            players.Add(new PlayerSprite(this, 0, new Vector3(3, world.getHeigth(3), 1.0f), playerTexture)
            {
                color = new Color(0x48, 0xe6, 0xfe, 255)
            });
            players.Add(new PlayerSprite(this, 1, new Vector3(-3, world.getHeigth(-3), 1.0f), playerTexture)
            {
                color = new Color(0xf8, 0xfe, 0x4d, 255)
            });

            // create game screens
            splitScreens = new RenderTarget2D[2];
            splitScreens[0] = new RenderTarget2D(GraphicsDevice, SPLIT_SCREEN_WIDTH, SPLIT_SCREEN_HEIGHT);
            splitScreens[1] = new RenderTarget2D(GraphicsDevice, SPLIT_SCREEN_WIDTH, SPLIT_SCREEN_HEIGHT);
            joinedScreen = new RenderTarget2D(GraphicsDevice, SCREEN_WIDTH, SCREEN_HEIGHT);

            // create cameras
            cameras = new GameCamera[2];
            cameras[0] = new GameCamera(this, splitScreens[0].ToVector(), 0, players[0].worldPosition);
            cameras[0].FollowPlayer(players[0]);
            cameras[1] = new GameCamera(this, splitScreens[1].ToVector(), 1, players[1].worldPosition);
            cameras[1].FollowPlayer(players[1]);

            joinedCamera = new GameCamera(this, GraphicsDevice.Viewport.ToVector(), 2, new Vector3(0.0f, 0.0f, 1.0f));


            // load GUI related stuff
            spriteFont = Content.Load<SpriteFont>("fonts/Geo");
            headlineFont = Content.Load<SpriteFont>("fonts/headline");
            scriptFont = Content.Load<SpriteFont>("fonts/script");
            menuButtons = Content.Load<Texture2D>("textures/menuButtons");

            // create tree collection
            treeCollection = new TreeCollection(this);
            treeCollection.Load();
            treeCollection.Reset();

            // create seed collection
            seedCollection = new SeedCollection(this);
            seedCollection.Load();
            seedCollection.Reset();
            CreateRandomSeeds(NUM_INITIAL_SEEDS, treeCollection.trees[0]);

            // create fairy collection
            fairyCollection = new FairyCollection(this);
            fairyCollection.Load(playerTexture);
            fairyCollection.Reset();
            
            /*
             spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied, null, null, null, null,
                               GameCamera.CurrentCamera.screenTransform);
                
             foreground.Draw(this, gameTime, i);
            */            

            // reset "The Void"
            ResetVoids(1.0f);

            this.State = GameState.INTRO;
        }
Ejemplo n.º 2
0
        public Tree(TreeCollection coll, Vector3 pos, TreeType type, bool isBlueprint, String preferredName)
        {
            position = pos;
            treeType = type;
            parentCollection = coll;
            fruitSize = new Vector2(parentCollection.fruitTexture.Width, parentCollection.fruitTexture.Height);
            texture = parentCollection.textures[(int)treeType];
            if (treeType != TreeType.BASE)
            {
                deadTexture = parentCollection.textures[(int)treeType + 4];
                xrayTexture = parentCollection.textures[(int)treeType + 8];
            }
            else
            {
                deadTexture = xrayTexture = texture;
            }

            screenSize = new Vector2(texture.Width, texture.Height);
            if (preferredName == "")
                name = names[random.Next(names.Length - 1)];
            else
                name = preferredName;

            if (treeType == TreeType.BASE)
            {
                offset = new Vector2(-0.5f * screenSize.X - 20, -screenSize.Y + 210.0f);
            }
            else
            {
                offset = new Vector2(-0.5f * screenSize.X, -screenSize.Y + 64.0f);
            }
            growth = 0.1f;
            status = TreeStatus.SEED;
            groundHeight = parentCollection.game.world.getHeigth(position.X);

            if (isBlueprint)
            {
                status = TreeStatus.BLUEPRINT;
                position.Y = groundHeight;
            }

            switch (treeType)
            {
                case TreeType.BASE:
                    position.Y = groundHeight;
                    status = TreeStatus.MATURE;
                    growth = 1.0f;
                    fruitTime = 15.0f;
                    resistance = 1.0f;
                    lifeSpan = 0.0f;
                    price = 0;
                    descriptionLines[0] = "The Tree of Light";
                    descriptionLines[1] = "Protect it at any cost.";
                    break;
                case TreeType.FIGHTER:
                    growthTime = 8.0f;
                    fruitTime = 20.0f;
                    resistance = 0.4f;
                    lifeSpan = 60.0f;
                    price = 3;
                    descriptionLines[0] = "Soldier Tree";
                    descriptionLines[1] = "Light but defensive tree.";
                    break;
                case TreeType.MOTHER:
                    growthTime = 15.0f;
                    fruitTime = 5.0f;
                    resistance = 0.6f;
                    lifeSpan = 80.0f;
                    price = 8;
                    descriptionLines[0] = "Producer Tree";
                    descriptionLines[1] = "Spawns many Souls.";
                    break;
                case TreeType.PAWN:
                    growthTime = 5.0f;
                    fruitTime = 7.0f;
                    resistance = 0.6f;
                    lifeSpan = 25.0f;
                    price = 2;
                    descriptionLines[0] = "Common Tree";
                    descriptionLines[1] = "Cheap jack of all trades.";
                    break;
                case TreeType.TANK:
                    growthTime = 25.0f;
                    fruitTime = 25.0f;
                    resistance = 0.3f;
                    lifeSpan = 130.0f;
                    price = 10;
                    descriptionLines[0] = "Defender Tree";
                    descriptionLines[1] = "Slow-growing heavy defender.";
                    break;
            }

            descriptionLines[2] = "Price: " + price.ToString() + " souls";

            // create first seed position
            if (!isBlueprint && status == TreeStatus.MATURE)
            {
                nextSeedPosition = GetNextSeedPosition();
            }
        }