Inheritance: Microsoft.Xna.Framework.DrawableGameComponent
Example #1
0
 public MSVolunteer(Vector3 position, Node path_to_mobber, MSUnit target, MSTower office, MSMap map, float initRotation)
     : base(position, path_to_mobber, map, false, initRotation)
 {
     this.target = target;
     this.office = office;
     this.isGoingToMobber = true;
 }
Example #2
0
        public MSMobber(Vector3 position, Node path, MSMap map, MSMilleniumDevelopmentGoal concern, float initRotation)
            : base(position, path, map, false, initRotation)
        {
            mobList = new List<MSMobber>();
            this.concern = concern;
            string moodFaceAssetName = "";
            switch (concern)
            {
                case MSMilleniumDevelopmentGoal.POVERTY:
                    moodFaceAssetName = "Moods/Hunger";
                    break;
                case MSMilleniumDevelopmentGoal.EDUCATION:
                    moodFaceAssetName = "Moods/Education";
                    break;
                case MSMilleniumDevelopmentGoal.GENDER_EQUALITY:
                    moodFaceAssetName = "Moods/Equality";
                    break;
                case MSMilleniumDevelopmentGoal.CHILD_HEALTH:
                    moodFaceAssetName = "Moods/Children";
                    break;
                case MSMilleniumDevelopmentGoal.MATERNAL_HEALTH:
                    moodFaceAssetName = "Moods/Maternity";
                    break;
                case MSMilleniumDevelopmentGoal.HIV_AIDS:
                    moodFaceAssetName = "Moods/Health";
                    break;
                case MSMilleniumDevelopmentGoal.ENVIRONMENT:
                    moodFaceAssetName = "Moods/Environment";
                    break;
                case MSMilleniumDevelopmentGoal.GLOBAL_PARTNERSHIP:
                    moodFaceAssetName = "Moods/Partnership";
                    break;
            }

            Vector3 screenProjection = Game.GraphicsDevice.Viewport.Project(Position, MSCamera.GetInstance().ProjectionMatrix, MSCamera.GetInstance().GetView(), Matrix.Identity);
            moodFace = new MSImageHolder(new Rectangle((int)screenProjection.X - 50, (int)screenProjection.Y - 50, 50, 50), Game.Content.Load<Texture2D>(moodFaceAssetName), MoodSwing.GetInstance().SpriteBatch, Game);
        }
Example #3
0
 public MSWorker(Vector3 position, Node path, MSChangeableBuilding to_build, MSMap map, float initRotation)
     : base(position, path, map, false, initRotation)
 {
     toBuild = to_build;
 }
Example #4
0
        public void sentinel(MSMap map, MSUnitHandler unitHandler)
        {
            if (capacity > 0 && this.State == MSChangeableBuildingState.IDLE)
            {
                for (int i = 0; i < unitHandler.Units.Count; i++)
                {
                    MSUnit unit = unitHandler.Units[i];
                    if (unit is MSMobber && !targetList.Contains(unit) )
                    {
                        Vector2 targetTileCoords = unit.TileCoordinate;
                        //int distance = Math.Abs(Row - (int)targetTileCoords.X) + Math.Abs(Column - (int)targetTileCoords.Y);
                        MS3DTile tile = (unit as MSMobber).Map.MapArray[(int)targetTileCoords.X, (int)targetTileCoords.Y];

                        Node path =
                            (MoodSwing.GetInstance().CurrentScreen as MSDistrictScreen).Map.GetPath(TileCoordinate, targetTileCoords);

                        int distance = 0;
                        while (path.next != null)
                        {
                            distance++;
                            path = path.next;
                        }

                        if (tile is MSRoad &&
                            distance <= Stats.GetRange())
                        {
                            MSMilleniumDevelopmentGoal goal = (unit as MSMobber).Concern;
                            if (Stats.GetEffectiveness(goal) == true)
                            {
                                capacity--;

                                /*unitHandler.Units[i] = new MSCitizen
                                (
                                    unit.Position,
                                    unit.Path,
                                    unit.Map,
                                    false,
                                    unit.Rotation
                                );

                                unit = unitHandler.Units[i];*/
                                //unit.IsStopped = true;

                                MSUnitHandler.GetInstance().SendVolunteer(map, unit, this);
                                targetList.Add(unit);
                                //MSMoodManager.GetInstance().TakeHealth();
                                //MSMoodManager.GetInstance().AddMDGScore(goal);

                            }
                            break;
                        }
                    }
                }
            }
        }
Example #5
0
 public MSCitizen(Vector3 position, Node path, MSMap map, bool is_mobbable, float initRotation)
     : base(position, path, map, is_mobbable, initRotation)
 {
     rand = MSRandom.Instance.GetUniform();
 }
Example #6
0
        public MSDistrictScreen(DistrictName district, MoodSwing game)
            : base(game.Content.Load<Texture2D>("districtmap"), 0, 0, 0, 0, game.SpriteBatch, game)
        {
            gameTime = 0;
            lastTotalRunTime = 0;

            this.name = district;
            String filename = "";
            if (district == DistrictName.FEAR)
            {
                filename = @"Content\smallMap.txt";
                districtName = "small";
                ultiGoal = 3;
            }
            else if (district == DistrictName.SADNESS)
            {
                filename = @"Content\mediumMap.txt";
                districtName = "medium";
                ultiGoal = 6;
            }
            else if (district == DistrictName.ANGER)
            {
                filename = @"Content\largeMap.txt";
                districtName = "large";
                ultiGoal = 8;
            }
            map = new MSMap(filename);

            MSCamera.initialize((game as MoodSwing).GraphicsDevice.Viewport,
                MSDistrictHall.getInstance().Position, MSDistrictHall.getInstance().Rotation);
            //citizensList = new List<MSCitizen>();
            unitHandler = MSUnitHandler.Restart();
            moodManager = MSMoodManager.GetInstance();
            MSMoodManager.Reset();
            resourceManager = MSResourceManager.GetInstance();
            MSResourceManager.instantiate(1000, map.InitialVolunteerCenters);

            foreach (MS3DTile tile in map.MapArray)
            {
                tile.LightSource = map.LightSource;
            }

            blackOutPanel = new MSPanel
            (
                game.Content.Load<Texture2D>("BlackOut"),
                BoundingRectangle,
                null,
                Shape.RECTANGULAR,
                spriteBatch,
                game
            );
            blackOutPanel.Visible = false;
            AddComponent(blackOutPanel);

            MSToolTip idleVolunteersToolTip = new MSToolTip
            (
                null,
                new Rectangle(52, 25, 50, 14),
                SpriteBatch,
                Game
            );
            MSPanel idleVolunteersPanel = new MSPanel
            (
                null,
                new Rectangle(52, 25, 50, 14),
                idleVolunteersToolTip,
                Shape.RECTANGULAR,
                SpriteBatch,
                Game
            );
            idleVolunteers = new MSTextField
            (
                "0",
                new Rectangle(82, 25, 20, 14),
                null,
                null,
                4,
                game.Content.Load<SpriteFont>("TopPanel"),
                Color.White,
                spriteBatch,
                game
            );
            idleVolunteersPanel.AddComponent(idleVolunteers);
            idleVolunteersToolTip.AddComponent(new MSWrappingLabel
            (
                new Point(82, 39),
                "Idle Volunteers",
                Game.Content.Load<SpriteFont>("ToolTipFont"),
                Color.White,
                Game.Content.Load<Texture2D>("BlackOut"),
                3, 3, 3, 3, null, null,
                SpriteBatch,
                Game
            ));

            MSToolTip totalVolunteersToolTip = new MSToolTip
            (
                null,
                new Rectangle(152, 25, 80, 14),
                SpriteBatch,
                Game
            );
            MSPanel totalVolunteersPanel = new MSPanel
            (
                null,
                new Rectangle(152, 25, 80, 14),
                totalVolunteersToolTip,
                Shape.RECTANGULAR,
                SpriteBatch,
                Game
            );
            totalVolunteers = new MSTextField(
                "0/0",
                new Rectangle(192, 34, 40, 14),
                null,
                null,
                9,
                game.Content.Load<SpriteFont>("TopPanel"),
                Color.White,
                spriteBatch,
                game);
            totalVolunteersPanel.AddComponent(totalVolunteers);
            totalVolunteersToolTip.AddComponent(new MSWrappingLabel
            (
                new Point(192, 48),
                "Total Volunteers/Volunteer Limit",
                Game.Content.Load<SpriteFont>("ToolTipFont"),
                Color.White,
                Game.Content.Load<Texture2D>("BlackOut"),
                3, 3, 3, 3, null, null,
                SpriteBatch,
                Game
            ));

            MSToolTip fundsToolTip = new MSToolTip
            (
                null,
                new Rectangle(262, 44, 150, 20),
                SpriteBatch,
                Game
            );
            MSPanel fundsPanel = new MSPanel
            (
                null,
                new Rectangle(262, 44, 150, 20),
                fundsToolTip,
                Shape.RECTANGULAR,
                SpriteBatch,
                Game
            );
            funds = new MSTextField
            (
                "0",
                new Rectangle(332, 44, 80, 20),
                null,
                null,
                8,
                game.Content.Load<SpriteFont>("TopPanel"),
                Color.White,
                spriteBatch,
                game
            );
            fundsPanel.AddComponent(funds);
            fundsToolTip.AddComponent(new MSWrappingLabel
            (
                new Point(332, 64),
                "Funds",
                Game.Content.Load<SpriteFont>("ToolTipFont"),
                Color.White,
                Game.Content.Load<Texture2D>("BlackOut"),
                3, 3, 3, 3, null, null,
                SpriteBatch,
                Game
            ));

            MSPanel topPanelBack = new MSPanel
            (
                Game.Content.Load<Texture2D>("GamePanel/WhiteBG"),
                new Rectangle(0, 0, 1024, 91),
                null,
                Shape.AMORPHOUS,
                SpriteBatch,
                Game
            );

            AddComponent(topPanelBack, Alignment.TOP_CENTER);

            MSPanel topPanel = new MSPanel
            (
                Game.Content.Load<Texture2D>("GamePanel/TopPanel"),
                new Rectangle(0, 0, 1024, 91),
                null,
                Shape.AMORPHOUS,
                SpriteBatch,
                Game
            );

            topPanel.AddComponent(idleVolunteersPanel);
            topPanel.AddComponent(totalVolunteersPanel);
            topPanel.AddComponent(fundsPanel);

            AddComponent(topPanel, Alignment.TOP_CENTER);

            mainMenuButton = new MSButton(
                null,
                new OpenExitConfirmation(OpenExitConfirmation.ExitType.ToMainMenu),
                new Rectangle(403, 92, 226, 57),
                game.Content.Load<Texture2D>("GamePanel/MainMenu"),
                game.Content.Load<Texture2D>("GamePanel/mainmenuclicked"),
                game.Content.Load<Texture2D>("GamePanel/mainmenuhovered"),
                null,
                Shape.AMORPHOUS,
                spriteBatch,
                game);

            optionsButton = new MSButton(
                null,
                OpenOptionsScreen.GetInstance(),
                new Rectangle(431, 151, 237, 57),
                game.Content.Load<Texture2D>("GamePanel/Options"),
                game.Content.Load<Texture2D>("GamePanel/optionsclicked"),
                game.Content.Load<Texture2D>("GamePanel/optionshovered"),
                null,
                Shape.AMORPHOUS,
                spriteBatch,
                game);

            exitButton = new MSButton(
                null,
                new OpenExitConfirmation(OpenExitConfirmation.ExitType.ToWindows),
                new Rectangle(460, 210, 277, 57),
                game.Content.Load<Texture2D>("GamePanel/quit"),
                game.Content.Load<Texture2D>("GamePanel/quitclicked"),
                game.Content.Load<Texture2D>("GamePanel/quithovered"),
                null,
                Shape.AMORPHOUS,
                spriteBatch,
                game);

            AddComponent(mainMenuButton);
            AddComponent(optionsButton);
            AddComponent(exitButton);

            mainMenuButton.Visible = false;
            optionsButton.Visible = false;
            exitButton.Visible = false;

            openInGameMenu = new MSAnimatingButton(
                   null,
                   new OpenInGameMenu(),
                   new Rectangle(465, 25, 111, 110),
                   game.Content.Load<Texture2D>("GamePanel/Logo"),
                   game.Content.Load<Texture2D>("GamePanel/LogoClicked"),
                   game.Content.Load<Texture2D>("GamePanel/LogoHovered"),
                   Color.White,
                   null,
                   Shape.CIRCULAR,
                   SpriteBatch,
                   Game);
            openInGameMenu.UnclickPosition = new SwingButtonOpenMovement();
            openInGameMenu.UnclickTimerLimit = 12;

            closeInGameMenu = new MSAnimatingButton(
                   null,
                   new CloseInGameMenu(),
                   new Rectangle(639, 235, 111, 110),
                   game.Content.Load<Texture2D>("GamePanel/Logo"),
                   game.Content.Load<Texture2D>("GamePanel/LogoClicked"),
                   game.Content.Load<Texture2D>("GamePanel/LogoHovered"),
                   Color.White,
                   null,
                   Shape.CIRCULAR,
                   SpriteBatch,
                   Game);

            closeInGameMenu.UnclickPosition = new SwingButtonCloseMovement();
            closeInGameMenu.UnclickTimerLimit = 12;
            closeInGameMenu.Visible = false;

            AddComponent(closeInGameMenu);
            AddComponent(openInGameMenu);

            AddComponent(moodManager.PovertyProgressBar);
            AddComponent(moodManager.EducationProgressBar);
            AddComponent(moodManager.GenderEqualityProgressBar);
            AddComponent(moodManager.ChildHealthProgressBar);
            AddComponent(moodManager.MaternalHealthProgressBar);
            AddComponent(moodManager.HivAidsProgressBar);
            AddComponent(moodManager.EnvironmentProgressBar);
            AddComponent(moodManager.GlobalPartnershipProgressBar);

            MSImageHolder translucentOverlay = new MSImageHolder
            (
                new Rectangle(0, 0, 1024, 91),
                Game.Content.Load<Texture2D>("GamePanel/translucent"),
                SpriteBatch,
                Game
            );

            AddComponent(translucentOverlay);

            Paused = false;
            MSStory.Init(district);
            load();
        }
