Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.IO;
- using System;
- using System.Collections.Generic;
- public class ShootingScript
- {
- public List<Weapon> weapons = new List<Weapon>();
- Weapon currentWeapon;
- public void Start()
- {
- Cannon cannon = new Cannon();
- Rocket rocket = new Rocket();
- Railgun railgun = new Railgun();
- weapons.Add(new Cannon());
- weapons.Add(new Rocket());
- weapons.Add(new Railgun());
- // weapons
- currentWeapon = weapons[0] as Weapon;
- }
- }
- public interface IWeapon
- {
- void Shoot();
- }
- public class Weapon
- {
- public float cooldown;
- public float elapsedTime;
- public string name;
- }
- public class Cannon : Weapon
- {
- public Cannon()
- {
- this.cooldown = 0.5f;
- this.elapsedTime = 0f;
- this.name = "DziaĆko";
- }
- public void Shoot()
- {
- }
- }
- public class Rocket : Weapon
- {
- public float cooldown;
- public float elapsedTime;
- public string name;
- public Rocket()
- {
- cooldown = 3f;
- elapsedTime = 0f;
- name = "Rakiety";
- }
- public void Shoot() // rocket
- {
- throw new System.NotImplementedException();
- }
- }
- public class Railgun : Weapon
- {
- public float cooldown;
- public float elapsedTime;
- public string name;
- public Railgun()
- {
- cooldown = 5f;
- elapsedTime = 0f;
- name = "Railgun";
- }
- public void Shoot() // railgun
- {
- throw new System.NotImplementedException();
- }
- }
- class Program
- {
- static void Main()
- {
- ShootingScript a = new ShootingScript();
- a.Start();
- Console.WriteLine(a.weapons[0].name);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment