Hi guys im trying to emplement a simple cooldown systesm and animate Fillamount of a gui so i can animatre it by its cooldown time.
100,44
101,23
102,31
112,1
using UnityEngine;
using System.Collections;
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class Player : MonoBehaviour {
//Mouse controll.
public float speed;
// Spacecraft Speed.
public float Spacecraftspeed = 0;
public float SpaceCraftAccelleration = 0.4f;
public float SpaceCraftMaximumSpeed = 12;
public float SpaceCraftBooster = 15;
public float FireRate = 2;
public Transform ship;
//CoolDowns:
public float Option1 = 5;
public float Option2 = 10;
public float Option3 = 20;
public float Option4 = 30;
public float FillAmountZer0 = 0;
//get Image / Fill for cooldown animation
public GameObject Cooldown1;
public GameObject Cooldown2;
public GameObject Cooldown3;
public GameObject Cooldown4;
//Cooldown Timers / Get Text GUI to animate Time.:
public GameObject Cooldown1_timer;
public GameObject Cooldown2_timer;
public GameObject Cooldown3_timer;
public GameObject Cooldown4_timer;
public GameObject MainGuns;
public GameObject Special01;
public GameObject Special02;
public GameObject Special03;
public GameObject Special04;
public Transform MainGunsLoc;
private Transform GunsLocation;
//---------------------------------------------------------------------------------------------------------------------
// Innput Controll.
void Update () {
// Mouse Movement
Ray hit : RaycastHit;
if(Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), hit))
transform.LookAt(hit.point);
}
if (Input.GetMouseButton(0))
Debug.Log("Pressed left click.");
// Fire Main Engine.
if (Input.GetMouseButton(1))
Debug.Log("Pressed right click.");
// Fire Main guns.
// ASDF INPUT:
//---------------------------------------------------------------------------------------------------------------------
if (Input.GetButtonDown("A"))
Debug.Log("Pressed A click.");
GunsLocation = (Transform)Instantiate (Special01, transform.position, transform.rotation);
Image Cooldown1 = GetComponent<Image>();
Cooldown1.fillAmount += 1.0f/Option1 * Time.deltaTime;
//---------------------------------------------------------------------------------------------------------------------
if (Input.GetButtonDown("S"))
Debug.Log("Pressed S click.");
GunsLocation = (Transform)Instantiate (Special02, transform.position, transform.rotation);
Image Cooldown2 = GetComponent<Image>();
Cooldown2.fillAmount += 1.0f/Option2 * Time.deltaTime;
//---------------------------------------------------------------------------------------------------------------------
if (Input.GetButtonDown("D"))
Debug.Log("Pressed D click.");
GunsLocation = (Transform)Instantiate (Special03, transform.position, transform.rotation);
Image Cooldown3 = GetComponent<Image>();
Cooldown3.fillAmount += 1.0f/Option3 * Time.deltaTime;
//---------------------------------------------------------------------------------------------------------------------
if (Input.GetButtonDown("F"))
Debug.Log("Pressed F click.");
GunsLocation = (Transform)Instantiate (Special04, transform.position, transform.rotation);
Image Cooldown4 = GetComponent<Image>();
Cooldown4.fillAmount += 1.0f/Option4 * Time.deltaTime;
}
}