mirror of
https://github.com/zoriya/Prototype-Magnifique.git
synced 2026-05-29 17:12:25 +00:00
Changing map generator
This commit is contained in:
@@ -32,8 +32,8 @@ public class MapGenerator : MonoBehaviour
|
||||
Camera cam = GameObject.Find("Main Camera").GetComponent<Camera>();
|
||||
Vector3 topLeft = new Vector3(0, map.height, 0);
|
||||
Vector3 bottomRight = new Vector3(map.width, 0, 0);
|
||||
|
||||
cam.transform.position = new Vector3(map.width / 2, map.height / 2, -Vector3.Distance(topLeft, bottomRight) / 2.5f);
|
||||
|
||||
NetworkManager netManager = GameObject.Find("GameManager").GetComponent<NetworkManager>();
|
||||
StartCoroutine(netManager.SetDeathZone(topLeft, bottomRight));
|
||||
}
|
||||
@@ -55,10 +55,15 @@ public class MapGenerator : MonoBehaviour
|
||||
return;
|
||||
|
||||
bool topPosition = (y + 1 < map.height) ? map.GetPixel(x, y + 1) == pixelColor : false;
|
||||
//bool underPosition = (y - 1 > 0) ? map.GetPixel(x, y - 1) == pixelColor : false;
|
||||
bool underPosition = (y - 1 > 0) ? map.GetPixel(x, y - 1) == pixelColor : false;
|
||||
bool leftPosition = (x - 1 > 0) ? map.GetPixel(x - 1, y) == pixelColor : false;
|
||||
bool rightPosition = (x + 1 < map.width) ? map.GetPixel(x + 1, y) == pixelColor : false;
|
||||
|
||||
bool topLeft = (x - 1 > 0 && y + 1 < map.height) ? map.GetPixel(x - 1, y + 1) == pixelColor : false;
|
||||
bool topRight = (x + 1 < map.width && y + 1 < map.height) ? map.GetPixel(x + 1, y + 1) == pixelColor : false;
|
||||
bool bottomLeft = (x - 1 > 0 && y - 1 > 0) ? map.GetPixel(x - 1, y - 1) == pixelColor : false;
|
||||
bool bottomRight = (x + 1 < map.width && y + 1 > 0) ? map.GetPixel(x - 1, y + 1) == pixelColor : false;
|
||||
|
||||
GameObject prefab = null;
|
||||
|
||||
if (topPosition)
|
||||
@@ -69,14 +74,29 @@ public class MapGenerator : MonoBehaviour
|
||||
|
||||
if (!rightPosition)
|
||||
prefab = tile.bothUnder;
|
||||
else if (!topRight)
|
||||
prefab = tile.cornerRTL;
|
||||
}
|
||||
else if (!rightPosition)
|
||||
{
|
||||
prefab = tile.rightUnder;
|
||||
|
||||
if (leftPosition && !topLeft)
|
||||
prefab = tile.cornerLTR;
|
||||
}
|
||||
else
|
||||
{
|
||||
prefab = tile.underPrefab;
|
||||
if (!topLeft)
|
||||
{
|
||||
if (topRight)
|
||||
prefab = tile.cornerLT;
|
||||
else
|
||||
prefab = tile.cornerLTRT;
|
||||
}
|
||||
else if (!topRight)
|
||||
prefab = tile.cornerRT;
|
||||
else
|
||||
prefab = tile.underPrefab;
|
||||
}
|
||||
}
|
||||
else if (!leftPosition)
|
||||
|
||||
@@ -13,4 +13,12 @@ public class MapTile
|
||||
public GameObject rightUnder;
|
||||
public GameObject bothUnder;
|
||||
public GameObject bothTop;
|
||||
|
||||
public GameObject cornerLT;
|
||||
public GameObject cornerRT;
|
||||
|
||||
public GameObject cornerLTR;
|
||||
public GameObject cornerRTL;
|
||||
|
||||
public GameObject cornerLTRT;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ public class PlayerMovement : MonoBehaviour
|
||||
[SerializeField] private float playerHookSpeed = 15;
|
||||
[SerializeField] private float springForce = Mathf.Infinity;
|
||||
[SerializeField] private float damperForce = Mathf.Infinity;
|
||||
[SerializeField] private float breakForce = 600;
|
||||
[SerializeField] private float ropeSwing = 1;
|
||||
private GameObject hook;
|
||||
private HookType hookType = HookType.Wall;
|
||||
@@ -238,19 +239,17 @@ public class PlayerMovement : MonoBehaviour
|
||||
if(hook != null)
|
||||
hook.GetComponent<LineRenderer>().SetPosition(0, rb.position);
|
||||
}
|
||||
//if(hookType == HookType.SmallProjectile)
|
||||
//if (hookType == HookType.SmallProjectile)
|
||||
//{
|
||||
// if(objectHooked != null)
|
||||
// if (objectHooked != null)
|
||||
// {
|
||||
// if (hook != null)
|
||||
// hook.GetComponent<LineRenderer>().SetPositions(new Vector3[] { rb.position, objectHooked.transform.position });
|
||||
|
||||
// objectHooked.GetComponent<SpringJoint>().connectedAnchor = rb.position;
|
||||
// }
|
||||
//}
|
||||
|
||||
//Handle dash after user pressed the button
|
||||
if(dashTime > 0)
|
||||
if (dashTime > 0)
|
||||
{
|
||||
rb.velocity = dashVelocity;
|
||||
dashVelocity.y -= dashVelocity.y / 10;
|
||||
@@ -338,23 +337,16 @@ public class PlayerMovement : MonoBehaviour
|
||||
{
|
||||
Destroy(hook);
|
||||
SpringJoint spring = GetComponent<SpringJoint>();
|
||||
spring.connectedAnchor = new Vector3(0, 0, 0);
|
||||
spring.spring = 0;
|
||||
spring.damper = 0;
|
||||
spring.maxDistance = 0;
|
||||
if(spring != null)
|
||||
{
|
||||
spring.connectedAnchor = new Vector3(0, 0, 0);
|
||||
spring.spring = 0;
|
||||
spring.damper = 0;
|
||||
spring.maxDistance = 0;
|
||||
}
|
||||
hookType = HookType.None;
|
||||
hookPosition = Vector3.zero;
|
||||
hookLength = 0;
|
||||
|
||||
if (objectHooked != null)
|
||||
{
|
||||
spring = objectHooked.GetComponent<SpringJoint>();
|
||||
spring.connectedBody = rb;
|
||||
spring.spring = 0;
|
||||
spring.damper = 0;
|
||||
spring.minDistance = 0;
|
||||
spring.maxDistance = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -376,17 +368,18 @@ public class PlayerMovement : MonoBehaviour
|
||||
}
|
||||
else if(hit.collider.tag == "SmallProjectile")
|
||||
{
|
||||
hookType = HookType.SmallProjectile;
|
||||
hook = Instantiate(hookObject, rb.position, Quaternion.identity);
|
||||
hook.GetComponent<LineRenderer>().SetPositions(new Vector3[] { rb.position, hit.point });
|
||||
objectHooked = hit.collider.gameObject;
|
||||
//Cancel et boop le projectile
|
||||
//hookType = HookType.SmallProjectile;
|
||||
//hook = Instantiate(hookObject, rb.position, Quaternion.identity);
|
||||
//hook.GetComponent<LineRenderer>().SetPositions(new Vector3[] { rb.position, hit.point });
|
||||
//objectHooked = hit.collider.gameObject;
|
||||
|
||||
SpringJoint spring = GetComponent<SpringJoint>();
|
||||
spring.spring = springForce;
|
||||
spring.damper = damperForce;
|
||||
spring.maxDistance = Vector3.Distance(rb.position, hit.point);
|
||||
//spring.minDistance = Vector3.Distance(rb.position, hit.point);
|
||||
spring.connectedBody = hit.collider.GetComponent<Rigidbody>();
|
||||
//SpringJoint spring = GetComponent<SpringJoint>();
|
||||
//spring.spring = springForce;
|
||||
//spring.damper = damperForce;
|
||||
//spring.maxDistance = Vector3.Distance(rb.position, hit.point);
|
||||
//spring.breakForce = breakForce;
|
||||
//spring.connectedBody = hit.collider.GetComponent<Rigidbody>();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -395,6 +388,7 @@ public class PlayerMovement : MonoBehaviour
|
||||
spring.connectedAnchor = hit.point;
|
||||
spring.spring = springForce;
|
||||
spring.damper = damperForce;
|
||||
spring.breakForce = Mathf.Infinity;
|
||||
spring.maxDistance = Vector3.Distance(rb.position, hit.point);
|
||||
|
||||
hook = Instantiate(hookObject, rb.position, Quaternion.identity);
|
||||
|
||||
Reference in New Issue
Block a user