예제 #1
0
        public void drawHex(Vector2 position, Color color, SpriteBatch spritebatch)
        {
            Rectangle pixelRectangle = new Rectangle((int)(this.position.X + position.X * hexsize) - 18,
                                                     (int)(this.position.Y + (hexsize * map.getPlanelength() - position.Y * hexsize - 1) - (position.X % 2) * (0.5f * hexsize)) + 18, hexsize, hexsize);

            spritebatch.Draw(Vars_Func.getPixel(), pixelRectangle, color);
        }
예제 #2
0
        override public void DrawModel(Camera camera, Vector3 drawPosition, Color drawColor, bool isEnlightend, float lightPower)
        {
            if (typ == Vars_Func.CreatureTyp.HQCreatur)
            {
                tempPosition = drawPosition;
                drawPosition = new Vector3(drawPosition.X, drawPosition.Y, drawPosition.Z + Vars_Func.getCreatureParams(typ).X);
                Matrix modelMatrix = Matrix.Identity *
                                     Matrix.CreateScale(Vars_Func.getCreatureParams(typ).Y) *
                                     Matrix.CreateRotationX(Vars_Func.getCreatureParams(typ).Z) *
                                     Matrix.CreateRotationY(0) *
                                     Matrix.CreateRotationZ(camera.Rotation) *
                                     Matrix.CreateTranslation(drawPosition);
                this.model.Color = drawColor;
                this.model.Draw(camera, modelMatrix, !(drawColor.Equals(Color.White)), isEnlightend, lightPower);

                drawPosition = new Vector3(drawPosition.X, drawPosition.Y, drawPosition.Z + Vars_Func.getCreatureParams(typ).X + tempZ);
                Matrix mouthMatrix = Matrix.Identity *
                                     Matrix.CreateScale(Vars_Func.getCreatureParams(typ).Y) *
                                     Matrix.CreateRotationX(Vars_Func.getCreatureParams(typ).Z) *
                                     Matrix.CreateRotationY(0) *
                                     Matrix.CreateRotationZ(camera.Rotation) *
                                     Matrix.CreateTranslation(drawPosition);
                Vars_Func.getHQMouthModel().Color = drawColor;
                Vars_Func.getHQMouthModel().Draw(camera, mouthMatrix, !(drawColor.Equals(Color.White)), isEnlightend, lightPower);
            }
            else
            {
                if (currentState == Vars_Func.CreatureState.Fighting)
                {
                    drawPosition = fightPosition;
                }
                else if (currentState == Vars_Func.CreatureState.Starting)
                {
                    drawPosition = startPosition;
                }
                else
                {
                    drawPosition = tempPosition;
                }

                drawPosition = new Vector3(drawPosition.X, drawPosition.Y, drawPosition.Z + Vars_Func.getCreatureParams(typ).X);
                Matrix modelMatrix = Matrix.Identity *
                                     Matrix.CreateScale(Vars_Func.getCreatureParams(typ).Y) *
                                     Matrix.CreateRotationX(Vars_Func.getCreatureParams(typ).Z) *
                                     Matrix.CreateRotationY(0) *
                                     Matrix.CreateRotationZ(degree) *
                                     Matrix.CreateTranslation(drawPosition);

                //Vars_Func.getCreatureModell(typ).Color = drawColor;
                //Vars_Func.getCreatureModell(typ).Draw(camera, modelMatrix);
                this.model.Color = drawColor;
                this.model.Draw(camera, modelMatrix, !(drawColor.Equals(Color.White)), isEnlightend, lightPower);
                Vars_Func.getCreatureShadow(typ).Draw(camera, modelMatrix, !(drawColor.Equals(Color.White)), isEnlightend, lightPower);
            }
        }
예제 #3
0
        override public void DrawModel(Renderer.Camera camera, Vector3 drawPosition, Color drawColor, bool isEnlightend, float lightPower)
        {
            drawPosition = new Vector3(drawPosition.X, drawPosition.Y, drawPosition.Z + Vars_Func.getNestParams(typ).X);

            Matrix modelMatrix = Matrix.Identity *
                                 Matrix.CreateScale(Vars_Func.getNestParams(typ).Y) *
                                 Matrix.CreateRotationX(Vars_Func.getNestParams(typ).Z) *
                                 Matrix.CreateRotationY(0) *
                                 Matrix.CreateRotationZ(0) *
                                 Matrix.CreateTranslation(drawPosition);

            Vars_Func.getNestModell(typ).Color = drawColor;
            Vars_Func.getNestModell(typ).Draw(camera, modelMatrix, !(drawColor.Equals(Color.White)), isEnlightend, lightPower / 2);


            if (typ == Vars_Func.NestTyp.Farm)
            {
                Vars_Func.getFarmInput().Color = drawColor;
                float   zValue      = MathHelper.Lerp(0.3f, -0.1f, ((float)(Player.Food) / 3000));
                Vector3 farmPostion = new Vector3(drawPosition.X, drawPosition.Y, drawPosition.Z - zValue);
                Matrix  farmMatrix  = Matrix.Identity *
                                      Matrix.CreateScale(Vars_Func.getNestParams(typ).Y) *
                                      Matrix.CreateRotationX(Vars_Func.getNestParams(typ).Z) *
                                      Matrix.CreateRotationY(0) *
                                      Matrix.CreateRotationZ(0) *
                                      Matrix.CreateTranslation(farmPostion);
                Vars_Func.getFarmInput().Draw(camera, farmMatrix, !(drawColor.Equals(Color.White)), isEnlightend, lightPower / 2);
            }

            else if (typ == Vars_Func.NestTyp.Temple)
            {
                Vars_Func.getTempelBath().Color  = drawColor;
                Vars_Func.getTempelStone().Color = drawColor;

                float zRoationSpeed = MathHelper.Lerp(0.1f, 1, ((float)(Player.Mana) / 30000));
                rotationSpeed += zRoationSpeed;

                Matrix tempelMatrix = Matrix.Identity *
                                      Matrix.CreateScale(Vars_Func.getNestParams(typ).Y) *
                                      Matrix.CreateRotationX(Vars_Func.getNestParams(typ).Z) *
                                      Matrix.CreateRotationY(0) *
                                      Matrix.CreateRotationZ(rotationSpeed) *
                                      Matrix.CreateTranslation(drawPosition);
                Vars_Func.getTempelStone().Draw(camera, tempelMatrix, !(drawColor.Equals(Color.White)), isEnlightend, lightPower / 2);

                Vector3 tempelBathPosition = new Vector3(drawPosition.X, drawPosition.Y, drawPosition.Z + 1f);
                Matrix  tempelBathMatrix   = Matrix.Identity *
                                             Matrix.CreateScale(10) *
                                             Matrix.CreateRotationX(Vars_Func.getNestParams(typ).Z) *
                                             Matrix.CreateRotationY(0) *
                                             Matrix.CreateRotationZ(0) *
                                             Matrix.CreateTranslation(tempelBathPosition);
                Vars_Func.getTempelBath().Draw(camera, tempelBathMatrix, !(drawColor.Equals(Color.White)), isEnlightend, lightPower / 2);
            }
        }
예제 #4
0
        override public void DrawModel(Camera camera, Vector3 drawPosition, Color drawColor, bool isEnlightend, float lightPower)
        {
            Matrix modelMatrix = Matrix.Identity *
                                 Matrix.CreateScale(1) *
                                 Matrix.CreateRotationX(0) *
                                 Matrix.CreateRotationY(0) *
                                 Matrix.CreateRotationZ(0) *
                                 Matrix.CreateTranslation(drawPosition);

            Vars_Func.getUpgradeModell(typ).Color = drawColor;
            Vars_Func.getUpgradeModell(typ).Draw(camera, modelMatrix, !(drawColor.Equals(Color.White)), isEnlightend, lightPower);
        }
예제 #5
0
        protected override void Initialize()
        {
            gamestate         = Vars_Func.GameState.StartMenu;
            hexagonSideLength = 1;               //dont change
            mapDrawWidth      = 10;              //dont go over 15
            planeLength       = 50;              //need an even number!
            minimapSize       = 5 * planeLength; //in pixel
            frameTimeCounter  = 0;
            frames            = 0;
            drawFrame         = 0;
            updateTimeCounter = 0;
            updates           = 0;
            drawUpdates       = 0;
            showIngameMenu    = false;
            buttonIsPressed   = false;
            reinitializeDone  = false;
            timeCounter       = 0.0f;
            minDelayTime      = 100.0f;

            Vars_Func.loadContent(Content);
            map = new Map(planeLength, Logic.Vars_Func.HexTyp.Sand, true, hexagonSideLength);
            Mapgenerator.generateMap(map, planeLength, (int)(planeLength / 10), (int)(planeLength / 5), false);

            //cameraposition HQ.X * 1.5, HQ.Y * 1.75
            camera = new Camera(new Vector3((map.HQPosition.X * 1.5f) + 1, (map.HQPosition.Y * 1.75f) - 10 + 0.875f, 11), new Vector3((map.HQPosition.X * 1.5f) + 1, (map.HQPosition.Y * 1.75f) + 0.875f, 0),
                                Vector3.UnitZ, GraphicsDevice.Viewport.AspectRatio, 0.5f, 1000.0f, planeLength, hexagonSideLength);
            view          = camera.View;
            projection    = camera.Projection;
            keyboard      = Keyboard.GetState();
            mouseState    = Mouse.GetState();
            mousePosition = Vars_Func.mousepos(GraphicsDevice, mouseState, projection, view);


            minimap = new Minimap(map, new Vector2(graphics.PreferredBackBufferWidth - minimapSize, 0), new Vector2(minimapSize, minimapSize));
            BasicGUI.createGUI();
            StartMenu_GUI.createGUI();
            MainMenu_GUI.createGUI();
            Highscore_GUI.createGUI();
            Setting_GUI.createGUI();
            IngameMenu_GUI.createGUI();
            Confirm_GUI.createGUI();
            GameOver_GUI.createGUI();
            IntroMenu_GUI.createGUI();
            //InsertNameGUI.createGUI();

            base.Initialize();
            Interaction.Game = this;
            reinitializeDone = true;
        }
예제 #6
0
        override public void DrawModel(Camera camera, Vector3 drawPosition, Color drawColor, bool isEnlightend, float lightPower)
        {
            drawPosition = tempPosition;
            drawPosition = new Vector3(drawPosition.X, drawPosition.Y, drawPosition.Z + 0.5f);

            Matrix modelMatrix = Matrix.Identity *
                                 Matrix.CreateScale(0.05f) *
                                 Matrix.CreateRotationX(MathHelper.PiOver2) *
                                 Matrix.CreateRotationY(0) *
                                 Matrix.CreateRotationZ(degree) *
                                 Matrix.CreateTranslation(drawPosition);

            //Vars_Func.getCreatureModell(typ).Color = drawColor;
            //Vars_Func.getCreatureModell(typ).Draw(camera, modelMatrix);
            this.model.Color = drawColor;
            this.model.Draw(camera, modelMatrix, !(drawColor.Equals(Color.White)), isEnlightend, lightPower);
            Vars_Func.getImpShadow().Draw(camera, modelMatrix, !(drawColor.Equals(Color.White)), isEnlightend, lightPower);
        }
예제 #7
0
 public Imp(Vector2 position, Environment.Map map)
 {
     actionTimeCounter = 0;
     hp            = 100;
     damage        = 0;
     thingTyp      = Vars_Func.ThingTyp.Imp;
     this.position = position;
     path          = new Stack <Vector2>();
     map.getHexagonAt(position).Imps.Add(this);
     map.ImpList.Add(this);
     currentJob         = new Job(Vars_Func.ImpJob.Idle);
     this.model         = new CharacterModel(Vars_Func.getImpModell().Model, Vars_Func.getImpModell().AnimationClip);
     updatePlayer       = true;
     currentHex         = map.getHexagonAt(position);
     oldHex             = map.getHexagonAt(position);
     targetHex          = null;
     animationSpeeds    = new float[4];
     animationSpeeds[0] = 2;
     animationSpeeds[1] = 1;
     animationSpeeds[2] = 1;
     animationSpeeds[3] = 1;
 }
예제 #8
0
        public void reinitialize()
        {
            Player.Gold               = 1000;
            Player.Mana               = 2000;
            Player.Food               = 200;
            Player.Score              = 0;
            Spells.SummonImpCost      = 0;
            BasicGUI.SelectedThingTyp = Vars_Func.ThingTyp.length;
            hexagonSideLength         = 1;               //dont change
            mapDrawWidth              = 10;              //dont go over 15
            planeLength               = 50;              //need an even number!
            minimapSize               = 5 * planeLength; //in pixel
            frameTimeCounter          = 0;
            frames            = 0;
            drawFrame         = 0;
            updateTimeCounter = 0;
            updates           = 0;
            drawUpdates       = 0;
            timeCounter       = 0.0f;
            WaveController.restart();

            map = new Map(planeLength, Logic.Vars_Func.HexTyp.Sand, true, hexagonSideLength);
            Mapgenerator.generateMap(map, planeLength, (int)(planeLength / 10), (int)(planeLength / 5), false);

            camera = new Camera(new Vector3((map.HQPosition.X * 1.5f) + 1, (map.HQPosition.Y * 1.75f) - 10 + 0.875f, 11), new Vector3((map.HQPosition.X * 1.5f) + 1, (map.HQPosition.Y * 1.75f) + 0.875f, 0),
                                Vector3.UnitZ, GraphicsDevice.Viewport.AspectRatio, 0.5f, 1000.0f, planeLength, hexagonSideLength);
            view          = camera.View;
            projection    = camera.Projection;
            keyboard      = Keyboard.GetState();
            mouseState    = Mouse.GetState();
            mousePosition = Vars_Func.mousepos(GraphicsDevice, mouseState, projection, view);
            minimap       = new Minimap(map, new Vector2(graphics.PreferredBackBufferWidth - minimapSize, 0), new Vector2(minimapSize, minimapSize));


            base.Initialize();
            Interaction.Game = this;
            GC.Collect();
        }
예제 #9
0
        override public void DrawModel(Renderer.Camera camera, Vector3 drawPosition, Color drawColor, bool isEnlightend, float lightPower)
        {
            Matrix modelMatrix = Matrix.Identity *
                                 Matrix.CreateScale(1) *
                                 Matrix.CreateRotationX(0 /*MathHelper.PiOver2*/) *
                                 Matrix.CreateRotationY(0) *
                                 Matrix.CreateRotationZ(0) *
                                 Matrix.CreateTranslation(drawPosition);

            Logic.Vars_Func.getWallModell(typ).Color = drawColor;
            Texture2D externalText = null;

            float percent = ((float)hp / initHP);

            if (percent <= 0.25f)
            {
                switch (typ)
                {
                case Vars_Func.WallTyp.Stone:
                    externalText = Vars_Func.getWall_RockTexture(2);
                    break;

                case Vars_Func.WallTyp.Gold:
                    externalText = Vars_Func.getWall_GoldTexture(2);
                    break;

                case Vars_Func.WallTyp.Diamond:
                    externalText = Vars_Func.getWall_DiamondTexture(2);
                    break;
                }
            }
            if (percent <= 0.5f)
            {
                switch (typ)
                {
                case Vars_Func.WallTyp.Stone:
                    externalText = Vars_Func.getWall_RockTexture(1);
                    break;

                case Vars_Func.WallTyp.Gold:
                    externalText = Vars_Func.getWall_GoldTexture(1);
                    break;

                case Vars_Func.WallTyp.Diamond:
                    externalText = Vars_Func.getWall_DiamondTexture(1);
                    break;
                }
            }
            if (percent <= 0.75f)
            {
                switch (typ)
                {
                case Vars_Func.WallTyp.Stone:
                    externalText = Vars_Func.getWall_RockTexture(0);
                    break;

                case Vars_Func.WallTyp.Gold:
                    externalText = Vars_Func.getWall_GoldTexture(0);
                    break;

                case Vars_Func.WallTyp.Diamond:
                    externalText = Vars_Func.getWall_DiamondTexture(0);
                    break;
                }
            }
            Logic.Vars_Func.getWallModell(typ).DrawTexture(camera, modelMatrix, externalText, !(drawColor.Equals(Color.White)), isEnlightend, lightPower);
        }
예제 #10
0
        public Creature(Vars_Func.CreatureTyp typ, Vector2 position, Nest home, Vars_Func.ThingTyp allignment, Environment.Map map, int[] upgrades, int startage = 0)
        {
            switch (typ)
            {
            case Vars_Func.CreatureTyp.Beetle:
                this.typ          = typ;
                this.position     = position;
                this.home         = home;
                thingTyp          = allignment;
                size              = 1;
                speed             = 1 + upgrades[2] * 0.2f;
                actionTimeCounter = 0;
                vision            = 4;
                damageTaken       = 0;
                hp          = 200 + upgrades[1] * 100;
                damage      = 10 + upgrades[0] * 4;
                age         = startage;
                maxAge      = 100;
                ageModifire = 1;
                map.getHexagonAt(position).Obj = this;
                map.Creatures.Add(this);
                animationSpeeds    = new float[2];
                animationSpeeds[0] = 2.5f;
                animationSpeeds[1] = 1;
                break;

            case Vars_Func.CreatureTyp.Skeleton:
                this.typ          = typ;
                this.position     = position;
                this.home         = home;
                thingTyp          = allignment;
                size              = 1;
                speed             = 1 + upgrades[2] * 0.2f;
                actionTimeCounter = 0;
                vision            = 4;
                damageTaken       = 0;
                hp          = 100 + upgrades[1] * 50;
                damage      = 15 + upgrades[0] * 6;
                age         = startage;
                maxAge      = 120;
                ageModifire = 1;
                map.getHexagonAt(position).Obj = this;
                map.Creatures.Add(this);
                animationSpeeds    = new float[2];
                animationSpeeds[0] = 2;
                animationSpeeds[1] = 0.8f;
                break;

            case Vars_Func.CreatureTyp.Knight:
                this.typ          = typ;
                this.position     = position;
                this.home         = home;
                thingTyp          = allignment;
                size              = 1;
                speed             = 1;
                actionTimeCounter = 0;
                vision            = 4;
                damageTaken       = 0;
                hp          = 150;
                damage      = 10;
                age         = startage;
                ageModifire = 1;
                map.getHexagonAt(position).Obj = this;
                map.Heroes.Add(this);
                currentState       = Vars_Func.CreatureState.Starting;
                startHex           = map.getHexagonAt(home.Position);
                startLerpCounter   = 0;
                reachGround        = false;
                animationSpeeds    = new float[3];
                animationSpeeds[0] = 2;
                animationSpeeds[1] = 0.8f;
                animationSpeeds[2] = 1;
                break;

            case Vars_Func.CreatureTyp.HQCreatur:
                this.typ          = typ;
                this.position     = position;
                this.home         = home;
                thingTyp          = allignment;
                size              = 1;
                speed             = 1;
                actionTimeCounter = 0;
                vision            = 4;
                damageTaken       = 0;
                hp          = 5000;
                damage      = 500;
                age         = startage;
                ageModifire = 1;
                map.getHexagonAt(position).Obj = this;
                map.Creatures.Add(this);
                map.getHexagonAt(position).IsHQ = true;
                map.getHexagonAt(position).EnlightendHexagon(map);
                currentState       = Vars_Func.CreatureState.PingPong;
                animationSpeeds    = new float[2];
                animationSpeeds[0] = 1;
                animationSpeeds[1] = 1;
                // Some Fireball Test
                //map.getHexagonAt(position).Fireball = Vars_Func.getFireBall();
                break;
            }
            this.model          = new CharacterModel(Vars_Func.getCreatureModell(typ).Model);
            model.AnimationClip = Vars_Func.getCreatureModell(typ).AnimationClip;
            updatePlayer        = true;
            currentHex          = map.getHexagonAt(position);
            oldHex       = map.getHexagonAt(position);
            targetHex    = null;
            oldTargetHex = null;
            tempZ        = 0;
        }
