Kenneth van Ewijk 9 лет назад
Родитель
Сommit
ec900f7410
6 измененных файлов с 63 добавлено и 3 удалено
  1. 1 0
      CrystalPoint.vcxproj
  2. 3 0
      CrystalPoint.vcxproj.filters
  3. 7 1
      Enemy.cpp
  4. 3 1
      Enemy.h
  5. 9 1
      World.cpp
  6. 40 0
      weapons.json

+ 1 - 0
CrystalPoint.vcxproj

@@ -222,6 +222,7 @@
     <ClInclude Include="WorldHandler.h" />
   </ItemGroup>
   <ItemGroup>
+    <None Include="weapons.json" />
     <None Include="worlds\fire.json" />
     <None Include="worlds\ice.json" />
     <None Include="worlds\rock.json" />

+ 3 - 0
CrystalPoint.vcxproj.filters

@@ -238,6 +238,9 @@
     <None Include="worlds\rock.json">
       <Filter>Source Files\json</Filter>
     </None>
+    <None Include="weapons.json">
+      <Filter>Source Files\json</Filter>
+    </None>
   </ItemGroup>
   <ItemGroup>
     <Media Include="WAVE\Sound.wav">

+ 7 - 1
Enemy.cpp

@@ -6,6 +6,8 @@
 
 Enemy::Enemy(const std::string &fileName,
 	const std::string &fileMusic,
+	float damage,
+	float health,
 	const Vec3f &position,
 	const Vec3f &rotation,
 	const float &scale)
@@ -18,7 +20,11 @@ Enemy::Enemy(const std::string &fileName,
 	target = position;
 	speed = 1;
 	radius = 10;
-	xp = 10;
+
+	xp = health;
+	this->health = health;
+	this->damage = damage;
+
 	hasTarget = false;
 	hit_sound_id = CrystalPoint::GetSoundSystem().LoadSound(fileMusic.c_str(), false);
 	music = CrystalPoint::GetSoundSystem().GetSound(hit_sound_id);

+ 3 - 1
Enemy.h

@@ -8,7 +8,7 @@
 class Enemy : public Entity
 {
 public:
-	Enemy(const std::string &fileName, const std::string &fileMusic, const Vec3f &position, const Vec3f &rotation, const float &scale);
+	Enemy(const std::string &fileName, const std::string &fileMusic, float damage, float health, const Vec3f &position, const Vec3f &rotation, const float &scale);
 	~Enemy();
 
 	Sound* music;
@@ -16,6 +16,8 @@ public:
 	bool hasTarget;
 	Vec3f target;
 	float speed,radius;
+	float health;
+	float damage;
 	int xp;
 	bool attack;
 

+ 9 - 1
World.cpp

@@ -126,12 +126,20 @@ World::World(const std::string &fileName)
 		if (e["music"].isNull())
 			std::cout << "Invalid world file: enemies music - " << fileName << "\n";
 
+		//Damage
+		if (e["damage"].isNull())
+			std::cout << "Invalid world file: enemies damage - " << fileName << "\n";
+
+		//Health
+		if (e["health"].isNull())
+			std::cout << "Invalid world file: enemies health - " << fileName << "\n";
+
 		//Create
 		Vec3f position(e["pos"][0].asFloat(), e["pos"][1].asFloat(), e["pos"][2].asFloat());
 		position.y = getHeight(position.x, position.z) + 2.0f;
 
 		maxEnemies++;
-		enemies.push_back(new Enemy(e["file"].asString(), e["music"].asString(), position, rotation, scale));
+		enemies.push_back(new Enemy(e["file"].asString(), e["music"].asString(), e["damage"].asFloat(), e["health"].asFloat(), position, rotation, scale));
 	}
 	maxCrystals = 0;
 	if (!v["crystal"].isNull())

+ 40 - 0
weapons.json

@@ -0,0 +1,40 @@
+{
+  "weapons": [
+    {
+      "name": "Fire reaper",
+      "damage": 1,
+      "element": "fire",
+      "file": "models/weapons/ZwaardMetTextures/TextureZwaard.obj",
+
+      "anchor": [ -2.0, 6.0, -2.1 ],
+      "collision": [ 0, 0, 0 ],
+      "maxRotation": [ 170, 70 ],
+      "minRotation": [ 20, -80 ],
+
+      "left": {
+        "offset": [ 4.5, -8, -1 ]
+      },
+      "right": {
+        "offset": [ 0.5, -8, -1 ]
+      }
+    },
+    {
+      "name": "Ice breaker",
+      "damage": 2,
+      "element": "ice",
+      "file": "models/weapons/ZwaardMetTextures/TextureZwaard.obj",
+
+      "anchor": [ -2.0, 6.0, -2.1 ],
+      "collision": [ 0, 0, 0 ],
+      "maxRotation": [ 170, 70 ],
+      "minRotation": [ 20, -80 ],
+
+      "left": {
+        "offset": [ 4.5, -8, -1 ]
+      },
+      "right": {
+        "offset": [ 0.5, -8, -1 ]
+      }
+    }
+  ]
+}