コード例 #1
0
ファイル: GameTips.cs プロジェクト: bburhans/vtank
        /// <summary>
        /// Create the default rotating game tip module
        /// </summary>
        public GameTips()
        {
            tips = TipLoader.GetTips();

            mode = TipMode.FullRotating;
            Scramble(new List <string>(tips.ToArray()));
            Initialize();
        }
コード例 #2
0
        public static void Main(string[] args)
        {
            var conn = new MySqlConnection("server=localhost;user=yelp_etl;password=P@ssword!;port=3306;");

            Console.WriteLine("Creating database: yelp...");

            try
            {
                DropDatabaseIfExist(conn);
                conn.Open();
                conn.Execute(File.ReadAllText(Path.Combine(Directory.GetCurrentDirectory(), "data", "yelp_db.sql")));
            }
            finally
            {
                conn.Close();
            }

            Console.WriteLine("Database created.");

            try
            {
                Console.WriteLine("Starting load...");

                //Long running task should start first
                var t1 = Task.Run(() => BusinessLoader.Load(Helpers.CreateConnectionToYelpDb()));
                var t2 = Task.Run(() => ReviewLoader.Load(Helpers.CreateConnectionToYelpDb()));

                //Faster loaders can run sequencially
                CheckinLoader.Load(Helpers.CreateConnectionToYelpDb());
                TipLoader.Load(Helpers.CreateConnectionToYelpDb());
                UserLoader.Load(Helpers.CreateConnectionToYelpDb());

                Task.WaitAll(t1, t2);
                Console.WriteLine("Load complete.");
            }
            catch (AggregateException aEx)
            {
                Console.WriteLine("Load Failure.");

                foreach (var ex in aEx.Flatten().InnerExceptions)
                {
                    Console.WriteLine(ex.Message);
                }

                throw;
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Load Failure: {ex.Message}.");
                DropDatabaseIfExist(conn);
            }

            conn.Dispose();

            Console.WriteLine("Press any key to exit.");
            Console.ReadLine();
        }
コード例 #3
0
ファイル: GameTips.cs プロジェクト: bburhans/vtank
        /// <summary>
        /// Create a context sensitive rotating tip module that displays on death
        /// </summary>
        /// <param name="context">The game's context</param>
        public GameTips(GameContext context)
        {
            this.context = context;

            tips = TipLoader.GetTips(context);

            mode = TipMode.OnDeath;
            Scramble(new List <string>(tips.ToArray()));
            Initialize();
        }
コード例 #4
0
ファイル: GameTips.cs プロジェクト: bburhans/vtank
        /// <summary>
        /// Create a tip module with the specified tip display mode
        /// </summary>
        /// <param name="context">The game's context</param>
        /// <param name="mode">The mode to display tips with</param>
        public GameTips(GameContext context, TipMode mode)
        {
            this.context = context;

            if (mode == TipMode.FullRotating)
            {
                tips = TipLoader.GetTips();
            }
            else
            {
                tips = TipLoader.GetTips(context);
            }

            this.mode = mode;
            Scramble(new List <string>(tips.ToArray()));
            Initialize();
        }
コード例 #5
0
        // try to load tip from resources
        public void TipLoaderFromResources()
        {
            // unset current tip if exists and create game object with TipLoader
            tip = null;
            GameObject tipLoaderGameObject = new GameObject("Test tip loader");
            TipLoader  tipLoader           = tipLoaderGameObject.AddComponent <TipLoader>();

            // tip loaded event
            TipLoader.OnTipLoaded += TipLoaded;

            // load tip
            tipLoader.Load();

            // if tip is not null, the test succeeded
            Assert.IsNotNull(tip);


            TipLoader.OnTipLoaded -= TipLoaded;
        }
コード例 #6
0
        // try to load tip from web
        public IEnumerator TipLoaderFromWeb()
        {
            // unset current tip if exists and create game object with TipLoader
            tip = null;
            GameObject tipLoaderGameObject = new GameObject("Test tip loader");
            TipLoader  tipLoader           = tipLoaderGameObject.AddComponent <TipLoader>();

            // load from web
            tipLoader.loadFromWeb = true;
            tipLoader.url         = "davand.net/app.php";

            // tip loaded event
            TipLoader.OnTipLoaded += TipLoaded;

            // load tip
            tipLoader.Load();

            // wait few seconds while tip loads
            yield return(new WaitForSeconds(3));

            // if tip is not null, the test succeeded
            Assert.IsNotNull(tip);
        }
コード例 #7
0
        private void Test(bool loadFromWeb)
        {
            // load sceneA, if sceneA is current scene then load sceneB
            string sceneForLoad = SceneManager.GetActiveScene().name.Equals("sceneA") ? "sceneB" : "sceneA";

            // if SceneLoader instance exists, set sceneLoaderPrefab as loader's game object
            GameObject sceneLoaderPrefab = SceneLoader.Instance?.gameObject;

            // if if SceneLoader instance doesn't exists, create main camera and the SceneLoader from prefab
            if (SceneLoader.Instance == null)
            {
                GameObject cam = new GameObject("Main Camera");
                cam.AddComponent <Camera>().tag = "MainCamera";

                sceneLoaderPrefab = AssetDatabase.LoadAssetAtPath <GameObject>("Assets/SLoader/Prefabs/SceneLoader.prefab");
            }

            if (loadFromWeb)
            {
                // test for loading a tip from web
                TipLoader tipLoader = sceneLoaderPrefab.GetComponent <TipLoader>();
                tipLoader.loadFromWeb = true;
                tipLoader.url         = "davand.net/app.php";
            }

            if (SceneLoader.Instance == null)
            {
                // if loader doesn't exists instantiate it, and set the first scene for loading
                MonoBehaviour.Instantiate(sceneLoaderPrefab);
                SceneLoader.Instance.firstSceneToLoad = sceneForLoad;
            }
            else
            {
                // load scene
                SceneLoader.Instance.LoadScene(sceneForLoad);
            }
        }