Guest User

bla bla

a guest
May 10th, 2014
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. using System.IO;
  2. using System;
  3. using System.Collections.Generic;
  4.  
  5. public class ShootingScript
  6. {
  7. public List<Weapon> weapons = new List<Weapon>();
  8. Weapon currentWeapon;
  9.  
  10. public void Start()
  11. {
  12. Cannon cannon = new Cannon();
  13. Rocket rocket = new Rocket();
  14. Railgun railgun = new Railgun();
  15.  
  16. weapons.Add(new Cannon());
  17. weapons.Add(new Rocket());
  18. weapons.Add(new Railgun());
  19.  
  20. // weapons
  21. currentWeapon = weapons[0] as Weapon;
  22. }
  23.  
  24.  
  25. }
  26.  
  27. public interface IWeapon
  28. {
  29. void Shoot();
  30. }
  31.  
  32. public class Weapon
  33. {
  34. public float cooldown;
  35. public float elapsedTime;
  36. public string name;
  37. }
  38.  
  39. public class Cannon : Weapon
  40. {
  41.  
  42.  
  43. public Cannon()
  44. {
  45. this.cooldown = 0.5f;
  46. this.elapsedTime = 0f;
  47. this.name = "DziaƂko";
  48. }
  49.  
  50. public void Shoot()
  51. {
  52.  
  53. }
  54.  
  55.  
  56. }
  57.  
  58. public class Rocket : Weapon
  59. {
  60. public float cooldown;
  61. public float elapsedTime;
  62. public string name;
  63.  
  64. public Rocket()
  65. {
  66. cooldown = 3f;
  67. elapsedTime = 0f;
  68. name = "Rakiety";
  69. }
  70.  
  71. public void Shoot() // rocket
  72. {
  73. throw new System.NotImplementedException();
  74. }
  75. }
  76.  
  77. public class Railgun : Weapon
  78. {
  79. public float cooldown;
  80. public float elapsedTime;
  81. public string name;
  82.  
  83. public Railgun()
  84. {
  85. cooldown = 5f;
  86. elapsedTime = 0f;
  87. name = "Railgun";
  88. }
  89.  
  90. public void Shoot() // railgun
  91. {
  92. throw new System.NotImplementedException();
  93. }
  94. }
  95.  
  96. class Program
  97. {
  98. static void Main()
  99. {
  100.  
  101.  
  102. ShootingScript a = new ShootingScript();
  103. a.Start();
  104. Console.WriteLine(a.weapons[0].name);
  105.  
  106. }
  107. }
Advertisement
Add Comment
Please, Sign In to add comment