This commit is contained in:
happy44300
2018-10-07 15:19:48 +02:00
parent c2b62a4a8d
commit 4e09a75384
7 changed files with 173 additions and 13 deletions
+5 -5
View File
@@ -37,8 +37,8 @@ Transform:
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1400916412662404}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 5, y: 5, z: 5}
m_LocalPosition: {x: -7.4888, y: 0.4874, z: 0}
m_LocalScale: {x: 0.7722022, y: 0.772194, z: 5}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
@@ -77,9 +77,9 @@ BoxCollider2D:
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
m_SpriteTilingProperty:
border: {x: 0.049999997, y: 0.049999997, z: 0.049999997, w: 0.049999997}
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5}
oldSize: {x: 0.16, y: 0.16}
oldSize: {x: 1.28, y: 1.28}
newSize: {x: 0.16, y: 0.16}
adaptiveTilingThreshold: 0.5
drawMode: 0
@@ -134,7 +134,7 @@ SpriteRenderer:
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0}
m_Sprite: {fileID: 21300000, guid: fd166c745c8b9cd4faf0b411262f69ae, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

+99
View File
@@ -0,0 +1,99 @@
fileFormatVersion: 2
guid: fd166c745c8b9cd4faf0b411262f69ae
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 7
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 0
aniso: -1
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: -1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 25e544eeebc36c446ab8d40d7c7a71cd
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:
+21
View File
@@ -0,0 +1,21 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GameManager : MonoBehaviour {
[SerializeField]
GameObject PlayerPrefab;
[SerializeField]
float RespawnTime = 5;
[SerializeField]
Vector3 RespawnPosition;
public void Respawn()
{
StartCoroutine("WaitForRespawn");
Instantiate(PlayerPrefab, RespawnPosition, Quaternion.identity);
}
IEnumerator WaitForRespawn()
{
yield return new WaitForSeconds(RespawnTime);
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f9a880a4af99f7b4ca47a85c5b10b90f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+29 -8
View File
@@ -16,7 +16,11 @@ public class PlayerController : MonoBehaviour
private bool IsGrounded = true;
RaycastHit2D hit;
SpriteRenderer rend;
private Vector2 _lastpos = Vector2.zero;
[SerializeField]
AudioClip DeathSound;
GameObject GameManager;
void Start ()
@@ -24,15 +28,19 @@ public class PlayerController : MonoBehaviour
rb2 = gameObject.GetComponent<Rigidbody2D>();
layerMask = ~layerMask;
rend = gameObject.GetComponent<SpriteRenderer>();
_lastpos = transform.position;
GameManager = GameObject.FindGameObjectWithTag("GameManager");
}
void Update ()
{
DectectInput();
}
#region
void OnCollisionStay2D(Collision2D other)
{
if (other.transform != null && hit.transform !=null)
@@ -44,11 +52,19 @@ public class PlayerController : MonoBehaviour
}
}
void DectectInput()
void ShortInput()
{
float horizontal = Input.GetAxisRaw("Horizontal")*sensiX;
float rawtical = Input.GetAxisRaw("Vertical")*sensiY;
// Si il faut rajouter su code pour différencer les manettes c'est ici
float horizontal = Input.GetAxisRaw("Horizontal") * sensiX;
float rawtical = Input.GetAxisRaw("Vertical") * sensiY;
DectectInput(horizontal, rawtical);
}
void DectectInput(float horizontal, float rawtical)
{
//Ici on preprocess les inputs
switch (Mathf.RoundToInt(Input.GetAxisRaw("Vertical")))
{
@@ -122,9 +138,14 @@ public class PlayerController : MonoBehaviour
rb2.AddForce(new Vector2(horizontal, vertical)*Time.deltaTime, ForceMode2D.Impulse);
}
#endregion
#endregion
public 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);
}
}
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 35b32c52a60dc7941aa679aa9985c868
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: