AppingCS

SnowBall_Shoot

Dec 9th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.88 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class SnowBall_Shot : MonoBehaviour {
  6. public int CostSnow = 20;
  7. public Text CostText;
  8. public GameObject SnowBall;
  9. public float Timer = 1;
  10.  
  11.     // Use this for initialization
  12.     void Start () {
  13.        
  14.     }
  15.    
  16.     // Update is called once per frame
  17.     void Update () {
  18.     if(CostSnow <= 0){
  19.         CostSnow = 0;
  20.     }
  21.         CostText.text = "<color=red>" + "Снежков : " + "</color>" + CostSnow;
  22.         if(Input.GetMouseButtonDown(0))
  23.         {
  24.             CostSnow -= 1;
  25.             if(CostSnow > 0){
  26.         Transform Snowball_move = Instantiate(SnowBall.transform, gameObject.transform.position, Quaternion.identity);
  27.             Snowball_move.GetComponent<Rigidbody>().AddForce(transform.forward * 1500);
  28.    
  29.            
  30.        
  31.         }else{
  32.             Debug.Log("Нет снежков !");
  33.         }
  34.         }
  35.     }
  36.    
  37.  
  38.     }
Advertisement
Add Comment
Please, Sign In to add comment