This commit is contained in:
Anonymous Raccoon
2018-11-01 17:15:45 +01:00
parent 649e16259a
commit 126c2ce90c
8 changed files with 74 additions and 190 deletions

View File

@@ -62,7 +62,7 @@ Rigidbody2D:
m_Interpolate: 0
m_SleepingMode: 1
m_CollisionDetection: 0
m_Constraints: 7
m_Constraints: 5
--- !u!61 &61082912475822452
BoxCollider2D:
m_ObjectHideFlags: 1

View File

@@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.44657844, g: 0.49641222, b: 0.57481694, a: 1}
m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
@@ -177,7 +177,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!1 &238427507
GameObject:
@@ -276,7 +276,7 @@ Transform:
m_LocalScale: {x: 22.419987, y: 6.028, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 8
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &312679463
GameObject:
@@ -392,7 +392,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 5
m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!82 &403186794
AudioSource:
@@ -500,10 +500,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f9a880a4af99f7b4ca47a85c5b10b90f, type: 3}
m_Name:
m_EditorClassIdentifier:
PlayerPrefab: {fileID: 1295779273530774, guid: f5eee23f42e32c740a46ae6b64fb96e1,
type: 2}
SpawnPosition: {x: -10, y: 6, z: 0}
RespawnTime: 5
RespawnPosition: {x: -10, y: 6, z: 0}
--- !u!1 &489446559
GameObject:
m_ObjectHideFlags: 0
@@ -3472,68 +3470,6 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &646383634
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 646383637}
- component: {fileID: 646383636}
- component: {fileID: 646383635}
m_Layer: 0
m_Name: EventSystem
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &646383635
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 646383634}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 1077351063, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_HorizontalAxis: Horizontal
m_VerticalAxis: Vertical
m_SubmitButton: Submit
m_CancelButton: Cancel
m_InputActionsPerSecond: 10
m_RepeatDelay: 0.5
m_ForceModuleActive: 0
--- !u!114 &646383636
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 646383634}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -619905303, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_FirstSelected: {fileID: 0}
m_sendNavigationEvents: 1
m_DragThreshold: 10
--- !u!4 &646383637
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 646383634}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 7
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &818206739
Prefab:
m_ObjectHideFlags: 0
@@ -3571,7 +3507,7 @@ Prefab:
objectReference: {fileID: 0}
- target: {fileID: 4160410025016832, guid: 92808b4d31a950f4b81823648c3f4381, type: 2}
propertyPath: m_RootOrder
value: 2
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1937531234487126, guid: 92808b4d31a950f4b81823648c3f4381, type: 2}
propertyPath: m_IsActive
@@ -3580,52 +3516,6 @@ Prefab:
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 92808b4d31a950f4b81823648c3f4381, type: 2}
m_IsPrefabAsset: 0
--- !u!1001 &872895748
Prefab:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 4345067943353424, guid: f5eee23f42e32c740a46ae6b64fb96e1, type: 2}
propertyPath: m_LocalPosition.x
value: -2.87
objectReference: {fileID: 0}
- target: {fileID: 4345067943353424, guid: f5eee23f42e32c740a46ae6b64fb96e1, type: 2}
propertyPath: m_LocalPosition.y
value: -0.615
objectReference: {fileID: 0}
- target: {fileID: 4345067943353424, guid: f5eee23f42e32c740a46ae6b64fb96e1, type: 2}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4345067943353424, guid: f5eee23f42e32c740a46ae6b64fb96e1, type: 2}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4345067943353424, guid: f5eee23f42e32c740a46ae6b64fb96e1, type: 2}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4345067943353424, guid: f5eee23f42e32c740a46ae6b64fb96e1, type: 2}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4345067943353424, guid: f5eee23f42e32c740a46ae6b64fb96e1, type: 2}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4345067943353424, guid: f5eee23f42e32c740a46ae6b64fb96e1, type: 2}
propertyPath: m_RootOrder
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1295779273530774, guid: f5eee23f42e32c740a46ae6b64fb96e1, type: 2}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: f5eee23f42e32c740a46ae6b64fb96e1, type: 2}
m_IsPrefabAsset: 0
--- !u!1 &963624497
GameObject:
m_ObjectHideFlags: 0
@@ -3807,7 +3697,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 6
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1919711501
GameObject:
@@ -3850,7 +3740,7 @@ Transform:
- {fileID: 489446560}
- {fileID: 963624498}
m_Father: {fileID: 0}
m_RootOrder: 4
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &2036025997
GameObject:

View File

@@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.44657844, g: 0.49641222, b: 0.57481694, a: 1}
m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
@@ -515,6 +515,7 @@ GameObject:
- component: {fileID: 925349207}
- component: {fileID: 925349206}
- component: {fileID: 925349208}
- component: {fileID: 925349209}
m_Layer: 0
m_Name: "B\xE9ton-Menu"
m_TagString: Untagged
@@ -593,6 +594,31 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
Speed: 0.5
--- !u!61 &925349209
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 925349205}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IsTrigger: 0
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5}
oldSize: {x: 10.24, y: 7.68}
newSize: {x: 10.24, y: 7.68}
adaptiveTilingThreshold: 0.5
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 10.24, y: 7.68}
m_EdgeRadius: 0
--- !u!1 &1184867774
GameObject:
m_ObjectHideFlags: 0

View File

@@ -8,16 +8,13 @@ public class EnvironementManager : MonoBehaviour
public TileBase imuable;
public GameObject FalllingDirt;
private void Update()
public void Mine(float x, float y)
{
//if (Input.GetMouseButtonDown(0))
//{
// Vector3 pos = cam.ScreenToWorldPoint(Input.mousePosition);
// BreakTile(tilemap.WorldToCell(pos));
//}
Vector3Int pos = tilemap.WorldToCell(new Vector3(x, y));
BreakTile(pos);
}
public void BreakTile(Vector3Int pos)
private void BreakTile(Vector3Int pos)
{
tilemap.SetTile(pos, null);

View File

@@ -1,21 +1,7 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine;
public class GameManager : MonoBehaviour {
[SerializeField]
GameObject PlayerPrefab;
[SerializeField]
float RespawnTime = 5;
public Vector3 RespawnPosition;
public void Respawn()
{
StartCoroutine("WaitForRespawn");
Instantiate(PlayerPrefab, RespawnPosition, Quaternion.identity);
}
IEnumerator WaitForRespawn()
{
yield return new WaitForSeconds(RespawnTime);
}
public class GameManager : MonoBehaviour
{
public Vector3 SpawnPosition;
public int RespawnTime = 5000; //In ms
}

View File

@@ -323,8 +323,7 @@ public class NetworkManager : NetworkLobbyManager
}
else
{
Vector3 pos = GameObject.Find("GameManager").GetComponent<GameManager>().RespawnPosition;
print(pos);
Vector3 pos = GameObject.Find("GameManager").GetComponent<GameManager>().SpawnPosition;
pController.transform.position = new Vector3(pos.x + player * 2, pos.y, pos.z);
}
pController.gameObject.GetComponent<Rigidbody2D>().velocity = new Vector3(0, 5, 0);

View File

@@ -1,4 +1,5 @@
using UnityEngine;
using System.Threading.Tasks;
using UnityEngine;
public class PlayerController : MonoBehaviour
{
@@ -14,10 +15,6 @@ public class PlayerController : MonoBehaviour
//variable pour le movement processing
[Space]
Rigidbody2D rb2;
[SerializeField]
float sensiX = 1;
[SerializeField]
float sensiY = 1;
private float vertical;
[SerializeField]
float DownDetector = 1;
@@ -25,7 +22,7 @@ public class PlayerController : MonoBehaviour
float SideMargin = 0.3f;
[SerializeField]
int layerMask = 1 << 9;
//int PlayerMask = 1 << 9;
//int PlayerMask = 1 << 9;
private bool IsGrounded = true;
RaycastHit2D hit;
SpriteRenderer rend;
@@ -33,8 +30,8 @@ public class PlayerController : MonoBehaviour
ParticleSystem Particule;
[SerializeField]
float UseRange = 1;
//variables de mort
//variables de mort
[SerializeField]
AudioClip DeathSound;
GameObject GameManager;
@@ -43,6 +40,7 @@ public class PlayerController : MonoBehaviour
AudioSource AS;
[SerializeField]
AudioClip LandingSound;
private EnvironementManager EnvironementManager;
void Start()
@@ -53,6 +51,7 @@ public class PlayerController : MonoBehaviour
GameManager = GameObject.FindGameObjectWithTag("GameManager");
AS = gameObject.GetComponent<AudioSource>();
Particule = GetComponentInChildren<ParticleSystem>();
EnvironementManager = GameManager.GetComponent<EnvironementManager>();
//gameObject.GetComponent<ParticleSystem>();
}
@@ -91,8 +90,8 @@ public class PlayerController : MonoBehaviour
void ShortInput()
{
// Si il faut rajouter du code pour différencer les manettes c'est ici
float horizontal = Input.GetAxisRaw(Horizontal) * sensiX;
float rawtical = Input.GetAxisRaw(Vertical) * sensiY;
float horizontal = Input.GetAxisRaw(Horizontal);
float rawtical = Input.GetAxisRaw(Vertical);
DectectInput(horizontal, rawtical);
}
@@ -107,7 +106,7 @@ public class PlayerController : MonoBehaviour
if (Input.GetKeyDown(JumpKey))
{
vertical = sensiY;
vertical = 1;
}
else
{
@@ -124,6 +123,7 @@ public class PlayerController : MonoBehaviour
{
IsGrounded = false;
}
//preprocess de mouvements latéraux
RaycastHit2D hitGauche = Physics2D.Raycast(transform.position, Vector2.left, SideMargin, layerMask);
RaycastHit2D hitDroit = Physics2D.Raycast(transform.position, Vector2.right, SideMargin, layerMask);
@@ -144,40 +144,20 @@ public class PlayerController : MonoBehaviour
}
Move(horizontal, vertical);
//on check pour péter un block
//Use clicked, (can be mining or something else).
if (Input.GetKey(UseKey))
{
Debug.Log("here");
Ray2D DestroyRay = new Ray2D(transform.position, Vector2.right);
RaycastHit2D hit;
if (rend.flipX)
{
hit = Physics2D.Raycast(DestroyRay.origin, DestroyRay.direction, UseRange, layerMask);
Debug.DrawRay(DestroyRay.origin, DestroyRay.direction, Color.blue);
}
else
float UseX = UseRange * (rend.flipX ? 1 : -1);
float UseY = 0;
if ((int)rawtical != 0)
{
DestroyRay = new Ray2D(transform.position, Vector2.left);
hit = Physics2D.Raycast(DestroyRay.origin, DestroyRay.direction, UseRange, layerMask);
Debug.DrawRay(DestroyRay.origin, DestroyRay.direction, Color.blue);
UseX = 0;
UseY = UseRange * (int)rawtical;
}
print(hit.collider);
if(hit.collider != null)
{
GameManager.GetComponent<EnvironementManager>().BreakTile(new Vector3Int(Mathf.RoundToInt(hit.transform.position[0]), Mathf.RoundToInt(hit.transform.position[1]), Mathf.RoundToInt(hit.transform.position[2]) ));
}
EnvironementManager.Mine(transform.position.x + UseX, transform.position.y + UseY);
}
}
}
private void Move(float horizontal, float vertical)
{
@@ -208,14 +188,20 @@ public class PlayerController : MonoBehaviour
rb2.velocity = new Vector2(horizontal * Time.deltaTime, rb2.velocity.y);
}
#endregion
public void Die()
public async void Die()
{
GameManager.GetComponent<AudioSource>().clip =DeathSound;
GameManager.GetComponent<AudioSource>().Play();
GameManager.GetComponent<GameManager>().Respawn();
Debug.Log("Les vivants morts: ceux qui tolèrent l'injustice");
Destroy(gameObject);
rend.enabled = false;
GetComponent<BoxCollider2D>().enabled = false;
await Task.Delay(GameManager.GetComponent<GameManager>().RespawnTime);
GetComponent<BoxCollider2D>().enabled = false;
transform.position = GameManager.GetComponent<GameManager>().SpawnPosition;
rend.enabled = false;
}
void PlaySound(AudioClip son)
{
AS.clip = son;

View File

@@ -577,7 +577,7 @@ PlayerSettings:
incrementalIl2cppBuild: {}
allowUnsafeCode: 0
additionalIl2CppArgs:
scriptingRuntimeVersion: 0
scriptingRuntimeVersion: 1
apiCompatibilityLevelPerPlatform: {}
m_RenderingPath: 1
m_MobileRenderingPath: 1