Inheritance: MonoBehaviour
Example #1
0
 // Use this for initialization
 void Start()
 {
     gs = this;
     coinScore = 0;
     distance = 0;
     totalScore = 0;
 }
Example #2
0
    public void SetGameScore(GameScore gameScore)
    {
        leftPlayerName.text = gameScore.leftPlayerName;
        leftScoreText.text  = gameScore.leftPlayerScore;

        rightPlayerName.text = gameScore.rightPlayerName;
        rightScoreText.text  = gameScore.rightPlayerScore;

        totalScoreText.text       = gameScore.totalScore;
        playerNameWhoWonText.text = $"{gameScore.playerNameWhoWon} Won!!";
    }
Example #3
0
    private void Die()
    {
        GameObject scoreText = Instantiate(_score3DTextPrefab, this.transform.position, Quaternion.identity) as GameObject;

        scoreText.GetComponent <KillScoreInfo>().ShowScore(_scoreValue.ToString());
        Instantiate(_deathExplosionPrefab, _bodyTransform.position, Quaternion.identity);
        AudioSource.PlayClipAtPoint(gettingHitSounds[Random.Range(0, gettingHitSounds.Length)], _bodyTransform.position, 1f);
        AudioSource.PlayClipAtPoint(_deathSound, _bodyTransform.position, 5f);
        GameScore.UpdateScore(_scoreValue);
        Destroy(this.gameObject);
    }
Example #4
0
        public ActionResult Create([Bind(Include = "ID,Name,Points")] GameScore gameScore)
        {
            if (ModelState.IsValid)
            {
                db.GameScores.Add(gameScore);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(gameScore));
        }
Example #5
0
 void MakeSingleInstance()
 {
     if (instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         instance = this; DontDestroyOnLoad(gameObject);
     }
 }
Example #6
0
    void Start()
    {
        gm  = GameObject.FindGameObjectWithTag("GameMaster").GetComponent <GameScore>();
        lm  = FindObjectOfType <LoadMateri> ();
        ch  = GameObject.Find("character");
        rip = FindObjectOfType <death> ();
        cus = FindObjectOfType <flash> ();


        //thescoremanager = FindObjectOfType<scoremanager>();
    }
    void RenderBag()
    {
        ScoreText.text = GameScore.ToString();

        BackroundRenderer.material.color = Color.Lerp(Color.black, Color.blue, BackroundColorLerp);

        BackroundColorLerp = Mathf.Lerp(BackroundColorLerp, 0, Time.deltaTime * 10);



        BackroundColorVelocity = Mathf.Lerp(BackroundColorLerp, 1, Time.deltaTime);
    }
Example #8
0
    void Start()
    {
        mQuarTime   = new QuarterTime();
        mDownAndDis = new DownAndDistance();
        mScores     = new GameScore();
        mGameState  = GAME_STATE.PRESNAP;

        // kind of a hack, move this later.
        SetFirstDownSpot();

        PlayRestart();
    }
Example #9
0
 public override void Interact()
 {
     if (State == ItemState.Disabled)
     {
         if (GameScore.CurrentEnergy - GameSettings.MAIN_FRAME_ENERGY_GAIN < 1f)
         {
             base.Interact();
             GameScore.AddEnergy(GameSettings.MAIN_FRAME_ENERGY_GAIN);
             AudioController.Instance.Play(Tags.SFX_Interact_MainFrame);
         }
     }
 }
 void Awake()
 {
     DontDestroyOnLoad(this.gameObject);
     if (main == null)
     {
         main = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
Example #11
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
     DontDestroyOnLoad(gameObject);
 }
Example #12
0
 void Update()
 {
     if (Input.GetKey(KeyCode.R))                                              //Si la tecla R se llega a apretar
     {
         GameScore.resetScore();                                               //Mandamos a llamar la funcion de resetscore in gamescore
         GetComponent <Rigidbody2D> ().velocity           = new Vector2(0, 0); //Se regresa la velocidad a 0,0
         GetComponent <Rigidbody2D> ().transform.position = new Vector2(0, 0); //Se regresa la bola a la posicion 0,0
         player1.transform.position = new Vector2(-0.05f, -2.78f);             //Regresamos la posicion de ambos jugadores
         player2.transform.position = new Vector2(-0.05f, 2.82f);              //Regresamos la posicion de ambos jugadores.
         StartCoroutine(InitiateBall());                                       //Volvemos a llamar la funcion de initiateball
     }
 }
 void Awake()
 {
     if (!Instance)
     {
         Instance = this;
         DontDestroyOnLoad(gameObject);
     }
     else
     {
         Destroy(gameObject);
     }
 }
Example #14
0
    private void Start()
    {
        score      = new GameScore();
        difficulty = Difficulty.EASY;

        Events.OnSelectFigure     += Event_OnSelectFigure;
        Events.OnClickPlaceholder += Event_OnClickPlaceholder;
        Events.OnGameEnded        += Event_OnGameEnded;
        Events.OnGameRestart      += Event_OnGameRestart;
        Events.OnDifficultyChange += Event_OnDifficultyChange;
        Events.OnBackToMain       += Event_OnBackToMain;
    }
Example #15
0
 //singleton
 void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(gameObject);
     }
     else
     {
         instance = this;
         DontDestroyOnLoad(gameObject); //persiste entre as cenas
     }
 }