Example #7
0
        public void Update(MSMap map)
        {
            List<MSUnit> toRemove = new List<MSUnit>();
            foreach (MSMobParam mp in this.mobTypeParam)
            {
                mp.incrTimer();
            }
            for (int i = 0; i < units.Count; i++)
            {
                MSUnit unit = units[i];
                if (!unit.DestinationReached)
                    unit.Walk(map.MapArray, units);

                else
                    toRemove.Add(unit);
            }

            foreach (MSUnit person in toRemove)
            {
                units.Remove(person);
                person.Dispose();
            }

            for (int i = 0; i < units.Count; i++)
            {
                int rnd = MSRandom.Instance.GetUniformInt(MAX_PROBABILITY);

                if (rnd <= MOB_RECRUIT_RATE && units[i].IsMobbable)
                {
                    foreach (MSUnit p in units)
                    {
                        if (p is MSMobber)
                        {
                            if (Vector3.Distance(units[i].Position, p.Position) <= MOB_RECRUIT_DISTANCE)
                            {
                                units[i] = new MSMobber(units[i].Position, p.Path, map, (p as MSMobber).Concern, p.Rotation);
                                units[i].Follow(p);
                                break;

                            }
                        }
                    }
                }
            }
        }
Example #8
0
 public void VolunteerCitizen(MSMap map)
 {
     MS3DTile bldg = map.GetRandomCitizenSource();
     MS3DTile center = map.GetNearestVolunteerCenter(bldg);
     Node path = map.GetPath(bldg.TileCoordinate, center.TileCoordinate);
     MSVolunteeringCitizen v = new MSVolunteeringCitizen(bldg.Position + MSUnit.UNITZ_POSITION, path, map, 0);
     units.Add(v);
 }
Example #9
0
        public void TryForBaby(MSMap map)
        {
            List<MSUnit> mobbers = new List<MSUnit>();

            for (int i = 0; i < 9; i++)
            {
                MSMobParam mp = this.mobTypeParam[i];
                int rnd = MSRandom.Instance.GetUniformInt(100);
                if (rnd < mp.getProbability())
                {
                    System.Console.WriteLine("SUCCESS");
                    MSUnit person;

                    MSUnchangeableBuilding source = map.GetRandomCitizenSource();

                    MSUnchangeableBuilding sink;
                    do
                    {
                        sink = map.GetRandomCitizenSource();
                    } while (source == sink);

                    Vector2 start = new Vector2(source.Row, source.Column);
                    Vector2 end = new Vector2(sink.Row, sink.Column);

                    MSMilleniumDevelopmentGoal? mdg = this.getGoal(i);

                    if (mdg != null)
                    {
                        MSMilleniumDevelopmentGoal mobmdg = (MSMilleniumDevelopmentGoal)mdg;
                        person = new MSMobber(
                                map.MapArray[(int)start.X, (int)start.Y].Position + MSUnit.UNITZ_POSITION,
                                map.GetPath(start, MSDistrictHall.getInstance().TileCoordinate), map, mobmdg, 0);
                    }
                    else
                    {
                        Node path = map.GetPath(start, end);
                        person = new MSCitizen(
                            map.MapArray[(int)start.X, (int)start.Y].Position + MSUnit.UNITZ_POSITION,
                            path, map, true, 0);
                    }

                    if (person != null)
                    {
                        if (mdg != null) units.Add(person);
                        else mobbers.Add(person);
                    }
                }
            }

            if( mobbers.Count > 0 )
                units.Add(mobbers.ElementAt<MSUnit>(MSRandom.Instance.GetUniformInt(mobbers.Count)));
        }
