Commit 19ed7887 authored by Markus Schlösser's avatar Markus Schlösser
Browse files

Added camera, updated Input Provider

parent 4aaea965
fileFormatVersion: 2
guid: 4b604b53d16368840a7ea2bd7e3aabca
guid: 68edc9b222fd4e54bbe5e1cbfa047b4e
folderAsset: yes
DefaultImporter:
externalObjects: {}
......
fileFormatVersion: 2
<<<<<<< HEAD
guid: 01b21adbbe9cfb744806052a7bef2b23
=======
guid: 6f03feec80bf91e40bca542a03631403
>>>>>>> origin/master
guid: ac0562712202d23438479ceea1a10455
folderAsset: yes
DefaultImporter:
externalObjects: {}
......
fileFormatVersion: 2
guid: 9e9aa7e5ccef5e04880aad5a2be1e520
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 7
mipmaps:
mipMapMode: 0
enableMipMap: 1
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: -1
aniso: -1
mipBias: -100
wrapU: -1
wrapV: -1
wrapW: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
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: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ExampleController : MonoBehaviour
{
public InputProviderPlayer InputProvider;
private void Start()
{
InputProvider = GetComponent<InputProviderPlayer>();
}
// Update is called once per frame
void Update ()
{
Vector2 movement = InputProvider.MoveDirection;
//Debug, check if movement is registered
if(movement.x != 0 || movement.y != 0)
print("Movement: x=" + movement.x + " y=" + movement.y);
}
}
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public abstract class InputProvider : MonoBehaviour
{
// Stores the direction the player intends to walk
public Vector2 MoveDirection { get; protected set; }
public bool JumpPressed { get; protected set; }
}
using UnityEngine;
public class InputProviderPlayer : InputProvider {
void Update()
{
MoveDirection = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
JumpPressed = Input.GetButtonDown("Jump");
}
}
using UnityEngine;
public interface IInputProvider {
Vector2 MoveDirection { get; }
bool JumpPressed { get; }
bool PeekingPressed { get; }
}
using UnityEngine;
[CreateAssetMenu]
public class KeyCodeInputProvider : ScriptableObject , IInputProvider {
[SerializeField] private KeyCode jump;
[SerializeField] private KeyCode peek;
public Vector2 MoveDirection => new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
public bool JumpPressed => Input.GetKeyDown(jump);
public bool PeekingPressed => Input.GetKey(peek);
}
......@@ -30,32 +30,36 @@ public class PlayerActor : MonoBehaviour {
return tmp < 0 ? tmp + m : tmp;
}
[SerializeField] private GameObject trackingPoint;
[SerializeField] private Tilemap tilemap;
[SerializeField] private Orientation orientation = Orientation.Up;
[SerializeField] private MovementDirection facing = MovementDirection.Right;
[SerializeField] public InputProviderPlayer InputProvider;
private void Start() {
InputProvider = GetComponent<InputProviderPlayer>();
}
[SerializeField] public IInputProvider inputProvider;
private void Update() {
if (isMoving) return;
transform.position = tilemap.GetCellCenterWorld(tilemap.WorldToCell(transform.position));
float direction = InputProvider.MoveDirection.x;
float direction = inputProvider.MoveDirection.x;
if (direction < 0) {
StartCoroutine(Move(MovementDirection.Left));
} else if (direction > 0) {
StartCoroutine(Move(MovementDirection.Right));
} else if (InputProvider.JumpPressed) {
} else if (inputProvider.JumpPressed) {
StartCoroutine(Jump());
}
if (inputProvider.PeekingPressed) {
trackingPoint.transform.localPosition = Vector3.up * 9;
} else {
trackingPoint.transform.localPosition = Vector3.zero;
}
}
private void UpdateOrientation() {
......@@ -216,15 +220,6 @@ public class PlayerActor : MonoBehaviour {
isMoving = false;
}
private RotatedTile Raycast(Vector3Int cellPosition, Vector3Int diretion) {
for (int i = 0; i < MAX_STEPS; ++i) {
RotatedTile tile = tilemap.GetTile<RotatedTile>(cellPosition + diretion * i);
if (tile != null) return tile;
}
return null;
}
private IEnumerator Jump() {
isMoving = true;
Vector3Int celllPos = tilemap.WorldToCell(transform.position);
......
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8c2fa31169218b543acfac6ff6ce0c2b, type: 3}
m_Name: New Input Provider Player
m_EditorClassIdentifier:
jump: 32
peek: 304
fileFormatVersion: 2
guid: 3319a29bf3d7a184890f278b08f8cd4b
MonoImporter:
guid: 026a5a3d17da2ec4b878bae9363baa61
NativeFormatImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
......@@ -113,108 +113,6 @@ NavMeshSettings:
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &1335448
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1335451}
- component: {fileID: 1335450}
- component: {fileID: 1335449}
- component: {fileID: 1335452}
m_Layer: 0
m_Name: slope1
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1335449
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1335448}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d85c951a8a8bd28448a328b753c74372, type: 3}
m_Name:
m_EditorClassIdentifier:
tilemap: {fileID: 185498795}
orientation: 0
InputProvider: {fileID: 1335452}
--- !u!212 &1335450
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1335448}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 4294967295
m_Materials:
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_Sprite: {fileID: 21300000, guid: d2823e2467bfc464e85b11b9a7867dea, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 1, y: 1}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!4 &1335451
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1335448}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 3.39, y: 5.68, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1335452
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1335448}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8c2fa31169218b543acfac6ff6ce0c2b, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &185498792
GameObject:
m_ObjectHideFlags: 0
......@@ -520,15 +418,51 @@ Tilemap:
m_ObjectToInstantiate: {fileID: 0}
m_TileFlags: 2
m_ColliderType: 2
- first: {x: 5, y: 8, z: 0}
second:
m_TileIndex: 7
m_TileSpriteIndex: 0
m_TileMatrixIndex: 3
m_TileColorIndex: 0
m_ObjectToInstantiate: {fileID: 0}
m_TileFlags: 2
m_ColliderType: 2
- first: {x: 3, y: 9, z: 0}
second:
m_TileIndex: 3
m_TileSpriteIndex: 2
m_TileMatrixIndex: 3
m_TileColorIndex: 0
m_ObjectToInstantiate: {fileID: 0}
m_TileFlags: 2
m_ColliderType: 2
- first: {x: 4, y: 9, z: 0}
second:
m_TileIndex: 2
m_TileSpriteIndex: 1
m_TileMatrixIndex: 2
m_TileColorIndex: 0
m_ObjectToInstantiate: {fileID: 0}
m_TileFlags: 2
m_ColliderType: 2
- first: {x: 5, y: 9, z: 0}
second:
m_TileIndex: 1
m_TileSpriteIndex: 0
m_TileMatrixIndex: 1
m_TileColorIndex: 0
m_ObjectToInstantiate: {fileID: 0}
m_TileFlags: 2
m_ColliderType: 2
m_AnimatedTiles: {}
m_TileAssetArray:
- m_RefCount: 2
m_Data: {fileID: 11400000, guid: f11ad8ee25ba757418fe29f03491430b, type: 2}
- m_RefCount: 1
- m_RefCount: 2
m_Data: {fileID: 11400000, guid: abd8b20869637f8499648c976eab026d, type: 2}
- m_RefCount: 16
- m_RefCount: 17
m_Data: {fileID: 11400000, guid: 20a9ff2cdea8c4144b7bcd136a52986d, type: 2}
- m_RefCount: 2
- m_RefCount: 3
m_Data: {fileID: 11400000, guid: 7b3c67dce1d8789468d91512f953bbe5, type: 2}
- m_RefCount: 2
m_Data: {fileID: 11400000, guid: 84b2e218d4d30144dbde79f0499c7097, type: 2}
......@@ -536,15 +470,17 @@ Tilemap:
m_Data: {fileID: 11400000, guid: 88bce14208020a2469df1c47b7ec53c5, type: 2}
- m_RefCount: 0
m_Data: {fileID: 0}
- m_RefCount: 0
m_Data: {fileID: 0}
- m_RefCount: 1
m_Data: {fileID: 11400000, guid: af9e9c5c7e4d807479465329ae5ab04e, type: 2}
m_TileSpriteArray:
- m_RefCount: 3
- m_RefCount: 5
m_Data: {fileID: 21300000, guid: d48532af0b85b9a4093f85a675f60009, type: 3}
- m_RefCount: 16
- m_RefCount: 17
m_Data: {fileID: 21300000, guid: b71d3df6a1ca4a44bad4d0877bc53e0e, type: 3}
- m_RefCount: 6
- m_RefCount: 7
m_Data: {fileID: 21300000, guid: 788213b0d137d4e4b96e99bab374c4b9, type: 3}
- m_RefCount: 0
m_Data: {fileID: 0}
m_TileMatrixArray:
- m_RefCount: 2
m_Data:
......@@ -564,7 +500,7 @@ Tilemap:
e31: 0
e32: 0
e33: 1
- m_RefCount: 1
- m_RefCount: 2
m_Data:
e00: 0.000000059604645
e01: 0.99999994
......@@ -582,7 +518,7 @@ Tilemap:
e31: 0
e32: 0
e33: 1
- m_RefCount: 20
- m_RefCount: 21
m_Data:
e00: 1
e01: 0
......@@ -600,7 +536,7 @@ Tilemap:
e31: 0
e32: 0
e33: 1
- m_RefCount: 2
- m_RefCount: 4
m_Data:
e00: -1
e01: 0.00000008742278
......@@ -619,7 +555,7 @@ Tilemap:
e32: 0
e33: 1
m_TileColorArray:
- m_RefCount: 25
- m_RefCount: 29
m_Data: {r: 1, g: 1, b: 1, a: 1}
m_AnimationFrameRate: 1
m_Color: {r: 1, g: 1, b: 1, a: 1}
......@@ -644,6 +580,179 @@ Tilemap:
e31: 0
e32: 0
e33: 1
--- !u!1 &427587212
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 427587216}
- component: {fileID: 427587215}
- component: {fileID: 427587214}
m_Layer: 0
m_Name: Player
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &427587214
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 427587212}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d85c951a8a8bd28448a328b753c74372, type: 3}
m_Name:
m_EditorClassIdentifier:
trackingPoint: {fileID: 1783365522}
tilemap: {fileID: 185498795}
orientation: 0
facing: 1
InputProvider: {fileID: 11400000, guid: 026a5a3d17da2ec4b878bae9363baa61, type: 2}
--- !u!212 &427587215
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 427587212}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 4294967295
m_Materials:
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_Sprite: {fileID: 21300000, guid: d2823e2467bfc464e85b11b9a7867dea, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 1, y: 1}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!4 &427587216
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 427587212}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 2.56, y: 5.58, z: -0.07109375}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1783365523}
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1331335945
GameObject:
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1331335946}
- component: {fileID: 1331335949}
- component: {fileID: 1331335948}
m_Layer: 0
m_Name: cm
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1331335946
Transform: