コード例 #1
0
ファイル: MissionManager.cs プロジェクト: geigi/what_the_hack
        /// <summary>
        /// This method is called when a mission finishes.
        /// It determines whether the mission is completed successfully or has failed.
        /// It also handles the payout as well as a possible reappearing of the mission.
        /// </summary>
        /// <param name="mission"></param>
        private void missionFinished(Mission mission)
        {
            data.InProgress.Remove(mission);
            InProgressMissionsChanged.Raise();
            missionWorkers[mission].Cleanup();
            missionWorkers.Remove(mission);
            mission.Cleanup();

            if (mission.Completed())
            {
                // Mission has completed successfully
                data.Completed.Add(mission);
                CompletedMissionsChanged.Raise();

                //Notification
                if (mission.GetSuccessText() != null && mission.GetSuccessText() != "")
                {
                    notificationManager.Success($"Mission: {mission.GetName()} completed! " +
                                                $"{mission.GetSuccessText()} You've earned: {mission.RewardMoney}$.");
                }
                else
                {
                    notificationManager.Success($"Mission: {mission.GetName()} completed! You've earned: {mission.RewardMoney}$.");
                }

                // Payout
                ContentHub.Instance.bank.Income(mission.RewardMoney);
            }
            else
            {
                // Mission has failed
                List <string> failedSkills = new List <string>();
                foreach (var skill in mission.Progress)
                {
                    if (skill.Value < 1f)
                    {
                        failedSkills.Add(skill.Key.skillName);
                    }
                }

                string failedSkillsText;
                if (failedSkills.Count > 1)
                {
                    failedSkillsText = "Skills ";

                    for (int i = 0; i < failedSkills.Count; i++)
                    {
                        if (i == failedSkills.Count - 1)
                        {
                            failedSkillsText += failedSkills[i] + " ";
                        }
                        else
                        {
                            failedSkillsText += failedSkills[i] + ", ";
                        }
                    }

                    failedSkillsText += "have failed.";
                }
                else
                {
                    failedSkillsText = "Skill " + failedSkills.First() + " has failed.";
                }

                //Notification
                if (mission.GetFailedText() != null && mission.GetFailedText() != "")
                {
                    notificationManager.Success($"Mission: {mission.GetName()} failed! " +
                                                $"{mission.GetFailedText()} " + failedSkillsText);
                }
                else
                {
                    notificationManager.Success($"Mission: {mission.GetName()} failed! " + failedSkillsText);
                }


                if (mission.Definition.Reappear)
                {
                    data.Available.Add(mission);
                }
            }
        }
コード例 #2
0
ファイル: MissionManager.cs プロジェクト: geigi/what_the_hack
        private void createMissionWorker(Mission mission)
        {
            var worker = new MissionWorker(mission);

            missionWorkers.Add(mission, worker);
        }
コード例 #3
0
ファイル: MissionManager.cs プロジェクト: geigi/what_the_hack
 /// <summary>
 /// Adds an employee to the mission worker of a mission.
 /// </summary>
 /// <param name="mission"></param>
 /// <param name="employee"></param>
 public void StartWorking(Mission mission, EmployeeData employee)
 {
     missionWorkers[mission].AddEmployee(employee);
 }
コード例 #4
0
ファイル: MissionManager.cs プロジェクト: geigi/what_the_hack
 /// <summary>
 /// Get the mission worker which belongs to this mission.
 /// </summary>
 /// <param name="m"></param>
 /// <returns></returns>
 public MissionWorker GetMissionWorker(Mission m)
 {
     return(missionWorkers[m]);
 }
コード例 #5
0
ファイル: MissionFactory.cs プロジェクト: geigi/what_the_hack
 /// <summary>
 /// Calculate the duration for this mission.
 /// </summary>
 /// <param name="mission"></param>
 private void calcDurationVariance(Mission mission)
 {
     mission.Duration       = Math.Max(MissionDurationMinimum, mission.Duration + RandomUtils.var(MissionDurationVariance));
     mission.RemainingTicks = mission.Duration * GameTime.GameTime.Instance.ClockSteps;
 }