-
Notifications
You must be signed in to change notification settings - Fork 0
/
Finish.cs
46 lines (37 loc) · 1.34 KB
/
Finish.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Finish : MonoBehaviour
{
[Header("X score: 1,2,3..")]
public int x;
[Header("The number of coins that the player will receive")]
public int addCoins;
private int Coin;
[HideInInspector]public CylinderCont cylinder;
[HideInInspector]public AudioSource sound;
private bool check = false;
void Start()
{
cylinder = GameObject.Find("Players/Cylinder").GetComponent<CylinderCont>();
sound = GameObject.Find("Finish").GetComponent<AudioSource>();
}
void OnCollisionEnter(Collision collision)
{
if (collision.collider.tag == "Player_") //When the player, namely the Player, touches the finish, add more to the total number of coins, set the finish points equal to X, victory = 1. Turn on the animation of victory.
{
if (check == false)
{
Coin = PlayerPrefs.GetInt("Coins");
Coin = Coin + addCoins;
PlayerPrefs.SetInt("Coins", Coin);
PlayerPrefs.SetInt("xScore", x);
PlayerPrefs.SetInt("isWin", 1);
cylinder.animator.SetBool("win", true);
sound.Play();
Vibration.Vibrate(100);
check = true;
}
}
}
}