]> Dogcows Code - chaz/carfire/blobdiff - CarFire/CarFire/CarFire/SaberMonster.cs
New IEntity properties: Coordinates (set), Identifier. Loadable entities should...
[chaz/carfire] / CarFire / CarFire / CarFire / SaberMonster.cs
index c2932eed05f96802579e167bc08da82dc121b0e6..f417d52c160a1470935d4249506789033955b705 100644 (file)
@@ -28,6 +28,8 @@ namespace CarFire
     /// </summary>\r
     public class SaberMonster : IMonster\r
     {\r
+        //starting health\r
+        int health = 100;\r
         /// <summary>\r
         /// Construct this type of monster.  This constructor is called\r
         /// by the map when the game requests entities.\r
@@ -100,8 +102,12 @@ namespace CarFire
             PathFinder pathFinder = new PathFinder(mGame.Grid);\r
             mPath = new List<Point>(32);\r
             mPath.Add(Coordinates);\r
-            mPath.AddRange(pathFinder.GetPath(mMotion.Coordinates, mIdlePath[mIdlePathIndex]));\r
-            mPath.Add(mIdlePath[mIdlePathIndex]);\r
+            List<Point> path = pathFinder.GetPath(mMotion.Coordinates, mIdlePath[mIdlePathIndex]);\r
+            if (path != null)\r
+            {\r
+                mPath.AddRange(path);\r
+                mPath.Add(mIdlePath[mIdlePathIndex]);\r
+            }\r
             mPathIndex = 0;\r
         }\r
 \r
@@ -115,8 +121,12 @@ namespace CarFire
                 PathFinder pathFinder = new PathFinder(mGame.Grid);\r
                 mPath = new List<Point>(32);\r
                 mPath.Add(Coordinates);\r
-                mPath.AddRange(pathFinder.GetPath(mMotion.Coordinates, mIdlePath[mIdlePathIndex % mIdlePath.Count]));\r
-                mPath.Add(mIdlePath[mIdlePathIndex % mIdlePath.Count]);\r
+                List<Point> path = pathFinder.GetPath(mMotion.Coordinates, mIdlePath[mIdlePathIndex % mIdlePath.Count]);\r
+                if (path != null)\r
+                {\r
+                    mPath.AddRange(path);\r
+                    mPath.Add(mIdlePath[mIdlePathIndex % mIdlePath.Count]);\r
+                }\r
                 mPathIndex = 0;\r
             }\r
 \r
@@ -188,7 +198,8 @@ namespace CarFire
         /// </summary>\r
         public int Health\r
         {\r
-            get { throw new NotImplementedException(); }\r
+            get { return this.health; }\r
+            \r
         }\r
 \r
         /// <summary>\r
@@ -197,9 +208,11 @@ namespace CarFire
         /// <param name="amount"></param>\r
         public void causeDamageTo(int amount)\r
         {\r
-            throw new NotImplementedException();\r
+            this.health -= amount;\r
         }\r
 \r
+        public bool IsCollidable { get { return true; } }\r
+\r
         /// <summary>\r
         /// Get the smoothed position.\r
         /// </summary>\r
@@ -208,7 +221,15 @@ namespace CarFire
         /// <summary>\r
         /// Get the grid coordinates.\r
         /// </summary>\r
-        public Point Coordinates { get { return mMotion.Coordinates; } }\r
+        public Point Coordinates {\r
+            get { return mMotion.Coordinates; }\r
+            set { mMotion = new MovementManager(value, mMotion.Speed); }\r
+        }\r
+\r
+        /// <summary>\r
+        /// Get the entity identifier.\r
+        /// </summary>\r
+        public char Identifier { get { return mId; } }\r
 \r
         #endregion\r
 \r
This page took 0.018695 seconds and 4 git commands to generate.