<|start_filename|>Assets/Scripts/Behaviour/CircleMovement.cs<|end_filename|>
﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace MinimalShooting
{
    /// <summary>
    /// CircleMovement
    /// This class implements circle movement on the XZ plane.
    /// </summary>
    public class CircleMovement : MonoBehaviour
    {
        // Radius.
        [SerializeField]
        float radius = 0.5f;

        // It determines how fast turn this can be.
        [SerializeField]
        float rate = 10.0f;


        // Update is called once per frame
        void Update()
        {
            // Use trigonometric functions to implement.
            // Cos for x coords.
            // Sin for z coords.
            float x = Mathf.Cos(Time.time * this.rate) * this.radius;
            float z = Mathf.Sin(Time.time * this.rate) * this.radius;
            transform.localPosition = new Vector3(x, 0.0f, z);
        }
    }
}


<|start_filename|>Assets/Scripts/Public/Singleton.cs<|end_filename|>
﻿using UnityEngine;
using System.Collections;

namespace MinimalShooting
{
	public abstract class SingletonMonobehaviour<T> : MonoBehaviour where T : MonoBehaviour
	{
		static T instance;

		public static T Instance
		{
			get
			{
				if (null == instance)
				{
					instance = FindObjectOfType(typeof(T)) as T;
					if (null == instance)
					{
						GameObject obj = new GameObject(typeof(T).Name);
						instance = obj.AddComponent<T>();
					}
				}

				return instance;
			}
		}
	}


	public abstract class Singleton<T> where T : class, new()
	{
		static T instance;

		public static T Instance
		{
			get
			{
				if (instance == null)
				{
					instance = new T();
				}

				return instance;
			}
		}
	}
}


<|start_filename|>Assets/Scripts/Behaviour/SelfDestroyed.cs<|end_filename|>
﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace MinimalShooting
{
    /// <summary>
    /// SelfDestroyed
    /// This class implements auto destroy game object after wait for seconds.
    /// </summary>
    public class SelfDestroyed : MonoBehaviour
    {
        // How long it will wait before destroy.
        [SerializeField]
        float delay = 1.0f;

        // If this variable sets true, this object is deactive.
        [SerializeField]
        bool keepObjectAlive = false;


        private void OnEnable()
        {
            StopAllCoroutines();
            StartCoroutine(DelayAndDestroy());
        }


        public void SetDelay(float delay)
        {
            this.delay = delay;
        }


        public void SetUndead(bool isUndead)
        {
            this.keepObjectAlive = isUndead;
        }


        IEnumerator DelayAndDestroy()
        {
            yield return new WaitForSeconds(this.delay);

            if (this.keepObjectAlive)
            {
                gameObject.SetActive(false);
            }
            else
            {
                Destroy(gameObject);
            }
        }
    }
}


<|start_filename|>Assets/Scripts/Behaviour/Rotator.cs<|end_filename|>
﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace MinimalShooting
{
    /// <summary>
    /// Rotator
    /// This class implements to rotate transform.
    /// </summary>
    public class Rotator : MonoBehaviour
    {
        [Header("Turn speed")]
        [SerializeField]
        float turnSpeed = 1.0f;

        [Header("Angle axis")]
        [SerializeField]
        Vector3 axis = Vector3.up;

        [Header("Random or not")]
        [SerializeField]
        bool randomAxis = false;


        private void OnEnable()
        {
            if (this.randomAxis)
            {
                // If the randomAxis sets true, it will be invert rotation axis by 50 percent probably.
                if (Random.Range(0, 100) < 50)
                {
                    this.axis *= -1.0f;
                }
            }
        }


        /// <summary>
        /// When apply speed faster or slower.
        /// </summary>
        /// <param name="rate"></param>
        public void SetSpeedOption(float rate)
        {
            this.turnSpeed *= rate;
        }


        // Update is called once per frame
        void Update()
        {
            // Rotate 360 degree per one seconds.
            // If turnSpeed is less than 1, it will be slower.
            // If turnSpeed is greater than 1, it will be faster.
            transform.Rotate(this.axis, 360.0f * this.turnSpeed * Time.deltaTime);
        }
    }
}
