Commit 8865b3dc authored by Chae Ho Shin's avatar Chae Ho Shin

Merge branch 'collision-model' of...

Merge branch 'collision-model' of https://git.kucatdog.net/flatland/curvedflats into collision-model
parents cb8b1572 725fce51
...@@ -661,6 +661,9 @@ MonoBehaviour: ...@@ -661,6 +661,9 @@ MonoBehaviour:
levelManager: {fileID: 279236944} levelManager: {fileID: 279236944}
player: {fileID: 739347346} player: {fileID: 739347346}
pathRenderer: {fileID: 948598108} pathRenderer: {fileID: 948598108}
playerSquare: {fileID: 934514725}
cameraMovement: {fileID: 1661408491}
scrollSpeed: 5
--- !u!4 &394305456 --- !u!4 &394305456
Transform: Transform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -1110,6 +1113,8 @@ MonoBehaviour: ...@@ -1110,6 +1113,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 0bf826b8a4774ba4b9c6a1cff6925667, type: 3} m_Script: {fileID: 11500000, guid: 0bf826b8a4774ba4b9c6a1cff6925667, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
objectType: 1
collisionPreset: 1
beta: 0 beta: 0
alpha: {x: 0, y: 0, z: 0} alpha: {x: 0, y: 0, z: 0}
v: {x: 0, y: 0, z: 0} v: {x: 0, y: 0, z: 0}
...@@ -1431,6 +1436,8 @@ MonoBehaviour: ...@@ -1431,6 +1436,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 9cbe363fdf02257478cb799cdf2190b3, type: 3} m_Script: {fileID: 11500000, guid: 9cbe363fdf02257478cb799cdf2190b3, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
objectType: 0
collisionPreset: 0
beta: 0 beta: 0
alpha: {x: 0, y: 0, z: 0} alpha: {x: 0, y: 0, z: 0}
v: {x: 0, y: 0, z: 0} v: {x: 0, y: 0, z: 0}
...@@ -1711,7 +1718,7 @@ GameObject: ...@@ -1711,7 +1718,7 @@ GameObject:
- component: {fileID: 934514726} - component: {fileID: 934514726}
- component: {fileID: 934514725} - component: {fileID: 934514725}
m_Layer: 2 m_Layer: 2
m_Name: Square m_Name: PlayerSquare
m_TagString: Untagged m_TagString: Untagged
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
...@@ -2662,6 +2669,8 @@ MonoBehaviour: ...@@ -2662,6 +2669,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 36bd4b20d3bc814459c577f508eda20c, type: 3} m_Script: {fileID: 11500000, guid: 36bd4b20d3bc814459c577f508eda20c, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
objectType: 2
collisionPreset: 2
beta: 0 beta: 0
alpha: {x: 0, y: 0, z: 0} alpha: {x: 0, y: 0, z: 0}
v: {x: 0, y: 0, z: 0} v: {x: 0, y: 0, z: 0}
...@@ -3577,6 +3586,9 @@ MonoBehaviour: ...@@ -3577,6 +3586,9 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
Levelmanager: {fileID: 279236944} Levelmanager: {fileID: 279236944}
minSize: 5
defaultSize: 10
maxSize: 50
--- !u!114 &1661408492 --- !u!114 &1661408492
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
......
...@@ -7,6 +7,10 @@ public class CameraMovement : MonoBehaviour ...@@ -7,6 +7,10 @@ public class CameraMovement : MonoBehaviour
public LevelManager Levelmanager; public LevelManager Levelmanager;
public double minSize = 5.0;
public double defaultSize = 10.0;
public double maxSize = 50.0;
Camera thecamera; Camera thecamera;
double aspect; double aspect;
double size; double size;
...@@ -16,8 +20,8 @@ public class CameraMovement : MonoBehaviour ...@@ -16,8 +20,8 @@ public class CameraMovement : MonoBehaviour
{ {
//playergamma = 1.0f; //playergamma = 1.0f;
thecamera = GetComponent<Camera>(); thecamera = GetComponent<Camera>();
aspect = 16.0f / 9.0f; aspect = 16.0 / 9.0;
size = 10.0f; size = defaultSize;
} }
// Update is called once per frame // Update is called once per frame
...@@ -48,4 +52,38 @@ public class CameraMovement : MonoBehaviour ...@@ -48,4 +52,38 @@ public class CameraMovement : MonoBehaviour
transform.Translate(-Vector3.forward * 50); // number is distance of camera from player transform.Translate(-Vector3.forward * 50); // number is distance of camera from player
} }
}
public double Size
{
get
{
return size;
}
set
{
if(value < minSize)
{
size = minSize;
}
else if (value > maxSize)
{
size = maxSize;
}
else
{
size = value;
}
}
}
/// <summary>
/// size/defaultSize
/// </summary>
public float SizeScale
{
get
{
return (float)size / (float)defaultSize;
}
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: e0ce320f331cd9349a5fcfac34484b83
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
namespace Assets.Scripts.Collision
{
/// <summary>
///
/// </summary>
static class CollisionPreset
{
public static CollisionType[] Player { get; private set; } = {
new CollisionType(ObjectType.player,true),
new CollisionType(ObjectType.normalobject,true),
new CollisionType(ObjectType.interactive,false),
new CollisionType(ObjectType.wall,true)
};
public static CollisionType[] NormalObject { get; private set; } = {
new CollisionType(ObjectType.player,true),
new CollisionType(ObjectType.normalobject,true),
new CollisionType(ObjectType.interactive,true),
new CollisionType(ObjectType.wall,true)
};
public static CollisionType[] Interactive { get; private set; } = {
new CollisionType(ObjectType.player,false),
new CollisionType(ObjectType.normalobject,true),
new CollisionType(ObjectType.interactive,true),
new CollisionType(ObjectType.wall,true)
};
public static CollisionType[] Wall { get; private set; } = {
new CollisionType(ObjectType.player,false),
new CollisionType(ObjectType.normalobject,false),
new CollisionType(ObjectType.interactive,false),
new CollisionType(ObjectType.wall,false)
};
}
/// <summary>
/// etc는 직접 어떻게 정할지 정해줘야함.
/// </summary>
public enum PresetType
{
player,
normalobject,
interactive,
wall,
etc
}
}
fileFormatVersion: 2
guid: 5d01750672178874ea2f4e1213fc3b32
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using Assets.Scripts.Collision;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Assets.Scripts.Collision
{
public struct CollisionType
{
public ObjectType other;
public bool isCollision;
public CollisionType(ObjectType other,bool isCollision)
{
this.other = other;
this.isCollision = isCollision;
}
}
}
fileFormatVersion: 2
guid: a4077f36a1fb2fb4fb415d9439b9255a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Assets.Scripts.Collision
{
public enum ObjectType
{
player,
normalobject,
interactive,
wall
}
}
fileFormatVersion: 2
guid: 2834fa3d0a508034a94d787cc74c3d3e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
...@@ -3,9 +3,21 @@ using System.Collections.Generic; ...@@ -3,9 +3,21 @@ using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using MathNet.Numerics.LinearAlgebra; using MathNet.Numerics.LinearAlgebra;
using MathNet.Numerics.LinearAlgebra.Double; using MathNet.Numerics.LinearAlgebra.Double;
using Assets.Scripts.Collision;
using System;
public class FlatlandMovement : MonoBehaviour public class FlatlandMovement : MonoBehaviour
{ {
//충돌처리
[SerializeField]
protected ObjectType objectType;
[SerializeField]
protected PresetType collisionPreset;
protected CollisionType[] howToCollison;
protected bool toggle = false; protected bool toggle = false;
protected bool grabbed = false; protected bool grabbed = false;
...@@ -50,10 +62,32 @@ public class FlatlandMovement : MonoBehaviour ...@@ -50,10 +62,32 @@ public class FlatlandMovement : MonoBehaviour
List<Hash128> collisions = new List<Hash128>(); List<Hash128> collisions = new List<Hash128>();
public ObjectType ObjectType { get { return objectType; } }
protected void Start() protected void Start()
{ {
Physics.IgnoreLayerCollision(0, 1); Physics.IgnoreLayerCollision(0, 1);
startScale = theobject.transform.localScale; startScale = theobject.transform.localScale;
switch (collisionPreset)
{
case PresetType.player:
howToCollison = CollisionPreset.Player;
break;
case PresetType.normalobject:
howToCollison = CollisionPreset.NormalObject;
break;
case PresetType.interactive:
howToCollison = CollisionPreset.Interactive;
break;
case PresetType.wall:
howToCollison = CollisionPreset.Wall;
break;
case PresetType.etc:
break;
default:
break;
}
} }
protected void FixedUpdate() protected void FixedUpdate()
...@@ -290,10 +324,20 @@ public class FlatlandMovement : MonoBehaviour ...@@ -290,10 +324,20 @@ public class FlatlandMovement : MonoBehaviour
return; return;
} }
//howToCollison
collisions.Add(collision.gameObject.GetComponent<ExtrudedMesh>().hash); collisions.Add(collision.gameObject.GetComponent<ExtrudedMesh>().hash);
FlatlandMovement other = collision.transform.parent.GetComponent<FlatlandMovement>(); FlatlandMovement other = collision.transform.parent.GetComponent<FlatlandMovement>();
CollisionType type = Array.Find(howToCollison, (x) => { return x.other == other.ObjectType; });
if (!type.isCollision)
{
//충돌하지 않을시 충돌하지 않음.
return;
}
Vector3 col = (other.v - this.v); Vector3 col = (other.v - this.v);
var totalThreeMomentum = this.GetThreeMomentum() + other.GetThreeMomentum(); var totalThreeMomentum = this.GetThreeMomentum() + other.GetThreeMomentum();
......
...@@ -11,6 +11,14 @@ public class Square : FlatLandObject ...@@ -11,6 +11,14 @@ public class Square : FlatLandObject
private float _zPosition => transform.position.z; private float _zPosition => transform.position.z;
private float PlayerVelocity; private float PlayerVelocity;
private Vector3 defaultScale;
private void Start()
{
defaultScale = GetComponent<Transform>().localScale;
}
public Vector3 GetNthPath(int n) // Get a path from (n)th destination to (n+1)th destination. public Vector3 GetNthPath(int n) // Get a path from (n)th destination to (n+1)th destination.
{ {
return pathList[n + 1] - pathList[n]; return pathList[n + 1] - pathList[n];
...@@ -30,4 +38,12 @@ public class Square : FlatLandObject ...@@ -30,4 +38,12 @@ public class Square : FlatLandObject
{ {
return pathVelocity[n + 1]; return pathVelocity[n + 1];
} }
public float Scale
{
set
{
GetComponent<Transform>().localScale = defaultScale * value;
}
}
} }
...@@ -30,6 +30,11 @@ public class UIManager : MonoBehaviour ...@@ -30,6 +30,11 @@ public class UIManager : MonoBehaviour
public LevelManager levelManager; public LevelManager levelManager;
public PlayerMovement player; public PlayerMovement player;
public PathRenderer pathRenderer; public PathRenderer pathRenderer;
public Square playerSquare;
public CameraMovement cameraMovement;
public float scrollSpeed = 1.0f;
private int prevSelectPathNum = -1; private int prevSelectPathNum = -1;
private Text pathName; private Text pathName;
...@@ -64,6 +69,9 @@ public class UIManager : MonoBehaviour ...@@ -64,6 +69,9 @@ public class UIManager : MonoBehaviour
{ {
wintext.gameObject.SetActive(true); wintext.gameObject.SetActive(true);
} }
//마우스 클릭시
if (Input.GetMouseButtonDown(0)) if (Input.GetMouseButtonDown(0))
{ {
ped.position = Input.mousePosition; ped.position = Input.mousePosition;
...@@ -110,6 +118,12 @@ public class UIManager : MonoBehaviour ...@@ -110,6 +118,12 @@ public class UIManager : MonoBehaviour
sliderflag = 0; sliderflag = 0;
} }
//마우스 휠
float scroll = Input.GetAxis("Mouse ScrollWheel") * scrollSpeed;
cameraMovement.Size += scroll;
playerSquare.Scale = 1/cameraMovement.SizeScale;
//player movement //player movement
if (pathRenderer.pathcreatable) if (pathRenderer.pathcreatable)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment