Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class LinternaMasZoomb : MonoBehaviour {
- [Header("Copyright")]
- [Header("By")]
- [Header("Diamond32 Tutoriales")]
- public Camera cam; //Camara Principal
- public Light light; //Luz de la linterna
- public KeyCode zoom; //Boton para hacer zoom
- public KeyCode OffOnLight; //Boton para encender y apagar linterna
- public int maximoZoom = 35; //Zoom maximo siempre tiene que estar menor que el field view original
- public Image barra; //BarraDeLaBateria
- private bool LinternaEncendida; //No mover
- public float Bateriamaxima; //Bateria maxima pueden ponerlo como quieran
- float CurBateria; //No mover
- [Header("Rellenar bateria Automaticamente")]
- public bool RellenarBateriaAlApagarLinterna;
- void Start () {
- light.enabled = (LinternaEncendida);
- CurBateria = Bateriamaxima;
- }
- // Update is called once per frame
- void Update () {
- barra.fillAmount = CurBateria / Bateriamaxima;
- if (CurBateria >= Bateriamaxima) {
- CurBateria = Bateriamaxima;
- }
- if (CurBateria <= 0) {
- CurBateria = 0;
- }
- if (LinternaEncendida) {
- CurBateria -= Time.fixedUnscaledDeltaTime;
- } else {
- if (RellenarBateriaAlApagarLinterna) {
- CurBateria += Time.fixedDeltaTime;
- }
- }
- if (CurBateria <= 0) {
- light.enabled = false;
- }
- if (Input.GetKeyDown (OffOnLight)) {
- light.enabled = !light.enabled;
- LinternaEncendida = !LinternaEncendida;
- }
- if (Input.GetKey (zoom)) {
- cam.fieldOfView = (maximoZoom);
- } else {
- cam.fieldOfView = 60;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement