Posts

Portfolio of my Projects

Image
This is a portfolio video of my game projects done in various engines including unity. Pls read more to view the video

Real Time(taking actual present system time) Countdown Timer

using System.Collections; using System.Collections.Generic; using UnityEngine; using System; using UnityEngine.UI; public class NewTimer : MonoBehaviour { public Text timerText; // Text that holds the time public float msToWait = 5000.0f; // Time in milliseconds private ulong TimerTarget; int buttoncounter = 0; // counting for clicks of button void Start () { TimerTarget = ulong.Parse(PlayerPrefs.GetString("LastChestOpen")); timerText = GetComponent<Text>(); } // Update is called once per frame void Update () { //set timer ulong diff = ((ulong) DateTime.Now.Ticks - TimerTarget); ulong m = diff / TimeSpan.TicksPerMillisecond; float secondsLeft = (float)(msToWait - m) / 1000.0f; string r = ""; //Hours r+= ((int) secondsLeft / 3600).ToString() + "H : "; secondsLeft -= ((int)secondsLeft / 3600) * 3600; //minutes r+= ((int) secondsLeft / 60).ToString("00") + "M : ";

Audio Playing for Different Objects On Trigger

using System.Collections; using System.Collections.Generic; using UnityEngine; public class TriggerAudio : MonoBehaviour { public AudioClip audioPlay; AudioSource audioSrc; bool alreadyPlayed = false; // Use this for initialization void Start () { audioSrc = GetComponent<AudioSource> (); } void OnTriggerEnter() { if (!alreadyPlayed) { audioSrc.PlayOneShot (audioPlay); alreadyPlayed = true; } } }