Example #10
0
        public void SendWorkers(MSMap map, MSChangeableBuilding bldg, int qty)
        {
            MSVolunteerCenter center = map.GetNearestVolunteerCenter(bldg);
            Node path = map.GetPath(center.TileCoordinate, bldg.TileCoordinate);

            for (int i = 0; i < qty; i++)
            {
                MSWorker worker = new MSWorker(center.Position + MSUnit.UNITZ_POSITION, path, bldg, map, 0);
                units.Add(worker);
            }
        }
Example #11
0
        public void SendVolunteer(MSMap map, MSUnit unit, MSTower office)
        {
            Node path1 = map.GetPath(new Vector2(office.Row, office.Column), unit.TileCoordinate);

            Node pathEnd = path1;
            while (pathEnd.next != null)
            {
                pathEnd = pathEnd.next;
            }
            pathEnd.next = unit.Path;

            MSVolunteer volunteer = new MSVolunteer
            (
                office.Position + MSUnit.UNITZ_POSITION,
                path1,
                unit,
                office,
                map,
                0
            );

            MSUnitHandler.GetInstance().AddUnit(volunteer);
        }
Example #12
0
 public void load(StreamReader sr, MSMap map)
 {
     int volunteerCount = Int32.Parse(sr.ReadLine());
     for (int i = 0; i < 0; i++)
     {
         this.VolunteerCitizen(map);
     }
     foreach (MSMobParam mp in this.mobTypeParam)
     {
         mp.timer = Int32.Parse(sr.ReadLine());
     }
 }
 public MSVolunteeringCitizen(Vector3 position, Node path, MSMap map, float initRotation)
     : base(position, path, map, false, initRotation)
 {
 }