From efd01c658678206ff16f8bcb6de97c0de6dee513 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=93=D0=B5=D0=BE=D1=80=D0=B3=D0=B8=D0=B9=20=D0=A6=D1=8B?= =?UTF-8?q?=D1=80=D0=BA=D0=BE=D0=B2?= Date: Mon, 10 Oct 2016 23:53:39 +0300 Subject: [PATCH] add simple crash logic --- theGame/Game.cs | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/theGame/Game.cs b/theGame/Game.cs index 319458b..006d4be 100644 --- a/theGame/Game.cs +++ b/theGame/Game.cs @@ -60,13 +60,28 @@ namespace theGame } - public void DoMoves() - { - for (int i = 0; i < rocks.Count; i++) - { - rocks[i].positionX--; - } - - } + public void DoMoves() + { + for (int i = 0; i < rocks.Count; i++) + { + rocks[i].positionX--; + } + + int deleted_rock_index = -1; + + for (int i = 0; i < rocks.Count; i++) + { + if (rocks[i].positionX == playerCraft.positionX && rocks[i].positionY == playerCraft.positionY) + { + deleted_rock_index = i; + playerCraft.Health = playerCraft.Health - 15; + } + } + + if (deleted_rock_index >= 0) + { + rocks.RemoveAt(deleted_rock_index); + } + } } }