Exemplo n.º 1
0
    public void launchMission(MissionData mission)
    {
        Debug.Log("launchMission: " + mission);
        setUiModeMissionControl();

        FlightPlan flightPlan = registry.flightPlans.Where(plan => plan.destination == mission.destinationData).First();
        Rocket     rocket     = GameObject.Instantiate(mission.rocketData.rocketObject);

        rocket.setSprite(mission.rocketData.icon);

        var activeMission = new ActiveMission(this, rocket, mission, Time.time, flightPlan);

        gameState.registerActiveMission(activeMission);
        gameState.funds -= mission.getCost();
        gameState.registerProgress(mission.destinationData.progressionValue);
        activeMission.launch();

        if (missionWillFail(mission))
        {
            float explodeAfter = mission.getDurationSeconds() * 0.1f * Convert.ToSingle(random.NextDouble());
            StartCoroutine(failMission(activeMission, explodeAfter));
        }
    }
 public bool canLaunchMission(MissionData mission)
 {
     return(mission.isValid() && gameState.funds >= mission.getCost());
 }