KerelOlivier
3 years ago
15 changed files with 513 additions and 2 deletions
@ -0,0 +1,13 @@
@@ -0,0 +1,13 @@
|
||||
# Default ignored files |
||||
/shelf/ |
||||
/workspace.xml |
||||
# Rider ignored files |
||||
/modules.xml |
||||
/.idea.LD50.iml |
||||
/contentModel.xml |
||||
/projectSettingsUpdater.xml |
||||
# Editor-based HTTP Client requests |
||||
/httpRequests/ |
||||
# Datasource local storage ignored files |
||||
/dataSources/ |
||||
/dataSources.local.xml |
@ -0,0 +1,4 @@
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project version="4"> |
||||
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" /> |
||||
</project> |
@ -0,0 +1,8 @@
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project version="4"> |
||||
<component name="UserContentModel"> |
||||
<attachedFolders /> |
||||
<explicitIncludes /> |
||||
<explicitExcludes /> |
||||
</component> |
||||
</project> |
@ -0,0 +1,6 @@
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project version="4"> |
||||
<component name="VcsDirectoryMappings"> |
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" /> |
||||
</component> |
||||
</project> |
@ -0,0 +1,8 @@
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 0366a53eb4119ab5ba6501929f29eef6 |
||||
folderAsset: yes |
||||
DefaultImporter: |
||||
externalObjects: {} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,109 @@
@@ -0,0 +1,109 @@
|
||||
{ |
||||
"name": "Player", |
||||
"maps": [ |
||||
{ |
||||
"name": "default", |
||||
"id": "83ceaef8-7a9f-40f7-8e71-469b434b3d9a", |
||||
"actions": [ |
||||
{ |
||||
"name": "Move", |
||||
"type": "Value", |
||||
"id": "1163ce9d-c7cb-41b7-b122-5360af9d9773", |
||||
"expectedControlType": "Vector2", |
||||
"processors": "", |
||||
"interactions": "", |
||||
"initialStateCheck": true |
||||
}, |
||||
{ |
||||
"name": "Fight", |
||||
"type": "Button", |
||||
"id": "9b6e6f96-096c-4d0e-ad98-05be447902a7", |
||||
"expectedControlType": "Button", |
||||
"processors": "", |
||||
"interactions": "", |
||||
"initialStateCheck": false |
||||
} |
||||
], |
||||
"bindings": [ |
||||
{ |
||||
"name": "WASD", |
||||
"id": "47d8955c-bf93-4735-804c-3b7dc82985c8", |
||||
"path": "2DVector", |
||||
"interactions": "", |
||||
"processors": "", |
||||
"groups": "", |
||||
"action": "Move", |
||||
"isComposite": true, |
||||
"isPartOfComposite": false |
||||
}, |
||||
{ |
||||
"name": "up", |
||||
"id": "949f9fa2-bf12-4f98-a1ec-4ca563c0566a", |
||||
"path": "<Keyboard>/w", |
||||
"interactions": "", |
||||
"processors": "", |
||||
"groups": "", |
||||
"action": "Move", |
||||
"isComposite": false, |
||||
"isPartOfComposite": true |
||||
}, |
||||
{ |
||||
"name": "down", |
||||
"id": "d9753777-7aaf-4e86-bbbc-a49cd33935dc", |
||||
"path": "<Keyboard>/s", |
||||
"interactions": "", |
||||
"processors": "", |
||||
"groups": "", |
||||
"action": "Move", |
||||
"isComposite": false, |
||||
"isPartOfComposite": true |
||||
}, |
||||
{ |
||||
"name": "left", |
||||
"id": "298f5cd4-04fe-4b2f-bd82-c1536d59658b", |
||||
"path": "<Keyboard>/a", |
||||
"interactions": "", |
||||
"processors": "", |
||||
"groups": "", |
||||
"action": "Move", |
||||
"isComposite": false, |
||||
"isPartOfComposite": true |
||||
}, |
||||
{ |
||||
"name": "right", |
||||
"id": "373de430-6124-4b20-a2c1-e3f0704857ba", |
||||
"path": "<Keyboard>/d", |
||||
"interactions": "", |
||||
"processors": "", |
||||
"groups": "", |
||||
"action": "Move", |
||||
"isComposite": false, |
||||
"isPartOfComposite": true |
||||
}, |
||||
{ |
||||
"name": "", |
||||
"id": "d6733eac-0ba0-49b9-af28-85a00c268050", |
||||
"path": "<Keyboard>/space", |
||||
"interactions": "", |
||||
"processors": "", |
||||
"groups": "", |
||||
"action": "Fight", |
||||
"isComposite": false, |
||||
"isPartOfComposite": false |
||||
}, |
||||
{ |
||||
"name": "", |
||||
"id": "c9b00421-6536-4edf-96cf-4e4f19a30c1b", |
||||
"path": "<Mouse>/leftButton", |
||||
"interactions": "", |
||||
"processors": "", |
||||
"groups": "", |
||||
"action": "Fight", |
||||
"isComposite": false, |
||||
"isPartOfComposite": false |
||||
} |
||||
] |
||||
} |
||||
], |
||||
"controlSchemes": [] |
||||
} |
@ -0,0 +1,14 @@
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 072cf7ce024a1a2ee8707f72b713be30 |
||||
ScriptedImporter: |
||||
internalIDToNameTable: [] |
||||
externalObjects: {} |
||||
serializedVersion: 2 |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
||||
script: {fileID: 11500000, guid: 8404be70184654265930450def6a9037, type: 3} |
||||
generateWrapperCode: 0 |
||||
wrapperCodePath: |
||||
wrapperClassName: |
||||
wrapperCodeNamespace: |
@ -0,0 +1,53 @@
@@ -0,0 +1,53 @@
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using UnityEngine; |
||||
using UnityEngine.InputSystem; |
||||
|
||||
public class PlayerController : MonoBehaviour |
||||
{ |
||||
private Rigidbody2D rb; |
||||
private SpriteRenderer sr; |
||||
private Camera main; |
||||
|
||||
//Input |
||||
private PlayerInput input; |
||||
private InputAction moveAction; |
||||
private InputAction fightAction; |
||||
|
||||
private Vector2 moveDirection; |
||||
private float moveSpeed = 5f; |
||||
|
||||
|
||||
// Start is called before the first frame update |
||||
private void Awake() |
||||
{ |
||||
rb = this.gameObject.GetComponent<Rigidbody2D>(); |
||||
input = this.gameObject.GetComponent<PlayerInput>(); |
||||
moveAction = input.actions["Move"]; |
||||
fightAction = input.actions["Fight"]; |
||||
|
||||
//Input events |
||||
moveAction.performed += ctx => Move(ctx.ReadValue<Vector2>()); |
||||
moveAction.canceled += ctx => Move(Vector2.zero); |
||||
main = Camera.main; |
||||
} |
||||
|
||||
private void FixedUpdate() |
||||
{ |
||||
//Update move direction |
||||
rb.MovePosition(rb.position + moveDirection * moveSpeed * Time.fixedDeltaTime); |
||||
} |
||||
|
||||
private void Update() |
||||
{ |
||||
//Update the sprite direction based on mouse position |
||||
Vector2 mousePos = main.ScreenToWorldPoint(Mouse.current.position.ReadValue()); |
||||
Vector2 direction = mousePos - (Vector2)transform.position; |
||||
float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg; |
||||
transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward); |
||||
} |
||||
|
||||
//update the move direction |
||||
void Move(Vector2 direction) => moveDirection = direction; |
||||
} |
@ -0,0 +1,11 @@
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2 |
||||
guid: ff7058e4b6f609474b877ecc3d8c9e62 |
||||
MonoImporter: |
||||
externalObjects: {} |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
After Width: | Height: | Size: 362 B |
@ -0,0 +1,120 @@
@@ -0,0 +1,120 @@
|
||||
fileFormatVersion: 2 |
||||
guid: ea7869a6d259396a0a452fe8ff118af0 |
||||
TextureImporter: |
||||
internalIDToNameTable: [] |
||||
externalObjects: {} |
||||
serializedVersion: 11 |
||||
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 |
||||
vTOnly: 0 |
||||
grayScaleToAlpha: 0 |
||||
generateCubemap: 6 |
||||
cubemapConvolution: 0 |
||||
seamlessCubemap: 0 |
||||
textureFormat: 1 |
||||
maxTextureSize: 2048 |
||||
textureSettings: |
||||
serializedVersion: 2 |
||||
filterMode: 0 |
||||
aniso: 1 |
||||
mipBias: 0 |
||||
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: 64 |
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0} |
||||
spriteGenerateFallbackPhysicsShape: 1 |
||||
alphaUsage: 1 |
||||
alphaIsTransparency: 1 |
||||
spriteTessellationDetail: -1 |
||||
textureType: 8 |
||||
textureShape: 1 |
||||
singleChannelComponent: 0 |
||||
flipbookRows: 1 |
||||
flipbookColumns: 1 |
||||
maxTextureSizeSet: 0 |
||||
compressionQualitySet: 0 |
||||
textureFormatSet: 0 |
||||
ignorePngGamma: 0 |
||||
applyGammaDecoding: 0 |
||||
platformSettings: |
||||
- serializedVersion: 3 |
||||
buildTarget: DefaultTexturePlatform |
||||
maxTextureSize: 2048 |
||||
resizeAlgorithm: 0 |
||||
textureFormat: -1 |
||||
textureCompression: 1 |
||||
compressionQuality: 50 |
||||
crunchedCompression: 0 |
||||
allowsAlphaSplitting: 0 |
||||
overridden: 0 |
||||
androidETC2FallbackOverride: 0 |
||||
forceMaximumCompressionQuality_BC6H_BC7: 0 |
||||
- serializedVersion: 3 |
||||
buildTarget: Standalone |
||||
maxTextureSize: 2048 |
||||
resizeAlgorithm: 0 |
||||
textureFormat: -1 |
||||
textureCompression: 1 |
||||
compressionQuality: 50 |
||||
crunchedCompression: 0 |
||||
allowsAlphaSplitting: 0 |
||||
overridden: 0 |
||||
androidETC2FallbackOverride: 0 |
||||
forceMaximumCompressionQuality_BC6H_BC7: 0 |
||||
- serializedVersion: 3 |
||||
buildTarget: WebGL |
||||
maxTextureSize: 2048 |
||||
resizeAlgorithm: 0 |
||||
textureFormat: -1 |
||||
textureCompression: 1 |
||||
compressionQuality: 50 |
||||
crunchedCompression: 0 |
||||
allowsAlphaSplitting: 0 |
||||
overridden: 0 |
||||
androidETC2FallbackOverride: 0 |
||||
forceMaximumCompressionQuality_BC6H_BC7: 0 |
||||
spriteSheet: |
||||
serializedVersion: 2 |
||||
sprites: [] |
||||
outline: [] |
||||
physicsShape: [] |
||||
bones: [] |
||||
spriteID: 5e97eb03825dee720800000000000000 |
||||
internalID: 0 |
||||
vertices: [] |
||||
indices: |
||||
edges: [] |
||||
weights: [] |
||||
secondaryTextures: [] |
||||
spritePackingTag: |
||||
pSDRemoveMatte: 0 |
||||
pSDShowRemoveMatteOption: 0 |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
Loading…
Reference in new issue