Esempio n. 1
0
        private void CampaignHandler_MissionCompleted(object sender, MissionCompletionEventArgs e)
        {
            var parentPanel = (MainMenuDarkeningPanel)Parent;

            parentPanel.Show(this);
            parentPanel.Alpha = 1.0f;

            ListBattles();

            // If another mission follows the completed mission, select the following mission.
            // Otherwise select the mission itself.

            // If we unlocked a specific mission, select it.
            if (e.PrimaryUnlockedMission != null)
            {
                SelectMission(e.PrimaryUnlockedMission);
                return;
            }

            // Otherwise, build a list of all missions that follow the completed mission
            // and select one of them. Could be that the user has already previously unlocked
            // all missions that follow the completed mission, hence there were no new unlocks.
            var followList = new List <string>();

            Array.ForEach(e.Mission.UnlockMissions, unlockedMissionName => followList.Add(unlockedMissionName));
            e.Mission.ConditionalMissionUnlocks.ForEach(c => followList.Add(c.UnlockMissionName));

            if (followList.Count == 0)
            {
                // No mission follows, select the entry that matches our current mission

                SelectMission(e.Mission);
                return;
            }

            foreach (string missionName in followList)
            {
                // At least one mission follows, iterate through possibly unlocked missions until we find one

                int index = lbCampaignList.Items.FindIndex(item =>
                {
                    var mission = (Mission)item.Tag;
                    return(mission.InternalName == missionName && mission.IsAvailableToPlay);
                });

                if (index > -1)
                {
                    lbCampaignList.SelectedIndex = index;
                    break;
                }
            }

            // If no following mission was unlocked, then select the entry that matches our current mission
            if (lbCampaignList.SelectedItem == null)
            {
                SelectMission(e.Mission);
            }
        }
Esempio n. 2
0
 private void CampaignHandler_MissionRankUpdated(object sender, MissionCompletionEventArgs e)
 {
     missionCompletionNotification.Show(e.Mission);
 }