Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static int scoreValue;
- void Start () {
- scoreValue = 0;
- }
- void Update () {
- Debug.Log ("ScoreValue: " + scoreValue);
- }
- void OnTriggerEnter2D(Collider2D col)
- {
- if (col.tag == "Farm") {
- collidedwithFarm = true;
- scoreValue = Random.Range (1, GameController.Fruit);
- Debug.Log ("Enemy takes: " + scoreValue);
- GameController.Fruit-= scoreValue;
- //Wallet += scoreValue;
- if (GameController.Fruit<= 0) {
- GameController.Fruit = 0;
- }
- }
- }
- public int randomValue;
- public int wallet;
- public bool collidedwithFarm = false;
- // Use this for initialization
- void Start () {
- wallet = 0;
- collidedwithFarm = false;
- randomValue = Random.Range (1, 101);
- }
- void OnTriggerEnter2D(Collider2D col)
- {
- if (col.tag == "playerKnife") {
- if (collidedwithFarm == false) {
- text.text = " " + randomValue;
- Debug.Log ("NOT COLLISION");
- GameController.Fruit+= randomValue;
- }
- else if (collidedwithFarm == true) {
- Debug.Log ("COLLISION");
- GameController.Fruit+= EnemyTheft.scoreValue+ randomValue;
- Debug.Log("Player gets back: " + EnemyTheft.scoreValue);
- wallet += EnemyTheft.scoreValue + randomValue;
- text.text = " " + wallet;
- Debug.Log ("In total: " + wallet);
- }
- }
- }
- public Text FruitText;
- public static int Fruit = 10;
- void Start()
- {
- SetFruitText ();
- Fruit = 10;
- }
- void SetFruitText ()
- {
- FruitText.text = "Fruits: " + Fruit.ToString();
- }
Add Comment
Please, Sign In to add comment