Example #16
0
 public override void Interact()
 {
     if (State == ItemState.Disabled)
     {
         if (GameScore.CurrentEnergy >= GameSettings.WATER_PUMP_COST)
         {
             base.Interact();
             GameScore.AddEnergy(-GameSettings.WATER_PUMP_COST);
             AudioController.Instance.Play(Tags.SFX_Interact_WaterPump);
             _ground.FloodVelocity -= GameSettings.WATER_PUMP_DECREASE_FLOOD_VELOCITY;
         }
     }
 }
        public async Task <List <GameScore> > GetScoresAroundMeAsync(string gamerTag, int radius)
        {
            GameScore score = await _db.GetGamerRankAsync(gamerTag);

            if (score == null)
            {
                return(null);
            }

            List <GameScore> res = await _db.GetScoresAroundMeAsync(gamerTag, score.Rank, radius);

            return(res.OrderBy(s => s.Rank).ToList());
        }
Example #18
0
 private void LoadJsonFile()
 {
     if (File.Exists(pathJosn))
     {
         string    dataAsJson = File.ReadAllText(pathJosn);
         GameScore newGS      = JsonUtility.FromJson <GameScore>(dataAsJson);
         print(newGS);
     }
     else
     {
         print("no File");
     }
 }
Example #19
0
        public void DeuceShouldAdvantage()
        {
            var score = new GameScore();

            score.JokoWinPoint();
            score.JokoWinPoint();
            score.JokoWinPoint();
            score.RafaWinPoint();
            score.RafaWinPoint();
            score.RafaWinPoint();
            score.RafaWinPoint();
            Assert.AreEqual("advantage rafa", score.Score);
        }
Example #20
0
    //
    // Submit button
    public void Submit()
    {
        int score = GameScore.GetScore();

        // post high score
        string name = nameInput.text;

        HighScoreClient.ScorePair pair = new HighScoreClient.ScorePair();
        pair.Name  = name;
        pair.Score = score;

        highScoreClient.PostNewHighScore(pair, OnComplete);
    }
Example #21
0
        public override void SaveHighScoreIfNecessary(GameScore currentGame)
        {
            var bestGame = GetHighScore();

            if (bestGame == null || bestGame.BestAttempt > currentGame.BestAttempt)
            {
                using (var db = new GameContext())
                {
                    db.GameScores.RemoveRange(db.GameScores);
                    db.GameScores.Add(currentGame);
                    db.SaveChanges();
                }
            }
        }
Example #22
0
        public void ShouldDeuce()
        {
            var score = new GameScore();

            score.JokoWinPoint();
            score.JokoWinPoint();
            score.JokoWinPoint();
            score.RafaWinPoint();
            score.RafaWinPoint();
            score.RafaWinPoint();
            Assert.AreEqual("40", score.JokoGameScore.Points);
            Assert.AreEqual("40", score.RafaGameScore.Points);
            Assert.AreEqual("deuce", score.Score);
        }
Example #23
0
    void Start()
    {
//		dpadRed.enabled = false;
//		dpadGreen.enabled = false;
//		readyUp.enabled = false;
        disableAssassin.enabled = false;
        //disableAssassinTakedown.enabled = false;
        disableBodyguard.enabled = false;
        StartCoroutine(StartHideMainTitle());
        musicSource.Play();
        gameScore = GameObject.FindGameObjectWithTag("Environment").GetComponent <GameScore>();

        assassinPlayerNum = gameScore.getAssassinPlayerNum();
    }
        public async Task <GameScore> Create(string userId, string userEmail, int highScore)
        {
            var newGameScore = new GameScore()
            {
                UserId    = userId,
                UserEmail = userEmail,
                HighScore = highScore
            };

            _gameScoreRepository.Add(newGameScore);
            await _gameScoreRepository.SaveChangesAsync();

            return(newGameScore);
        }
