Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        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> > ();
        }
Exemplo n.º 3
0
        void OnEnable()
        {
#if FULLLOG
            MoreDebug.Log("go: " + gameObject.name);
#endif
            StartCampaign();
        }
Exemplo n.º 4
0
        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();
        }
Exemplo n.º 5
0
        // methods

        public void ForceUpdate()
        {
#if FULLLOG
            MoreDebug.Log("ForceUpdate");
#endif
            UpdateFromData();
        }
Exemplo n.º 6
0
        void LoadAGame(string savegamename)
        {
#if FULLLOG
            MoreDebug.Log(".");
#endif
            pregameState = false;
        }
Exemplo n.º 7
0
        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();
                }
            }
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        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();
            }
        }
Exemplo n.º 10
0
        public void DeactivateTrigger()
        {
#if FULLLOG
            MoreDebug.Log(".");
#endif
            // does nothing
        }
Exemplo n.º 11
0
        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();
            }
        }
Exemplo n.º 12
0
        public void ActivateTrigger()
        {
#if FULLLOG
            MoreDebug.Log(".");
#endif
            Launch();
        }
Exemplo n.º 13
0
        public void IncrementFailCriterion(int critIdx)
        {
#if FULLLOG
            MoreDebug.Log("go: " + gameObject.name);
#endif
            failCriteria[critIdx].Increment();
        }
Exemplo n.º 14
0
        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 ();
        }
Exemplo n.º 15
0
        // 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;
        }
Exemplo n.º 16
0
        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();
        }
Exemplo n.º 17
0
        void PlayTheTutorial()
        {
#if FULLLOG
            MoreDebug.Log(".");
#endif
            pregameState = false;
        }
Exemplo n.º 18
0
        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);
        }
Exemplo n.º 19
0
        // 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.");
            }
        }
Exemplo n.º 20
0
        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;
            }
        }
Exemplo n.º 21
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
        }
Exemplo n.º 22
0
        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;
        }
Exemplo n.º 23
0
        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++;
            }
        }
Exemplo n.º 24
0
        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());
        }
Exemplo n.º 25
0
        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
                }
            }
        }
Exemplo n.º 26
0
        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));
                }
            }
        }
Exemplo n.º 27
0
        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;
        }
Exemplo n.º 28
0
        // 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
        }
Exemplo n.º 29
0
        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);
            }
        }
Exemplo n.º 30
0
        public void EndTransition()
        {
#if FULLLOG
            MoreDebug.Log(".");
#endif

            StartCoroutine(doEndTransition());
        }