Skip to content

Commit

Permalink
Added ramp and fixed issue with spawn
Browse files Browse the repository at this point in the history
  • Loading branch information
loco-choco committed Sep 9, 2022
1 parent f54ef31 commit eb29dee
Show file tree
Hide file tree
Showing 46 changed files with 1,302 additions and 200 deletions.
Binary file modified CustomShipLib/AssetBundles/shipspawner
Binary file not shown.
4 changes: 2 additions & 2 deletions CustomShipLib/AssetBundles/shipspawner.manifest
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
ManifestFileVersion: 0
CRC: 921915599
CRC: 784699139
Hashes:
AssetFileHash:
serializedVersion: 2
Hash: 9fb7225b6bacf30c8372ca5a68e336d9
Hash: 8dff243e4605d09493afed4c20f560fd
TypeTreeHash:
serializedVersion: 2
Hash: fc02bf6dedc4609611fd4aebc9b9806d
Expand Down
14 changes: 6 additions & 8 deletions CustomShipLib/ShipSpawner/LauchPadSpawn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ namespace SlateShipyard.ShipSpawner
//Giving the prefab, this will spawn on the best place a ship
public class LaunchPadSpawn : MonoBehaviour
{
Rigidbody rigidbody;
OWRigidbody rigidbody;
public void Start()
{
rigidbody = gameObject.GetAttachedOWRigidbody()._rigidbody;
rigidbody = gameObject.GetAttachedOWRigidbody();
}
public bool SpawnShip(Func<GameObject> shipPrefab, bool spawnEvenIfNotAllowed)
{
Expand All @@ -23,12 +23,10 @@ public bool SpawnShip(Func<GameObject> shipPrefab, bool spawnEvenIfNotAllowed)
Destroy(g);
return false;
}
g.transform.position = transform.position;
g.transform.rotation = transform.rotation;
//GameObject g = Instantiate(shipPrefab, transform.position, transform.rotation);
Rigidbody r = g.GetAttachedOWRigidbody()._rigidbody;
r.velocity = rigidbody.velocity;
r.angularVelocity = rigidbody.angularVelocity;
OWRigidbody r = g.GetAttachedOWRigidbody();
r.WarpToPositionRotation(transform.position, transform.rotation);
r.SetVelocity(rigidbody.GetPointVelocity(transform.position));
r.SetAngularVelocity(rigidbody.GetAngularVelocity());
return true;
}

Expand Down
54 changes: 54 additions & 0 deletions CustomShipLib/ShipSpawner/RampUI/RampAngleUI.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using UnityEngine;
using UnityEngine.UI;

namespace SlateShipyard.ShipSpawner.RampUI
{
public class RampAngleUI : MonoBehaviour
{
float maxAngle = 90f;
float minAngle = 0f;

float targetAngle = 0f;
float angleStep = 5f;
float angleChangeSpeed = 180f;

public Text angleDisplayText;
public InteractReceiver increaseAngle;
public InteractReceiver decreaseAngle;

public void Start()
{
increaseAngle.OnReleaseInteract += OnAngleIncrease;
decreaseAngle.OnReleaseInteract += OnAngleDecrease;
}
public void OnDestroy()
{
increaseAngle.OnReleaseInteract -= OnAngleIncrease;
decreaseAngle.OnReleaseInteract -= OnAngleDecrease;
}

public void OnAngleIncrease()
{
targetAngle += angleStep;
targetAngle = Mathf.Clamp(targetAngle, minAngle, maxAngle);
angleDisplayText.text = $" {(int)(targetAngle)}°";
increaseAngle.ResetInteraction();
}
public void OnAngleDecrease()
{
targetAngle -= angleStep;
targetAngle = Mathf.Clamp(targetAngle, minAngle, maxAngle);
angleDisplayText.text = $" {(int)(targetAngle)}°";
decreaseAngle.ResetInteraction();
}
public void Update()
{
Vector3 currentAngle = transform.localEulerAngles;
float difference = targetAngle - transform.localEulerAngles.z;
float step = Mathf.Clamp(Mathf.Abs(difference), 0f, angleChangeSpeed) * Time.deltaTime * Mathf.Sign(difference);
currentAngle.z += step;
transform.localEulerAngles = currentAngle;

}
}
}
24 changes: 23 additions & 1 deletion CustomShipLib/ShipyardSpawner.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using SlateShipyard.ShipSpawner;
using SlateShipyard.ShipSpawner.RampUI;
using SlateShipyard.ShipSpawner.SelectionUI;

