diff --git a/Assets/Models/Resources/resource.blend b/Assets/Models/Resources/resource.blend
new file mode 100644
index 0000000..6f570fd
Binary files /dev/null and b/Assets/Models/Resources/resource.blend differ
diff --git a/Assets/Models/Resources/resource.blend1 b/Assets/Models/Resources/resource.blend1
new file mode 100644
index 0000000..c3a413a
Binary files /dev/null and b/Assets/Models/Resources/resource.blend1 differ
diff --git a/Assets/Models/Resources/resource.xml b/Assets/Models/Resources/resource.xml
new file mode 100644
index 0000000..1d4a59d
--- /dev/null
+++ b/Assets/Models/Resources/resource.xml
@@ -0,0 +1,1800 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Assets/Scripts/Gui/main.lua b/Assets/Scripts/Gui/main.lua
index 3436c20..4494797 100644
--- a/Assets/Scripts/Gui/main.lua
+++ b/Assets/Scripts/Gui/main.lua
@@ -30,10 +30,12 @@ ListboxType = {
CONTROLS = 0,
RESOLUTION = 1,
MAPS = 2,
- UNITS = 3,
- SKYBOX_TEXTURES = 4,
- LAND_TEXTURES = 5,
- CPU_DIFFICULTIES = 6,
- FACTIONS = 7,
- CONSOLE = 8
+ VEHICLES = 3,
+ STRUCTURES = 4,
+ RESOURCE_DEPOSITS = 5,
+ SKYBOX_TEXTURES = 6,
+ LAND_TEXTURES = 7,
+ CPU_DIFFICULTIES = 8,
+ FACTIONS = 9,
+ CONSOLE = 10
}
diff --git a/Assets/Scripts/Gui/mapEditor.lua b/Assets/Scripts/Gui/mapEditor.lua
index 07161aa..a462588 100644
--- a/Assets/Scripts/Gui/mapEditor.lua
+++ b/Assets/Scripts/Gui/mapEditor.lua
@@ -1,4 +1,4 @@
-numGui = 5
+numGui = 6
Size = {x = 140, y = 20}
startX = 100
@@ -14,29 +14,34 @@ gui = {
pos = {x = startX + Size.x + 10, y = 400},
size = Size,
guiType = GuiType.LISTBOX,
- listboxType = ListboxType.UNITS,
- vehicles = true,
+ listboxType = ListboxType.VEHICLES,
numMaxDisplay = 5
},
{
pos = {x = startX + 2 * (Size.x + 10), y = 400},
size = Size,
guiType = GuiType.LISTBOX,
- listboxType = ListboxType.UNITS,
- vehicles = false,
+ listboxType = ListboxType.STRUCTURES,
numMaxDisplay = 5
},
{
pos = {x = startX + 3 * (Size.x + 10), y = 400},
size = Size,
guiType = GuiType.LISTBOX,
- listboxType = ListboxType.SKYBOX_TEXTURES,
+ listboxType = ListboxType.RESOURCE_DEPOSITS,
numMaxDisplay = 5
},
{
pos = {x = startX + 4 * (Size.x + 10), y = 400},
size = Size,
guiType = GuiType.LISTBOX,
+ listboxType = ListboxType.SKYBOX_TEXTURES,
+ numMaxDisplay = 5
+ },
+ {
+ pos = {x = startX + 5 * (Size.x + 10), y = 400},
+ size = Size,
+ guiType = GuiType.LISTBOX,
listboxType = ListboxType.LAND_TEXTURES,
numMaxDisplay = 5
}
diff --git a/Assets/Scripts/projectileData.lua b/Assets/Scripts/projectileData.lua
index 26acd8e..0301ded 100644
--- a/Assets/Scripts/projectileData.lua
+++ b/Assets/Scripts/projectileData.lua
@@ -1,242 +1,244 @@
-numberOfTypesOfWeapons = 2
-g = 2.2
-speed = {
- {
- {10,10,10,10,10,10,10,10,10,10,10}
- },
- {
- {10,10,10,10,10,10,10,10,10,10,10}
- },
- {
- {10, 10, 10, 10}
- },
- {
- {10, 10, 10, 10}
- },
- {
- {5,5}
- },
- {
- {7,7,7,7,7}
- },
- {},
- {},
- {.05},
- {
- {.1, .1},
- {.1, .1}
- }
-}
-length = {
- {
- {1,1,1,1,1,1,1,1,1,1,1,1,1}
- },
- {
- {1,1,1,1,1,1,1,1,1,1,1,1,1}
- },
- {
- {1,1,1,1}
- },
- {
- {1,1,1,1}
- },
- {
- {1,1}
- },
- {
- {1,1,1,1,1}
- },
- {},
- {},
- {
- {.5}
- },
- {
- {1,1},
- {1,1}
- },
- {}
-}
-scale = {
- {
- {1, 1, 1, .5, .5, .5, .5, .5, .5, .5, .5, .5, .5}
- },
- {
- {1, 1, 1, .23, .23, .23, .23, .23, .23, .23, .23, .23, .23}
- },
- {
- {.45, .45, .45, .45}
- },
- {
- {.5, .5, .5, .5}
- },
- {
- {.95, .95}
- },
- {
- {.6, .6, .6, .6, .6}
- }
-}
-pos = {
- {
- {
- {x = 0, y = 0, z = 1.05},
- {x = 0, y = 0, z = 1.05},
- {x = 0, y = 0, z = 1.05},
- {x = 0, y = 0, z = 1.5},
- {x = 0, y = 0, z = 2.5},
- {x = 0, y = 0, z = 2.5},
- {x = 0, y = 0, z = 2.5},
- {x = 0, y = 0, z = 2.5},
- {x = 0, y = 0, z = 2.5},
- {x = 0, y = 0, z = 2.5},
- {x = 0, y = 0, z = 2.5},
- {x = 0, y = 0, z = 2.5},
- {x = 0, y = 0, z = 2.5}
- }
- },
- {
- {
- {x = 0, y = 0, z = 0.79254},
- {x = 0, y = 0, z = 0.79254},
- {x = 0, y = 0, z = 0.79254},
- {x = 0, y = 0, z = 0.17723},
- {x = 0, y = 0, z = 0.17723},
- {x = 0, y = 0, z = 0.17723},
- {x = 0, y = 0, z = 0.17723},
- {x = 0, y = 0, z = 0.17723},
- {x = 0, y = 0, z = 0.17723},
- {x = 0, y = 0, z = 0.17723},
- {x = 0, y = 0, z = 0.17723},
- {x = 0, y = 0, z = 0.17723},
- {x = 0, y = 0, z = 0.17723}
- }
- },
- {
- {
- {x = 0, y = 0, z = -0.36178},
- {x = 0, y = 0, z = -0.36178},
- {x = 0, y = 0, z = -0.36178},
- {x = 0, y = 0, z = -0.36178}
- },
- {x = 0, y = -3, z = 0}
- },
- {
- {
- {x = 0, y = 0, z = -0.30074},
- {x = 0, y = 0, z = -0.30074},
- {x = 0, y = 0, z = -0.30074},
- {x = 0, y = 0, z = -0.30074}
- },
- {x = 0, y = -2, z = 0}
- },
- {
- {
- {x = 0, y = 0, z = -0.62118},
- {x = 0, y = 0, z = -0.62118}
- },
- {
- {x = 0.24482, y = 1.14985, z = 1.32775},
- {x = 0.24482, y = 1.14985, z = 1.62698},
- {x = 0.24482, y = 1.14985, z = 1.88017},
- {x = -0.24482, y = 1.14985, z = 1.32775},
- {x = -0.24482, y = 1.14985, z = 1.62698},
- {x = -0.24482, y = 1.14985, z = 1.88017}
- }
- },
- {
- {
- {x = 0, y = 0, z = -0.59117},
- {x = 0, y = 0, z = -0.59117},
- {x = 0, y = 0, z = -0.59117},
- {x = 0, y = 0, z = -0.59117},
- {x = 0, y = 0, z = -0.59117}
- },
- {{x = 0.17192, y = 0.57858, z = 0.64471}, {x = -0.17192, y = 0.57858, z = 0.64471}}
- },
- {},
- {},
- {
- {x = 0, y =-.3, z =-1.5}
- },
- {
- {
- {x = -.25, y =0, z =0},
- {x = .25, y =0, z =0}
- },
- {
- {x = -.25, y =0, z =0},
- {x = .25, y =0, z =0}
- }
- },
- {}
-}
-damage = {
- {
- {50, 50, 50, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}
- },
- {
- {50, 50, 50, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}
- },
- {
- {50,50,50,50},
- {50}
- },
- {
- {50,50,50,50},
- {50}
- },
- {
- {10,10},
- {}
- },
- {
- {10,10,10,10,10},
- {}
- },
- {},
- {},
- {
- {}
- },
- {
- {50,50},
- {50,50}
- },
- {}
-}
-projectileName = {
- {"shell"},
- {"shell"},
- {"shell"},
- {"shell"},
- {"shell","guidedMissile"},
- {"shell","guidedMissile"},
- {""},
- {""},
- {"torpedo"},
- {"missile","missile"},
-}
-meshPath = {
- {PATH .. "Models/Shell/shell.x"},
- {PATH .. "Models/Shell/shell.x"},
- {PATH .. "Models/Shell/shell.x", PATH .. "Models/Depth charge/depthCharge.x"},
- {PATH .. "Models/Shell/shell.x", PATH .. "Models/Depth charge/depthCharge.x"},
- {PATH .. "Models/Shell/shell.x", PATH .. "Models/Guided missile/guidedMissile.x"},
- {PATH .. "Models/Shell/shell.x", PATH .. "Models/Guided missile/guidedMissile.x"},
- {},
- {},
- {PATH .. "Models/Torpedo/torpedo.x"},
- {PATH .. "Models/Jets/aam.x", PATH .. "Models/Jets/awm.x"}
-}
-diffuseMapTextPath = {
- {},
- {},
- {},
- {},
- {},
- {},
- {},
- {},
- {}
+projectiles = {
+ numberOfTypesOfWeapons = 2,
+ g = 2.2,
+ speed = {
+ {
+ {10,10,10,10,10,10,10,10,10,10,10}
+ },
+ {
+ {10,10,10,10,10,10,10,10,10,10,10}
+ },
+ {
+ {10, 10, 10, 10}
+ },
+ {
+ {10, 10, 10, 10}
+ },
+ {
+ {5,5}
+ },
+ {
+ {7,7,7,7,7}
+ },
+ {},
+ {},
+ {.05},
+ {
+ {.1, .1},
+ {.1, .1}
+ }
+ },
+ length = {
+ {
+ {1,1,1,1,1,1,1,1,1,1,1,1,1}
+ },
+ {
+ {1,1,1,1,1,1,1,1,1,1,1,1,1}
+ },
+ {
+ {1,1,1,1}
+ },
+ {
+ {1,1,1,1}
+ },
+ {
+ {1,1}
+ },
+ {
+ {1,1,1,1,1}
+ },
+ {},
+ {},
+ {
+ {.5}
+ },
+ {
+ {1,1},
+ {1,1}
+ },
+ {}
+ },
+ scale = {
+ {
+ {1, 1, 1, .5, .5, .5, .5, .5, .5, .5, .5, .5, .5}
+ },
+ {
+ {1, 1, 1, .23, .23, .23, .23, .23, .23, .23, .23, .23, .23}
+ },
+ {
+ {.45, .45, .45, .45}
+ },
+ {
+ {.5, .5, .5, .5}
+ },
+ {
+ {.95, .95}
+ },
+ {
+ {.6, .6, .6, .6, .6}
+ }
+ },
+ pos = {
+ {
+ {
+ {x = 0, y = 0, z = 1.05},
+ {x = 0, y = 0, z = 1.05},
+ {x = 0, y = 0, z = 1.05},
+ {x = 0, y = 0, z = 1.5},
+ {x = 0, y = 0, z = 2.5},
+ {x = 0, y = 0, z = 2.5},
+ {x = 0, y = 0, z = 2.5},
+ {x = 0, y = 0, z = 2.5},
+ {x = 0, y = 0, z = 2.5},
+ {x = 0, y = 0, z = 2.5},
+ {x = 0, y = 0, z = 2.5},
+ {x = 0, y = 0, z = 2.5},
+ {x = 0, y = 0, z = 2.5}
+ }
+ },
+ {
+ {
+ {x = 0, y = 0, z = 0.79254},
+ {x = 0, y = 0, z = 0.79254},
+ {x = 0, y = 0, z = 0.79254},
+ {x = 0, y = 0, z = 0.17723},
+ {x = 0, y = 0, z = 0.17723},
+ {x = 0, y = 0, z = 0.17723},
+ {x = 0, y = 0, z = 0.17723},
+ {x = 0, y = 0, z = 0.17723},
+ {x = 0, y = 0, z = 0.17723},
+ {x = 0, y = 0, z = 0.17723},
+ {x = 0, y = 0, z = 0.17723},
+ {x = 0, y = 0, z = 0.17723},
+ {x = 0, y = 0, z = 0.17723}
+ }
+ },
+ {
+ {
+ {x = 0, y = 0, z = -0.36178},
+ {x = 0, y = 0, z = -0.36178},
+ {x = 0, y = 0, z = -0.36178},
+ {x = 0, y = 0, z = -0.36178}
+ },
+ {x = 0, y = -3, z = 0}
+ },
+ {
+ {
+ {x = 0, y = 0, z = -0.30074},
+ {x = 0, y = 0, z = -0.30074},
+ {x = 0, y = 0, z = -0.30074},
+ {x = 0, y = 0, z = -0.30074}
+ },
+ {x = 0, y = -2, z = 0}
+ },
+ {
+ {
+ {x = 0, y = 0, z = -0.62118},
+ {x = 0, y = 0, z = -0.62118}
+ },
+ {
+ {x = 0.24482, y = 1.14985, z = 1.32775},
+ {x = 0.24482, y = 1.14985, z = 1.62698},
+ {x = 0.24482, y = 1.14985, z = 1.88017},
+ {x = -0.24482, y = 1.14985, z = 1.32775},
+ {x = -0.24482, y = 1.14985, z = 1.62698},
+ {x = -0.24482, y = 1.14985, z = 1.88017}
+ }
+ },
+ {
+ {
+ {x = 0, y = 0, z = -0.59117},
+ {x = 0, y = 0, z = -0.59117},
+ {x = 0, y = 0, z = -0.59117},
+ {x = 0, y = 0, z = -0.59117},
+ {x = 0, y = 0, z = -0.59117}
+ },
+ {{x = 0.17192, y = 0.57858, z = 0.64471}, {x = -0.17192, y = 0.57858, z = 0.64471}}
+ },
+ {},
+ {},
+ {
+ {x = 0, y =-.3, z =-1.5}
+ },
+ {
+ {
+ {x = -.25, y =0, z =0},
+ {x = .25, y =0, z =0}
+ },
+ {
+ {x = -.25, y =0, z =0},
+ {x = .25, y =0, z =0}
+ }
+ },
+ {}
+ },
+ damage = {
+ {
+ {50, 50, 50, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}
+ },
+ {
+ {50, 50, 50, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}
+ },
+ {
+ {50,50,50,50},
+ {50}
+ },
+ {
+ {50,50,50,50},
+ {50}
+ },
+ {
+ {10,10},
+ {}
+ },
+ {
+ {10,10,10,10,10},
+ {}
+ },
+ {},
+ {},
+ {
+ {}
+ },
+ {
+ {50,50},
+ {50,50}
+ },
+ {}
+ },
+ projectileName = {
+ {"shell"},
+ {"shell"},
+ {"shell"},
+ {"shell"},
+ {"shell","guidedMissile"},
+ {"shell","guidedMissile"},
+ {""},
+ {""},
+ {"torpedo"},
+ {"missile","missile"},
+ },
+ meshPath = {
+ {PATH .. "Models/Shell/shell.x"},
+ {PATH .. "Models/Shell/shell.x"},
+ {PATH .. "Models/Shell/shell.x", PATH .. "Models/Depth charge/depthCharge.x"},
+ {PATH .. "Models/Shell/shell.x", PATH .. "Models/Depth charge/depthCharge.x"},
+ {PATH .. "Models/Shell/shell.x", PATH .. "Models/Guided missile/guidedMissile.x"},
+ {PATH .. "Models/Shell/shell.x", PATH .. "Models/Guided missile/guidedMissile.x"},
+ {},
+ {},
+ {PATH .. "Models/Torpedo/torpedo.x"},
+ {PATH .. "Models/Jets/aam.x", PATH .. "Models/Jets/awm.x"}
+ },
+ diffuseMapTextPath = {
+ {},
+ {},
+ {},
+ {},
+ {},
+ {},
+ {},
+ {},
+ {}
+ }
}
diff --git a/Assets/Scripts/resourceData.lua b/Assets/Scripts/resourceData.lua
new file mode 100644
index 0000000..c129964
--- /dev/null
+++ b/Assets/Scripts/resourceData.lua
@@ -0,0 +1,25 @@
+resources = {
+ num = 1,
+
+ meshPath = {
+ "resource.xml"
+ },
+ name = {
+ "Resource",
+ },
+ basePath = {
+ PATH .. 'Models/Resources/'
+ },
+ unitCornerPoints = {
+ {
+ {x = .9, y = -1, z = -6},
+ {x = -.9, y = -1, z = -6},
+ {x = -.9, y = -1, z = 5.8},
+ {x = .9, y = -1, z = 5.8},
+ {x = .9, y = 3.5, z = -6},
+ {x = -.9, y = 3.5, z = -6},
+ {x = -.9, y = 3.5, z = 5.8},
+ {x = .9, y = 3.5, z = 5.8}
+ }
+ }
+}
diff --git a/Assets/Scripts/unitData.lua b/Assets/Scripts/unitData.lua
index eff811b..dd8e518 100644
--- a/Assets/Scripts/unitData.lua
+++ b/Assets/Scripts/unitData.lua
@@ -1,278 +1,280 @@
-numUnits = 4
+UnitClass = {VESSEL = 0, ENGINEER = 1, SAMPLE_STRUCTURE = 2}
+UnitType = {UNDERWATER = 0, SEA_LEVEL = 1, HOVER = 2, LAND = 3, AIR = 4}
-UnitClass = {VESSEL = 0, ENGINEER = 1, SAMPLE_STRUCTURE = 2};
-
-UnitType = {UNDERWATER = 0, SEA_LEVEL = 1, HOVER = 2, LAND = 3, AIR = 4};
-
-unitClass = {
- UnitClass.VESSEL, UnitClass.VESSEL,
- UnitClass.ENGINEER, UnitClass.SAMPLE_STRUCTURE
-};
-
-unitType = {
- UnitType.HOVER, UnitType.SEA_LEVEL,
- UnitType.LAND, UnitType.HOVER
-}
-
-isVehicle = {
- true, true, true, false
-};
-
-health = {500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500}
-cost = {500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500}
-range = {15, 15, 14, 14, 13, 13, 12, 12, 15, 25}
-
-unitCornerPoints = {
- {
- {x = .9, y = -1, z = -6},
- {x = -.9, y = -1, z = -6},
- {x = -.9, y = -1, z = 5.8},
- {x = .9, y = -1, z = 5.8},
- {x = .9, y = 3.5, z = -6},
- {x = -.9, y = 3.5, z = -6},
- {x = -.9, y = 3.5, z = 5.8},
- {x = .9, y = 3.5, z = 5.8}
- },
- {
- {x = .5, y = -.5, z = -7.05},
- {x = -.5, y = -.5, z = -7.05},
- {x = -.5, y = -.5, z = 6.4},
- {x = .5, y = -.5, z = 6.4},
- {x = .5, y = 3, z = -7.05},
- {x = -.5, y = 3, z = -7.05},
- {x = -.5, y = 3, z = 6.4},
- {x = .5, y = 3, z = 6.4}
- },
- {
- {x = .5, y = -.5, z = -3.4},
- {x = -.5, y = -.5, z = -3.4},
- {x = -.5, y = -.5, z = 3.4},
- {x = .5, y = -.4, z = 3.4},
- {x = .5, y = 2.1, z = -3.4},
- {x = -.5, y = 2, z = -3.4},
- {x = -.5, y = 2, z = 3.4},
- {x = .5, y = 2, z = 3.4}
- },
- {
- {x = 1, y = -.25, z = -1},
- {x = -1, y = -.25, z = -1},
- {x = -1, y = -.25, z = 1},
- {x = 1, y = -.25, z = 1},
- {x = 1, y = .8, z = -1},
- {x = -1, y = .8, z = -1},
- {x = -1, y = .8, z = 1},
- {x = 1, y = .8, z = 1}
- },
- {
- {x = .7, y = -.3, z = -4},
- {x = -.7, y = -.3, z = -4},
- {x = -.7, y = -.3, z = 3.4},
- {x = .7, y = -.3, z = 3.4},
- {x = .7, y = 2.9, z = -4},
- {x = -.7, y = 2.9, z = -4},
- {x = -.7, y = 2.9, z = 3.4},
- {x = .7, y = 2.9, z = 3.4}
- },
- {
- {x = .5, y = -.5, z = -6.1},
- {x = -.5, y = -.5, z = -6.1},
- {x = -.5, y = -.5, z = 5.2},
- {x = .5, y = -.5, z = 5.2},
- {x = .5, y = 2.2, z = -6.1},
- {x = -.5, y = 2.2, z = -6.1},
- {x = -.5, y = 2.2, z = 5.2},
- {x = .5, y = 2.2, z = 5.2}
- },
- {
- {x = 2, y = -.5, z = -10},
- {x = -2, y = -.5, z = -10},
- {x = -2, y = -.5, z = 9},
- {x = 2, y = -.5, z = 9},
- {x = 2, y = 5.5, z = -10},
- {x = -2, y = 5.5, z = -10},
- {x = -2, y = 5.5, z = 9},
- {x = 2, y = 5.5, z = 9}
- },
- {
- {x = 2, y = -1, z = -10},
- {x = -2, y = -1, z = -10},
- {x = -2, y = -1, z = 9},
- {x = 2, y = -1, z = 9},
- {x = 2, y = 4.5, z = -10},
- {x = -2, y = 4.5, z = -10},
- {x = -2, y = 4.5, z = 9},
- {x = 2, y = 4.5, z = 9}
- },
- {
- {x = .25, y = -.5, z = -2},
- {x = -.25, y = -.5, z = -2},
- {x = -.25, y = -.5, z = 3},
- {x = .25, y = -.5, z = 3},
- {x = .25, y = .7, z = -2},
- {x = -.25, y = .7, z = -2},
- {x = -.25, y = .7, z = 3},
- {x = .25, y = .7, z = 3}
- },
- {
- {x = .6, y =-.1, z =-1.3},
- {x = -.6, y =-.1, z =-1.3},
- {x = -.6, y =-.1, z =.8},
- {x = .6, y =-.1, z =.8},
- {x = .6, y =.3, z =-1.3},
- {x = -.6, y =.3, z =-1.3},
- {x = -.6, y =.3, z =.8},
- {x = .6, y =.3, z =.8}
- },
- {
- {x = .5, y =-.1, z =-1.3},
- {x = -.5, y =-.1, z =-1.3},
- {x = -.5, y =-.1, z =.7},
- {x = .5, y =-.1, z =.7},
- {x = .5, y =.15, z =-1.3},
- {x = -.5, y =.15, z =-1.3},
- {x = -.5, y =.15, z =.7},
- {x = .5, y =.15, z =.7}
- }
-};
-unitCuboidDimensions = {
- {
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1}
- },
- {
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1}
- },
- {
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1}
- },
- {
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1}
- },
- {
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1}
- },
- {
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1}
- },
- {
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1}
- },
- {
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1},
- {x = 1, y = 1, z = 1}
- },
- {
- {x = .1, y = .1, z = .1},
- {x = .1, y = .1, z = .1},
- {x = .1, y = .1, z = .1},
- {x = .1, y = .1, z = .1},
- {x = .1, y = .1, z = .1},
- {x = .1, y = .1, z = .1},
- {x = .1, y = .1, z = .1},
- {x = .1, y = .1, z = .1}
- },
- {
- {x = .1, y = .1, z = .1},
- {x = .1, y = .1, z = .1},
- {x = .1, y = .1, z = .1},
- {x = .1, y = .1, z = .1},
- {x = .1, y = .1, z = .1},
- {x = .1, y = .1, z = .1},
- {x = .1, y = .1, z = .1},
- {x = .1, y = .1, z = .1}
- },
- {
- {x = .1, y = .1, z = .1},
- {x = .1, y = .1, z = .1},
- {x = .1, y = .1, z = .1},
- {x = .1, y = .1, z = .1},
- {x = .1, y = .1, z = .1},
- {x = .1, y = .1, z = .1},
- {x = .1, y = .1, z = .1},
- {x = .1, y = .1, z = .1}
- }
-};
-
-unitAxisLength = {8, 8, 6, 6, 5, 5, 8, 8, 7, 2, 2}
-lineOfSight = {5, 8, 4, 4, 3, 3, 6, 6, 3, 3, 8}
-name = {
- "Battleship", "Battleship",
- "Battleship", "Sample",
- "Cruiser", "Cruiser",
- "Aircraft carrier", "Aircraft carrier",
- "Submarine",
- "Jet", "Jet"
-}
-meshPath = {
- "battleship00.xml", "battleship00.xml",
- "battleship00.xml", "sample.xml",
- "cruiser00.xml", "cruiser01.xml",
- "aircraftCarrier00.xml", "aircraftCarrier01.xml",
- "submarine.xml",
- "jet00.xml", "jet01.xml"
-}
modelPrefix = "Models/"
vehiclePrefix = modelPrefix .. "Units/Vehicles/"
structurePrefix = modelPrefix .. "Units/Structures/"
-basePath = {
- PATH .. vehiclePrefix .. "Battleships/", PATH .. vehiclePrefix .. "Battleships/",
- PATH .. vehiclePrefix .. "Battleships/", PATH .. structurePrefix .. "Sample/",
- PATH .. vehiclePrefix .. "Cruisers/", PATH .. vehiclePrefix .. "Cruisers/",
- PATH .. vehiclePrefix .. "Aircraft carriers/", PATH .. vehiclePrefix .. "Aircraft carriers/",
- PATH .. vehiclePrefix .. "Submarines/",
- PATH .. vehiclePrefix .. "Jets/", PATH .. vehiclePrefix .. "Jets/"
-};
+
+units = {
+ num = 4,
+
+ unitClass = {
+ UnitClass.VESSEL, UnitClass.VESSEL,
+ UnitClass.ENGINEER, UnitClass.SAMPLE_STRUCTURE
+ },
+
+ unitType = {
+ UnitType.HOVER, UnitType.SEA_LEVEL,
+ UnitType.LAND, UnitType.HOVER
+ },
+
+ isVehicle = {
+ true, true, true, false
+ },
+
+ health = {500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500},
+ cost = {500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500},
+ range = {15, 15, 14, 14, 13, 13, 12, 12, 15, 25},
+
+ unitCornerPoints = {
+ {
+ {x = .9, y = -1, z = -6},
+ {x = -.9, y = -1, z = -6},
+ {x = -.9, y = -1, z = 5.8},
+ {x = .9, y = -1, z = 5.8},
+ {x = .9, y = 3.5, z = -6},
+ {x = -.9, y = 3.5, z = -6},
+ {x = -.9, y = 3.5, z = 5.8},
+ {x = .9, y = 3.5, z = 5.8}
+ },
+ {
+ {x = .5, y = -.5, z = -7.05},
+ {x = -.5, y = -.5, z = -7.05},
+ {x = -.5, y = -.5, z = 6.4},
+ {x = .5, y = -.5, z = 6.4},
+ {x = .5, y = 3, z = -7.05},
+ {x = -.5, y = 3, z = -7.05},
+ {x = -.5, y = 3, z = 6.4},
+ {x = .5, y = 3, z = 6.4}
+ },
+ {
+ {x = .5, y = -.5, z = -3.4},
+ {x = -.5, y = -.5, z = -3.4},
+ {x = -.5, y = -.5, z = 3.4},
+ {x = .5, y = -.4, z = 3.4},
+ {x = .5, y = 2.1, z = -3.4},
+ {x = -.5, y = 2, z = -3.4},
+ {x = -.5, y = 2, z = 3.4},
+ {x = .5, y = 2, z = 3.4}
+ },
+ {
+ {x = 1, y = -.25, z = -1},
+ {x = -1, y = -.25, z = -1},
+ {x = -1, y = -.25, z = 1},
+ {x = 1, y = -.25, z = 1},
+ {x = 1, y = .8, z = -1},
+ {x = -1, y = .8, z = -1},
+ {x = -1, y = .8, z = 1},
+ {x = 1, y = .8, z = 1}
+ },
+ {
+ {x = .7, y = -.3, z = -4},
+ {x = -.7, y = -.3, z = -4},
+ {x = -.7, y = -.3, z = 3.4},
+ {x = .7, y = -.3, z = 3.4},
+ {x = .7, y = 2.9, z = -4},
+ {x = -.7, y = 2.9, z = -4},
+ {x = -.7, y = 2.9, z = 3.4},
+ {x = .7, y = 2.9, z = 3.4}
+ },
+ {
+ {x = .5, y = -.5, z = -6.1},
+ {x = -.5, y = -.5, z = -6.1},
+ {x = -.5, y = -.5, z = 5.2},
+ {x = .5, y = -.5, z = 5.2},
+ {x = .5, y = 2.2, z = -6.1},
+ {x = -.5, y = 2.2, z = -6.1},
+ {x = -.5, y = 2.2, z = 5.2},
+ {x = .5, y = 2.2, z = 5.2}
+ },
+ {
+ {x = 2, y = -.5, z = -10},
+ {x = -2, y = -.5, z = -10},
+ {x = -2, y = -.5, z = 9},
+ {x = 2, y = -.5, z = 9},
+ {x = 2, y = 5.5, z = -10},
+ {x = -2, y = 5.5, z = -10},
+ {x = -2, y = 5.5, z = 9},
+ {x = 2, y = 5.5, z = 9}
+ },
+ {
+ {x = 2, y = -1, z = -10},
+ {x = -2, y = -1, z = -10},
+ {x = -2, y = -1, z = 9},
+ {x = 2, y = -1, z = 9},
+ {x = 2, y = 4.5, z = -10},
+ {x = -2, y = 4.5, z = -10},
+ {x = -2, y = 4.5, z = 9},
+ {x = 2, y = 4.5, z = 9}
+ },
+ {
+ {x = .25, y = -.5, z = -2},
+ {x = -.25, y = -.5, z = -2},
+ {x = -.25, y = -.5, z = 3},
+ {x = .25, y = -.5, z = 3},
+ {x = .25, y = .7, z = -2},
+ {x = -.25, y = .7, z = -2},
+ {x = -.25, y = .7, z = 3},
+ {x = .25, y = .7, z = 3}
+ },
+ {
+ {x = .6, y =-.1, z =-1.3},
+ {x = -.6, y =-.1, z =-1.3},
+ {x = -.6, y =-.1, z =.8},
+ {x = .6, y =-.1, z =.8},
+ {x = .6, y =.3, z =-1.3},
+ {x = -.6, y =.3, z =-1.3},
+ {x = -.6, y =.3, z =.8},
+ {x = .6, y =.3, z =.8}
+ },
+ {
+ {x = .5, y =-.1, z =-1.3},
+ {x = -.5, y =-.1, z =-1.3},
+ {x = -.5, y =-.1, z =.7},
+ {x = .5, y =-.1, z =.7},
+ {x = .5, y =.15, z =-1.3},
+ {x = -.5, y =.15, z =-1.3},
+ {x = -.5, y =.15, z =.7},
+ {x = .5, y =.15, z =.7}
+ }
+ },
+ unitCuboidDimensions = {
+ {
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1}
+ },
+ {
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1}
+ },
+ {
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1}
+ },
+ {
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1}
+ },
+ {
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1}
+ },
+ {
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1}
+ },
+ {
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1}
+ },
+ {
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1},
+ {x = 1, y = 1, z = 1}
+ },
+ {
+ {x = .1, y = .1, z = .1},
+ {x = .1, y = .1, z = .1},
+ {x = .1, y = .1, z = .1},
+ {x = .1, y = .1, z = .1},
+ {x = .1, y = .1, z = .1},
+ {x = .1, y = .1, z = .1},
+ {x = .1, y = .1, z = .1},
+ {x = .1, y = .1, z = .1}
+ },
+ {
+ {x = .1, y = .1, z = .1},
+ {x = .1, y = .1, z = .1},
+ {x = .1, y = .1, z = .1},
+ {x = .1, y = .1, z = .1},
+ {x = .1, y = .1, z = .1},
+ {x = .1, y = .1, z = .1},
+ {x = .1, y = .1, z = .1},
+ {x = .1, y = .1, z = .1}
+ },
+ {
+ {x = .1, y = .1, z = .1},
+ {x = .1, y = .1, z = .1},
+ {x = .1, y = .1, z = .1},
+ {x = .1, y = .1, z = .1},
+ {x = .1, y = .1, z = .1},
+ {x = .1, y = .1, z = .1},
+ {x = .1, y = .1, z = .1},
+ {x = .1, y = .1, z = .1}
+ }
+ },
+
+ unitAxisLength = {8, 8, 6, 6, 5, 5, 8, 8, 7, 2, 2},
+ lineOfSight = {5, 8, 4, 4, 3, 3, 6, 6, 3, 3, 8},
+ name = {
+ "Battleship", "Battleship",
+ "Battleship", "Sample",
+ "Cruiser", "Cruiser",
+ "Aircraft carrier", "Aircraft carrier",
+ "Submarine",
+ "Jet", "Jet"
+ },
+ meshPath = {
+ "battleship00.xml", "battleship00.xml",
+ "battleship00.xml", "sample.xml",
+ "cruiser00.xml", "cruiser01.xml",
+ "aircraftCarrier00.xml", "aircraftCarrier01.xml",
+ "submarine.xml",
+ "jet00.xml", "jet01.xml"
+ },
+ basePath = {
+ PATH .. vehiclePrefix .. "Battleships/", PATH .. vehiclePrefix .. "Battleships/",
+ PATH .. vehiclePrefix .. "Battleships/", PATH .. structurePrefix .. "Sample/",
+ PATH .. vehiclePrefix .. "Cruisers/", PATH .. vehiclePrefix .. "Cruisers/",
+ PATH .. vehiclePrefix .. "Aircraft carriers/", PATH .. vehiclePrefix .. "Aircraft carriers/",
+ PATH .. vehiclePrefix .. "Submarines/",
+ PATH .. vehiclePrefix .. "Jets/", PATH .. vehiclePrefix .. "Jets/"
+ }
+}
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0ae7005..8c565ac 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -12,19 +12,20 @@ set(UNIT_BUTTONS unitButton.cpp buildButton.cpp)
set(OPTIONS_BUTTONS optionsButton.cpp tabButton.cpp okButton.cpp defaultsButton.cpp)
set(IN_GAME_APP_STATE_BUTTONS mainMenuButton.cpp)
set(MAP_EDITOR_BUTTONS mapEditorButton.cpp newMapButton.cpp loadMapButton.cpp exportButton.cpp)
-set(BUTTONS singlePlayerButton.cpp exitButton.cpp backButton.cpp consoleCommand.cpp playButton.cpp ${OPTIONS_BUTTONS} ${IN_GAME_APP_STATE_BUTTONS} ${MAP_EDITOR_BUTTONS} ${UNIT_BUTTONS})
-set(LISTBOXES skyboxTextureListbox.cpp landTextureListbox.cpp unitListbox.cpp)
+set(BUTTONS singlePlayerButton.cpp exitButton.cpp backButton.cpp playButton.cpp ${OPTIONS_BUTTONS} ${IN_GAME_APP_STATE_BUTTONS} ${MAP_EDITOR_BUTTONS} ${UNIT_BUTTONS})
+set(LISTBOXES skyboxTextureListbox.cpp landTextureListbox.cpp gameObjectListbox.cpp)
set(GUI tooltip.cpp concreteGuiManager.cpp ${BUTTONS} ${LISTBOXES})
set(STATES activeGameState.cpp inGameAppState.cpp guiAppState.cpp mapEditorAppState.cpp)
set(UTIL util.cpp binds.h)
-set(CONTROLLERS unitFrameController.cpp cameraController.cpp)
-set(CORE gameManager.cpp defConfigs.cpp ${CONTROLLERS})
+set(CONTROLLERS gameObjectFrameController.cpp cameraController.cpp)
+set(CONSOLE console.cpp abstractCommand.cpp addUnitCommand.cpp addResourceCommand.cpp)
+set(CORE gameManager.cpp defConfigs.cpp ${CONSOLE} ${CONTROLLERS})
set(PROJECTILES projectile.cpp)
set(FX explosion.cpp)
set(VEHICLES vehicle.cpp engineer.cpp)
-set(UNITS unitFactory.cpp unit.cpp structure.cpp ${VEHICLES})
-set(CONTENT player.cpp pathfinder.cpp map.cpp ${UNITS} ${PROJECTILES} ${FX})
+set(UNITS gameObjectFactory.cpp unit.cpp structure.cpp ${VEHICLES})
+set(CONTENT player.cpp pathfinder.cpp map.cpp gameObject.cpp gameObjectFrame.h resourceDeposit.cpp ${UNITS} ${PROJECTILES} ${FX})
set(GAME_SRC ${STATES} ${GUI} ${CORE} ${CONTENT} ${UTIL})
set(SFML_DIR external/SFML)
diff --git a/abstractCommand.cpp b/abstractCommand.cpp
new file mode 100644
index 0000000..5807c62
--- /dev/null
+++ b/abstractCommand.cpp
@@ -0,0 +1,34 @@
+#include "abstractCommand.h"
+
+#include
+#include
+
+namespace battleship{
+ using namespace std;
+
+ vector AbstractCommand::explodeString(string commandStr){
+ vector spaceIds;
+ vector fullCommand;
+
+ for(int i = 0; i < commandStr.length(); i++)
+ if(commandStr[i] == ' ')
+ spaceIds.push_back(i);
+
+ fullCommand.push_back(commandStr.substr(0, spaceIds[0]));
+
+ for(int i = 0; i < spaceIds.size(); i++){
+ bool lastSpace = (i == spaceIds.size() - 1);
+ string argument = commandStr.substr(spaceIds[i] + 1, lastSpace ? string::npos : spaceIds[i + 1] - spaceIds[i] - 1);
+ fullCommand.push_back(argument);
+ }
+
+ return fullCommand;
+ }
+
+ void AbstractCommand::handle(){
+ if(cmdStr.find(" ") == -1)
+ return;
+
+ arguments = explodeString(cmdStr);
+ }
+}
diff --git a/abstractCommand.h b/abstractCommand.h
new file mode 100644
index 0000000..b02f6eb
--- /dev/null
+++ b/abstractCommand.h
@@ -0,0 +1,22 @@
+#ifndef ABSTRACT_COMMAND_H
+#define ABSTRACT_COMMAND_H
+
+#include
+#include
+
+namespace battleship{
+ class AbstractCommand{
+ protected:
+ AbstractCommand(std::string str) : cmdStr(str){}
+ virtual void execute(){}
+ virtual void validate(){}
+ virtual void handle();
+
+ std::string cmdStr;
+ std::vector arguments;
+ private:
+ std::vector explodeString(std::string);
+ };
+}
+
+#endif
diff --git a/activeGameState.cpp b/activeGameState.cpp
index 6a8dd7e..1c0ad9e 100755
--- a/activeGameState.cpp
+++ b/activeGameState.cpp
@@ -20,7 +20,7 @@
#include "structure.h"
#include "util.h"
#include "tooltip.h"
-#include "unitFrameController.h"
+#include "gameObjectFrameController.h"
#include "cameraController.h"
#include "concreteGuiManager.h"
@@ -43,7 +43,12 @@ namespace battleship{
mainPlayer = Map::getSingleton()->getPlayer(playerId);
initDragbox();
- initDepthText();
+
+ refinedsText = initText(Vector2(0, 100));
+ wealthText = initText(Vector2(0, 200));
+ researchText = initText(Vector2(0, 300));
+ textNode = initText(Vector2(0, 400));
+ depth = 1;
}
ActiveGameState::~ActiveGameState() {
@@ -65,33 +70,41 @@ namespace battleship{
root->getGuiNode()->attachChild(dragboxNode);
}
- void ActiveGameState::initDepthText(){
- Root *root = Root::getSingleton();
- Text *t = new Text(GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", L"depth: ");
-
- Material *tm = new Material(root->getLibPath() + "text");
+ Node* ActiveGameState::initText(Vector2 pos){
+ Material *tm = new Material(Root::getSingleton()->getLibPath() + "text");
tm->addBoolUniform("texturingEnabled", false);
tm->addVec4Uniform("diffuseColor", Vector4(1, 1, 1, 1));
+
+ Text *t = new Text(GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", L"");
t->setMaterial(tm);
- textNode = new Node(Vector3(0, 100, 0));
- textNode->addText(t);
+ Node *node = new Node(Vector3(pos.x, pos.y, 0));
+ node->addText(t);
- depth = 1;
+ return node;
}
void ActiveGameState::onAttached() {
AbstractAppState::onAttached();
Root::getSingleton()->getGuiNode()->attachChild(textNode);
+ Root::getSingleton()->getGuiNode()->attachChild(refinedsText);
+ Root::getSingleton()->getGuiNode()->attachChild(wealthText);
+ Root::getSingleton()->getGuiNode()->attachChild(researchText);
}
void ActiveGameState::onDettached() {
AbstractAppState::onDettached();
- Root::getSingleton()->getGuiNode()->attachChild(textNode);
+ Root::getSingleton()->getGuiNode()->dettachChild(textNode);
+ Root::getSingleton()->getGuiNode()->dettachChild(refinedsText);
+ Root::getSingleton()->getGuiNode()->dettachChild(wealthText);
+ Root::getSingleton()->getGuiNode()->dettachChild(researchText);
}
void ActiveGameState::update() {
textNode->getText(0)->setText(L"Depth: " + to_wstring(depth));
+ refinedsText->getText(0)->setText(L"Refineds: " + to_wstring(mainPlayer->getRefineds()));
+ wealthText->getText(0)->setText(L"Wealth: " + to_wstring(mainPlayer->getWealth()));
+ researchText->getText(0)->setText(L"Research: " + to_wstring(mainPlayer->getResearch()));
if (isSelectionBox)
updateSelectionBox();
@@ -105,7 +118,7 @@ namespace battleship{
if(!camCtr->isLookingAround())
camCtr->updateCameraPosition();
- UnitFrameController *ufCtr = UnitFrameController::getSingleton();
+ GameObjectFrameController *ufCtr = GameObjectFrameController::getSingleton();
if(ufCtr->isPlacingFrames())
ufCtr->update();
@@ -113,8 +126,8 @@ namespace battleship{
void ActiveGameState::deselectUnits(){
mainPlayer->deselectUnits();
- UnitFrameController *ufCtr = UnitFrameController::getSingleton();
- ufCtr->removeUnitFrames();
+ GameObjectFrameController *ufCtr = GameObjectFrameController::getSingleton();
+ ufCtr->removeGameObjectFrames();
ufCtr->setPlacingFrames(false);
ConcreteGuiManager::getSingleton()->removeAllGuiElements();
@@ -275,11 +288,11 @@ namespace battleship{
std::map::iterator it = unitData.find(node);
Unit *unit = nullptr;
- UnitFrameController *ufCtr = UnitFrameController::getSingleton();
+ GameObjectFrameController *ufCtr = GameObjectFrameController::getSingleton();
if(ufCtr->isPlacingFrames()){
- Model *model = ufCtr->getUnitFrame(0).model;
- unit = new Structure(mainPlayer, ufCtr->getUnitFrame(0).id, model->getPosition(), model->getOrientation());
+ GameObjectFrame goFr = ufCtr->getGameObjectFrame(0);
+ unit = new Structure(mainPlayer, goFr.getId(), goFr.getModel()->getPosition(), goFr.getModel()->getOrientation());
mainPlayer->addUnit(unit);
}
@@ -325,7 +338,7 @@ namespace battleship{
void ActiveGameState::onAction(int bind, bool isPressed) {
GameManager *gm = GameManager::getSingleton();
InGameAppState *inGameState = (InGameAppState*) gm->getStateManager()->getAppStateByType((int)AppStateType::IN_GAME_STATE);
- UnitFrameController *ufCtr = UnitFrameController::getSingleton();
+ GameObjectFrameController *ufCtr = GameObjectFrameController::getSingleton();
switch((Bind)bind){
case Bind::DRAG_BOX:
@@ -346,7 +359,7 @@ namespace battleship{
type = Order::TYPE::BUILD;
ufCtr->setPlacingFrames(false);
ufCtr->setRotatingFrames(false);
- ufCtr->removeUnitFrames();
+ ufCtr->removeGameObjectFrames();
}
issueOrder(type, shiftPressed);
@@ -392,7 +405,7 @@ namespace battleship{
{
shiftPressed = isPressed;
- UnitFrameController *ufCtr = UnitFrameController::getSingleton();
+ GameObjectFrameController *ufCtr = GameObjectFrameController::getSingleton();
ufCtr->setPaintSelecting(shiftPressed);
if(isPressed){
@@ -450,7 +463,7 @@ namespace battleship{
break;
case Bind::DESELECT_STRUCTURE:
- ufCtr->removeUnitFrames();
+ ufCtr->removeGameObjectFrames();
ufCtr->setPlacingFrames(false);
break;
}
@@ -458,7 +471,7 @@ namespace battleship{
void ActiveGameState::onAnalog(int bind, float strength) {
CameraController *camCtr = CameraController::getSingleton();
- UnitFrameController *ufCtr = UnitFrameController::getSingleton();
+ GameObjectFrameController *ufCtr = GameObjectFrameController::getSingleton();
switch((Bind)bind){
case Bind::LOOK_UP:
@@ -475,7 +488,7 @@ namespace battleship{
if(camCtr->isLookingAround())
CameraController::getSingleton()->orientCamera(Vector3(0, 1, 0), strength);
else if(ufCtr->isPlacingFrames() && ufCtr->isRotatingFrames())
- ufCtr->rotateUnitFrames(100 * strength);
+ ufCtr->rotateGameObjectFrames(100 * strength);
break;
}
diff --git a/activeGameState.h b/activeGameState.h
index 2db8e28..447dc69 100755
--- a/activeGameState.h
+++ b/activeGameState.h
@@ -30,7 +30,7 @@ namespace battleship{
inline std::vector& getUnitGroup(int i){return unitGroups[i];}
private:
void initDragbox();
- void initDepthText();
+ vb01::Node* initText(vb01::Vector2);
void deselectUnits();
void renderUnits();
void updateSelectionBox();
@@ -43,7 +43,7 @@ namespace battleship{
GuiAppState *guiState;
Player *mainPlayer;
vb01::Quad *dragbox = nullptr;
- vb01::Node *dragboxNode = nullptr, *textNode = nullptr;
+ vb01::Node *dragboxNode = nullptr, *textNode = nullptr, *refinedsText = nullptr, *wealthText = nullptr, *researchText = nullptr;
vb01::Vector2 clickPoint;
std::vector unitScreenPosVec;
std::vector unitLightNodes;
diff --git a/addResourceCommand.cpp b/addResourceCommand.cpp
new file mode 100644
index 0000000..a0f4c37
--- /dev/null
+++ b/addResourceCommand.cpp
@@ -0,0 +1,44 @@
+#include "addResourceCommand.h"
+#include "map.h"
+#include "player.h"
+
+namespace battleship{
+ void AddResourceCommand::validate(){
+ if(arguments.size() != 3)
+ return;
+
+ playerId = atoi(arguments[0].c_str());
+
+ if(playerId != 0 && playerId != 1)
+ return;
+
+ resourceId = atoi(arguments[1].c_str());
+
+ if(!(0 <= resourceId && resourceId <= 2))
+ return;
+
+ resourceAmmount = atoi(arguments[2].c_str());
+ }
+
+ void AddResourceCommand::addResource(){
+ Player *player = Map::getSingleton()->getPlayer(playerId);
+
+ switch(resourceId){
+ case 0:
+ player->addRefineds(resourceAmmount);
+ break;
+ case 1:
+ player->addWealth(resourceAmmount);
+ break;
+ case 2:
+ player->addResearch(resourceAmmount);
+ break;
+ }
+ }
+
+ void AddResourceCommand::execute(){
+ AbstractCommand::handle();
+ validate();
+ addResource();
+ }
+}
diff --git a/addResourceCommand.h b/addResourceCommand.h
new file mode 100644
index 0000000..b5c55bb
--- /dev/null
+++ b/addResourceCommand.h
@@ -0,0 +1,19 @@
+#ifndef ADD_RESOURCE_COMMAND_H
+#define ADD_RESOURCE_COMMAND_H
+
+#include "abstractCommand.h"
+
+namespace battleship{
+ class AddResourceCommand : public AbstractCommand{
+ public:
+ AddResourceCommand(std::string argsStr) : AbstractCommand(argsStr){}
+ void execute();
+ private:
+ void validate();
+ void addResource();
+
+ int playerId, resourceId, resourceAmmount;
+ };
+}
+
+#endif
diff --git a/addUnitCommand.cpp b/addUnitCommand.cpp
new file mode 100644
index 0000000..f225ba8
--- /dev/null
+++ b/addUnitCommand.cpp
@@ -0,0 +1,59 @@
+#include
+#include
+
+#include "addUnitCommand.h"
+#include "console.h"
+#include "addUnitCommand.h"
+#include "inGameAppState.h"
+#include "player.h"
+#include "gameObjectFactory.h"
+
+namespace battleship{
+ using namespace gameBase;
+ using namespace vb01;
+
+ void AddUnitCommand::validate(){
+ if(!(arguments.size() == 2 || arguments.size() == 5 || arguments.size() == 9))
+ return;
+
+ playerId = atoi(arguments[0].c_str());
+
+ if(playerId != 0 && playerId != 1)
+ return;
+
+ unitId = atoi(arguments[1].c_str());
+
+ if(!(0 <= unitId && unitId <= (int)generateView()["units"]["num"]))
+ return;
+
+ if(arguments.size() >= 5){
+ float x = atoi(arguments[2].c_str());
+ float y = atoi(arguments[3].c_str());
+ float z = atoi(arguments[4].c_str());
+ pos = Vector3(x, y, z);
+ }
+ else if(2 < arguments.size() && arguments.size() < 5)
+ return;
+
+ if(arguments.size() == 9){
+ float w = atoi(arguments[5].c_str());
+ float x = atoi(arguments[6].c_str());
+ float y = atoi(arguments[7].c_str());
+ float z = atoi(arguments[8].c_str());
+ rot = Quaternion(w, x, y, z);
+ }
+ else if(5 < arguments.size() && arguments.size() < 9)
+ return;
+ }
+
+ void AddUnitCommand::addUnit(){
+ Player* player = Map::getSingleton()->getPlayer(playerId);
+ player->addUnit(GameObjectFactory::createUnit(player, unitId, pos, rot));
+ }
+
+ void AddUnitCommand::execute(){
+ AbstractCommand::handle();
+ validate();
+ addUnit();
+ }
+}
diff --git a/addUnitCommand.h b/addUnitCommand.h
new file mode 100644
index 0000000..a0d5429
--- /dev/null
+++ b/addUnitCommand.h
@@ -0,0 +1,25 @@
+#ifndef ADD_UNIT_COMMAND_H
+#define ADD_UNIT_COMMAND_H
+
+#include "abstractCommand.h"
+
+#include
+#include
+
+namespace battleship{
+ class AddUnitCommand : public AbstractCommand{
+ public:
+ AddUnitCommand(std::string argsStr) : AbstractCommand(argsStr){}
+ void validate();
+ void execute();
+ private:
+ int playerId, unitId;
+ bool posEnabled, rotEnabled;
+ vb01::Vector3 pos = vb01::Vector3::VEC_ZERO;
+ vb01::Quaternion rot = vb01::Quaternion::QUAT_W;
+
+ void addUnit();
+ };
+}
+
+#endif
diff --git a/buildButton.cpp b/buildButton.cpp
index b5f93cc..e36c9ec 100644
--- a/buildButton.cpp
+++ b/buildButton.cpp
@@ -1,7 +1,7 @@
#include "buildButton.h"
#include "gameManager.h"
-#include "unit.h"
-#include "unitFrameController.h"
+#include "gameObject.h"
+#include "gameObjectFrameController.h"
#include
@@ -17,11 +17,8 @@ namespace battleship{
}
void BuildButton::onClick(){
- sol::state_view SOL_LUA_STATE = generateView();
- string modelPath = (string)SOL_LUA_STATE["basePath"][structureId + 1] + (string)SOL_LUA_STATE["meshPath"][structureId + 1];
-
- UnitFrameController *ufCtr = UnitFrameController::getSingleton();
- ufCtr->addUnitFrame(UnitFrameController::UnitFrame(modelPath, structureId, (int)UnitType::LAND));
+ GameObjectFrameController *ufCtr = GameObjectFrameController::getSingleton();
+ ufCtr->addGameObjectFrame(GameObjectFrame(structureId, GameObject::Type::UNIT));
ufCtr->setPlacingFrames(true);
}
}
diff --git a/concreteGuiManager.cpp b/concreteGuiManager.cpp
index bec5f96..bddb542 100644
--- a/concreteGuiManager.cpp
+++ b/concreteGuiManager.cpp
@@ -15,7 +15,7 @@
#include "exportButton.h"
#include "skyboxTextureListbox.h"
#include "landTextureListbox.h"
-#include "unitListbox.h"
+#include "gameObjectListbox.h"
#include "playButton.h"
#include "inGameAppState.h"
#include "mainMenuButton.h"
@@ -166,6 +166,9 @@ namespace battleship{
return button;
}
+ Listbox* ConcreteGuiManager::parseGameObjectListbox(){
+ }
+
Listbox* ConcreteGuiManager::parseListbox(int guiId){
sol::state_view SOL_LUA_STATE = generateView();
sol::table guiTable = SOL_LUA_STATE["gui"][guiId + 1];
@@ -220,23 +223,31 @@ namespace battleship{
listbox = new Listbox(pos, size, lines, maxDisplay, fontPath, closable);
break;
- case UNITS:{
- string path = GameManager::getSingleton()->getPath();
- bool vehicles = guiTable["vehicles"];
- int numUnits = SOL_LUA_STATE["numUnits"];
+ case VEHICLES:
+ case STRUCTURES:
+ case RESOURCE_DEPOSITS:{
+ bool resources = (listboxType == RESOURCE_DEPOSITS);
+ sol::table gameObjTable = SOL_LUA_STATE[resources ? "resources" : "units"];
+ int numGameObjs = gameObjTable["num"];
+
+ for(int i = 0; i < numGameObjs; i++){
+ bool canAdd = true;
- for(int i = 0; i < numUnits; i++){
- bool v = SOL_LUA_STATE["isVehicle"][i + 1];
+ if(!resources){
+ bool vehicles = (listboxType == VEHICLES);
+ bool v = gameObjTable["isVehicle"][i + 1];
+ canAdd = (v == vehicles);
+ }
- if(v == vehicles)
- lines.push_back(SOL_LUA_STATE["name"][i + 1]);
+ if(canAdd)
+ lines.push_back(gameObjTable["name"][i + 1]);
}
-
+
numLines = lines.size();
closable = true;
maxDisplay = (numLines > numMaxDisplay ? numMaxDisplay : numLines);
-
- listbox = new UnitListbox(pos, size, lines, maxDisplay, fontPath);
+
+ listbox = new GameObjectListbox(!resources, pos, size, lines, maxDisplay, fontPath);
break;
}
case SKYBOX_TEXTURES:
diff --git a/concreteGuiManager.h b/concreteGuiManager.h
index 606413f..b0339ee 100644
--- a/concreteGuiManager.h
+++ b/concreteGuiManager.h
@@ -38,7 +38,9 @@ namespace battleship{
CONTROLS,
RESOLUTION,
MAPS,
- UNITS,
+ VEHICLES,
+ STRUCTURES,
+ RESOURCE_DEPOSITS,
SKYBOX_TEXTURES,
LAND_TEXTURES,
CPU_DIFFICULTIES,
@@ -60,6 +62,7 @@ namespace battleship{
private:
ConcreteGuiManager(){}
vb01Gui::Button* parseButton(int);
+ vb01Gui::Listbox* parseGameObjectListbox();
vb01Gui::Listbox* parseListbox(int);
vb01Gui::Checkbox* parseCheckbox(int);
vb01Gui::Slider* parseSlider(int);
diff --git a/console.cpp b/console.cpp
new file mode 100755
index 0000000..421a745
--- /dev/null
+++ b/console.cpp
@@ -0,0 +1,22 @@
+#include "console.h"
+#include "addUnitCommand.h"
+#include "addResourceCommand.h"
+
+using namespace std;
+
+namespace battleship{
+ void Console::execute(string cmdStr) {
+ int space = cmdStr.find(" ");
+ string cmdName, argsStr;
+
+ if(space != -1){
+ cmdName = cmdStr.substr(0, space);
+ argsStr = cmdStr.substr(space + 1, string::npos);
+ }
+
+ if(cmdName == "add-unit")
+ AddUnitCommand(argsStr).execute();
+ else if(cmdName == "add-resource")
+ AddResourceCommand(argsStr).execute();
+ }
+}
diff --git a/console.h b/console.h
new file mode 100755
index 0000000..9675c27
--- /dev/null
+++ b/console.h
@@ -0,0 +1,13 @@
+#ifndef CONSOLE_COMMAND_H
+#define CONSOLE_COMMAND_H
+
+#include
+
+namespace battleship{
+ class Console{
+ public:
+ static void execute(std::string);
+ };
+}
+
+#endif
diff --git a/consoleCommand.cpp b/consoleCommand.cpp
deleted file mode 100755
index 178d7c6..0000000
--- a/consoleCommand.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-#include
-#include
-#include
-#include
-
-#include
-#include
-
-#include "consoleCommand.h"
-#include "inGameAppState.h"
-#include "player.h"
-#include "unitFactory.h"
-
-using namespace std;
-using namespace vb01;
-using namespace vb01Gui;
-using namespace gameBase;
-
-namespace battleship{
- void ConsoleCommand::execute(string commandStr) {
- vector fullCommand;
- parse(commandStr, fullCommand);
-
- if (fullCommand[0] == "add-unit") {
- validateAddUnitArguments(fullCommand);
- Vector3 pos = Vector3::VEC_ZERO;
- Quaternion rot = Quaternion::QUAT_W;
-
- if(fullCommand.size() == 6)
- pos = Vector3(atof(fullCommand[3].c_str()), atof(fullCommand[4].c_str()), atof(fullCommand[5].c_str()));
-
- executeAddUnit(atoi(fullCommand[1].c_str()), atoi(fullCommand[2].c_str()), pos, rot);
- }
- }
-
- void ConsoleCommand::parse(string commandStr, vector &fullCommand){
- vector spaceIds;
-
- for(int i = 0; i < commandStr.length(); i++)
- if(commandStr[i] == ' ')
- spaceIds.push_back(i);
-
- fullCommand.push_back(commandStr.substr(0, spaceIds[0]));
-
- for(int i = 0; i < spaceIds.size(); i++){
- bool lastSpace = (i == spaceIds.size() - 1);
- string argument = commandStr.substr(spaceIds[i] + 1, lastSpace ? string::npos : spaceIds[i + 1] - spaceIds[i] - 1);
- fullCommand.push_back(argument);
- }
- }
-
- //TODO implement rotation argument
- void ConsoleCommand::validateAddUnitArguments(vector &fullCommand){
- //addUnit [ ]
- if(fullCommand.size() != 3 || fullCommand.size() != 6)
- return;
-
- int playerId = atoi(fullCommand[1].c_str());
-
- if(playerId != 0 && playerId != 1)
- return;
-
- int unitId = atoi(fullCommand[2].c_str());
-
- if(!(0 <= unitId && unitId <= (int)generateView()["numUnits"]))
- return;
- }
-
- void ConsoleCommand::executeAddUnit(int playerId, int unitId, Vector3 pos, Quaternion rot) {
- Player* player = Map::getSingleton()->getPlayer(playerId);
- player->addUnit(UnitFactory::createUnit(player, unitId, pos, rot));
- }
-}
diff --git a/consoleCommand.h b/consoleCommand.h
deleted file mode 100755
index 03f712b..0000000
--- a/consoleCommand.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#pragma once
-#ifndef CONSOLE_COMMAND_H
-#define CONSOLE_COMMAND_H
-
-#include
-#include
-
-#include
-#include
-
-namespace battleship{
- class ConsoleCommand{
- public:
- static void execute(std::string);
- private:
- static void parse(std::string, std::vector&);
- static void validateAddUnitArguments(std::vector&);
- static void executeAddUnit(int, int, vb01::Vector3, vb01::Quaternion);
- static void validateDebugUnitsArguments();
- };
-}
-
-#endif
diff --git a/defConfigs.h b/defConfigs.h
index c16ebdf..12fb1bd 100755
--- a/defConfigs.h
+++ b/defConfigs.h
@@ -39,6 +39,7 @@ namespace battleship{
"Scripts/unitData.lua",
"Scripts/vehicleData.lua",
"Scripts/structureData.lua",
+ "Scripts/resourceData.lua",
"Scripts/player.lua"
};
diff --git a/gameObject.cpp b/gameObject.cpp
new file mode 100644
index 0000000..b31676f
--- /dev/null
+++ b/gameObject.cpp
@@ -0,0 +1,81 @@
+#include "gameObject.h"
+#include "gameManager.h"
+#include "defConfigs.h"
+
+#include
+
+#include
+
+#include
+
+namespace battleship{
+ using namespace std;
+ using namespace vb01;
+ using namespace gameBase;
+ using namespace configData;
+
+ void GameObject::update(){
+ }
+
+ void GameObject::placeAt(Vector3 p) {
+ model->setPosition(p);
+ pos = p;
+ }
+
+ void GameObject::orientAt(Quaternion rotQuat){
+ model->setOrientation(rotQuat);
+ rot = rotQuat;
+ }
+
+ void GameObject::initProperties(){
+ }
+
+ void GameObject::destroyModel(){
+ Root::getSingleton()->getRootNode()->dettachChild(model);
+ delete model;
+ }
+
+ void GameObject::initModel(bool textured){
+ sol::table SOL_LUA_STATE = generateView()[GameObject::getGameObjTableName()];
+ string basePath = SOL_LUA_STATE["basePath"][id + 1];
+ string meshPath = SOL_LUA_STATE["meshPath"][id + 1];
+
+ model = new Model(basePath + meshPath);
+ Root *root = Root::getSingleton();
+ string libPath = root->getLibPath();
+
+ Material *mat = new Material(libPath + "texture");
+
+ if(textured){
+ string f[]{GameManager::getSingleton()->getPath() + configData::DEFAULT_TEXTURE};
+ Texture *diffuseTexture = new Texture(f, 1, false);
+ mat->addBoolUniform("texturingEnabled", true);
+ mat->addBoolUniform("lightingEnabled", false);
+ mat->addTexUniform("textures[0]", diffuseTexture, true);
+ }
+ else{
+ mat->addBoolUniform("texturingEnabled", false);
+ mat->addBoolUniform("lightingEnabled", false);
+ mat->addVec4Uniform("diffuseColor", Vector4::VEC_ZERO);
+ model->setWireframe(true);
+ }
+
+ model->setMaterial(mat);
+ root->getRootNode()->attachChild(model);
+ }
+
+ void GameObject::destroySound(){}
+
+ void GameObject::initSound(){}
+
+ string GameObject::getGameObjTableName(){
+ switch(type){
+ case GameObject::Type::UNIT:
+ return "units";
+ case GameObject::Type::PROJECTILE:
+ return "projectiles";
+ case GameObject::Type::RESOURCE_DEPOSIT:
+ return "resources";
+ }
+ }
+}
diff --git a/gameObject.h b/gameObject.h
new file mode 100644
index 0000000..668baa1
--- /dev/null
+++ b/gameObject.h
@@ -0,0 +1,58 @@
+#ifndef GAME_OBJECT_H
+#define GAME_OBJECT_H
+
+#include
+#include
+#include
+
+namespace battleship{
+ class Player;
+
+ class GameObject{
+ public:
+ enum class Type{UNIT, PROJECTILE, RESOURCE_DEPOSIT};
+
+ GameObject(Type t, int i, Player *pl, vb01::Vector3 vec, vb01::Quaternion quat) : type(t), id(i), player(pl), pos(vec), rot(quat){}
+ ~GameObject(){}
+ virtual void update();
+ virtual void toggleSelection(bool sel){selected = sel;}
+ void placeAt(vb01::Vector3);
+ void orientAt(vb01::Quaternion);
+ std::string getGameObjTableName();
+ inline vb01::Vector3 getCorner(int i){return corners[i];}
+ inline bool isSelected(){return selected;}
+ inline bool isSelectable(){return selectable;}
+ inline bool isDebuggable(){return debugging;}
+ inline vb01::Vector3 getPos() {return pos;}
+ inline vb01::Quaternion getRot(){return rot;}
+ inline float getWidth() {return width;}
+ inline float getHeight() {return height;}
+ inline float getLength() {return length;}
+ inline vb01::Model* getModel() {return model;}
+ inline Player* getPlayer(){return player;}
+ inline void toggleDebugging(bool d){this->debugging=d;}
+ inline vb01::Vector3 getDirVec() {return dirVec;}
+ inline vb01::Vector3 getLeftVec() {return leftVec;}
+ inline vb01::Vector3 getUpVec() {return upVec;}
+ inline int getId() {return id;}
+ inline Type getType(){return type;}
+ private:
+ protected:
+ virtual void initProperties();
+ virtual void destroyModel();
+ virtual void initModel(bool = true);
+ virtual void destroySound();
+ virtual void initSound();
+
+ Type type;
+ int id;
+ Player *player;
+ vb01::Model *model = nullptr;
+ vb01::Vector3 pos = vb01::Vector3(0, 0, 0), upVec = vb01::Vector3(0, 1, 0), dirVec = vb01::Vector3(0, 0, 1), leftVec = vb01::Vector3(1, 0, 0), corners[8];
+ vb01::Quaternion rot;
+ bool selected = false, selectable, debugging = false;
+ float width, height, length;
+ };
+}
+
+#endif
diff --git a/gameObjectFactory.cpp b/gameObjectFactory.cpp
new file mode 100644
index 0000000..ccbf7a2
--- /dev/null
+++ b/gameObjectFactory.cpp
@@ -0,0 +1,37 @@
+#include "gameObjectFactory.h"
+#include "player.h"
+#include "vehicle.h"
+#include "engineer.h"
+#include "projectile.h"
+#include "resourceDeposit.h"
+#include "defConfigs.h"
+
+#include
+
+#include
+
+namespace battleship{
+ using namespace std;
+ using namespace vb01;
+ using namespace gameBase;
+
+ Unit* GameObjectFactory::createUnit(Player *player, int id, Vector3 pos, Quaternion rot){
+ sol::state_view SOL_LUA_STATE = generateView();
+ int unitClass = SOL_LUA_STATE["units"]["unitClass"][id + 1];
+
+ switch((UnitClass)unitClass){
+ case UnitClass::ENGINEER:
+ return new Engineer(player, id, pos, rot);
+ default:
+ return new Vehicle(player, id, pos, rot);
+ }
+ }
+
+ Projectile* GameObjectFactory::createProjectile(Unit *unti, int id, Vector3 pos, Quaternion rot){
+ return nullptr;
+ }
+
+ ResourceDeposit* GameObjectFactory::createResourceDeposit(int id, Vector3 pos, Quaternion rot){
+ return new ResourceDeposit(id, pos, rot);
+ }
+}
diff --git a/gameObjectFactory.h b/gameObjectFactory.h
new file mode 100644
index 0000000..d4ba61a
--- /dev/null
+++ b/gameObjectFactory.h
@@ -0,0 +1,23 @@
+#ifndef GAME_OBJECT_FACTORY_H
+#define GAME_OBJECT_FACTORY_H
+
+#include
+#include
+
+namespace battleship{
+ class Unit;
+ class Projectile;
+ class ResourceDeposit;
+ class Player;
+
+ class GameObjectFactory{
+ public:
+ enum GameObjectType{UNIT, PROJECTILE, RESOURCE_DEPOSIT};
+ static Unit* createUnit(Player*, int, vb01::Vector3, vb01::Quaternion);
+ static Projectile* createProjectile(Unit*, int, vb01::Vector3, vb01::Quaternion);
+ static ResourceDeposit* createResourceDeposit(int, vb01::Vector3, vb01::Quaternion);
+ private:
+ };
+}
+
+#endif
diff --git a/gameObjectFrame.cpp b/gameObjectFrame.cpp
new file mode 100644
index 0000000..4a9efa5
--- /dev/null
+++ b/gameObjectFrame.cpp
@@ -0,0 +1,5 @@
+#include "gameObjectFrame.h"
+
+namespace battleship{
+
+}
diff --git a/gameObjectFrame.h b/gameObjectFrame.h
new file mode 100644
index 0000000..5140920
--- /dev/null
+++ b/gameObjectFrame.h
@@ -0,0 +1,22 @@
+#ifndef GAME_OBJECT_FRAME_H
+#define GAME_OBJECT_FRAME_H
+
+#include "gameObject.h"
+
+#include
+#include
+
+namespace battleship{
+ struct GameObjectFrame : public GameObject{
+ enum Status{PLACEABLE, NOT_PLACEABLE, PLACED};
+
+ GameObjectFrame(int i, GameObject::Type t, vb01::Vector3 pos = vb01::Vector3::VEC_ZERO, vb01::Quaternion rot = vb01::Quaternion::QUAT_W) : GameObject(t, i, nullptr, pos, rot) {
+ initModel(false);
+ }
+ ~GameObjectFrame(){}
+
+ Status status;
+ };
+}
+
+#endif
diff --git a/gameObjectFrameController.cpp b/gameObjectFrameController.cpp
new file mode 100644
index 0000000..90de7f0
--- /dev/null
+++ b/gameObjectFrameController.cpp
@@ -0,0 +1,143 @@
+#include
+
+#include "gameObjectFrameController.h"
+#include "unit.h"
+#include "util.h"
+#include "map.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+namespace battleship{
+ using namespace std;
+ using namespace vb01;
+ using namespace gameBase;
+
+ static GameObjectFrameController *gameObjectFrameController = nullptr;
+
+ GameObjectFrameController* GameObjectFrameController::getSingleton(){
+ if(!gameObjectFrameController)
+ gameObjectFrameController = new GameObjectFrameController();
+
+ return gameObjectFrameController;
+ }
+
+ void GameObjectFrameController::paintSelect(Vector3 rowEnd, float width, float length){
+ Vector3 rowDir = rowEnd - paintSelectRowStart;
+ float lenRow = rowDir.getLength();
+ float hypothenuse = sqrt(width * width + length * length);
+ int numStructsInRow = int(lenRow / hypothenuse);
+
+ while(gameObjectFrames.size() > numStructsInRow)
+ removeGameObjectFrame(gameObjectFrames.size() - 1);
+
+ if(gameObjectFrames.size() < numStructsInRow){
+ int structureId = gameObjectFrames[0].getId();
+ Vector3 buildDir = rowDir;
+
+ if(gameObjectFrames.size() > 1)
+ buildDir = gameObjectFrames[1].getModel()->getPosition() - gameObjectFrames[0].getModel()->getPosition();
+
+ Vector3 pos = paintSelectRowStart + buildDir.norm() * hypothenuse * gameObjectFrames.size();
+ addGameObjectFrame(GameObjectFrame(structureId, GameObject::Type::UNIT, pos));
+ }
+ }
+
+ //TODO implement terrain evenness check
+ void GameObjectFrameController::placeGameObjectFrame(int id, Vector3 newPos, float width, float length){
+ GameObjectFrame &s = gameObjectFrames[id];
+ Model *model = s.getModel();
+
+ if(!rotatingStructure)
+ model->setPosition(newPos);
+
+ Map *map = Map::getSingleton();
+ MeshData meshData = map->getNodeParent()->getChild(0)->getMesh(0)->getMeshBase();
+ MeshData::Vertex *verts = meshData.vertices;
+ int numVerts = 3 * meshData.numTris;
+
+ float maxUnevenness = generateView()["maxUnevenness"], unevenness = 0;
+
+ for(int i = 0; i < numVerts; i++){
+ float diffX = fabs(model->getPosition().x - verts[i].pos.x);
+ float diffY = fabs(model->getPosition().y - verts[i].pos.y);
+ float diffZ = fabs(model->getPosition().z - verts[i].pos.z);
+
+ if(diffX < 0.5 * width && diffZ < 0.5 * length && diffY > unevenness){
+ unevenness = diffY;
+
+ if(unevenness > maxUnevenness)
+ break;
+ }
+ }
+
+ Vector4 color;
+
+ if(unevenness > maxUnevenness){
+ color = Vector4(1, 0, 0, 1);
+ s.status = GameObjectFrame::NOT_PLACEABLE;
+ }
+ else{
+ color = Vector4(0, 1, 0, 1);
+ s.status = GameObjectFrame::PLACEABLE;
+ }
+
+ Material *mat = model->getMaterial();
+ mat->setVec4Uniform("diffuseColor", color);
+ }
+
+ void GameObjectFrameController::update(){
+ Vector3 startPos = Root::getSingleton()->getCamera()->getPosition();
+ vector results;
+ Ray::retrieveCollisions(startPos, (screenToSpace(getCursorPos()) - startPos).norm(), Map::getSingleton()->getNodeParent()->getChild(0), results);
+ Ray::sortResults(results);
+ if(results.empty()) return;
+
+ Vector3 newPos, rowEnd;
+ sol::table unitTable = generateView()[gameObjectFrames[0].getGameObjTableName()]["unitCornerPoints"][gameObjectFrames[0].getId() + 1];
+ float width = (float)unitTable[1]["x"] - (float)unitTable[2]["x"];
+ float length = (float)unitTable[4]["z"] - (float)unitTable[1]["z"];
+
+ if(paintSelecting)
+ paintSelect(results[0].pos, width, length);
+ else if(!(paintSelecting || rotatingStructure))
+ newPos = results[0].pos;
+
+ for(int i = 0; i < gameObjectFrames.size(); i++){
+ if(paintSelecting){
+ float hypothenuse = sqrt(width * width + length * length);
+ Vector3 dir = (results[0].pos - paintSelectRowStart).norm();
+ newPos = paintSelectRowStart + dir * hypothenuse * i;
+ }
+
+ placeGameObjectFrame(i, newPos, width, length);
+ }
+ }
+
+ void GameObjectFrameController::removeGameObjectFrame(int i){
+ Model *model = gameObjectFrames[i].getModel();
+ model->getParent()->dettachChild(model);
+ delete model;
+ gameObjectFrames.erase(gameObjectFrames.begin() + i);
+ }
+
+ void GameObjectFrameController::removeGameObjectFrames(){
+ while(gameObjectFrames.size() > 0)
+ removeGameObjectFrame(0);
+ }
+
+ void GameObjectFrameController::rotateGameObjectFrames(float angle){
+ for(GameObjectFrame &s : gameObjectFrames)
+ if(s.status != GameObjectFrame::PLACED){
+ Model *model = s.getModel();
+ Quaternion rot = model->getOrientation();
+ model->setOrientation(Quaternion(angle, Vector3::VEC_J) * rot);
+ }
+ }
+}
diff --git a/gameObjectFrameController.h b/gameObjectFrameController.h
new file mode 100644
index 0000000..799d692
--- /dev/null
+++ b/gameObjectFrameController.h
@@ -0,0 +1,45 @@
+#ifndef GAME_OBJECT_FRAME_CONTROLLER_H
+#define GAME_OBJECT_FRAME_CONTROLLER_H
+
+#include
+#include
+
+#include
+#include
+
+#include "gameObjectFrame.h"
+
+namespace vb01{
+ class Model;
+}
+
+namespace battleship{
+ class GameObjectFrameController{
+ public:
+ static GameObjectFrameController* getSingleton();
+ void update();
+ void removeGameObjectFrame(int);
+ void removeGameObjectFrames();
+ void rotateGameObjectFrames(float);
+ inline int getNumGameObjectFrames(){return gameObjectFrames.size();}
+ inline void addGameObjectFrame(GameObjectFrame u){gameObjectFrames.push_back(u);}
+ inline GameObjectFrame& getGameObjectFrame(int i){return gameObjectFrames[i];}
+ inline bool isPlacingFrames(){return placingStructures;}
+ inline void setPlacingFrames(bool ps){placingStructures = ps;}
+ inline bool isPaintSelecting(){return paintSelecting;}
+ inline void setPaintSelecting(bool ps){paintSelecting = ps;}
+ inline bool isRotatingFrames(){return rotatingStructure;}
+ inline void setRotatingFrames(bool rs){rotatingStructure = rs;}
+ inline void setPaintSelectRowStart(vb01::Vector3 st){paintSelectRowStart = st;}
+ private:
+ GameObjectFrameController(){}
+ void paintSelect(vb01::Vector3, float, float);
+ void placeGameObjectFrame(int, vb01::Vector3, float, float);
+
+ std::vector gameObjectFrames;
+ vb01::Vector3 paintSelectRowStart, rowDir;
+ bool placingStructures = false, paintSelecting = false, rotatingStructure = false;
+ };
+}
+
+#endif
diff --git a/gameObjectListbox.cpp b/gameObjectListbox.cpp
new file mode 100644
index 0000000..7c9fca8
--- /dev/null
+++ b/gameObjectListbox.cpp
@@ -0,0 +1,21 @@
+#include
+
+#include "gameObject.h"
+#include "gameObjectListbox.h"
+#include "gameObjectFrameController.h"
+
+namespace battleship{
+ using namespace std;
+ using namespace vb01;
+ using namespace vb01Gui;
+ using namespace gameBase;
+
+ GameObjectListbox::GameObjectListbox(bool ul, Vector2 pos, Vector2 size, vector lines, int maxDisplay, string fontPath) : Listbox(pos, size, lines, maxDisplay, fontPath), unitListbox(ul) {}
+
+ void GameObjectListbox::onClose(){
+ GameObjectFrameController *ufCtr = GameObjectFrameController::getSingleton();
+ GameObject::Type type = (unitListbox ? GameObject::Type::UNIT : GameObject::Type::RESOURCE_DEPOSIT);
+ ufCtr->addGameObjectFrame(GameObjectFrame(selectedOption, type));
+ ufCtr->setPlacingFrames(true);
+ }
+}
diff --git a/gameObjectListbox.h b/gameObjectListbox.h
new file mode 100644
index 0000000..0d7967f
--- /dev/null
+++ b/gameObjectListbox.h
@@ -0,0 +1,16 @@
+#ifndef UNIT_LISTBOX_H
+#define UNIT_LISTBOX_H
+
+#include
+
+namespace battleship{
+ class GameObjectListbox : public vb01Gui::Listbox{
+ public:
+ GameObjectListbox(bool, vb01::Vector2, vb01::Vector2, std::vector, int, std::string);
+ void onClose();
+ private:
+ bool unitListbox;
+ };
+}
+
+#endif
diff --git a/inGameAppState.cpp b/inGameAppState.cpp
index 188bf82..219dca5 100755
--- a/inGameAppState.cpp
+++ b/inGameAppState.cpp
@@ -11,8 +11,8 @@
#include "defConfigs.h"
#include "inGameAppState.h"
-#include "consoleCommand.h"
-#include "unitFrameController.h"
+#include "console.h"
+#include "gameObjectFrameController.h"
#include "concreteGuiManager.h"
#include "vessel.h"
@@ -36,13 +36,13 @@ namespace battleship{
ConcreteGuiManager::getSingleton()->readLuaScreenScript("console.lua");
}
- InGameAppState::ConsoleButton::ConsoleButton::ConsoleCommandEntryButton::ConsoleCommandEntryButton(Textbox *t, Listbox *l, Vector2 pos, Vector2 size, string name) : Button(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", -1, true) {
+ InGameAppState::ConsoleButton::ConsoleButton::ConsoleCommandEntryButton::ConsoleCommandEntryButton(Textbox *t, Listbox *l, Vector2 pos, Vector2 size, string name) : Button(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", 257, true) {
textbox = t;
listbox = l;
}
void InGameAppState::ConsoleButton::ConsoleButton::ConsoleCommandEntryButton::onClick() {
- ConsoleCommand::execute(wstringToString(textbox->getText()));
+ Console::execute(wstringToString(textbox->getText()));
}
InGameAppState::InGameAppState(vector difficultyLevels, vector factions, string mapName) : AbstractAppState(
@@ -124,14 +124,14 @@ namespace battleship{
for(Player *p : Map::getSingleton()->getPlayers())
for(Unit *u : p->getUnits())
- u->reinitUnit();
+ u->reinit();
}
}
void InGameAppState::onAction(int bind, bool isPressed) {
switch((Bind)bind){
case Bind::TOGGLE_MAIN_MENU:
- if(isPressed && !UnitFrameController::getSingleton()->isPlacingFrames())
+ if(isPressed && !GameObjectFrameController::getSingleton()->isPlacingFrames())
toggleMainMenu();
break;
}
diff --git a/map.cpp b/map.cpp
index 7b30da2..1f591c7 100755
--- a/map.cpp
+++ b/map.cpp
@@ -8,7 +8,8 @@
#include "map.h"
#include "player.h"
-#include "unitFactory.h"
+#include "gameObject.h"
+#include "gameObjectFactory.h"
#include "pathfinder.h"
#include "gameManager.h"
#include "defConfigs.h"
@@ -133,6 +134,23 @@ namespace battleship{
string playerInd = "players";
for(int i = 0; i < numPlayers; i++){
+ if(i == 0){
+ int numNpcObjs = SOL_LUA_STATE[mapTable][playerInd][i + 1]["numNpcGameObjs"];
+
+ for(int j = 0; j < numNpcObjs; j++){
+ sol::table npcObjTable = SOL_LUA_STATE[mapTable][playerInd][i + 1]["npcGameObjs"][j + 1];
+ int id = npcObjTable["id"];
+
+ sol::table posTable = npcObjTable["pos"];
+ Vector3 pos = Vector3(posTable["x"], posTable["y"], posTable["z"]);
+
+ sol::table rotTable = npcObjTable["rot"];
+ Quaternion rot = Quaternion(rotTable["w"], rotTable["x"], rotTable["y"], rotTable["z"]);
+
+ addNpcGameObject((GameObject*)GameObjectFactory::createResourceDeposit(id, pos, rot));
+ }
+ }
+
//int spawnPointId = SOL_LUA_STATE[mapTable]["spawnPointInd"][i + 1][spawnPointId];
int numUnits = SOL_LUA_STATE[mapTable][playerInd][i + 1]["numUnits"];
@@ -149,7 +167,7 @@ namespace battleship{
int id = unitTable["id"];
- players[i]->addUnit(UnitFactory::createUnit(players[i], id, pos, rot));
+ players[i]->addUnit(GameObjectFactory::createUnit(players[i], id, pos, rot));
}
}
}
diff --git a/map.h b/map.h
index f83bc2e..dd91ca5 100755
--- a/map.h
+++ b/map.h
@@ -16,6 +16,7 @@ namespace vb01{
namespace battleship{
class Player;
+ class GameObject;
struct Cell;
class Map {
@@ -58,6 +59,8 @@ namespace battleship{
inline vb01::Vector3 getSpawnPoint(int i){return spawnPoints[i];}
inline void addSpawnPoint(vb01::Vector3 sp){spawnPoints.push_back(sp);}
inline std::vector& getCells(){return cells;}
+ inline void addNpcGameObject(GameObject *obj){npcGameObjects.push_back(obj);}
+ inline std::vector getNpcGameObjects(){return npcGameObjects;}
private:
std::string mapTable = "map";
vb01::Node *terrainNode = nullptr, *cellNode = nullptr;
@@ -67,6 +70,7 @@ namespace battleship{
std::vector spawnPoints;
std::vector players;
std::vector| cells;
+ std::vector npcGameObjects;
Map(){}
void preprareScene();
diff --git a/mapEditorAppState.cpp b/mapEditorAppState.cpp
index cb2b27d..c74ec88 100644
--- a/mapEditorAppState.cpp
+++ b/mapEditorAppState.cpp
@@ -2,7 +2,8 @@
#include "gameManager.h"
#include "defConfigs.h"
#include "cameraController.h"
-#include "unitFrameController.h"
+#include "gameObjectFactory.h"
+#include "gameObjectFrameController.h"
#include "player.h"
#include "map.h"
#include "mesh.h"
@@ -56,6 +57,7 @@ namespace battleship{
AssetManager *assetManager = AssetManager::getSingleton();
assetManager->load(basePath + "Models/Units/", true);
+ assetManager->load(basePath + "Models/Resources/", true);
assetManager->load(basePath + DEFAULT_TEXTURE);
}
@@ -413,7 +415,27 @@ namespace battleship{
mapScript += "},\nplayers = {\n";
for(int i = 0; i < map->getNumPlayers(); i++){
- mapScript += "{\nspawnPoint = 0,\n";
+ mapScript += "{\n";
+
+ if(i > 0)
+ mapScript += "spawnPoint = 0,\n";
+ else{
+ vector npcGameObjs = map->getNpcGameObjects();
+ mapScript += "numNpcGameObjs = " + to_string(npcGameObjs.size()) + ",\n";
+ mapScript += "npcGameObjs = {\n";
+
+ for(GameObject *npcGameObj : npcGameObjs){
+ Vector3 pos = npcGameObj->getPos();
+ string posStr = "x = " + to_string(pos.x) + ", y = " + to_string(pos.y) + ", z = " + to_string(pos.z);
+
+ Quaternion rot = npcGameObj->getRot();
+ string rotStr = "w = " + to_string(rot.w) + ", x = " + to_string(rot.x) + ", y = " + to_string(rot.y) + ", z = " + to_string(rot.z);
+
+ mapScript += "{id = " + to_string(npcGameObj->getId()) + ", pos = {" + posStr + "}, rot = {" + rotStr + "}},\n";
+ }
+
+ mapScript += "},\n";
+ }
int numUnits = map->getPlayer(i)->getNumberOfUnits();
mapScript += "numUnits = " + to_string(numUnits) + ",\n";
@@ -545,7 +567,7 @@ namespace battleship{
if(!(camCtr->isLookingAround() || mapEditor->isPushing()))
camCtr->updateCameraPosition();
- UnitFrameController *ufCtr = UnitFrameController::getSingleton();
+ GameObjectFrameController *ufCtr = GameObjectFrameController::getSingleton();
if(ufCtr->isPlacingFrames())
ufCtr->update();
@@ -578,21 +600,31 @@ namespace battleship{
void MapEditorAppState::onDettached(){}
void MapEditorAppState::onAction(int bind, bool isPressed){
- UnitFrameController *ufCtr = UnitFrameController::getSingleton();
+ GameObjectFrameController *ufCtr = GameObjectFrameController::getSingleton();
switch((Bind)bind){
case Bind::LOOK_AROUND:
if(ufCtr->isPlacingFrames()){
- Player *player = Map::getSingleton()->getPlayer(0);
- UnitFrameController::UnitFrame &frame = ufCtr->getUnitFrame(0);
- player->addUnit(new Unit(player, frame.id, frame.model->getPosition(), frame.model->getOrientation()));
+ Map *map = Map::getSingleton();
+ Player *player = map->getPlayer(0);
+ GameObjectFrame &frame = ufCtr->getGameObjectFrame(0);
+ Model *model = frame.getModel();
+ Vector3 pos = model->getPosition();
+ Quaternion rot = model->getOrientation();
+
+ if(frame.getType() == GameObject::Type::RESOURCE_DEPOSIT){
+ ResourceDeposit *dep = GameObjectFactory::createResourceDeposit(frame.getId(), pos, rot);
+ map->addNpcGameObject((GameObject*)dep);
+ }
+ else
+ player->addUnit(GameObjectFactory::createUnit(player, frame.getId(), pos, rot));
}
else
CameraController::getSingleton()->setLookingAround(isPressed);
break;
case Bind::DESELECT_STRUCTURE:
- ufCtr->removeUnitFrames();
+ ufCtr->removeGameObjectFrames();
ufCtr->setPlacingFrames(false);
break;
case Bind::INCREASE_RADIUS:
diff --git a/player.h b/player.h
index 215e613..932372d 100755
--- a/player.h
+++ b/player.h
@@ -31,8 +31,17 @@ namespace battleship{
inline int getFaction(){return faction;}
inline int getSide(){return side;}
inline vb01::Vector3 getSpawnPoint(){return spawnPoint;}
+ inline int getRefineds(){return refineds;}
+ inline void setRefineds(int ref){this->refineds = ref;}
+ inline void addRefineds(int ref){this->refineds += ref;}
+ inline int getWealth(){return wealth;}
+ inline void setWealth(int w){this->wealth = w;}
+ inline void addWealth(int w){this->wealth += w;}
+ inline int getResearch(){return research;}
+ inline void setResearch(int r){this->research = r;}
+ inline void addResearch(int r){this->research += r;}
private:
- int credits, faction, difficulty,side,id;
+ int refineds = 0, wealth = 0, research = 0, faction, difficulty,side,id;
std::vector units, selectedUnits;
vb01::Vector3 spawnPoint;
};
diff --git a/projectile.cpp b/projectile.cpp
index 539f9ea..47b3ccf 100755
--- a/projectile.cpp
+++ b/projectile.cpp
@@ -23,7 +23,7 @@ namespace battleship{
using namespace configData;
using namespace gameBase;
- Projectile::Projectile(Unit *unit, Node *node, Vector3 pos, Vector3 dir, Vector3 left, Vector3 up, int id, int weaponTypeId, int weaponId) {
+ Projectile::Projectile(Unit *unit, Node *node, Vector3 pos, Vector3 dir, Vector3 left, Vector3 up, int id, int weaponTypeId, int weaponId) : GameObject(GameObject::Type::PROJECTILE, id, unit->getPlayer(), pos, Quaternion::QUAT_W){
this->unit = unit;
this->id = id;
this->weaponTypeId = weaponTypeId;
@@ -43,7 +43,7 @@ namespace battleship{
}
void Projectile::initProperties(int weaponId){
- sol::state_view SOL_LUA_STATE = generateView();
+ sol::table SOL_LUA_STATE = generateView()[GameObject::getGameObjTableName()];
rayLength = SOL_LUA_STATE["rayLength"][id + 1][weaponTypeId + 1][weaponId + 1];
damage = SOL_LUA_STATE["damage"][id + 1][weaponTypeId + 1][weaponId + 1];
speed = SOL_LUA_STATE["speed"][id + 1][weaponTypeId + 1][weaponId + 1];
@@ -51,7 +51,7 @@ namespace battleship{
void Projectile::initModel(Node *node){
if(!node){
- sol::state_view SOL_LUA_STATE = generateView();
+ sol::table SOL_LUA_STATE = generateView()[GameObject::getGameObjTableName()];
string meshPath = SOL_LUA_STATE["meshPath"][id + 1][weaponTypeId + 1];
this->node = new Model(meshPath);
@@ -72,7 +72,7 @@ namespace battleship{
void Projectile::initSound(){
GameManager *gm = GameManager::getSingleton();
- sol::state_view SOL_LUA_STATE = generateView();
+ sol::table SOL_LUA_STATE = generateView()[GameObject::getGameObjTableName()];
string unitName = SOL_LUA_STATE["name"][id + 1];
string projectileName = SOL_LUA_STATE["projectileName"][id + 1][weaponTypeId + 1];
string p1 = gm->getPath() + "Sounds/" + unitName + "s/" + projectileName + ".ogg";
diff --git a/projectile.h b/projectile.h
index e66c7e8..9f4bcf0 100755
--- a/projectile.h
+++ b/projectile.h
@@ -1,4 +1,3 @@
-#pragma once
#ifndef PROJECTILE_H
#define PROJECTILE_H
@@ -8,6 +7,7 @@
#include
#include "gameManager.h"
+#include "gameObject.h"
#include "util.h"
namespace vb01{
@@ -19,7 +19,7 @@ namespace vb01{
namespace battleship {
class Unit;
- class Projectile {
+ class Projectile : public GameObject{
public:
Projectile(Unit*, vb01::Node*, vb01::Vector3, vb01::Vector3, vb01::Vector3, vb01::Vector3, int, int, int);
virtual ~Projectile();
@@ -40,8 +40,7 @@ namespace battleship {
bool exploded = false;
float speed, rayLength, scale;
int damage, id, weaponTypeId;
- vb01::Vector3 initPos, pos, dirVec, leftVec, upVec;
- vb01::Quaternion rot;
+ vb01::Vector3 initPos;
s64 lastUpdateTime = 0;
Unit *unit = nullptr;
sf::SoundBuffer *shotSfxBuffer, *explosionSfxBuffer;
diff --git a/resourceDeposit.cpp b/resourceDeposit.cpp
new file mode 100644
index 0000000..563e6af
--- /dev/null
+++ b/resourceDeposit.cpp
@@ -0,0 +1,14 @@
+#include "resourceDeposit.h"
+
+namespace battleship{
+ using namespace vb01;
+
+ ResourceDeposit::ResourceDeposit(int id, Vector3 pos, Quaternion rot) : GameObject(GameObject::Type::RESOURCE_DEPOSIT, id, nullptr, pos, rot){
+ initModel();
+ placeAt(pos);
+ orientAt(rot);
+ }
+
+ void ResourceDeposit::update(){
+ }
+}
diff --git a/resourceDeposit.h b/resourceDeposit.h
new file mode 100644
index 0000000..5881834
--- /dev/null
+++ b/resourceDeposit.h
@@ -0,0 +1,15 @@
+#ifndef RESOURCE_DEPOSIT_H
+#define RESOURCE_DEPOSIT_H
+
+#include "gameObject.h"
+
+namespace battleship{
+ class ResourceDeposit : public GameObject{
+ public:
+ ResourceDeposit(int, vb01::Vector3, vb01::Quaternion);
+ void update();
+ private:
+ };
+}
+
+#endif
diff --git a/unit.cpp b/unit.cpp
index a8cfaf2..18368ec 100755
--- a/unit.cpp
+++ b/unit.cpp
@@ -22,24 +22,30 @@ using namespace gameBase;
using namespace std;
namespace battleship{
- Unit::Unit(Player *player, int id, Vector3 pos, Quaternion rot) {
+ Unit::Unit(Player *player, int id, Vector3 pos, Quaternion rot) : GameObject(GameObject::Type::UNIT, id, player, pos, rot){
this->id = id;
this->player = player;
- initProperties();
- initModel();
- initSound();
- initUnitStats();
- placeUnit(pos);
- orientUnit(rot);
+ init();
+
+ hpBackgroundNode = createBar(lenHpBar, Vector4(0, 0, 0, 1));
+ hpForegroundNode = createBar(lenHpBar, Vector4(0, 1, 0, 1));
}
//TODO complete implementation
Unit::~Unit() {
}
+ void Unit::init(){
+ initProperties();
+ initModel();
+ initSound();
+ placeAt(pos);
+ orientAt(rot);
+ }
+
void Unit::initProperties(){
- sol::state_view SOL_LUA_STATE = generateView();
+ sol::table SOL_LUA_STATE = generateView()[GameObject::getGameObjTableName()];
health = SOL_LUA_STATE["health"][id + 1];
maxHealth = health;
@@ -60,31 +66,6 @@ namespace battleship{
length = corners[3].z - corners[0].z;
}
- void Unit::destroyModel(){
- Root::getSingleton()->getRootNode()->dettachChild(model);
- delete model;
- }
-
- void Unit::initModel(){
- sol::state_view SOL_LUA_STATE = generateView();
- string basePath = SOL_LUA_STATE["basePath"][id + 1];
- string meshPath = SOL_LUA_STATE["meshPath"][id + 1];
-
- model = new Model(basePath + meshPath);
- Root *root = Root::getSingleton();
- string libPath = root->getLibPath();
-
- Material *mat = new Material(libPath + "texture");
- string f[]{GameManager::getSingleton()->getPath() + configData::DEFAULT_TEXTURE};
- Texture *diffuseTexture = new Texture(f, 1, false);
- mat->addBoolUniform("texturingEnabled", true);
- mat->addBoolUniform("lightingEnabled", false);
- mat->addTexUniform("textures[0]", diffuseTexture, true);
-
- model->setMaterial(mat);
- root->getRootNode()->attachChild(model);
- }
-
void Unit::destroySound(){
selectionSfx->stop();
delete selectionSfx;
@@ -92,7 +73,7 @@ namespace battleship{
}
void Unit::initSound(){
- sol::state_view SOL_LUA_STATE = generateView();
+ sol::table SOL_LUA_STATE = generateView()[GameObject::getGameObjTableName()];
string name = SOL_LUA_STATE["name"][id + 1];
selectionSfxBuffer = new sf::SoundBuffer();
string p = GameManager::getSingleton()->getPath() + "Sounds/" + name + "s/selection.ogg";
@@ -101,14 +82,14 @@ namespace battleship{
selectionSfx = new sf::Sound(*selectionSfxBuffer);
}
- void Unit::reinitUnit(){
+ void Unit::reinit(){
destroySound();
destroyModel();
initModel();
initSound();
initProperties();
- placeUnit(pos);
- orientUnit(rot);
+ placeAt(pos);
+ orientAt(rot);
}
Node* Unit::createBar(float initLen, Vector4 color){
@@ -129,8 +110,6 @@ namespace battleship{
}
void Unit::initUnitStats(){
- hpBackgroundNode = createBar(lenHpBar, Vector4(0, 0, 0, 1));
- hpForegroundNode = createBar(lenHpBar, Vector4(0, 1, 0, 1));
}
void Unit::update() {
@@ -213,16 +192,6 @@ namespace battleship{
removeOrder(orders.size() - 1);
}
- void Unit::placeUnit(Vector3 p) {
- model->setPosition(p);
- pos = p;
- }
-
- void Unit::orientUnit(Quaternion rotQuat){
- model->setOrientation(rotQuat);
- rot = rotQuat;
- }
-
std::vector Unit::getProjectiles(){
std::vector projectiles;
InGameAppState *inGameState = ((InGameAppState*)GameManager::getSingleton()->getStateManager()->getAppStateByType((int)AppStateType::IN_GAME_STATE));
diff --git a/unit.h b/unit.h
index cc6f9ac..05252d0 100755
--- a/unit.h
+++ b/unit.h
@@ -1,5 +1,3 @@
-#pragma once
-#include "external/vb01/quaternion.h"
#ifndef UNIT_H
#define UNIT_H
@@ -11,6 +9,7 @@
#include
#include "gameManager.h"
+#include "gameObject.h"
#include "projectile.h"
namespace vb01{
@@ -47,7 +46,7 @@ namespace battleship{
enum class UnitClass {VESSEL, ENGINEER, SAMPLE_BUILDING};
enum class UnitType {UNDERWATER, SEA_LEVEL, HOVER, LAND, AIR, NONE = -1};
- class Unit {
+ class Unit : public GameObject{
public:
Unit(Player*, int, vb01::Vector3, vb01::Quaternion);
~Unit();
@@ -56,38 +55,23 @@ namespace battleship{
virtual void halt();
void toggleSelection(bool);
void setOrder(Order);
- void placeUnit(vb01::Vector3);
- void orientUnit(vb01::Quaternion);
void addProjectile(Projectile*);
std::vector getProjectiles();
virtual void addOrder(Order);
- virtual void reinitUnit();
+ virtual void reinit();
inline vb01::Vector3 getCorner(int i){return corners[i];}
- inline bool isSelected(){return selected;}
- inline bool isSelectable(){return selectable;}
- inline bool isDebuggable(){return debugging;}
inline bool isWorking(){return working;}
inline vb01::Vector2 getScreenPos(){return screenPos;}
- inline vb01::Vector3 getPos() {return pos;}
inline vb01::Vector3* getPosPtr() {return &pos;}
- inline vb01::Quaternion getRot(){return rot;}
inline float getLineOfSight() {return lineOfSight;}
- inline float getWidth() {return width;}
- inline float getHeight() {return height;}
- inline float getLength() {return length;}
inline vb01::Model* getNode() {return model;}
- inline Player* getPlayer(){return player;}
inline UnitType getType() {return type;}
inline UnitClass getUnitClass() {return unitClass;}
- inline void toggleDebugging(bool d){this->debugging=d;}
inline void takeDamage(int damage) {health -= damage;}
- inline int getId() {return id;}
inline int getPlayerId() {return playerId;}
- inline vb01::Vector3 getDirVec() {return dirVec;}
- inline vb01::Vector3 getLeftVec() {return leftVec;}
- inline vb01::Vector3 getUpVec() {return upVec;}
private:
void updateScreenCoordinates();
+ void init();
inline bool canDisplayOrderLine(){return vb01::getTime() - orderLineDispTime < orderVecDispLength;}
const int orderVecDispLength = 2000;
@@ -95,24 +79,19 @@ namespace battleship{
sf::Sound *selectionSfx = nullptr;
vb01::Node *hpBackgroundNode = nullptr, *hpForegroundNode = nullptr;
protected:
- Player *player;
UnitClass unitClass;
UnitType type;
vb01::Vector2 screenPos;
std::vector orders;
- vb01::Vector3 pos = vb01::Vector3(0, 0, 0), upVec = vb01::Vector3(0, 1, 0), dirVec = vb01::Vector3(0, 0, 1), leftVec = vb01::Vector3(1, 0, 0), corners[8];
- vb01::Quaternion rot = vb01::Quaternion::QUAT_W;
+ vb01::Vector3 corners[8];
int health, maxHealth, cost, id, playerId, lenHpBar = 200;
s64 orderLineDispTime = 0;
- vb01::Model *model;
- bool selected = false, selectable, debugging = false, working = true;
- float lineOfSight, range, width, height, length;
+ bool working = true;
+ float lineOfSight, range;
void removeOrder(int);
void displayUnitStats(vb01::Node*, vb01::Node*, int, int, vb01::Vector2 = vb01::Vector2::VEC_ZERO);
virtual void initProperties();
- virtual void destroyModel();
- virtual void initModel();
virtual void destroySound();
virtual void initSound();
virtual void initUnitStats();
diff --git a/unitFactory.cpp b/unitFactory.cpp
deleted file mode 100644
index 57facaf..0000000
--- a/unitFactory.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-#include "unitFactory.h"
-#include "player.h"
-#include "vehicle.h"
-#include "engineer.h"
-#include "defConfigs.h"
-
-#include
-
-#include
-
-namespace battleship{
- using namespace std;
- using namespace vb01;
- using namespace gameBase;
-
- Unit* UnitFactory::createUnit(Player *player, int id, Vector3 pos, Quaternion rot){
- sol::state_view SOL_LUA_STATE = generateView();
- int unitClass = SOL_LUA_STATE["unitClass"][id + 1];
- Unit *unit = nullptr;
-
- switch((UnitClass)unitClass){
- case UnitClass::ENGINEER:
- unit = new Engineer(player, id, pos, rot);
- break;
- default:
- unit = new Vehicle(player, id, pos, rot);
- break;
- }
-
- return unit;
- }
-}
diff --git a/unitFactory.h b/unitFactory.h
deleted file mode 100644
index 79b3524..0000000
--- a/unitFactory.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef UNIT_FACTORY_H
-#define UNIT_FACTORY_H
-
-#include
-#include
-
-namespace battleship{
- class Unit;
- class Player;
-
- class UnitFactory{
- public:
- static Unit* createUnit(Player*, int, vb01::Vector3, vb01::Quaternion);
- private:
- };
-}
-
-#endif
diff --git a/unitFrameController.cpp b/unitFrameController.cpp
deleted file mode 100644
index 060c3c8..0000000
--- a/unitFrameController.cpp
+++ /dev/null
@@ -1,158 +0,0 @@
-#include
-
-#include "unitFrameController.h"
-#include "unit.h"
-#include "util.h"
-#include "map.h"
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-
-namespace battleship{
- using namespace std;
- using namespace vb01;
- using namespace gameBase;
-
- static UnitFrameController *unitFrameController = nullptr;
-
- UnitFrameController::UnitFrame::UnitFrame(string modelPath, int i, int t, Vector3 pos, Quaternion rot) : id(i), type(t) {
- Root *root = Root::getSingleton();
- Material *mat = new Material(root->getLibPath() + "texture");
- mat->addBoolUniform("texturingEnabled", false);
- mat->addBoolUniform("lightingEnabled", false);
- mat->addVec4Uniform("diffuseColor", Vector4::VEC_ZERO);
-
- model = new Model(modelPath);
- model->setWireframe(true);
- model->setMaterial(mat);
- model->setPosition(pos);
- model->setOrientation(rot);
- root->getRootNode()->attachChild(model);
- }
-
- UnitFrameController* UnitFrameController::getSingleton(){
- if(!unitFrameController)
- unitFrameController = new UnitFrameController();
-
- return unitFrameController;
- }
-
- void UnitFrameController::paintSelect(Vector3 rowEnd, float width, float length){
- Vector3 rowDir = rowEnd - paintSelectRowStart;
- float lenRow = rowDir.getLength();
- float hypothenuse = sqrt(width * width + length * length);
- int numStructsInRow = int(lenRow / hypothenuse);
-
- while(unitFrames.size() > numStructsInRow)
- removeUnitFrame(unitFrames.size() - 1);
-
- if(unitFrames.size() < numStructsInRow){
- int structureId = unitFrames[0].id;
- sol::state_view SOL_LUA_STATE = generateView();
- string modelPath = (string)SOL_LUA_STATE["basePath"][structureId + 1] + (string)SOL_LUA_STATE["meshPath"][structureId + 1];
- Vector3 buildDir = rowDir;
-
- if(unitFrames.size() > 1)
- buildDir = unitFrames[1].model->getPosition() - unitFrames[0].model->getPosition();
-
- Vector3 pos = paintSelectRowStart + buildDir.norm() * hypothenuse * unitFrames.size();
- addUnitFrame(UnitFrame(modelPath, structureId, (int)UnitType::LAND, pos));
- }
- }
-
- //TODO implement terrain evenness check
- void UnitFrameController::placeUnitFrame(int id, Vector3 newPos, float width, float length){
- UnitFrame &s = unitFrames[id];
-
- if(!rotatingStructure)
- s.model->setPosition(newPos);
-
- Map *map = Map::getSingleton();
- MeshData meshData = map->getNodeParent()->getChild(0)->getMesh(0)->getMeshBase();
- MeshData::Vertex *verts = meshData.vertices;
- int numVerts = 3 * meshData.numTris;
-
- float maxUnevenness = generateView()["maxUnevenness"], unevenness = 0;
-
- for(int i = 0; i < numVerts; i++){
- float diffX = fabs(s.model->getPosition().x - verts[i].pos.x);
- float diffY = fabs(s.model->getPosition().y - verts[i].pos.y);
- float diffZ = fabs(s.model->getPosition().z - verts[i].pos.z);
-
- if(diffX < 0.5 * width && diffZ < 0.5 * length && diffY > unevenness){
- unevenness = diffY;
-
- if(unevenness > maxUnevenness)
- break;
- }
- }
-
- Vector4 color;
-
- if(unevenness > maxUnevenness){
- color = Vector4(1, 0, 0, 1);
- s.status = UnitFrame::NOT_PLACEABLE;
- }
- else{
- color = Vector4(0, 1, 0, 1);
- s.status = UnitFrame::PLACEABLE;
- }
-
- Material *mat = s.model->getMaterial();
- mat->setVec4Uniform("diffuseColor", color);
- }
-
- void UnitFrameController::update(){
- Vector3 startPos = Root::getSingleton()->getCamera()->getPosition();
- vector results;
- Ray::retrieveCollisions(startPos, (screenToSpace(getCursorPos()) - startPos).norm(), Map::getSingleton()->getNodeParent()->getChild(0), results);
- Ray::sortResults(results);
- if(results.empty()) return;
-
- Vector3 newPos, rowEnd;
- sol::state_view SOL_LUA_STATE = generateView();
- sol::table unitTable = SOL_LUA_STATE["unitCornerPoints"][unitFrames[0].id + 1];
- float width = (float)unitTable[1]["x"] - (float)unitTable[2]["x"];
- float length = (float)unitTable[4]["z"] - (float)unitTable[1]["z"];
-
- if(paintSelecting)
- paintSelect(results[0].pos, width, length);
- else if(!(paintSelecting || rotatingStructure))
- newPos = results[0].pos;
-
- for(int i = 0; i < unitFrames.size(); i++){
- if(paintSelecting){
- float hypothenuse = sqrt(width * width + length * length);
- Vector3 dir = (results[0].pos - paintSelectRowStart).norm();
- newPos = paintSelectRowStart + dir * hypothenuse * i;
- }
-
- placeUnitFrame(i, newPos, width, length);
- }
- }
-
- void UnitFrameController::removeUnitFrame(int i){
- unitFrames[i].model->getParent()->dettachChild(unitFrames[i].model);
- delete unitFrames[i].model;
- unitFrames.erase(unitFrames.begin() + i);
- }
-
- void UnitFrameController::removeUnitFrames(){
- while(unitFrames.size() > 0)
- removeUnitFrame(0);
- }
-
- void UnitFrameController::rotateUnitFrames(float angle){
- for(UnitFrame &s : unitFrames)
- if(s.status != UnitFrame::PLACED){
- Quaternion rot = s.model->getOrientation();
- s.model->setOrientation(Quaternion(angle, Vector3::VEC_J) * rot);
- }
- }
-}
diff --git a/unitFrameController.h b/unitFrameController.h
deleted file mode 100644
index 1c889b9..0000000
--- a/unitFrameController.h
+++ /dev/null
@@ -1,55 +0,0 @@
-#ifndef UNIT_FRAME_CONTROLLER_H
-#define UNIT_FRAME_CONTROLLER_H
-
-#include
-#include
-
-#include
-#include
-
-namespace vb01{
- class Model;
-}
-
-namespace battleship{
- class UnitFrameController{
- public:
- struct UnitFrame{
- enum Status{PLACEABLE, NOT_PLACEABLE, PLACED};
-
- UnitFrame(std::string, int, int, vb01::Vector3 = vb01::Vector3::VEC_ZERO, vb01::Quaternion = vb01::Quaternion::QUAT_W);
- ~UnitFrame(){}
- void update();
-
- vb01::Model *model;
- int id, type;
- Status status;
- };
-
- static UnitFrameController* getSingleton();
- void update();
- void removeUnitFrame(int);
- void removeUnitFrames();
- void rotateUnitFrames(float);
- inline int getNumUnitFrames(){return unitFrames.size();}
- inline void addUnitFrame(UnitFrame u){unitFrames.push_back(u);}
- inline UnitFrame& getUnitFrame(int i){return unitFrames[i];}
- inline bool isPlacingFrames(){return placingStructures;}
- inline void setPlacingFrames(bool ps){placingStructures = ps;}
- inline bool isPaintSelecting(){return paintSelecting;}
- inline void setPaintSelecting(bool ps){paintSelecting = ps;}
- inline bool isRotatingFrames(){return rotatingStructure;}
- inline void setRotatingFrames(bool rs){rotatingStructure = rs;}
- inline void setPaintSelectRowStart(vb01::Vector3 st){paintSelectRowStart = st;}
- private:
- UnitFrameController(){}
- void paintSelect(vb01::Vector3, float, float);
- void placeUnitFrame(int, vb01::Vector3, float, float);
-
- std::vector unitFrames;
- vb01::Vector3 paintSelectRowStart, rowDir;
- bool placingStructures = false, paintSelecting = false, rotatingStructure = false;
- };
-}
-
-#endif
diff --git a/unitListbox.cpp b/unitListbox.cpp
deleted file mode 100644
index 12cb823..0000000
--- a/unitListbox.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-#include
-
-#include "unitListbox.h"
-#include "unit.h"
-#include "unitFrameController.h"
-
-namespace battleship{
- using namespace std;
- using namespace vb01;
- using namespace vb01Gui;
- using namespace gameBase;
-
- UnitListbox::UnitListbox(Vector2 pos, Vector2 size, vector lines, int maxDisplay, string fontPath) : Listbox(pos, size, lines, maxDisplay, fontPath){
- }
-
- void UnitListbox::onClose(){
- UnitFrameController *ufCtr = UnitFrameController::getSingleton();
-
- int id = selectedOption;
- sol::state_view SOL_LUA_STATE = generateView();
- string modelPath = (string)SOL_LUA_STATE["basePath"][id + 1] + (string)SOL_LUA_STATE["meshPath"][id + 1];
- ufCtr->addUnitFrame(UnitFrameController::UnitFrame(modelPath, id, (int)UnitType::LAND));
-
- ufCtr->setPlacingFrames(true);
- }
-}
diff --git a/unitListbox.h b/unitListbox.h
deleted file mode 100644
index ab66a7f..0000000
--- a/unitListbox.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef UNIT_LISTBOX_H
-#define UNIT_LISTBOX_H
-
-#include
-
-namespace battleship{
- class UnitListbox : public vb01Gui::Listbox{
- public:
- UnitListbox(vb01::Vector2, vb01::Vector2, std::vector, int, std::string);
- void onClose();
- private:
- };
-}
-
-#endif
diff --git a/vehicle.cpp b/vehicle.cpp
index 4bcaa33..1dc2f7f 100644
--- a/vehicle.cpp
+++ b/vehicle.cpp
@@ -60,7 +60,7 @@ namespace battleship{
break;
}
- placeUnit(pos + dir * speed);
+ placeAt(pos + dir * speed);
}
void Vehicle::initProperties(){
@@ -122,12 +122,12 @@ namespace battleship{
Ray::sortResults(res);
if(!res.empty()){
- placeUnit(res[0].pos);
+ placeAt(res[0].pos);
float angle = upVec.getAngleBetween(res[0].norm);
Vector3 axis = upVec.cross(res[0].norm).norm();
Quaternion rotQuat = Quaternion(angle, axis);
- orientUnit(rotQuat * rot);
+ orientAt(rotQuat * rot);
}
*/
}
|