updateScore() public method

public updateScore ( int toAdd ) : void
toAdd int
return void
Beispiel #1
0
    public GameObject nextPlayer;// Drag & Drop the prefab with the Ghost script attached to it
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Egg")
        {
            scoreScript.updateScore();

            Destroy(other.gameObject); // Or whatever way you want to remove the coin.
            if (scoreScript.score == 1)
            {
                (Instantiate(FEggPrefab, Spawn.position, Spawn.rotation)).SetTarget(gameObject, 8);
            }
            else if (scoreScript.score == 2)
            {
                nextPlayer = GameObject.FindGameObjectsWithTag("Player")[1];
                (Instantiate(FEggPrefab, Spawn.position, Spawn.rotation)).SetTarget(nextPlayer, 8);
            }
            else
            {
                nextPlayer = GameObject.FindGameObjectsWithTag("Player")[2];
                (Instantiate(FEggPrefab, Spawn.position, Spawn.rotation)).SetTarget(nextPlayer, 8);
            }
        }
        else if (other.tag == "EndPoint")
        {
            PlayerPrefs.SetInt("TotalEggs", scoreScript.score + PlayerPrefs.GetInt("TotalEggs"));
            gameController.CompleteLevel();
        }
        else
        {
        }
    }
Beispiel #2
0
    void OnTriggerEnter2D(Collider2D col)
    {
        if (col.tag == "food")
        {
            Tail.Grow(5);
            StartCoroutine(Tail.Flash());
            food.GetComponent <Food>().respawn();
            Score.updateScore(50);
        }
        else if (col.tag == "Wall")
        {
            float rotZ     = transform.eulerAngles.z;
            float rotZWall = col.gameObject.transform.eulerAngles.z;
            transform.rotation = Quaternion.Euler(0, 0, rotZWall - rotZ);
        }
        else if (col.tag == "Wall_2")
        {
            float rotZ = transform.eulerAngles.z;
            transform.rotation = Quaternion.Euler(0, 0, -rotZ);
        }
        else
        {
            TurnOffRotationMode();

            aud = GetComponent <AudioSource>();
            aud.Play();
            death = true;

            deathScreen.GetComponent <Image>().CrossFadeAlpha(1, 1, false);
        }
    }
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            //try
            //{

            string ID         = this.txtID.Text;
            string courseID   = this.cbbCourse.SelectedValue.ToString();
            double scoreValue = Convert.ToDouble(txtScore.Text);
            string comment    = this.txtComment.Text;

            if (score.updateScore(ID, courseID, scoreValue, comment))
            {
                MessageBox.Show("Student Score Updated", "Update Score", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Student Score Not Updated", "Update Score", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            BindingSource bs = new BindingSource();
            DataTable     dt = StudentProjectController.FillDataSetProject(this.txtID.Text.ToString()).Tables[0];

            bs.DataSource = dt;
            this.dataSearchID.DataSource = bs;
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show(ex.Message, "Update Score", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //}
        }
Beispiel #4
0
 void OnTriggerEnter2D(Collider2D other)
 {
     //Checks if the tag of the object colliding with the game object is the destined target.
     if (other.tag == target)
     {
         //If the destined target has the Player tag then call the playerDead function in the gameManager script
         if (other.tag == "Player")
         {
             gameManager.playerDead();
         }
         else
         {
             //If the tag is not Player then call the updateScore function in the Score script
             //Sets the HasShot variable from the PlayerControl script to false to allow the player to shoot again
             Score.updateScore();
             FindObjectOfType <PlayerControl>().HasShot = false;
         }
         //Plays the EnemyDeath sound and destroys the target gameObject, spawns the explosion animation at the position the gameObject was destroyed at and then destroys this animation also
         FindObjectOfType <AudioManager>().Play("EnemyDeath");
         Destroy(other.gameObject);
         GameObject fire = (GameObject)Instantiate(explosion, other.gameObject.transform.position, Quaternion.identity);
         Destroy(fire, 1.0f);
         Destroy(gameObject);
     }
 }
    private void DestroyShip()
    {
        GameObject explosionAnimation = Instantiate(explosion, transform.position, Quaternion.identity);

        Destroy(explosionAnimation, 0.25f);
        Destroy(gameObject);
        Score.updateScore();
    }
Beispiel #6
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.CompareTag("Player"))
     {
         Score.updateScore();
         Destroy(gameObject);
     }
 }
Beispiel #7
0
 public void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.tag == "bullet")
     {
         gameObject.SetActive(false);
         GameObject.Destroy(collision.gameObject);
         scoreScript.updateScore(10);
     }
 }
Beispiel #8
0
 private void OnCollisionEnter(Collision col)
 {
     if (col.gameObject.tag == "bullet")
     {
         TeleportRandomly();
         GameObject.Destroy(col.gameObject);
         scoreScript.updateScore(10);
     }
 }
