Ejemplo n.º 1
0
 public void OnSpawn(TextScore textScore, BallController controller)
 {
     this.textScore  = textScore;
     this.controller = controller;
     addForce();
     StartCoroutine(TimeToLiveCoroutine());
 }
Ejemplo n.º 2
0
 void Start()
 {
     if (sore == null)
     {
         DontDestroyOnLoad(gameObject);
         sore = this;
     }
     else if (sore != this)
     {
         Destroy(gameObject);
     }
     Load();
 }
Ejemplo n.º 3
0
 void LoadNewImage()
 {
     counter++;
     if (counter == 7)
     {
         TextScore.ResetText();
         currentImage.sprite = healthStatus [0];
         counter             = 0;
     }
     else
     {
         currentImage.sprite = healthStatus [counter];
     }
 }
Ejemplo n.º 4
0
    void OnTriggerEnter2D(Collider2D col)
    {
        if (col.gameObject.tag == "Blast")
        {
            TextScore.UpdateText();
            pl.SendMessage("SpawnPipe");
            Destroy(col.gameObject);
            Destroy(gameObject);
        }

        if (col.gameObject.tag == "Player")
        {
            pl = col.gameObject;
            col.SendMessage("LoadNewImage");
            col.SendMessage("PlayAnimation");
            col.SendMessage("Generate");
            Destroy(gameObject);
        }
    }
Ejemplo n.º 5
0
    // Update is called once per frame
    void Update()
    {
        if (ScoreScript.scoreValue >= scoreToWin)
        {
            winText.text = "You win!";
            winPanel.SetActive(true);
            gameOverPanel.SetActive(false);
            hpBar.SetActive(false);
            TextScore.SetActive(false);
            Player.SetActive(false);
        }

        if (healthSystem.health <= 0 && ScoreScript.scoreValue < scoreToWin)
        {
            gameOverText.text = "Game Over";
            gameOverPanel.SetActive(true);
            winPanel.SetActive(false);
            hpBar.SetActive(false);
            TextScore.SetActive(false);
        }
    }
Ejemplo n.º 6
0
    // Update is called once per frame
    void Update()
    {
        //Debug.Log("tilecheck: " + TileEventCheck);
        if (!TileEventCheck)
        {
            //Debug.Log("waypointindex received: " + player1.GetComponent<FollowThePath>().waypointIndex);
            //stop player movement once destination reached
            if (player1.GetComponent <FollowThePath>().waypointIndex >
                player1StartWaypoint + diceSideThrown)
            {
                player1.GetComponent <FollowThePath>().moveAllowed = false;
                player1MoveText.gameObject.SetActive(false);
                //everytime player 1 gets a turn set bool value to true
                player1turn = true;

                StartEvent1();

                player2MoveText.gameObject.SetActive(true);
                player1StartWaypoint = player1.GetComponent <FollowThePath>().waypointIndex - 1;

                SetQuestion();
            }

            if (player2.GetComponent <FollowThePath>().waypointIndex >
                player2StartWaypoint + diceSideThrown)
            {
                //Debug.Log("Enter player 2");
                player2.GetComponent <FollowThePath>().moveAllowed = false;
                player2MoveText.gameObject.SetActive(false);
                //everytime player 1 gets a turn set bool value to true
                player2turn = true;

                StartEvent1();

                player1MoveText.gameObject.SetActive(true);
                player2StartWaypoint = player2.GetComponent <FollowThePath>().waypointIndex - 1;

                SetQuestion();
            }
        }

        //tile event
        if (TileEventCheck)
        {
            checkWaypoint();
        }

        //if player 1 or 2 reaches first
        if (player1.GetComponent <FollowThePath>().waypointIndex ==
            player1.GetComponent <FollowThePath>().waypoints.Length ||
            player2.GetComponent <FollowThePath>().waypointIndex ==
            player2.GetComponent <FollowThePath>().waypoints.Length)
        {
            if (PanelEvent.gameObject.activeInHierarchy == true)
            {
                PanelEvent.gameObject.SetActive(false);
            }

            if (PanelQuiz.gameObject.activeInHierarchy == true)
            {
                PanelQuiz.gameObject.SetActive(false);
            }
            //if player 1 has a higher score then player 1 wins
            if (player1score > player2score)
            {
                PanelEnd.gameObject.SetActive(true);
                TextEnd.gameObject.SetActive(true);
                TextEnd.GetComponent <Text>().text = "Player 1 Wins";
                TextScore.gameObject.SetActive(true);
                TextScore.GetComponent <Text>().text = "Player 1: " + player1score + "\n" + "Player 2: " + player2score;
                gameOver = true;
            }
            else
            {
                PanelEnd.gameObject.SetActive(true);
                TextEnd.gameObject.SetActive(true);
                TextEnd.GetComponent <Text>().text = "Player 2 Wins";
                TextScore.gameObject.SetActive(true);
                TextScore.GetComponent <Text>().text = "Player 2: " + player2score + "\n" + "Player 1: " + player1score;
                gameOver = true;
            }
        }
    }
Ejemplo n.º 7
0
        public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req, ILogger log, ExecutionContext context)
        {
            #region cultureInfo - formats numbers into specific culture
            var cultureInfo = new CultureInfo("en-US");
            CultureInfo.DefaultThreadCurrentCulture = cultureInfo;
            #endregion

            log.LogInformation("C# HTTP trigger function processed a request.");

            #region ConfigurationBuilder() - builds key/value based configuration settings for use in an application
            var config = new ConfigurationBuilder()
                         .SetBasePath(context.FunctionAppDirectory)
                         .AddJsonFile("local.settings.json", optional: true, reloadOnChange: true)
                         .AddEnvironmentVariables()
                         .Build();
            #endregion

            string  requestBody = await new StreamReader(req.Body).ReadToEndAsync();
            dynamic data        = JsonConvert.DeserializeObject(requestBody);

            var randomScore = new Random().Next(1, 9);

            TextScore textScore = new TextScore()
            {
                DocumentName       = data?.name,
                TextSentimentScore = randomScore
            };

            string secret = data?.secret;

            var regexItem = new Regex("^[a-zA-Z0-9 ]+$");

            if (!(regexItem.IsMatch(textScore.DocumentName)))
            {
                return((ActionResult) new BadRequestObjectResult($"String cannot be empty or contain special characters"));
            }

            if (!(regexItem.IsMatch(secret)))
            {
                return((ActionResult) new BadRequestObjectResult($"Password cannot be empty or contain special characters"));
            }

            if (textScore.DocumentName.Length > 20 || secret.Length > 20)
            {
                return((ActionResult) new BadRequestObjectResult($"Sorry, string and password cannot exceed 20 characters"));
            }

            if (secret != "cloudrocks")
            {
                return((ActionResult) new BadRequestObjectResult($"Sorry, wrong password. Try again."));
            }

            var connectionstring = config.GetConnectionString("SqlConnectionString");

            using (SqlConnection conn = new SqlConnection(connectionstring))
            {
                conn.Open();
                var text = $"INSERT INTO DocumentTextScore (DocumentName, TextSentimentScore)" +
                           "VALUES ('" + textScore.DocumentName + "', " + textScore.TextSentimentScore + ")";
                //textScore.TextSentimentScore.ToString().Replace(",",".")

                using (SqlCommand cmd = new SqlCommand(text, conn))
                {
                    // Execute the command and the # rows affected.
                    var rows = await cmd.ExecuteNonQueryAsync();

                    log.LogInformation($"{rows} rows were updated");
                }
            }

            return((ActionResult) new OkObjectResult($"Hi {textScore.DocumentName}, You lucky number is: {textScore.TextSentimentScore} " + Environment.NewLine + "To see all results please visit https://webapplicationdaso.azurewebsites.net"));
            //return new RedirectResult("https://webapplicationdaso.azurewebsites.net/", true);
        }