void Start() { originalPosition = transform.localPosition; audioSource = GetComponent <AudioSource>(); holographicSight = GetComponent <HolographicSight>(); laserSight = GetComponent <LaserSight>(); silencer = GetComponent <Silencer>(); bool hologramSightAttached = PlayerPrefs.GetInt("HologramSight", 0) == 1; bool laserSightAttached = PlayerPrefs.GetInt("LaserSight", 0) == 1; bool silencerAttached = PlayerPrefs.GetInt("Silencer", 0) == 1; if (hologramSightAttached) { holographicSight.Enable(); } if (laserSightAttached) { laserSight.Enable(); } if (silencerAttached) { silencer.Enable(); } }
static void Main(string[] args) { IGun playerGun; Rifle rifle = new Rifle(); HolographicSight sight = new HolographicSight(); DotSight dotSight = new DotSight(); playerGun = rifle; // Player mengambil Rifle playerGun.Reload(); playerGun.Shoot(); // Shoot(); Console.WriteLine("Ammo Left : {0}", rifle.Ammo); playerGun.FiringMode(); playerGun.Shoot(); // Shoot(); Console.WriteLine("Ammo Left : {0}", rifle.Ammo); rifle.Sight = sight; playerGun.Scope(); rifle.Sight = dotSight; playerGun.Scope(); playerGun.Shoot(); Console.ReadKey(); }