using UnityEngine;
Expand All @@ -14,7 +15,7 @@ public static GameObject SpawnShipyard(Transform transform, Vector3 position, Qu

//SpawnPosition
LaunchPadSpawn spawner = t.GetChild(0).gameObject.AddComponent<LaunchPadSpawn>();
//UI Stuff
////UI Stuff-----
Transform screen = t.GetChild(2).GetChild(0);
//Buttons
GameObject selectButton = screen.GetChild(0).gameObject;
Expand Down Expand Up @@ -46,7 +47,28 @@ public static GameObject SpawnShipyard(Transform transform, Vector3 position, Qu
selection.nextShipButton = next;
selection.previousShipButton = previous;
selection.spawnShipButton = select;
////---------

//Ramp
Transform ramp = t.GetChild(4);
Transform rampUIScreen = t.GetChild(5).GetChild(0);

RampAngleUI rampAnlgleUI = ramp.gameObject.AddComponent<RampAngleUI>();

//Buttons
GameObject decreaseButton = rampUIScreen.GetChild(0).gameObject;
InteractReceiver decrease = decreaseButton.AddComponent<InteractReceiver>();
decrease.ChangePrompt("decrease");

Text angleValue = rampUIScreen.GetChild(1).gameObject.GetComponent<Text>();

GameObject increaseButton = rampUIScreen.GetChild(2).gameObject;
InteractReceiver increase = increaseButton.AddComponent<InteractReceiver>();
increase.ChangePrompt("increase");

rampAnlgleUI.increaseAngle = increase;
rampAnlgleUI.decreaseAngle = decrease;
rampAnlgleUI.angleDisplayText = angleValue;

return t.gameObject;
}
Expand Down
2 changes: 1 addition & 1 deletion CustomShipLib/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"author": "Locochoco",
"name": "Slate's Shipyard",
"uniqueName": "Locochoco.SlateShipyard",
"version": "0.1.0",
"version": "0.1.1",
"owmlVersion": "2.0.0"
}
Binary file modified assets/3dModels.blend
Binary file not shown.
Binary file added assets/3dModels.blend1
Binary file not shown.
62 changes: 17 additions & 45 deletions assets/meshes/base.obj
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ v 0.000000 1.561771 -26.125488
v 0.000000 2.869070 -26.125488
v 15.356176 1.561771 -21.135963
v 15.356176 2.869070 -21.135963
v 24.846817 1.561771 -8.073218
v 24.846817 2.869070 -8.073218
v 24.846815 1.561771 8.073220
v 24.846815 2.869070 8.073220
v 15.356174 1.561771 21.135963
v 15.356174 2.869070 21.135963
v -0.000002 1.561771 26.125488
Expand All @@ -25,63 +21,39 @@ vt 0.000088 0.006365
vt 0.008133 0.000088
vt 0.085659 0.099444
vt 0.077614 0.105721
vt 0.163186 0.198800
vt 0.155141 0.205077
vt 0.240713 0.298156
vt 0.232669 0.304433
vt 0.318240 0.397512
vt 0.775352 0.999912
vt 0.310196 0.403789
vt 0.395766 0.496866
vt 0.387722 0.503143
vt 0.473293 0.596220
vt 0.465249 0.602498
vt 0.550820 0.695576
vt 0.542776 0.701852
vt 0.628346 0.794929
vt 0.620302 0.801206
vt 0.701548 0.258263
vt 0.779075 0.357618
vt 0.783397 0.483566
vt 0.712862 0.588001
vt 0.594413 0.631031
vt 0.391445 0.370917
vt 0.461980 0.266483
vt 0.580429 0.223452
vt 0.705872 0.894283
vt 0.697828 0.900559
vt 0.318240 0.397512
vt 0.395766 0.496866
vt 0.473293 0.596220
vt 0.550820 0.695576
vt 0.628346 0.794929
vt 0.783397 0.993635
vt 0.775352 0.999912
vt 0.159467 0.841101
vt 0.081940 0.741746
vt 0.077619 0.615797
vt 0.148154 0.511363
vt 0.266603 0.468332
vt 0.469570 0.728446
vt 0.399035 0.832881
vt 0.280586 0.875911
vt 0.705872 0.894283
vn 0.3090 0.0000 -0.9511
vn 0.8090 0.0000 -0.5878
vn 0.0000 -1.0000 -0.0000
vn 1.0000 0.0000 0.0000
vn 0.8090 0.0000 0.5878
vn 0.3090 0.0000 0.9511
vn -0.3090 0.0000 0.9511
vn -0.8090 0.0000 0.5878
vn -1.0000 0.0000 0.0000
vn 0.0000 1.0000 0.0000
vn -0.8090 0.0000 -0.5878
vn -0.3090 0.0000 -0.9511
vn 0.0000 -1.0000 -0.0000
usemtl None
s off
f 1/1/1 2/2/1 4/3/1 3/4/1
f 3/4/2 4/3/2 6/5/2 5/6/2
f 5/6/3 6/5/3 8/7/3 7/8/3
f 7/8/4 8/7/4 10/9/4 9/10/4
f 9/10/5 10/9/5 12/11/5 11/12/5
f 11/12/6 12/11/6 14/13/6 13/14/6
f 13/14/7 14/13/7 16/15/7 15/16/7
f 15/16/8 16/15/8 18/17/8 17/18/8
f 4/19/9 2/20/9 20/21/9 18/22/9 16/23/9 14/13/9 12/11/9 10/24/9 8/25/9 6/26/9
f 17/18/10 18/17/10 20/27/10 19/28/10
f 19/28/11 20/27/11 2/29/11 1/30/11
f 1/31/12 3/32/12 5/33/12 7/34/12 9/35/12 11/12/12 13/14/12 15/36/12 17/37/12 19/38/12
f 1/5/2 3/4/2 5/6/2 7/7/2 9/8/2 11/9/2 13/10/2 15/11/2
f 3/4/3 4/3/3 6/12/3 5/6/3
f 5/6/4 6/12/4 8/13/4 7/7/4
f 7/7/5 8/13/5 10/14/5 9/8/5
f 9/8/6 10/14/6 12/15/6 11/9/6
f 11/9/7 12/15/7 14/16/7 13/10/7
f 4/3/8 2/17/8 16/18/8 14/16/8 12/15/8 10/14/8 8/13/8 6/12/8
f 13/10/9 14/16/9 16/18/9 15/11/9
f 15/11/10 16/18/10 2/17/10 1/5/10
10 changes: 10 additions & 0 deletions assets/meshes/baserRamp.mtl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Blender MTL File: '3dModels.blend'
# Material Count: 1

