Shouldn't be able to damage other characters now.
authorKyle <Kyle@92bb83a3-7c8f-8a45-bc97-515c4e399668>
Tue, 27 Apr 2010 20:29:13 +0000 (20:29 +0000)
committerKyle <Kyle@92bb83a3-7c8f-8a45-bc97-515c4e399668>
Tue, 27 Apr 2010 20:29:13 +0000 (20:29 +0000)
git-svn-id: https://bd85.net/svn/cs3505_group@170 92bb83a3-7c8f-8a45-bc97-515c4e399668

CarFire/CarFire/CarFire/GameLogic.cs

index ee5535a..aa37290 100644 (file)
@@ -24,77 +24,89 @@ namespace CarFire
         /// <param name="thisPlayer">index of the player to center the screen around</param>\r
         public void Update(TimeSpan timespan, int thisPlayer)\r
         {\r
-            //Handle projectiles - update and check for wall collisions\r
-            for (int i = 0; i < mGame.State.mProjectiles.Count; i++)\r
+            //TODO make a seperate one for battle\r
+            if (mGame.State.Map.Type == Map.Mode.Campaign || mGame.State.Map.Type == Map.Mode.Battle)\r
             {\r
-                bool removed = false;\r
-                //Check to see if there are any entities in the square with the projectile\r
-                if (!mGame.IsCellOpen(new Point(mGame.State.mProjectiles[i].Coordinates.X, mGame.State.mProjectiles[i].Coordinates.Y)))\r
+                //Handle projectiles - update and check for wall collisions\r
+                for (int i = 0; i < mGame.State.mProjectiles.Count; i++)\r
                 {\r
-                    //The projectile has hit something.\r
-                    IEntity hitEntity = mGame.GetEntityAtCoordinates(new Point(mGame.State.mProjectiles[i].Coordinates.X, mGame.State.mProjectiles[i].Coordinates.Y));\r
-                    //If it is a monster than decrement monster health and increment the score of the player who shot it.\r
-                    if (hitEntity is IMonster)\r
+                    bool removed = false;\r
+                    //Check to see if there are any entities in the square with the projectile\r
+                    if (!mGame.IsCellOpen(new Point(mGame.State.mProjectiles[i].Coordinates.X, mGame.State.mProjectiles[i].Coordinates.Y)))\r
                     {\r
-                        IMonster hitMonster = (IMonster)hitEntity;\r
-                        hitMonster.causeDamageTo(mGame.State.mProjectiles[i].Damage);\r
-                        if (hitMonster.Health > 0)\r
+                        //The projectile has hit something.\r
+                        IEntity hitEntity = mGame.GetEntityAtCoordinates(new Point(mGame.State.mProjectiles[i].Coordinates.X, mGame.State.mProjectiles[i].Coordinates.Y));\r
+                        //If it is a monster than decrement monster health and increment the score of the player who shot it.\r
+                        if (hitEntity is IMonster)\r
                         {\r
-                            mGame.State.mCharacters[mGame.State.mProjectiles[i].CharacterIndex].Score += mGame.State.HitMonsterScore;\r
-                            Console.WriteLine(mGame.State.mCharacters[mGame.State.mProjectiles[i].CharacterIndex].Score);\r
-                        }\r
-                        else\r
-                        {\r
-                            mGame.State.mCharacters[mGame.State.mProjectiles[i].CharacterIndex].Score += mGame.State.KillMonsterScore;\r
-                            Console.WriteLine(mGame.State.mCharacters[mGame.State.mProjectiles[i].CharacterIndex].Score);\r
-                            //Remove dead monsters\r
-                            mGame.State.Entities.Remove(hitEntity);\r
+                            IMonster hitMonster = (IMonster)hitEntity;\r
+                            hitMonster.causeDamageTo(mGame.State.mProjectiles[i].Damage);\r
+                            if (hitMonster.Health > 0)\r
+                            {\r
+                                mGame.State.mCharacters[mGame.State.mProjectiles[i].CharacterIndex].Score += mGame.State.HitMonsterScore;\r
+                                Console.WriteLine(mGame.State.mCharacters[mGame.State.mProjectiles[i].CharacterIndex].Score);\r
+                            }\r
+                            else\r
+                            {\r
+                                mGame.State.mCharacters[mGame.State.mProjectiles[i].CharacterIndex].Score += mGame.State.KillMonsterScore;\r
+                                Console.WriteLine(mGame.State.mCharacters[mGame.State.mProjectiles[i].CharacterIndex].Score);\r
+                                //Remove dead monsters\r
+                                mGame.State.Entities.Remove(hitEntity);\r
+                            }\r
                         }\r
+                        mGame.State.mProjectiles.RemoveAt(i);\r
+                        removed = true;\r
+                        i--;\r
                     }\r
-                    mGame.State.mProjectiles.RemoveAt(i);\r
-                    removed = true;\r
-                    i--;\r
+                    if (!removed)\r
+                        mGame.State.mProjectiles[i].Update(timespan);\r
+\r
                 }\r
-                if (!removed)\r
-                    mGame.State.mProjectiles[i].Update(timespan);\r
+                //Check for collisons\r
+                /*\r
+                \r
+                 */\r
+                //Update input for each player\r
+                for (int i = 0; i < mGame.State.NumberOfPlayers; i++)\r
+                {\r
+                    if (mGame.State.mCharacters[i] != null)\r
+                        mGame.State.mCharacters[i].Update(timespan, mGame.State.GetKeysDown(i));\r
+                }\r
+                if (mGame.State.mCharacters[thisPlayer] != null)\r
+                {\r
+                    mGame.State.Map.CenterCell = mGame.State.mCharacters[thisPlayer].Position;\r
+                }\r
+                //Handle wall collisions of projectiles again...\r
+                for (int i = 0; i < mGame.State.mProjectiles.Count; i++)\r
+                {\r
+                    if (!mGame.State.Map.IsCellOpen(new Point(mGame.State.mProjectiles[i].Coordinates.X, mGame.State.mProjectiles[i].Coordinates.Y)))\r
+                    {\r
+                        mGame.State.mProjectiles.RemoveAt(i);\r
+                        i--;\r
+                    }\r
 \r
+                }\r
             }\r
-            //Check for collisons\r
-            for (int j = 0; j < mGame.State.mCharacters.Length; j++)\r
+                /*\r
+            else if (mGame.State.Map.Type == Map.Mode.Battle)\r
             {\r
+                for (int j = 0; j < mGame.State.mCharacters.Length; j++)\r
+                {\r
 \r
-                if (mGame.State.mCharacters[j] != null)\r
-                    for (int i = 0; i < mGame.State.mProjectiles.Count; i++)\r
-                    {\r
-                        if (mGame.State.mProjectiles[i].Coordinates.X == mGame.State.mCharacters[j].Coordinates.X && mGame.State.mProjectiles[i].Coordinates.Y == mGame.State.mCharacters[j].Coordinates.Y)\r
+                    if (mGame.State.mCharacters[j] != null)\r
+                        for (int i = 0; i < mGame.State.mProjectiles.Count; i++)\r
                         {\r
-                            mGame.State.mCharacters[j].causeDamageTo(mGame.State.mProjectiles[i].Damage);\r
-                            Console.WriteLine(mGame.State.mCharacters[j].Health);\r
-                            mGame.State.mProjectiles.RemoveAt(i);\r
-                            i--;\r
+                            if (mGame.State.mProjectiles[i].Coordinates.X == mGame.State.mCharacters[j].Coordinates.X && mGame.State.mProjectiles[i].Coordinates.Y == mGame.State.mCharacters[j].Coordinates.Y)\r
+                            {\r
+                                mGame.State.mCharacters[j].causeDamageTo(mGame.State.mProjectiles[i].Damage);\r
+                                Console.WriteLine(mGame.State.mCharacters[j].Health);\r
+                                mGame.State.mProjectiles.RemoveAt(i);\r
+                                i--;\r
+                            }\r
                         }\r
-                    }\r
-            }\r
-            //Update input for each player\r
-            for (int i = 0; i < mGame.State.NumberOfPlayers; i++)\r
-            {\r
-                if(mGame.State.mCharacters[i] != null)\r
-                    mGame.State.mCharacters[i].Update(timespan, mGame.State.GetKeysDown(i));\r
-            }\r
-            if (mGame.State.mCharacters[thisPlayer] != null)\r
-            {\r
-                mGame.State.Map.CenterCell = mGame.State.mCharacters[thisPlayer].Position;\r
-            }\r
-            //Handle wall collisions of projectiles again...\r
-            for (int i = 0; i < mGame.State.mProjectiles.Count; i++)\r
-            {\r
-                if (!mGame.State.Map.IsCellOpen(new Point(mGame.State.mProjectiles[i].Coordinates.X, mGame.State.mProjectiles[i].Coordinates.Y)))\r
-                {\r
-                    mGame.State.mProjectiles.RemoveAt(i);\r
-                    i--;\r
                 }\r
-\r
             }\r
+                 */\r
         }\r
     }\r
 }\r
This page took 0.029054 seconds and 4 git commands to generate.