Inheritance: MonoBehaviour
示例#1
0
 void Start()
 {
     scorekp = GameObject.Find ("ScoreKeeper").GetComponent<scoreKeeper> ();
     float distance = this.transform.position.z - Camera.main.transform.position.z;
     Vector3 leftCam = Camera.main.ViewportToWorldPoint (new Vector3(0,0,distance));
     Vector3 rightCam = Camera.main.ViewportToWorldPoint (new Vector3(1,1,distance));
     min = leftCam;
     max = rightCam;
 }
示例#2
0
 void OnTriggerEnter(Collider otherCollider)
 {
     if (otherCollider == expectedCollider)
     {
         scoreKeeper scoreKeep = FindObjectOfType <scoreKeeper>();
         scoreKeep.IncrementScore(scorePerHit);
         print("Second trigger triggered");
     }
 }
示例#3
0
 void Start()
 {
     GetComponent <Rigidbody2D>().velocity = new Vector2(-14f, 0);
     p1Goal      = GameObject.Find("P1Goal");
     p2Goal      = GameObject.Find("P2Goal");
     p1Text      = GameObject.Find("P1 Score").GetComponent <Text>();
     totalP1Text = GameObject.Find("Total P1 Score").GetComponent <Text>();
     p2Text      = GameObject.Find("P2 Score").GetComponent <Text>();
     totalP2Text = GameObject.Find("Total P2 Score").GetComponent <Text>();
     ScoreKeeper = GameObject.Find("ScoreKeeper").GetComponent <scoreKeeper>();
 }
示例#4
0
    // Use this for initialization
    void Start()
    {
        score = 0;

        scoreKeeper previousScore = FindObjectOfType <scoreKeeper> ();

        if (previousScore)
        {
            score = previousScore.score;
            Destroy(previousScore.gameObject);
        }
    }
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Player")
     {
         other.GetComponent <AudioSource>().Play(0);
         ScoreKeeper = other.gameObject.GetComponent <scoreKeeper>();
         ScoreKeeper.addCoins();
         Instantiate(prefabSFX, new Vector3(this.transform.position.x, this.transform.position.y, this.transform.position.z), Quaternion.identity);
         coinUI.GetComponent <Animator>().Play("uiSpin", -1, 0f);
         Destroy(this.gameObject);
     }
 }
示例#6
0
    void OnTriggerEnter2D(Collider2D col)
    {
        if (col.gameObject.tag == "Player")
        {
            Debug.Log("Start");
            scoreKeeper script = goScorer.GetComponent <scoreKeeper>();

            GameObject parent = transform.parent.gameObject;

            script.Score(parent);

            Debug.Log("End");
        }
    }
示例#7
0
    void Start()
    {
        keeper = FindObjectOfType <scoreKeeper>() ?? Instantiate(new scoreKeeper());
        int highscore = getHighScore();

        scoreText.text = $"score: {(int)keeper.score}";
        if (keeper.score > highscore)
        {
            highscore = (int)keeper.score;
            saveHighScore(highscore);
        }

        highScoreText.text = $"high score: {highscore}";
    }
示例#8
0
    void Start()
    {
        AddLayer(5);
        Debug.Log("start");
        currentSpeed = initialFallSpeed;
        timePassed   = 0;
        nextOffset   = 0;
        multiplier   = 1;

        keeper = FindObjectOfType <scoreKeeper>();
        if (keeper == null)
        {
            var temp = Instantiate(new GameObject());
            keeper = temp.AddComponent <scoreKeeper>();
        }
        keeper.score = 0;
    }
示例#9
0
 // Use this for initialization
 void Start()
 {
     p1FinalText       = GameObject.Find("P1 Final Score").GetComponent <Text>();
     p2FinalText       = GameObject.Find("P2 Final Score").GetComponent <Text>();
     wonResult         = GameObject.Find("Won").GetComponent <Text>();
     ScoreKeeper       = GameObject.Find("ScoreKeeper").GetComponent <scoreKeeper>();
     p1FinalText.text += ScoreKeeper.Truep1Score.ToString();
     p2FinalText.text += ScoreKeeper.Truep2Score.ToString();
     if (ScoreKeeper.Truep1Score > ScoreKeeper.Truep2Score)
     {
         wonResult.text = "Player 1 is the winner";
     }
     else if (ScoreKeeper.Truep2Score > ScoreKeeper.Truep1Score)
     {
         wonResult.text = "Player 2 is the winner";
     }
     else if (ScoreKeeper.Truep1Score > ScoreKeeper.Truep2Score)
     {
         wonResult.text = "Draw";
     }
 }
示例#10
0
	void OnCollisionEnter(Collision collision){
		scoreKeeper scoreKeep = FindObjectOfType<scoreKeeper>();
		scoreKeep.IncrementScore(scorePerHit);
	}
示例#11
0
 private void Start()
 {
     scoreKeeperScript = FindObjectOfType <scoreKeeper>();
 }
示例#12
0
 // Use this for initialization
 void Start()
 {
     scoreText      = GetComponent <Text> ();
     scoreDisplayed = FindObjectOfType <scoreKeeper>();
 }
示例#13
0
 // Use this for initialization
 void Start()
 {
     playerRef = GameObject.Find("Player").GetComponent <scoreKeeper>();
 }
 private void Start()
 {
     scoreKeeperScript = FindObjectOfType <scoreKeeper>();
     progressBar       = gameObject.GetComponent <Image>();
 }
示例#15
0
 void Start()
 {
     scoreKeeper = GameObject.FindObjectOfType <scoreKeeper>();
 }
示例#16
0
 private void Start()
 {
     scoreKeeper = GameObject.Find("Score").GetComponent <scoreKeeper>();
 }