newmtl None
Ns 500
Ka 0.8 0.8 0.8
Kd 0.8 0.8 0.8
Ks 0.8 0.8 0.8
d 1
illum 2
33 changes: 33 additions & 0 deletions assets/meshes/baserRamp.obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Blender v3.0.0 OBJ File: '3dModels.blend'
# www.blender.org
mtllib baserRamp.mtl
v 15.356176 1.561771 -21.135963
v 15.356176 2.869070 -21.135963
v 24.846817 1.561771 -8.073218
v 24.846817 2.869070 -8.073218
v 24.846815 1.561771 8.073220
v 24.846815 2.869070 8.073220
v 15.356174 1.561771 21.135963
v 15.356174 2.869070 21.135963
vt 0.077614 0.105721
vt 0.085659 0.099444
vt 0.163186 0.198800
vt 0.155141 0.205077
vt 0.240713 0.298156
vt 0.232669 0.304433
vt 0.318240 0.397512
vt 0.310196 0.403789
vn 0.8090 0.0000 -0.5878
vn 1.0000 0.0000 0.0000
vn 0.8090 0.0000 0.5878
vn -1.0000 0.0000 -0.0000
vn 0.0000 1.0000 0.0000
vn 0.0000 -1.0000 0.0000
usemtl None
s off
f 1/1/1 2/2/1 4/3/1 3/4/1
f 3/4/2 4/3/2 6/5/2 5/6/2
f 5/6/3 6/5/3 8/7/3 7/8/3
f 1/1/4 7/8/4 8/7/4 2/2/4
f 4/3/5 2/2/5 8/7/5 6/5/5
f 1/1/6 3/4/6 5/6/6 7/8/6
15 changes: 15 additions & 0 deletions unity/SlateShipyard/Assets/Scenes/SampleScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,21 @@ PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 1278936191894081391, guid: cefd7a2af1897134bb1425b29120401a,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1278936191894081391, guid: cefd7a2af1897134bb1425b29120401a,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1278936191894081391, guid: cefd7a2af1897134bb1425b29120401a,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4553042900396060771, guid: cefd7a2af1897134bb1425b29120401a,
type: 3}
propertyPath: m_Name
Expand Down
Loading

0 comments on commit eb29dee

Please sign in to comment.