Guest User

Untitled

a guest
Oct 18th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. public static int scoreValue;
  2.  
  3. void Start () {
  4. scoreValue = 0;
  5. }
  6.  
  7. void Update () {
  8. Debug.Log ("ScoreValue: " + scoreValue);
  9. }
  10.  
  11. void OnTriggerEnter2D(Collider2D col)
  12. {
  13. if (col.tag == "Farm") {
  14. collidedwithFarm = true;
  15. scoreValue = Random.Range (1, GameController.Fruit);
  16. Debug.Log ("Enemy takes: " + scoreValue);
  17. GameController.Fruit-= scoreValue;
  18. //Wallet += scoreValue;
  19. if (GameController.Fruit<= 0) {
  20. GameController.Fruit = 0;
  21. }
  22. }
  23. }
  24.  
  25. public int randomValue;
  26. public int wallet;
  27.  
  28. public bool collidedwithFarm = false;
  29.  
  30. // Use this for initialization
  31. void Start () {
  32. wallet = 0;
  33. collidedwithFarm = false;
  34. randomValue = Random.Range (1, 101);
  35.  
  36. }
  37.  
  38. void OnTriggerEnter2D(Collider2D col)
  39. {
  40. if (col.tag == "playerKnife") {
  41. if (collidedwithFarm == false) {
  42. text.text = " " + randomValue;
  43. Debug.Log ("NOT COLLISION");
  44. GameController.Fruit+= randomValue;
  45. }
  46. else if (collidedwithFarm == true) {
  47. Debug.Log ("COLLISION");
  48. GameController.Fruit+= EnemyTheft.scoreValue+ randomValue;
  49. Debug.Log("Player gets back: " + EnemyTheft.scoreValue);
  50. wallet += EnemyTheft.scoreValue + randomValue;
  51. text.text = " " + wallet;
  52. Debug.Log ("In total: " + wallet);
  53. }
  54. }
  55. }
  56.  
  57. public Text FruitText;
  58. public static int Fruit = 10;
  59.  
  60. void Start()
  61. {
  62. SetFruitText ();
  63. Fruit = 10;
  64. }
  65.  
  66.  
  67. void SetFruitText ()
  68. {
  69. FruitText.text = "Fruits: " + Fruit.ToString();
  70. }
Add Comment
Please, Sign In to add comment