- Timestamp:
- 2015-06-24 15:14:15 (8 years ago)
- Location:
- 2014/30/MitjaK/Attack to Agora/Attack to Agora/Attack to Agora/Attack to Agora
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
2014/30/MitjaK/Attack to Agora/Attack to Agora/Attack to Agora/Attack to Agora/Attack_to_Agora.cs
r6249 r6272 24 24 PlatformCharacter taistelija; 25 25 26 int kenttaNro = 1;26 int kenttaNro = 2; 27 27 28 28 /// <summary> 29 29 /// Viimeisen pelissä olevan kentän indeksi. 30 30 /// </summary> 31 const int VIIMEINEN_KENTTA = 9;31 const int VIIMEINEN_KENTTA = 15; 32 32 33 33 public override void Begin() … … 192 192 } 193 193 194 void LuoChromaCase() 195 { 196 Mouse.IsCursorVisible = true; 197 198 List<GameObject> pItems = new List<GameObject>(); 199 200 for (int i = 0; i < 40; i++) 201 { 202 GameObject obj = new GameObject(50, 50); 203 obj.Color = RandomGen.NextColor(); 204 obj.Tag = 50.0; 205 pItems.Add(obj); 206 } 207 208 GameObject cCaseDialog = new GameObject(LoadImage("laatikko_opening")); // koko debug 209 Add(cCaseDialog); 210 211 Mouse.ListenOn(cCaseDialog, MouseButton.Left, ButtonState.Pressed, delegate 212 { 213 cCaseDialog.Destroy(); 214 215 GameObject cCaseFront = new GameObject(200.0, 200.0); 216 cCaseFront.Color = new Color(0, 64, 0, 32); 217 218 ChromaCase cCase = new ChromaCase(pItems, cCaseFront, null, 20); 219 cCase.Add(Vector.Zero, 2); 220 cCase.ItemReceived += GotItemFromCase; 221 cCase.Start(); 222 223 }, null); 224 } 225 226 void GotItemFromCase(GameObject o) 227 { 228 229 } 230 194 231 /// <summary> 195 232 /// Asetetaan pelaajalle ohjaimet. … … 201 238 Keyboard.Listen(Key.Space, ButtonState.Pressed, LiikutaYlos, null, taistelija); 202 239 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 240 241 #if DEBUG 242 Keyboard.Listen(Key.C, ButtonState.Pressed, LuoChromaCase, null); 243 #endif 203 244 } 204 245 -
2014/30/MitjaK/Attack to Agora/Attack to Agora/Attack to Agora/Attack to Agora/ChromaCase.cs
r6252 r6272 10 10 private Vector ShownItemPosition = Vector.Zero; 11 11 private int CurrentItem = 0; 12 public int Items; 12 13 13 14 private List<GameObject> PossibleItems = new List<GameObject>(); … … 18 19 public Vector Position = Vector.Zero; 19 20 20 public const double START_SPEED = 0. 1;21 public const double STOP_SPEED = 2.0;21 public const double START_SPEED = 0.02; 22 public const double STOP_SPEED = 1.0; 22 23 private Timer changeTimer = new Timer(); 23 24 … … 34 35 /// <param name="possibleItems"></param> 35 36 /// <param name="finalItem"></param> 36 public ChromaCase(List<GameObject> possibleItems, GameObject f inalItem)37 public ChromaCase(List<GameObject> possibleItems, GameObject front, GameObject finalItem, int items) 37 38 { 38 39 this.PossibleItems.AddRange(possibleItems); 39 40 if (finalItem != null) 40 41 FinalItem = finalItem; 42 43 this.OpeningScreenFront = front; 44 this.Items = items; 41 45 } 42 46 … … 61 65 public void Start() 62 66 { 67 GenerateItemList(Items); 68 63 69 if (ShownItems.Count == 0) 64 70 return; 65 66 double speedIncrease = (STOP_SPEED - START_SPEED) / ShownItems.Count; 71 // y == startSpeed 72 // x == speedIncrease 73 // n == shownItems.Count 74 // z == stopSpeed 75 // solve x y*x^n=z => x = (z / y) ^ (1 / n) 76 double speedIncrease = Math.Pow((STOP_SPEED / START_SPEED), (1.0 / ShownItems.Count)); 67 77 68 78 changeTimer.Interval = START_SPEED; 69 changeTimer.Timeout += delegate { ChangeItem(); };70 79 changeTimer.Timeout += delegate 71 80 { 72 changeTimer.Interval += speedIncrease; 73 if (changeTimer.Interval >= STOP_SPEED) 81 Game.Instance.MessageDisplay.Add("Item " + CurrentItem.ToString() + ", delay " + changeTimer.Interval); 82 changeTimer.Interval *= speedIncrease; 83 if (CurrentItem == ShownItems.Count - 1) 74 84 { 75 85 changeTimer.Timeout += delegate … … 80 90 }; 81 91 } 92 else ChangeItem(); 82 93 }; 83 94 changeTimer.Start(); 84 95 85 96 // eka esine näkyville 86 ChangeItem( );97 ChangeItem(false); 87 98 } 88 99 89 100 private void ChangeItem(bool destroyOld = true) 90 101 { 102 if (CurrentItem >= ShownItems.Count - 1) 103 return; 104 91 105 if (destroyOld) 92 106 { 93 ShownItems[CurrentItem].Destroy();107 Game.Instance.Remove(ShownItems[CurrentItem]); 94 108 CurrentItem++; 95 109 }
Note: See TracChangeset
for help on using the changeset viewer.