예제 #11
0
        public Nest(Vars_Func.NestTyp typ, Vector2 position, Environment.Map map, Vector2 targetPosition)
        {
            nextUpgradeCost = 100;
            Environment.Hexagon hex = map.getHexagonAt(position);
            if (typ != Vars_Func.NestTyp.Entrance)
            {
                map.Rooms.ElementAt(map.getHexagonAt(position).RoomNumber - 1).NestType   = typ;
                map.Rooms.ElementAt(map.getHexagonAt(position).RoomNumber - 1).RoomObject = this;
            }
            possibleNextNestHexagons = new List <Vector2>();
            nestHexagons             = new List <Vector2>();
            nestHexagons.Add(position);
            switch (typ)
            {
            case Vars_Func.NestTyp.Entrance:
                hex.Building = true;
                hex.Nest     = true;
                map.Entrances.Add(this);
                hex.IsEntrance = true;
                hex.EnlightendHexagon(map);
                map.Light = Vars_Func.getEntranceRayModel();
                thingTyp  = Vars_Func.ThingTyp.Nest;
                break;

            case Vars_Func.NestTyp.Beetle:
                hex.Typ      = Vars_Func.HexTyp.BeetleNest;
                hex.Building = true;
                hex.Nest     = true;
                getsFeeded   = false;
                maxNutrition = 500f;
                nutrition    = 0f;
                upgrades     = new List <Upgrade>();
                thingTyp     = Vars_Func.ThingTyp.Nest;

                for (int i = 0; i < 6; ++i)
                {
                    Vector2 neighbor = hex.Neighbors[i];
                    nestHexagons.Add(neighbor);
                    map.getHexagonAt(neighbor).Typ      = Vars_Func.HexTyp.BeetleNest;
                    map.getHexagonAt(neighbor).Building = true;
                    map.getHexagonAt(neighbor).Nest     = true;
                }
                for (int i = 0; i < 6; ++i)
                {
                    Vector2 neighbor = hex.Neighbors[i];
                    for (int j = 0; j < 6; ++j)
                    {
                        Vector2 nextNeighbor = map.getHexagonAt(neighbor).Neighbors[j];
                        if (!map.getHexagonAt(nextNeighbor).Nest&&
                            map.getHexagonAt(nextNeighbor).RoomNumber == map.getHexagonAt(neighbor).RoomNumber&&
                            !possibleNextNestHexagons.Contains(nextNeighbor))
                        {
                            possibleNextNestHexagons.Add(nextNeighbor);
                        }
                    }
                }
                map.Nests.Add(this);
                break;

            case Vars_Func.NestTyp.Skeleton:
                hex.Typ      = Vars_Func.HexTyp.Graveyard;
                hex.Building = true;
                hex.Nest     = true;
                getsFeeded   = false;
                maxNutrition = 500f;
                nutrition    = 0f;
                upgrades     = new List <Upgrade>();
                thingTyp     = Vars_Func.ThingTyp.Nest;

                for (int i = 0; i < 6; ++i)
                {
                    Vector2 neighbor = hex.Neighbors[i];
                    nestHexagons.Add(neighbor);
                    map.getHexagonAt(neighbor).Typ        = Vars_Func.HexTyp.Graveyard;
                    map.getHexagonAt(neighbor).Building   = true;
                    map.getHexagonAt(neighbor).Nest       = true;
                    map.getHexagonAt(neighbor).GrowObject = Vars_Func.GrowObject.Graveyard;
                }
                for (int i = 0; i < 6; ++i)
                {
                    Vector2 neighbor = hex.Neighbors[i];
                    for (int j = 0; j < 6; ++j)
                    {
                        Vector2 nextNeighbor = map.getHexagonAt(neighbor).Neighbors[j];
                        if (!map.getHexagonAt(nextNeighbor).Nest&&
                            map.getHexagonAt(nextNeighbor).RoomNumber == map.getHexagonAt(neighbor).RoomNumber&&
                            !possibleNextNestHexagons.Contains(nextNeighbor))
                        {
                            possibleNextNestHexagons.Add(nextNeighbor);
                        }
                    }
                }
                map.Nests.Add(this);
                break;

            case Vars_Func.NestTyp.Farm:
                hex.Typ       = Vars_Func.HexTyp.Farm;
                hex.Building  = true;
                hex.Nest      = true;
                nutrition     = 1;
                maxNutrition  = 1;
                thingTyp      = Vars_Func.ThingTyp.Nest;
                food          = 0;
                getsHarvested = false;
                foodCounter   = 0;

                for (int i = 0; i < 6; ++i)
                {
                    Vector2 neighbor = hex.Neighbors[i];
                    nestHexagons.Add(neighbor);
                    map.getHexagonAt(neighbor).Typ        = Vars_Func.HexTyp.Farm;
                    map.getHexagonAt(neighbor).Building   = true;
                    map.getHexagonAt(neighbor).Nest       = true;
                    map.getHexagonAt(neighbor).GrowObject = Vars_Func.GrowObject.Farm;
                }
                for (int i = 0; i < 6; ++i)
                {
                    Vector2 neighbor = hex.Neighbors[i];
                    for (int j = 0; j < 6; ++j)
                    {
                        Vector2 nextNeighbor = map.getHexagonAt(neighbor).Neighbors[j];
                        if (!map.getHexagonAt(nextNeighbor).Nest&&
                            map.getHexagonAt(nextNeighbor).RoomNumber == map.getHexagonAt(neighbor).RoomNumber&&
                            !possibleNextNestHexagons.Contains(nextNeighbor))
                        {
                            possibleNextNestHexagons.Add(nextNeighbor);
                        }
                    }
                }
                map.Farms.Add(this);
                break;

            case Vars_Func.NestTyp.Temple:
                hex.Typ      = Vars_Func.HexTyp.Temple;
                hex.Building = true;
                hex.Nest     = true;
                nutrition    = 1;
                maxNutrition = 1;
                thingTyp     = Vars_Func.ThingTyp.Nest;
                foodCounter  = 0;

                for (int i = 0; i < 6; ++i)
                {
                    Vector2 neighbor = hex.Neighbors[i];
                    nestHexagons.Add(neighbor);
                    map.getHexagonAt(neighbor).Typ        = Vars_Func.HexTyp.Temple;
                    map.getHexagonAt(neighbor).Building   = true;
                    map.getHexagonAt(neighbor).Nest       = true;
                    map.getHexagonAt(neighbor).GrowObject = Vars_Func.GrowObject.Temple;
                }
                for (int i = 0; i < 6; ++i)
                {
                    Vector2 neighbor = hex.Neighbors[i];
                    for (int j = 0; j < 6; ++j)
                    {
                        Vector2 nextNeighbor = map.getHexagonAt(neighbor).Neighbors[j];
                        if (!map.getHexagonAt(nextNeighbor).Nest&&
                            map.getHexagonAt(nextNeighbor).RoomNumber == map.getHexagonAt(neighbor).RoomNumber&&
                            !possibleNextNestHexagons.Contains(nextNeighbor))
                        {
                            possibleNextNestHexagons.Add(nextNeighbor);
                        }
                    }
                }
                map.Temples.Add(this);
                break;
            }
            this.typ            = typ;
            this.position       = position;
            this.targetPosition = targetPosition;
            hex.Obj             = this;
        }
예제 #12
0
        protected override void Draw(GameTime gameTime)
        {
            //Frames per second
            frameTimeCounter += gameTime.ElapsedGameTime.Milliseconds;
            ++frames;
            if (frameTimeCounter >= 1000)
            {
                drawFrame         = frames;
                frames            = 0;
                frameTimeCounter -= 1000;
            }

            GraphicsDevice.Clear(Color.Black);
            effect.View               = camera.View;
            effect.Projection         = camera.Projection;
            effect.VertexColorEnabled = true;
            effect.CurrentTechnique.Passes[0].Apply();
            map.DrawModel(camera, indexOfMiddleHexagon, camera.Target, mapDrawWidth);

            spriteBatch.Begin();

            //if (Interaction.GameState != Vars_Func.GameState.MainMenu &&
            //    Interaction.GameState != Vars_Func.GameState.Highscore &&
            //    Interaction.GameState != Vars_Func.GameState.Tutorial)
            //{
            //    minimap.drawMinimap(spriteBatch, indexOfMiddleHexagon);
            //}
            //GUI.Draw(spriteBatch, font, mouseState, camera, map);
            //GUI.Draw(spriteBatch, font, minimap, indexOfMiddleHexagon);
            ////spriteBatch.DrawString(font, mouseState.X.ToString() + " : " + mouseState.Y.ToString(), new Vector2(20, 200), Color.Black);
            ////spriteBatch.DrawString(font, mousePosition.X.ToString() + " : " + mousePosition.Y.ToString() + " : " + mousePosition.Z.ToString(), new Vector2(20, 220), Color.Black);
            //spriteBatch.DrawString(font, "FPS: " + drawFrame.ToString(), new Vector2(20, 240), Color.Black);
            //spriteBatch.DrawString(font, "UPS: " + drawUpdates.ToString(), new Vector2(20, 260), Color.Black);

            switch (gamestate)
            {
                #region Startmenu
            case Vars_Func.GameState.StartMenu:
                StartMenu_GUI.Draw(spriteBatch, font);
                break;

                #endregion
                #region Mainmenu
            case Vars_Func.GameState.MainMenu:
                // Draw the old one unil menu is ready
                if (!MainMenu_GUI.UpdateReady)
                {
                    StartMenu_GUI.Draw(spriteBatch, font);
                }
                else
                {
                    MainMenu_GUI.Draw(spriteBatch, font);
                }
                break;

                #endregion
                #region Ingame
            case Vars_Func.GameState.Ingame:
                if (reinitializeDone)
                {
                    //minimap.drawMinimap(spriteBatch, indexOfMiddleHexagon);
                    BasicGUI.Draw(spriteBatch, font, minimap, indexOfMiddleHexagon);
                    //spriteBatch.DrawString(font, mouseState.X.ToString() + " : " + mouseState.Y.ToString(), new Vector2(20, 200), Color.Black);
                    //spriteBatch.DrawString(font, mousePosition.X.ToString() + " : " + mousePosition.Y.ToString() + " : " + mousePosition.Z.ToString(), new Vector2(20, 220), Color.Black);
                    //spriteBatch.DrawString(font, "FPS: " + drawFrame.ToString(), new Vector2(20, 240), Color.Black);
                    //spriteBatch.DrawString(font, "UPS: " + drawUpdates.ToString(), new Vector2(20, 260), Color.Black);

                    if (showIngameMenu)
                    {
                        if (!IngameMenu_GUI.UpdateReady)
                        {
                            //Do nothing
                        }
                        else
                        {
                            IngameMenu_GUI.Draw(spriteBatch, font);
                        }
                    }
                }
                else
                {
                    MainMenu_GUI.Draw(spriteBatch, font);
                }
                break;

                #endregion
                #region Highscore
            case Vars_Func.GameState.Highscore:
                if (showIngameMenu)
                {
                    if (!Highscore_GUI.UpdateReady)
                    {
                        IngameMenu_GUI.Draw(spriteBatch, font);
                    }
                    else
                    {
                        Highscore_GUI.Draw(spriteBatch, font);
                    }
                }
                else
                {
                    if (!Highscore_GUI.UpdateReady)
                    {
                        MainMenu_GUI.Draw(spriteBatch, font);
                    }
                    else
                    {
                        Highscore_GUI.Draw(spriteBatch, font);
                    }
                }
                break;

                #endregion
                #region Settings
            case Vars_Func.GameState.Settings:
                if (showIngameMenu)
                {
                    if (!Setting_GUI.UpdateReady)
                    {
                        IngameMenu_GUI.Draw(spriteBatch, font);
                    }
                    else
                    {
                        Setting_GUI.Draw(spriteBatch, font);
                        if (Setting_GUI.UseFullscreen && !this.graphics.IsFullScreen)
                        {
                            this.graphics.ToggleFullScreen();
                        }
                        else if (!Setting_GUI.UseFullscreen && this.graphics.IsFullScreen)
                        {
                            this.graphics.ToggleFullScreen();
                        }
                    }
                }
                else
                {
                    if (!Setting_GUI.UpdateReady)
                    {
                        MainMenu_GUI.Draw(spriteBatch, font);
                    }
                    else
                    {
                        Setting_GUI.Draw(spriteBatch, font);
                        if (Setting_GUI.UseFullscreen && !this.graphics.IsFullScreen)
                        {
                            this.graphics.ToggleFullScreen();
                        }
                        else if (!Setting_GUI.UseFullscreen && this.graphics.IsFullScreen)
                        {
                            this.graphics.ToggleFullScreen();
                        }
                    }
                }
                break;

                #endregion
                #region Confirm
            case Vars_Func.GameState.Confirm:
                if (!Confirm_GUI.UpdateReady)
                {
                    BasicGUI.Draw(spriteBatch, font, minimap, indexOfMiddleHexagon);
                    IngameMenu_GUI.Draw(spriteBatch, font);
                }
                else
                {
                    BasicGUI.Draw(spriteBatch, font, minimap, indexOfMiddleHexagon);
                    Confirm_GUI.Draw(spriteBatch, font);
                }
                break;

                #endregion
                #region GameOver
            case Vars_Func.GameState.GameOver:
                if (!GameOver_GUI.UpdateReady)
                {
                    BasicGUI.Draw(spriteBatch, font, minimap, indexOfMiddleHexagon);
                }
                else
                {
                    BasicGUI.Draw(spriteBatch, font, minimap, indexOfMiddleHexagon);
                    GameOver_GUI.Draw(spriteBatch, font);
                }

                break;

                #endregion
                #region Intro
            case Vars_Func.GameState.Intro:
                if (!IntroMenu_GUI.UpdateReady)
                {
                    MainMenu_GUI.Draw(spriteBatch, font);
                }
                else
                {
                    IntroMenu_GUI.Draw(spriteBatch, font);
                }
                break;

                #endregion
                #region Insert Name After Confirm
            case Vars_Func.GameState.InsertNameConfirm:
                if (!InsertNameGUI.UpdateReady)
                {
                    BasicGUI.Draw(spriteBatch, font, minimap, indexOfMiddleHexagon);
                    Confirm_GUI.Draw(spriteBatch, font);
                }
                else
                {
                    BasicGUI.Draw(spriteBatch, font, minimap, indexOfMiddleHexagon);
                    InsertNameGUI.Draw(spriteBatch, font);
                }
                break;

                #endregion
                #region Insert Name Before Reset
            case Vars_Func.GameState.InserNameReset:
                if (!InsertNameGUI.UpdateReady)
                {
                    BasicGUI.Draw(spriteBatch, font, minimap, indexOfMiddleHexagon);
                    GameOver_GUI.Draw(spriteBatch, font);
                }
                else
                {
                    BasicGUI.Draw(spriteBatch, font, minimap, indexOfMiddleHexagon);
                    InsertNameGUI.Draw(spriteBatch, font);
                }
                break;

                #endregion
                #region Insert Name Before Quit
            case Vars_Func.GameState.InserNameQuit:
                if (!InsertNameGUI.UpdateReady)
                {
                    BasicGUI.Draw(spriteBatch, font, minimap, indexOfMiddleHexagon);
                    GameOver_GUI.Draw(spriteBatch, font);
                }
                else
                {
                    BasicGUI.Draw(spriteBatch, font, minimap, indexOfMiddleHexagon);
                    InsertNameGUI.Draw(spriteBatch, font);
                }
                break;

                #endregion
            default:
                break;
            }
            spriteBatch.Draw(Vars_Func.getCursor(), new Vector2(mouseState.X, mouseState.Y), Color.White);

            spriteBatch.End();

            base.Draw(gameTime);
        }
예제 #13
0
        protected override void Update(GameTime gameTime)
        {
            timeCounter += gameTime.ElapsedGameTime.Milliseconds;

            // updates per second
            updateTimeCounter += gameTime.ElapsedGameTime.Milliseconds;
            ++updates;
            if (updateTimeCounter >= 1000)
            {
                drawUpdates        = updates;
                updates            = 0;
                updateTimeCounter -= 1000;
            }

            //// DON'T TOUCH THIS////
            keyboard       = Keyboard.GetState();
            lastMouseState = mouseState;
            mouseState     = Mouse.GetState();
            //mousePosition = Vars_Func.mousepos(GraphicsDevice, mouseState, projection, view);
            //camera.Update(gameTime, gameTime.ElapsedGameTime.Milliseconds, mouseState);
            //view = camera.View;
            //map.update(gameTime, gameTime.ElapsedGameTime.Milliseconds);
            ////// DON'T TOUCH THIS////

            //indexOfMiddleHexagon = Vars_Func.gridColision(camera.Target, planeLength, hexagonSideLength);
            //Vector2 mouseover = Vars_Func.gridColision(mousePosition, planeLength, hexagonSideLength);

            //Vars_Func.resetHexagonColors(map);

            //wavecontroller.update(gameTime, map);

            //Interaction.Update(gameTime, map, mouseover, mouseState, lastMouseState, keyboard);
            //GUI.update(gameTime, map, mouseState);
            if (Interaction.GameState == Vars_Func.GameState.GameOver)
            {
                gamestate = Vars_Func.GameState.GameOver;
            }

            switch (gamestate)
            {
                #region Startmenu
            case Vars_Func.GameState.StartMenu:
                StartMenu_GUI.update(gameTime, mouseState, keyboard);
                if (timeCounter > minDelayTime)
                {
                    if (StartMenu_GUI.getGUI_Button() != null && StartMenu_GUI.getGUI_Button().Typ == Vars_Func.GUI_Typ.StartButton)
                    {
                        gamestate   = Vars_Func.GameState.MainMenu;
                        timeCounter = 0;
                    }
                }
                break;

                #endregion
                #region Mainmenu
            case Vars_Func.GameState.MainMenu:
                MainMenu_GUI.update(gameTime, mouseState, keyboard);
                Highscore_GUI.restGUI();
                Setting_GUI.restGUI();
                GameOver_GUI.restGUI();
                IntroMenu_GUI.restGUI();
                showIngameMenu = false;

                if (MainMenu_GUI.getGUI_Button() != null)
                {
                    if (timeCounter > minDelayTime)
                    {
                        switch (MainMenu_GUI.getGUI_Button().Typ)
                        {
                        case Vars_Func.GUI_Typ.NewGameButton:
                            reinitialize();
                            //gamestate = Vars_Func.GameState.Ingame;
                            gamestate   = Vars_Func.GameState.Intro;
                            timeCounter = 0;
                            //MainMenu_GUI.restGUI();
                            break;

                        case Vars_Func.GUI_Typ.SettingsButton:
                            gamestate   = Vars_Func.GameState.Settings;
                            timeCounter = 0;
                            break;

                        case Vars_Func.GUI_Typ.HighScoreButton:
                            gamestate   = Vars_Func.GameState.Highscore;
                            timeCounter = 0;
                            break;

                        case Vars_Func.GUI_Typ.QuitButton:
                            timeCounter = 0;
                            this.Exit();
                            break;

                        default: break;
                        }
                    }
                }
                break;

                #endregion
                #region Ingame
            case Vars_Func.GameState.Ingame:
                MainMenu_GUI.restGUI();
                Setting_GUI.restGUI();
                Highscore_GUI.restGUI();
                Confirm_GUI.restGUI();
                GameOver_GUI.restGUI();

                IntroMenu_GUI.restGUI();
                if (keyboard.IsKeyDown(Keys.Tab) && !buttonIsPressed)
                {
                    buttonIsPressed = true;
                    showIngameMenu  = !showIngameMenu;
                }
                if (!keyboard.IsKeyDown(Keys.Tab) && buttonIsPressed)
                {
                    buttonIsPressed = false;
                }

                // Add ingame menu
                if (showIngameMenu)
                {
                    IngameMenu_GUI.update(gameTime, mouseState, keyboard);
                    if (IngameMenu_GUI.getGUI_Button() != null)
                    {
                        switch (IngameMenu_GUI.getGUI_Button().Typ)
                        {
                        case Vars_Func.GUI_Typ.NewGameButton:
                            showIngameMenu = false;
                            IngameMenu_GUI.restGUI();
                            break;

                        case Vars_Func.GUI_Typ.SettingsButton:
                            gamestate = Vars_Func.GameState.Settings;
                            break;

                        case Vars_Func.GUI_Typ.HighScoreButton:
                            gamestate = Vars_Func.GameState.Highscore;
                            break;

                        case Vars_Func.GUI_Typ.StartButton:
                            //Player.saveScore();
                            //reinitialize();
                            gamestate = Vars_Func.GameState.Confirm;
                            break;

                        default: break;
                        }
                    }
                }
                else
                {
                    mousePosition = Vars_Func.mousepos(GraphicsDevice, mouseState, projection, view);
                    camera.Update(gameTime, gameTime.ElapsedGameTime.Milliseconds, mouseState);
                    view = camera.View;

                    map.update(gameTime, gameTime.ElapsedGameTime.Milliseconds, this);
                    //// DON'T TOUCH THIS////
                    indexOfMiddleHexagon = Vars_Func.gridColision(camera.Target, planeLength, hexagonSideLength);
                    Vector2 mouseover = Vars_Func.gridColision(mousePosition, planeLength, hexagonSideLength);

                    Vars_Func.resetHexagonColors(map);

                    WaveController.update(gameTime, map);
                    BasicGUI.update(gameTime, map, mouseState);
                    Interaction.Update(gameTime, map, mouseover, mouseState, lastMouseState, keyboard);
                }
                break;

                #endregion
                #region Highscore
            case Vars_Func.GameState.Highscore:
                Highscore_GUI.update(gameTime, mouseState, keyboard);
                if (showIngameMenu)
                {
                    IngameMenu_GUI.restGUI();
                    if (timeCounter > minDelayTime)
                    {
                        if (Highscore_GUI.getGUI_Button() != null && Highscore_GUI.getGUI_Button().Typ == Vars_Func.GUI_Typ.StartButton)
                        {
                            gamestate   = Vars_Func.GameState.Ingame;
                            timeCounter = 0;
                        }
                    }
                }
                else
                {
                    MainMenu_GUI.restGUI();
                    if (timeCounter > minDelayTime)
                    {
                        if (Highscore_GUI.getGUI_Button() != null && Highscore_GUI.getGUI_Button().Typ == Vars_Func.GUI_Typ.StartButton)
                        {
                            gamestate   = Vars_Func.GameState.MainMenu;
                            timeCounter = 0;
                        }
                    }
                }
                break;

                #endregion
                #region Settings
            case Vars_Func.GameState.Settings:
                Setting_GUI.update(gameTime, mouseState, lastMouseState, keyboard);
                if (showIngameMenu)
                {
                    IngameMenu_GUI.restGUI();
                    if (timeCounter > minDelayTime)
                    {
                        if (Setting_GUI.getGUI_Button() != null && Setting_GUI.getGUI_Button().Typ == Vars_Func.GUI_Typ.StartButton)
                        {
                            gamestate   = Vars_Func.GameState.Ingame;
                            timeCounter = 0;
                        }
                    }
                }
                else
                {
                    MainMenu_GUI.restGUI();
                    if (timeCounter > minDelayTime)
                    {
                        if (Setting_GUI.getGUI_Button() != null && Setting_GUI.getGUI_Button().Typ == Vars_Func.GUI_Typ.StartButton)
                        {
                            gamestate   = Vars_Func.GameState.MainMenu;
                            timeCounter = 0;
                        }
                    }
                }

                break;

                #endregion
                #region Confirm
            case Vars_Func.GameState.Confirm:
                Confirm_GUI.update(gameTime, mouseState, keyboard);
                if (timeCounter > minDelayTime)
                {
                    if (Confirm_GUI.getGUI_Button() != null && Confirm_GUI.getGUI_Button().Typ == Vars_Func.GUI_Typ.NewGameButton)
                    {
                        showIngameMenu = false;
                        IngameMenu_GUI.restGUI();
                        gamestate = Vars_Func.GameState.Ingame;
                        //showIngameMenu = false;
                        //IngameMenu_GUI.restGUI();
                        //gamestate = Vars_Func.GameState.GameOver;
                        timeCounter = 0;
                    }
                    if (Confirm_GUI.getGUI_Button() != null && Confirm_GUI.getGUI_Button().Typ == Vars_Func.GUI_Typ.QuitButton)
                    {
                        Player.saveScore();
                        reinitialize();
                        IntroMenu_GUI.createGUI();
                        MainMenu_GUI.createGUI();
                        Highscore_GUI.createGUI();
                        gamestate = Vars_Func.GameState.MainMenu;
                        //gamestate = Vars_Func.GameState.InsertNameConfirm;
                        //showIngameMenu = false;
                        //IngameMenu_GUI.restGUI();
                        //gamestate = Vars_Func.GameState.Ingame;
                        timeCounter = 0;
                    }
                }
                break;

                #endregion
                #region GameOver
            case Vars_Func.GameState.GameOver:
                GameOver_GUI.update(gameTime, mouseState, keyboard);
                if (timeCounter > minDelayTime)
                {
                    if (GameOver_GUI.getGUI_Button() != null && GameOver_GUI.getGUI_Button().Typ == Vars_Func.GUI_Typ.NewGameButton)
                    {
                        showIngameMenu = false;
                        Player.saveScore();
                        reinitialize();
                        MainMenu_GUI.createGUI();
                        IngameMenu_GUI.restGUI();
                        Highscore_GUI.createGUI();
                        gamestate = Vars_Func.GameState.Ingame;
                        //gamestate = Vars_Func.GameState.InserNameReset;
                        //timeCounter = 0;
                    }

                    if (GameOver_GUI.getGUI_Button() != null && GameOver_GUI.getGUI_Button().Typ == Vars_Func.GUI_Typ.QuitButton)
                    {
                        Player.saveScore();
                        this.Exit();
                        //gamestate = Vars_Func.GameState.InserNameQuit;
                        //timeCounter = 0;
                    }
                }
                break;

                #endregion
                #region Intro
            case Vars_Func.GameState.Intro:
                IntroMenu_GUI.update(gameTime, mouseState, keyboard);
                if (timeCounter > minDelayTime)
                {
                    if (IntroMenu_GUI.getGUI_Button() != null && IntroMenu_GUI.getGUI_Button().Typ == Vars_Func.GUI_Typ.NewGameButton)
                    {
                        MainMenu_GUI.restGUI();
                        reinitialize();
                        Setting_GUI.ShowHelp = true;
                        gamestate            = Vars_Func.GameState.Ingame;
                        timeCounter          = 0;
                    }
                    if (IntroMenu_GUI.getGUI_Button() != null && IntroMenu_GUI.getGUI_Button().Typ == Vars_Func.GUI_Typ.QuitButton)
                    {
                        MainMenu_GUI.restGUI();
                        reinitialize();
                        Setting_GUI.ShowHelp = false;
                        gamestate            = Vars_Func.GameState.Ingame;
                        timeCounter          = 0;
                    }
                }
                break;

                #endregion
                #region Insert Name After Confirm
            case Vars_Func.GameState.InsertNameConfirm:
                InsertNameGUI.update(gameTime, mouseState, keyboard);
                if (timeCounter > minDelayTime)
                {
                    if (InsertNameGUI.getGUI_Button() != null && InsertNameGUI.getGUI_Button().Typ == Vars_Func.GUI_Typ.QuitButton)
                    {
                        //Retrun the player name
                        string PlayerName = InsertNameGUI.getPlayerName();

                        //TODO: pass on to the Player class

                        Player.saveScore();
                        reinitialize();
                        IntroMenu_GUI.createGUI();
                        MainMenu_GUI.createGUI();
                        gamestate   = Vars_Func.GameState.MainMenu;
                        timeCounter = 0;
                    }
                }
                break;

                #endregion
                #region Insert Name Before Reset
            case Vars_Func.GameState.InserNameReset:
                InsertNameGUI.update(gameTime, mouseState, keyboard);
                if (timeCounter > minDelayTime)
                {
                    if (InsertNameGUI.getGUI_Button() != null && InsertNameGUI.getGUI_Button().Typ == Vars_Func.GUI_Typ.QuitButton)
                    {
                        //Retrun the player name
                        string PlayerName = InsertNameGUI.getPlayerName();

                        //TODO: pass on to the Player class

                        showIngameMenu = false;
                        Player.saveScore();
                        reinitialize();
                        MainMenu_GUI.createGUI();
                        IngameMenu_GUI.restGUI();
                        gamestate   = Vars_Func.GameState.Ingame;
                        timeCounter = 0;
                    }
                }
                break;

                #endregion
                #region Insert Name Before Quit
            case Vars_Func.GameState.InserNameQuit:
                InsertNameGUI.update(gameTime, mouseState, keyboard);
                if (timeCounter > minDelayTime)
                {
                    if (InsertNameGUI.getGUI_Button() != null && InsertNameGUI.getGUI_Button().Typ == Vars_Func.GUI_Typ.QuitButton)
                    {
                        timeCounter = 0;
                        //Retrun the player name
                        string PlayerName = InsertNameGUI.getPlayerName();

                        //TODO: pass on to the Player class

                        Player.saveScore();
                        this.Exit();
                    }
                }
                break;

                #endregion
            default:
                break;
            }
            base.Update(gameTime);
        }