Example #25
0
        public void RafaShouldWin()
        {
            var score = new GameScore();

            score.JokoWinPoint();
            score.JokoWinPoint();
            score.RafaWinPoint();
            score.RafaWinPoint();
            score.RafaWinPoint();
            score.RafaWinPoint();
            Assert.AreEqual("30", score.JokoGameScore.Points);
            Assert.AreEqual("game", score.RafaGameScore.Points);
            Assert.AreEqual("game rafa", score.Score);
        }
Example #26
0
 private Game ConvertGame(GameScore gs)
 {
     return(new Game
     {
         KickOff = DateTimeParser.ParseDate(gs.KickOffAt),
         HomeTeam = dbUnit.Teams.Get()
                    .Where(t => t.Name.Equals(gs.HomeTeam))
                    .FirstOrDefault(),
         AwayTeam = dbUnit.Teams.Get()
                    .Where(t => t.Name.Equals(gs.AwayTeam))
                    .FirstOrDefault(),
         MatchDay = GetMatchday(gs) ?? CreateMatchDay(gs)
     });
 }
Example #27
0
        // GET: GameScores/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            GameScore gameScore = db.GameScores.Find(id);

            if (gameScore == null)
            {
                return(HttpNotFound());
            }
            return(View(gameScore));
        }
Example #28
0
 void LoadScore()
 {
     if (File.Exists(filePath + "/" + FILE_NAME))
     {
         string loadedJson = File.ReadAllText(filePath + "/" + FILE_NAME);
         gameScore = JsonUtility.FromJson <GameScore>(loadedJson);
         Debug.Log("File loaded successfully");
     }
     else
     {
         gameScore.score = 100;
         Debug.Log("File not found");
     }
 }
Example #29
0
        public void AdvantageShouldBackToDeuce()
        {
            var score = new GameScore();

            score.JokoWinPoint();
            score.JokoWinPoint();
            score.JokoWinPoint();
            score.RafaWinPoint();
            score.RafaWinPoint();
            score.RafaWinPoint();
            score.RafaWinPoint();
            score.JokoWinPoint();
            Assert.AreEqual("deuce", score.Score);
        }
Example #30
0
        public async Task <IList <GameScore> > GetPlayerScores(int playerId)
        {
            string           query        = @"SELECT ps.player_id, ps.score, ps.session_start, ps.session_end 
                                FROM player_stats ps 
                                    INNER JOIN player 
                                        ON ps.player_id = player.player_id 
                                WHERE player.player_id = @ID";
            List <GameScore> playerScores = new List <GameScore>();

            using (var connection = new SqlConnection(ConnectionString))
            {
                await connection.OpenAsync();

                using (var tran = connection.BeginTransaction())
                {
                    using (var command = new SqlCommand(query, connection, tran))
                    {
                        try
                        {
                            command.Parameters.Add("@ID", SqlDbType.NVarChar);
                            command.Parameters["@ID"].Value = playerId;

                            SqlDataReader rdr = await command.ExecuteReaderAsync();

                            while (rdr.Read())
                            {
                                GameScore gameScore = new GameScore
                                {
                                    Score        = (int)rdr["score"],
                                    SessionStart = DateTime.Parse(rdr["session_start"].ToString()),
                                    SessionEnd   = DateTime.Parse(rdr["session_end"].ToString())
                                };
                                playerScores.Add(gameScore);
                            }
                            await rdr.CloseAsync();
                        }
                        catch (Exception Ex)
                        {
                            await connection.CloseAsync();

                            string msg = Ex.Message.ToString();
                            tran.Rollback();
                            throw;
                        }
                    }
                }
            }
            return(playerScores);
        }
