Beispiel #1
0
        public void Update(GameTime gameTime)
        {
            elapsedTime += (float)gameTime.ElapsedGameTime.TotalSeconds;

            for (int i = 0; i < missionCooldowns.Length; i++)
            {
                ExtendedTimer timer = missionCooldowns[i];

                if (timer.IsCounting)
                {
                    timer.Update(gameTime);
                }
                else if (timer.IsDoneCounting)
                {
                    while (missions[i] == null)
                    {
                        missions[i] = MissionManager.LoadMission(MissionManager.GetRandomMissionId());
                    }
                    missions[i].Contractor = this; //There is an error here when you close the game. Could be handles with a save and load function
                    //Though note that this error doesn't happen all the time
                    missions[i].State = Mission.EState.Offered;
                    timer.Reset(Game1.random.Next(minMissionCooldown, maxMissionCooldown), false);
                }
                else
                { /* Do nothing */
                }
            }

            HandleInteractions();
        }
Beispiel #2
0
        public Planet(string name, int maxNrOfMissions, Sprite highlightedSprite, Sprite sprite, Vector2 position)
        {
            this.name              = name;
            this.maxNrOfMissions   = maxNrOfMissions;
            this.highlightedSprite = highlightedSprite;
            this.sprite            = sprite;
            this.position          = position;

            font          = AssetManager.FontAsset("default_font");
            isHighlighted = false;

            missions           = new Mission[maxNrOfMissions];
            missionCooldowns   = new ExtendedTimer[maxNrOfMissions];
            minMissionCooldown = 20000; /* ms */
            maxMissionCooldown = 30000; /* ms */

            scale  = Vector2.One;
            origin = new Vector2(sprite.Width * 0.5f, sprite.Height * 0.5f);
            radius = (sprite.Width * 0.5f) - 1f;

            EventManager.Register(this);

            if (scale.X == scale.Y)
            {
                radius = (float)Math.Floor((decimal)sprite.Width / 2);
            }
            else
            {
                throw new NotImplementedException();
            }

            highlightedSpriteOrigin = new Vector2(highlightedSprite.Width * 0.5f, highlightedSprite.Height * 0.5f);
            highlightedSpriteOffset = new Vector2((highlightedSprite.Width - sprite.Width) * 0.5f, (highlightedSprite.Height - sprite.Height) * 0.5f);

            for (int i = 0; i < missionCooldowns.Length; i++)
            {
                if (missionCooldowns[i] == null)
                {
                    missionCooldowns[i] = new ExtendedTimer(Game1.random.Next(minMissionCooldown, maxMissionCooldown), false);
                }
            }

            for (int i = 0; i < missions.Length; i++)
            {
                int rand = MissionManager.GetRandomMissionId();
                missions[i] = MissionManager.LoadMission(rand);
                if (missions[i] == null)
                {
                    continue;
                }
                missions[i].Contractor = this;
                missions[i].State      = Mission.EState.Offered;
            }
        }
Beispiel #3
0
        public MissionInterfaceButton(Rectangle bounds, Texture2D backgroundAvailable, Texture2D backgroundSelected, Texture2D backgroundUnavailable, Mission mission, ExtendedTimer timer, string text, SpriteFont font)
        {
            this.backgroundSelected    = backgroundSelected;
            this.backgroundAvailable   = backgroundAvailable;
            this.backgroundUnavailable = backgroundUnavailable;

            Mission = mission;
            Timer   = timer;

            Button = new UIButton(bounds, backgroundAvailable, text, font, () =>
            {
                IsSelected = true;
            });

            Button.HoveredTexture = backgroundSelected;
        }
Beispiel #4
0
 public MissionInterfaceButton(UIButton button, Mission mission, ExtendedTimer timer)
 {
     Button  = button;
     Mission = mission;
     Timer   = timer;
 }