Beispiel #9
0
    void FixedUpdate()
    {
        float distanceToPlayer = (player.transform.position - this.transform.position).magnitude;

        if (distanceToPlayer < distanceToRun)
        {
            secondsSinceLastRun = 0;
            RunAway();
        }
        else
        {
            secondsSinceLastRun += Time.deltaTime; // add in the time from the past frame.
            if (secondsSinceLastRun < restTimeAfterRun)
            {
                // we ran away within the past restTimeAfterRun seconds, so we can't run away right now.
                // do nothing
            }
            else
            {
                if (!isMovingRandomly)
                {
                    isMovingRandomly = true;
                    // restart invoking RandomMotion.
                    float startRandomMovementAtTime = Random.Range(0f, 4f);
                    float randomMovementInterval    = Random.Range(3f, 6f);
                    InvokeRepeating("RandomMotion", startRandomMovementAtTime, randomMovementInterval);
                }
            }
        }

        float distanceToHomeCenter = (this.transform.position - home.transform.position).magnitude;

        if (homeRadius - distanceToHomeCenter > homeRadius / 20)
        {
            if (!isHome)
            {
                // this is the first and only time we update the score.
                // after this, we'll update isHome so we won't ever update the score again for the same cat.
                score.updateScore();
            }
            isHome = true; // if cat is home, it stays home
        }
        if (isHome)
        {
            // going to manually make the collider act "hollow" by reflecting velocity whenever the cat attempts to leave home.
            // technically we probably could do this with a mesh collider, but this is easier to reason about for me right now.
            // source: https://answers.unity.com/questions/1074916/create-hollow-sphere-with-objects-bouncing-around.html
            // note that changing the velocity with Vector3.Reflect probably requires that the normal vector param be normalized. Not sure why-- it's not documented or noted in the answer anywhere.
            // Also note that changing velocity directly is discouraged, so ehh.... TODO maybe.
            if (distanceToHomeCenter > homeRadius)
            {
                // cat's attempting to leave!
                catRigidBody.velocity = Vector3.Reflect(catRigidBody.velocity, (home.transform.position - this.transform.position).normalized);
                catRigidBody.position = home.transform.position + (this.transform.position - home.transform.position).normalized * homeRadius * 0.999f;
            }
        }
    }
Beispiel #10
0
 private void OnTriggerEnter2D(Collider2D col)
 {
     if (col.tag == target)
     {
         Destroy(col.gameObject);
         Score.updateScore();
         Destroy(gameObject);
         GameObject expl = Instantiate(explosion, col.transform.position, Quaternion.identity);
         Destroy(expl, 0.3f);
     }
 }
Beispiel #11
0
    public void takeDamage(int dmg)
    {
        int x = Random.Range(0, clips.Length);

        aS.PlayOneShot(clips[x]);
        health            -= dmg;
        healthSlider.value = health;
        if (health <= 0)
        {
            lossScreen.SetActive(true);
            Cursor.visible   = true;
            Cursor.lockState = CursorLockMode.None;
            pC.isPaused      = true;
            sC.updateScore();
        }
    }
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == target)
        {
            if (other.tag == "Player")
            {
                gameManager.playerDead();
            }
            else
            {
                Score.updateScore();
            }

            Destroy(other.gameObject);
            Destroy(gameObject);
        }
    }
Beispiel #13
0
    void OnCollisionEnter2D(Collision2D col)
    {
        if (gameObject.tag == "Alien")
        {
            Score score = GameObject.Find("score").GetComponent <Score> ();
            score.updateScore(gameObject);
            MovementManager mm = GameObject.Find("alienManager").GetComponent <MovementManager> ();
            mm.increaseGameSpeed();
            if (!GameData.gameHuman)
            {
                Sensor s = GameObject.Find("autoPlayer").GetComponent <Sensor> ();
                s.removeFromGrid(gameObject.GetComponent <alienController> ().gridpos);
            }
            ExplosionManager e = gameObject.GetComponent <ExplosionManager> ();
            e.explode();
        }

        if (gameObject.tag == "RedShip")
        {
            Score score = GameObject.Find("score").GetComponent <Score> ();
            score.updateScore(gameObject);
            if (!GameData.gameHuman)
            {
                if (sensor == null)
                {
                    sensor = GameObject.Find("autoPlayer").GetComponent <Sensor> ();
                }
                sensor.setRedShip(null);
            }
        }

        if (gameObject.tag == "FinishLine" && col.gameObject.tag == "Alien")
        {
            gm.startGameAuto();
        }

        if (gameObject.tag == "Player")
        {
            gm.playerDead();
        }

        if (gameObject.tag != "FinishLine")
        {
            Destroy(gameObject);
        }
    }
Beispiel #14
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == target)
     {
         if (other.tag == "Player")
         {
             gameManager.playerDead();
         }
         else
         {
             Score.updateScore();
         }
         Destroy(other.gameObject);
         GameObject fire = (GameObject)Instantiate(explosion, other.gameObject.transform.position, Quaternion.identity);
         Destroy(fire, 1.0f);
         Score.updateScore();
         Destroy(gameObject);
     }
 }
Beispiel #15
0
    public void updateScore(int update)
    {
        Score s = Text.GetComponent <Score>();

        s.updateScore(update);
    }
Beispiel #16
0
    void OnDestroy()
    {
        Score score = GameObject.Find("score").GetComponent <Score> ();

        score.updateScore(gameObject);
    }