Example #31
0
        public void UpdateScoresFailure()
        {
            var gameScore = new GameScore
            {
                AwayTeam    = "BASEL",
                HomeTeam    = "MANUTD",
                Group       = "A",
                KickOffAt   = "2017-09-28T66:00:00",
                LeagueTitle = "Champions League 2017/18",
                MatchDay    = 1,
                Score       = "2:0"
            };

            Assert.Throws <ClientRequestException>(() => service.UpdateScores(new GameScore[] { gameScore }));
        }
 partial void InsertGameScore(GameScore instance);
	// coroutine for api to send score to database
	private IEnumerator WaitRequestSendScore(GameScore gs){
		string gsJson = JsonUtility.ToJson (gs);
		//var encoding = new System.Text.UTF8Encoding();
		var postHeader = new Dictionary<string, string>();
		postHeader.Add("Content-Type", "text/json");
		//postHeader.Add("Content-Length", gsJson.Length.ToString());
		using (var www = new WWW(sendscoresurl, Encoding.UTF8.GetBytes(gsJson), postHeader))
		{
			
			yield return www;
			if (www.error == null)
			{
				//no error
				AddScoreReturn returnValue = JsonUtility.FromJson<AddScoreReturn> (www.text);
				//if get a correct response then show the leaderboards on the page on which the user's score is diplayed
				NavController.OnButtonLeaderboards ();
				HighScores (((returnValue.rank) / scoresPerPage));
			} 
			//error sending the score and receiving appropriate response
			else {
				PopUpText.text = "ERROR: Score could not be added.";
				HighScorePopUP.SetActive (true);
				isScoreError = true;
			}

		}
	}
 partial void DeleteGameScore(GameScore instance);
Example #35
0
 // Use this for initialization
 void Start()
 {
     timeLimit = defaulTimeLimit;
     timeNumber = (int)timeLimit;
     gamescore = GetComponent<GameScore>();
     //itemmanager2 = GetComponent<ItemManager2>();
     //defaultColor = countTime.GetComponent<Text>().color;
     //countTime.GetComponent<Text> ().text = defaulTimeLimit.ToString ();
 }
	//function called when user clicks submit for gameover
    public void AddScore()
    {
		if (NameInput.text != "" && TeamInput.text != "") {
			AddScoreButton.interactable = false;
			GameScore sendingScore = new GameScore () {
				Id = null,
				Name = NameInput.text,
				TeamName = TeamInput.text,
				Score = player.Score,
				LoansClosed = player.NumPropertiesClosed
			};
            		//start api call
			StartCoroutine (WaitRequestSendScore (sendingScore));

        
		}
		else {
			//if the user did not enter both the name and team name an error message opens
			HighScorePopUP.SetActive (true);
			PopUpText.text = "You must enter both a name and team name to submit a high score.";
		}
    }
Example #37
0
 public static string GameScoreToString(GameScore score) 
 {
     string sRet = "_ : _";
     switch (score)
     {
         case GameScore.NotSet:
             sRet = "_ : _";
             break;
         case GameScore.Score_BYE:
             sRet = " BYE ";
             break;
         case GameScore.Score_0_0:
             sRet = "0 : 0";
             break;
         case GameScore.Score_0_1:
             sRet = "0 : 1";
             break;
         case GameScore.Score_1_0:
             sRet = "1 : 0";
             break;
         case GameScore.Score_1_1:
             sRet = "1 : 1";
             break;
         case GameScore.Score_2_0:
             sRet = "2 : 0";
             break;
         case GameScore.Score_0_2:
             sRet = "0 : 2";
             break;
         case GameScore.Score_2_1:
             sRet = "2 : 1";
             break;
         case GameScore.Score_1_2:
             sRet = "1 : 2";
             break;
         default:
             break;
     }
     return sRet;
 }
Example #38
0
    void Awake()
    {
        DontDestroyOnLoad(this);

        secretsFound = new List<int>();
        completedLevels = new List<string>();

        if (!instance) {
            instance = this;
        }

        LoadFromString();
        saveOnExit = true;
    }
Example #39
0
    UiResultRow AddOrGetView(PlayerData player, GameScore score)
    {
        if (!Views.ContainsKey(player))
        {
            var view = List.AddItem(score, RowPrototype);
            view.PlayerName.text = player.Name;
            Views.Add(player, view);
        }

        return Views[player];
    }
 partial void UpdateGameScore(GameScore instance);
Example #41
0
    //public GUISkin skin;
    // Use this for initialization
    void Start()
    {
        touch = false;

        touchImage = GameObject.Find ("Panel").transform.Find("TouchImage").gameObject;
        gamescore = GameObject.FindWithTag("GameController").GetComponent<GameScore>();
        touchParticle = GameObject.Find("UIParticle/touch_effect");
    }
Example #42
0
 void Start()
 {
     score = (GameScore) GameObject.Find("Town").GetComponent("GameScore");
 }
Example #43
0
 // Use this for initialization
 void Start()
 {
     gamescore = GetComponent<GameScore>();
     gamescore.GameResult();
 }
Example #44
0
 public void OnApplicationQuit()
 {
     s_Instance = null;
 }
Example #45
0
 void OnApplicationQuit()
 {
     instance = null;
 }