Esempio n. 1
0
    public IEnumerator Start()
    {
        scoresDownloaded = false;
        bool scoresDownloadedTemp = true;

        serverAccessed = false;
        levelScores    = new string[4];
        int stage = GameManager.GetStage();
        int level = GameManager.GetLevel();

        bool notUpdated = false;

        for (int stars = 0; stars < 4; stars++)
        {
            WWWForm form = new WWWForm();
            form.AddField("stagePost", stage);
            form.AddField("levelPost", level);
            form.AddField("starsPost", stars);

            WWW highscoresData = new WWW("https://" + url, form);
            yield return(highscoresData);         // on attend que les scores soient téléchargés

            if (!string.IsNullOrEmpty(highscoresData.error))
            {
                Debug.print(highscoresData.error);
                levelScores[stars]   = "Unable to access server";
                scoresDownloadedTemp = false; // si un est faux, il devient faux
                // ET METTRE EN PLACE LE STOCKAGE DES NOUVEAUX TEMPS EN LOCAL POUR LES ENVOYER PLUS TARD QD LA CONNEXION SE REFAIT
            }
            else
            {
                levelScores[stars] = highscoresData.text;
            }

            print("enter");
            int localScore = (stage == 0 ? LocalHighScores.GetLocalChallengeScore(level, stars) : LocalHighScores.localScores[10 * (stage - 1) + level][stars]);
            if (localScore != 0 && int.Parse(GetDataValue(levelScores[stars], "Time")) > localScore)  //temps local meilleur => on update
            {
                notUpdated = true;
                yield return(UploadScore.insertScore(PlayerPrefs.GetString("PlayerPseudo"), stage, level, localScore, stars));

                Debug.print("LocalScore put online");
            }
        }
        if (notUpdated)
        {
            print("Restart");
            yield return(Start());  // on retélécharge les scores !
        }
        scoresDownloaded = scoresDownloadedTemp;
        serverAccessed   = true;
        Debug.print("Highscores Downloaded in " + Time.time + ", " + scoresDownloaded);
        GameObject.FindWithTag("ScoresScript").GetComponent <DisplayScores>().displayScores(SQLScores.GetLevelScores(stage, level));
    }
Esempio n. 2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            attackerTexture = Content.Load<Texture2D>(@"Images\bluecircle");
            healyTexture = Content.Load<Texture2D>(@"Images\healyOrb");
            DefaultFont = Content.Load<SpriteFont>(@"Fonts\BasicFont");
            DefaultFont_Embiggened = Content.Load<SpriteFont>(@"Fonts\BasicFontLarge");
            StatusFont = Content.Load<SpriteFont>(@"Fonts\StatusbarFont");
            MessageTitleFont = Content.Load<SpriteFont>(@"Fonts\dialogtitle");
            redcircletexture = Content.Load<Texture2D>(@"Images\redcircle");
            greencircletexture = Content.Load<Texture2D>(@"Images\greencircle");
            yellowcircletexture = Content.Load<Texture2D>(@"Images\yellowcircle");
            SpeckImage = Content.Load<Texture2D>(@"Images\whitespeck");
            RedSpeck = Content.Load<Texture2D>(@"Images\redspeck");
            GreenSpeck = Content.Load<Texture2D>(@"Images\greenspeck");
            YellowSpeck = Content.Load<Texture2D>(@"Images\yellowspeck");
            audioEngine = new AudioEngine(@"Content\Audio\GameSounds.xgs");
            soundBank = new SoundBank(audioEngine, @"Content\Audio\Sound Bank.xsb");
            waveBank = new WaveBank(audioEngine, @"Content\Audio\Wave Bank.xwb");
            LogoImage = Content.Load<Texture2D>(@"Images\bclogo");
            LogoImage2 = Content.Load<Texture2D>(@"Images\basecampBCDodgerdisclaim");
            LogoImage3 = Content.Load<Texture2D>(@"Images\toomanylogos");

            GrenEffect = soundBank.GetCue("gren");

            foreach (Type iteratetype in StateTypes)
            {

                CallLoadContent(iteratetype);

            }

            String usehighscorefile = GetHighScoresFile();
            if (File.Exists(usehighscorefile))
                hsm = HighScoreManager.FromFile(usehighscorefile);
            else
                hsm = new HighScoreManager(usehighscorefile);
            HighScoreData = hsm["BCDodger"];
            ContentLoaded = true;
            //TrackCue.Play();
            // TODO: use this.Content to load your game content here
        }
Esempio n. 3
0
        //the following are commented out: level saving and loading to/from files is done via the EditorSet now.
        /*
        public static LevelSet FromFile(String filename)
        {

            IFormatter binformatter = new BinaryFormatter();

                using (FileStream inputstream = new FileStream(filename, FileMode.Open))
                {
                    using (GZipStream gzstream = new GZipStream(inputstream, CompressionMode.Decompress))
                    {
                        LevelSet returnthis = (LevelSet) binformatter.Deserialize(gzstream);
                        return returnthis;
                    }
                }

        }

        public void Save(String filename)
        {
            FileStream outstream=null;
            IFormatter binformatter = new BinaryFormatter();
            try
            {

                outstream = new FileStream(filename, FileMode.OpenOrCreate);

                //create a GZip stream...
                using (GZipStream gzstream = new GZipStream(outstream, CompressionMode.Compress))
                {

                    Cursor.Current = Cursors.WaitCursor;
                    binformatter.Serialize(gzstream, this);
                    Cursor.Current = Cursors.Default;
                }

            }
            catch (Exception e)
            {
                Debug.Print("Exception in LevelSet.Save:" + e.Message);

            }
            finally
            {
                if(outstream!=null) outstream.Close();

            }

        }
         * */
        public LevelSet()
        {
            HighScores = new LocalHighScores(20);
            GraphicsPath testpath = new GraphicsPath();
            //testpath.AddString("Testing", new Font("Celestia Redux", 28), new Point(90, 32), StringFormat.GenericDefault);
            //testpath.Flatten();
            testpath.AddRectangle(new Rectangle(90, 32, 84, 84));
            //PathData["testing path"] = new ObjectPathData(testpath);
        }
Esempio n. 4
0
 public void VersionUpdates()
 {
     LocalHighScores.CleanLocalScores();
 }