public void BeginMission() { // must be called after pausegame.beginplay() #if FULLLOG MoreDebug.Log("go: " + gameObject.name); #endif if (!PauseGame.exists) { #if FULLLOG MoreDebug.Log("No PauseGame -----"); #endif } if (InfoPriority >= operation.MissionTerseness) { MessageBoxParams parms = new MessageBoxParams(); parms.Message = StartingInfo; parms.MessageBoxTitle = MissionTitle; parms.Button1Action = PauseGame.only.queueResume; parms.MultipleCallBehaviour = MultipleCallBehaviours.Queue; EasyMessageBox.Show(parms); PauseGame.only.queuePause(); } // reset the goal state currentState = initialState; isActive = true; CurrentLevel = Registry.only.GetObject <LevelManager> ().MapOverlayName; operation.StartMission(); // set flags BeginEvent.Invoke(); }
public virtual void Awake() { // singleton #if FULLLOG MoreDebug.Log("singleton, keep."); #endif // singleton exists = false; if (only == null) { DontDestroyOnLoad(gameObject); only = this; #if FULLLOG MoreDebug.Log("Singleton created"); #endif } else if (only != this) { #if FULLLOG MoreDebug.LogError("More than one registry found."); #endif Destroy(gameObject); #if FULLLOG MoreDebug.Log("Duplicate singleton destroyed."); #endif } exists = true; // local init ms_registry = new Dictionary <Type, iUniRegister> (); mg_registry = new Dictionary <Type, List <iMultiRegister> > (); }
void OnEnable() { #if FULLLOG MoreDebug.Log("go: " + gameObject.name); #endif StartCampaign(); }
private IEnumerator ShowOperationStatus() { #if FULLLOG MoreDebug.Log("."); #endif yield return(new WaitForSeconds(2)); if (!PauseGame.exists) { #if FULLLOG MoreDebug.Log("No PauseGame -----"); #endif } string sceneresult = "There are " + Missions.Length + "(" + missioncount.MaximumCount + ") missions " + newline + "Actual wins: " + missioncount.GroupCount[1] + newline + "Actual losses: " + missioncount.GroupCount[0]; MessageBoxParams parms = new MessageBoxParams(); parms.Message = sceneresult; parms.MessageBoxTitle = "Operation is Ended"; parms.Button1Action = PauseGame.only.queueResume; parms.MultipleCallBehaviour = MultipleCallBehaviours.Queue; EasyMessageBox.Show(parms); PauseGame.only.queuePause(); }
// methods public void ForceUpdate() { #if FULLLOG MoreDebug.Log("ForceUpdate"); #endif UpdateFromData(); }
void LoadAGame(string savegamename) { #if FULLLOG MoreDebug.Log("."); #endif pregameState = false; }
public void LoseMission() { #if FULLLOG MoreDebug.Log("go: " + gameObject.name); #endif missioncount.Decrement(ActivityCounter.losestring); #if FULLLOG if (!missioncount.isValid()) { MoreDebug.LogError("Op count invalid"); } #endif if (missioncount.isDone()) { if (CalculateOperationWinStatus()) { WinOperation(); } else { LoseOperation(); } } }
private bool CalculateOperationWinStatus() { #if FULLLOG MoreDebug.Log("go: " + gameObject.name); #endif // if the operation ends now, will it be won or lost? int misswon = 0, misslose = 0; foreach (MissionManager mi in Missions) { if (mi == null) { break; } if ((mi.currentState == GoalManager.GoalState.assumewin) || (mi.currentState == GoalManager.GoalState.realwin)) { misswon++; } else if ((mi.currentState == GoalManager.GoalState.assumelose) || (mi.currentState == GoalManager.GoalState.reallose)) { misslose++; } } bool opwon; bool assumewin = ((OperationBias == GoalManager.GoalState.realwin) || (OperationBias == GoalManager.GoalState.assumewin)); if ((misswon > misslose) || ((misswon == misslose) && assumewin)) { opwon = true; } else { opwon = false; } return(opwon); }
private void LoseOperation() { #if FULLLOG MoreDebug.Log("qaa go: " + gameObject.name); #endif if (!PauseGame.exists) { #if FULLLOG MoreDebug.Log("No PauseGame -----"); #endif } if (InfoPriority > CampaignManager.campaign.OperationTerseness) { MessageBoxParams parms = new MessageBoxParams(); parms.Message = FailureInfo; parms.MessageBoxTitle = oname; parms.Button1Action = PauseGame.only.queueResume; parms.MultipleCallBehaviour = MultipleCallBehaviours.Queue; EasyMessageBox.Show(parms); PauseGame.only.queuePause(); } OnLoseOperation.Invoke(); level.LoseAnOperation(); // Remember winning the operation does not win the level or (necessarily) end the operation if (ForceLevelLose) { EndOperation(); level.LoseLevel(); } }
public void DeactivateTrigger() { #if FULLLOG MoreDebug.Log("."); #endif // does nothing }
public void SetParam(string name, string val) { #if FULLLOG MoreDebug.Log("."); #endif if (name == "Height") { Height = float.Parse(val); } else if (name == "Color") { BoomColor = MoreColor.StringToColor(val); } else if (name == "Smoke") { ShowSmoke = (val == "true"); } else if (name == "Flash") { ShowFlash = (val == "true"); } else { throw new ArgumentException(); } }
public void ActivateTrigger() { #if FULLLOG MoreDebug.Log("."); #endif Launch(); }
public void IncrementFailCriterion(int critIdx) { #if FULLLOG MoreDebug.Log("go: " + gameObject.name); #endif failCriteria[critIdx].Increment(); }
void SucceedMission() { #if FULLLOG MoreDebug.Log("go: " + gameObject.name); #endif if (!isActive) { return; } #if FULLLOG MoreDebug.Log("real."); #endif if (!PauseGame.exists) { #if FULLLOG MoreDebug.Log("No PauseGame -----"); #endif } if (InfoPriority > operation.MissionTerseness) { MessageBoxParams parms = new MessageBoxParams(); parms.Message = SuccessInfo; parms.MessageBoxTitle = MissionTitle; parms.Button1Action = PauseGame.only.queueResume; parms.MultipleCallBehaviour = MultipleCallBehaviours.Queue; EasyMessageBox.Show(parms); PauseGame.only.queuePause(); } currentState = GoalManager.GoalState.realwin; SuccessEvent.Invoke(); operation.WinMission(); isActive = false; //Reset (); }
// Unity methods void Awake() { #if FULLLOG MoreDebug.Log("go: " + gameObject.name); MoreDebug.Log("Campaign count: " + _count); #endif // class init campaign = null; allCampaigns[_count] = this; _count++; // local init currentLevel = -1; // Create events if (OnBeginCampaign == null) { OnBeginCampaign = new UnityEvent(); } if (OnEndCampaign == null) { OnEndCampaign = new UnityEvent(); } if (OnWinCampaign == null) { OnWinCampaign = new UnityEvent(); } if (OnLoseCampaign == null) { OnLoseCampaign = new UnityEvent(); } isActive = false; }
private void EndOperation() { // Ending the operation does not win or lose it. #if FULLLOG MoreDebug.Log(" qaa go: " + gameObject.name); #endif foreach (MissionManager mm in Missions) { mm.isActive = false; } if (!missioncount.isDone()) { // then win status has not been determined and announced yet if (CalculateOperationWinStatus()) { WinOperation(); } else { LoseOperation(); } } StartCoroutine(ShowOperationStatus()); OnEndOperation.Invoke(); level.DecrementOperations(); }
void PlayTheTutorial() { #if FULLLOG MoreDebug.Log("."); #endif pregameState = false; }
private void StartCampaign() { // Called when enabled // todo: can we just put this in OnEnable() ? #if FULLLOG MoreDebug.Log("go: " + gameObject.name); #endif // announce the start of the campaign PauseGame.only.beginPlay(); OnBeginCampaign.Invoke(); // show the campaign start screen if (!PauseGame.exists) { #if FULLLOG MoreDebug.Log("No PauseGame -----"); #endif } MessageBoxParams parms = new MessageBoxParams(); parms.Message = StartingInfo; parms.MessageBoxTitle = CampaignName; parms.Button1Action = PauseGame.only.queueResume; parms.MultipleCallBehaviour = MultipleCallBehaviours.Queue; EasyMessageBox.Show(parms); PauseGame.only.queuePause(); // load the first level currentLevel = 0; LoadLevel(currentLevel); }
// Unity methods void Awake() { // singleton exists = false; if (only == null) { // DontDestroyOnLoad (gameObject); only = this; } else if (only != this) { Destroy(gameObject); } exists = true; // local init #if FULLLOG MoreDebug.Log("singleton, nokeep."); #endif if (onCampaignPick == null) { onCampaignPick = new UnityEvent(); } if (onMapPick == null) { onMapPick = new UnityEvent(); } if (onSavegamePick == null) { onSavegamePick = new UnityEvent(); } if (MainMenu == null) { Debug.LogError("MainMenuTree: Main menu not set."); } }
public void queueResume() { #if FULLLOG MoreDebug.Log(" "); #endif if (!(paused && playing)) { return; } #if FULLLOG MoreDebug.Log("Queuestatus: " + queuestatus); #endif if (queuestatus > 1) { queuestatus--; } else // queuestatus == 1 { setPlayMode(); paused = false; PauseTriggers[TriggerIndex].GameResumeEvent.Invoke(); TriggerIndex = -1; queuestatus = 0; } }
private void UpdateText(Text ht, HudBridgeElement hd) { ht.text = hd.Caption + NewLine + hd.Value; #if FULLLOG MoreDebug.Log("(" + hd.Key + ") Update text: " + hd.Caption + " / " + hd.Value); #endif }
public void forcePause(int counter) { #if FULLLOG MoreDebug.Log(" "); #endif if (!playing) { return; } #if FULLLOG MoreDebug.Log("Queuestatus: " + queuestatus); #endif if (queuestatus == 0) { TriggerIndex = counter; paused = true; setPauseMode(); if (manual) { PauseTriggers[TriggerIndex].ManualPauseEvent.Invoke(); manual = false; } PauseTriggers[TriggerIndex].GamePauseEvent.Invoke(); } queuestatus = 9999; }
public void queuePause(int counter) { #if FULLLOG MoreDebug.Log(" "); #endif if (!playing) { return; } #if FULLLOG MoreDebug.Log("Queuestatus: " + queuestatus); #endif if (queuestatus > 0) { queuestatus++; } else // queuestatus == 0 { paused = true; TriggerIndex = counter; setPauseMode(); PauseTriggers[TriggerIndex].GamePauseEvent.Invoke(); queuestatus++; } }
void Start() { #if FULLLOG MoreDebug.Log("."); #endif RegisterSelf(); if (LevelManager.exists) { // running as part of campaign or at least level... InitPoi(); #if FULLLOG MoreDebug.Log(ShowAllPoi()); #endif level.OnGetLocation.AddListener(GiveNextPoiToLevel); level.LocationActive = true; level.EndOfLocations = false; } else if (SceneLoader.exists) { if (SceneLoader.only.gameObject.scene == SceneManager.GetActiveScene()) { // transition has no sceneloader, so running standalone -- load player overlay SceneLoader.only.BeginTransition(false); } // else running solo map, do nothing SceneLoader.only.EndTransition(); if (PauseGame.exists) { PauseGame.only.beginPlay(); } } StartCoroutine(doSpawnPlayer()); }
void Update() { for (int cc = 0; cc < PauseTriggers.Length; cc++) { if (Input.GetButtonDown(PauseTriggers[cc].Keyname) && playing) { if (paused) { if (TriggerIndex != cc) { continue; //for loop } // else... #if FULLLOG MoreDebug.Log("Pause button hit - resuming."); #endif // TriggerIndex = -1; manual = true; forceResume(); } else { #if FULLLOG MoreDebug.Log("Pause button hit - pausing."); #endif // TriggerIndex = cc; manual = true; forcePause(cc); } break; // for loop } } }
public static IEnumerator doSpawnPlayer() { #if FULLLOG MoreDebug.Log("."); #endif const float waitTime = 3.0f; GameObject spawn, player; while (true) { #if FULLLOG MoreDebug.Log(" Attempting player spawn."); #endif // Put the player on an (the) entry point. // todo: add alternate entry points and a way to pick one. spawn = GameObject.FindWithTag("Respawn"); player = GameObject.FindWithTag("Player"); if ((spawn != null) && (player != null)) { player.transform.position = spawn.transform.position; player.transform.rotation = spawn.transform.rotation; PauseGame.only.RecheckPlayer(); #if FULLLOG MoreDebug.Log(" Player spawn succeeded."); #endif break; } else { yield return(new WaitForSecondsRealtime(waitTime)); } } }
void Awake() { #if FULLLOG MoreDebug.Log("."); #endif if (timerBegunEvent == null) { timerBegunEvent = new UnityEvent(); } if (timerCancelEvent == null) { timerCancelEvent = new UnityEvent(); } if (timerExpiredEvent == null) { timerExpiredEvent = new UnityEvent(); } if (timerDoneEvent == null) { timerDoneEvent = new UnityEvent(); } if (timerTickEvent == null) { timerTickEvent = new UnityEvent(); } timerLength = minutes * 60f; paused = false; TimerBegun = false; TimerDone = false; }
// Unity methods void Awake() { #if FULLLOG MoreDebug.Log("go: " + gameObject.name); #endif // singleton exists = false; if (only == null) { DontDestroyOnLoad(gameObject); only = this; #if FULLLOG MoreDebug.Log("Singleton created."); #endif } else if (only != this) { Destroy(this); #if FULLLOG MoreDebug.Log("Duplicate singleton destroyed."); #endif } exists = true; // local init // set internal variables PrimarySceneName = SceneManager.GetActiveScene().name; // fallback should be replaced by loadlevel or loadoverlay }
public IEnumerator doEndTransition() { #if FULLLOG MoreDebug.Log("."); #endif do { yield return(new WaitForSecondsRealtime(LoadWait)); } while (QueueActive); #if FULLLOG MoreDebug.Log("Setting active scene:" + PrimarySceneName); #endif SceneManager.SetActiveScene(SceneManager.GetSceneByName(PrimarySceneName)); if (UseTransitionScene) { #if FULLLOG MoreDebug.Log("Unloading transition scene:" + TransitionSceneName); #endif yield return(null); SceneManager.UnloadSceneAsync(TransitionSceneName); } if (PlayerSceneName.Length > 0) { SceneManager.LoadSceneAsync(PlayerSceneName, LoadSceneMode.Additive); } }
public void EndTransition() { #if FULLLOG MoreDebug.Log("."); #endif StartCoroutine(doEndTransition()); }