示例#1
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> > ();
        }
示例#2
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();
                }
            }
        }
示例#3
0
        void OnDestroy()
        {
#if FULLLOG
            MoreDebug.LogError("Verify this isn't a duplicate!");
#endif
            only   = null;
            exists = false;
        }
示例#4
0
        }); // 0=lose, 1=win

        #endregion

        #region Methods

        // Unity methods
        void Awake()
        {
#if FULLLOG
            MoreDebug.Log("singleton, nokeep.");
#endif
            // singleton
            exists = false;
            if (only == null)
            {
                // DontDestroyOnLoad (gameObject);
                only = this;
#if FULLLOG
                MoreDebug.Log("Singleton created. qqq");
#endif
            }
            else if (only != this)
            {
                MoreDebug.LogError("More than one level manager found.");
                Destroy(gameObject);
#if FULLLOG
                MoreDebug.Log("Duplicate singleton destroyed.");
#endif
            }
            exists = true;

            // local init

            // Check for a pregame manager
            if (PregameManager.only != null)   // Created but maybe not awake yet
            {
                Game = PregameManager.only;
            }
            // Check for a campaign manager
            if ((CampaignManager.count > 0) && (CampaignManager.campaign != null))
            {
                Campaign = CampaignManager.campaign;
            }
            // Create events
            if (OnBeginLevel == null)
            {
                OnBeginLevel = new UnityEvent();
            }
            if (OnEndLevel == null)
            {
                OnEndLevel = new UnityEvent();
            }
            if (OnGetLocation == null)
            {
                OnGetLocation = new LocationEvent();
            }

            // done with Awake()
        }
示例#5
0
        // methods
        // Unity methods

        protected override void Awake()
        {
            base.Awake();
            t = GetComponent <Timer> ();
#if FULLLOG
            if (t == null)
            {
                MoreDebug.LogError("Hud Timer Bridge found no timer");
            }
#endif
            LoadHudData(t.ShowElapsed, t.timerTickEvent, t.timerDoneEvent, Caption, t.timerDoneMessage, 0);
        }
示例#6
0
        // local methods

        public static void BeginCampaign(string _cn_)
        {
            // Called by game (or pregame) manager -- entry point
#if FULLLOG
            MoreDebug.Log(_cn_ + " (" + count + ") " + MoreDebug.splatRow);
#endif

            if (count == 0)
            {
                MoreDebug.LogError("No campaigns registered.");
                QuitClean.QuitGame();
            }

            foreach (CampaignManager cm in allCampaigns)
            {
                if (cm == null)
                {
#if FULLLOG
                    MoreDebug.Log("Null skipped.");
#endif
                    continue;
                }
                else if (cm.CampaignName == _cn_)
                {
#if FULLLOG
                    MoreDebug.Log(cm.CampaignName + " selected.");
#endif
                    campaign          = cm;
                    campaign.isActive = true;
                    campaign.enabled  = true;
#if FULLLOG
                    if (campaign.isActiveAndEnabled)
                    {
                        MoreDebug.Log(campaign.CampaignName + " is active and enabled(tm).");
                    }
                    else
                    {
                        MoreDebug.Log(campaign.CampaignName + " is NOT active and enabled(tm).");
                    }
#endif
                }
                else
                {
#if FULLLOG
                    MoreDebug.Log(cm.CampaignName + " destroyed.");
#endif
                    Destroy(cm.gameObject);
                }
            }
        }
示例#7
0
        private void LoadLevel(int levelindex)
        {
#if FULLLOG
            MoreDebug.Log("level:" + levelindex + " scene:" + campaign.Levels[levelindex].LevelSceneName + MoreDebug.splatRow);
#endif
            if (!isActive)
            {
                MoreDebug.LogError("Trying to run an inactive campaign!");
                return;
            }
            // Yup - load the level
            SceneLoader.only.BeginTransition(true);
            SceneLoader.only.LoadLevel(campaign.Levels[levelindex].LevelSceneName);
            // SceneManager.LoadScene(campaign.Levels [levelindex].LevelSceneName);
        }
示例#8
0
        /*
         * public void WinAnOperationWeighted(int weight){
         #if FULLLOG
         *  MoreDebug.Log(".");
         #endif
         *  operationcounts.GroupInc(ActivityCounter.winstring, weight);
         * }
         *
         * public void LoseAnOperationWeighted(int weight){
         #if FULLLOG
         *  MoreDebug.Log(".");
         #endif
         *  operationcounts.GroupInc(ActivityCounter.losestring, weight);
         * }
         */

        public void DecrementOperations()
        {
#if FULLLOG
            MoreDebug.Log(".");
#endif

            operationcounts.Decrement();

#if FULLLOG
            if (!operationcounts.isValid())
            {
                MoreDebug.LogError("Op count invalid");
            }
#endif

            if (operationcounts.isDone())
            {
                EndLevel();
            }
        }