Commit 9851e683 authored by Christopher Benes's avatar Christopher Benes
Browse files

Merge branch 'master' into feature/Level

# Conflicts:
#	Assets/_Game/Prefabs/Cannon.prefab
#	Assets/_Game/Scripts/CannonController.cs
parents 05160591 93a690f1
...@@ -98,7 +98,7 @@ MonoBehaviour: ...@@ -98,7 +98,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 7e98e65d5258913459ccbd3759232399, type: 3} m_Script: {fileID: 11500000, guid: 7e98e65d5258913459ccbd3759232399, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
waitTime: 3 waitTime: 2
child: {fileID: 1417612902657568} child: {fileID: 1417612902657568}
--- !u!198 &198244601809831776 --- !u!198 &198244601809831776
ParticleSystem: ParticleSystem:
......
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: BodyParts
m_Shader: {fileID: 203, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _InvFade: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _TintColor: {r: 0.5, g: 0.5, b: 0.5, a: 0.5}
fileFormatVersion: 2 fileFormatVersion: 2
guid: 7d76a63dfd317814d9eef925c0df39c7 guid: c4fc0d9c88e2d91469ee107a729ea1af
folderAsset: yes NativeFormatImporter:
DefaultImporter:
externalObjects: {} externalObjects: {}
mainObjectFileID: 2100000
userData: userData:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:
This diff is collapsed.
fileFormatVersion: 2 fileFormatVersion: 2
guid: 7302d929ac7a2f44180b44e09592ac8a guid: 9e17a0d4a71e81e459bf89deb0ba7bef
folderAsset: yes NativeFormatImporter:
DefaultImporter:
externalObjects: {} externalObjects: {}
mainObjectFileID: 100100000
userData: userData:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -3,33 +3,21 @@ ...@@ -3,33 +3,21 @@
public class CannonController : MonoBehaviour, IResetable { public class CannonController : MonoBehaviour, IResetable {
[SerializeField] private GameObject cannonBarrel; [SerializeField] private GameObject cannonBarrel;
[SerializeField] private GameObject fire; [SerializeField] private GameObject fire;
[SerializeField] private float shotsPerSeconds; [SerializeField] private float fireDelay;
[SerializeField] private float speed = 10f; [SerializeField] private float speed = 10f;
[SerializeField] private Animator anim; [SerializeField] private Animator anim;
[SerializeField] private Animator animRadVorne; [SerializeField] private Animator animRadVorne;
[SerializeField] private Animator animRadHinten; [SerializeField] private Animator animRadHinten;
[SerializeField] private float startAfterTime;
private float cooldown; private void Start()
{
void Awake() InvokeRepeating("FireCannon", 0.0f, fireDelay);
{
cooldown = startAfterTime;
}
private void FixedUpdate () {
if (cooldown <= 0) {
anim.SetTrigger("Fire");
animRadVorne.SetTrigger("Fire");
animRadHinten.SetTrigger("Fire");
} else {
cooldown = Mathf.Max(0, cooldown - Time.deltaTime);
}
} }
public void Fire() { public void FireCannon() {
anim.SetTrigger("Fire");
GameObject obj = Instantiate(fire, cannonBarrel.transform.Find("FirePoint").position, cannonBarrel.transform.rotation); GameObject obj = Instantiate(fire, cannonBarrel.transform.Find("FirePoint").position, cannonBarrel.transform.rotation);
cooldown = 1f / (shotsPerSeconds);
// Drehung // Drehung
obj.transform.rotation = Quaternion.Euler(0, 0, 90) * cannonBarrel.transform.rotation; obj.transform.rotation = Quaternion.Euler(0, 0, 90) * cannonBarrel.transform.rotation;
obj.transform.localScale = transform.lossyScale; obj.transform.localScale = transform.lossyScale;
...@@ -38,6 +26,6 @@ public class CannonController : MonoBehaviour, IResetable { ...@@ -38,6 +26,6 @@ public class CannonController : MonoBehaviour, IResetable {
} }
public void ResetToLevelBegin() { public void ResetToLevelBegin() {
cooldown = startAfterTime;
} }
} }
using UnityEngine; using System;
using TMPro;
using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
public class LevelSelectController : MonoBehaviour { public class LevelSelectController : MonoBehaviour {
//[SerializeField] private GameObject levelButtonPrefab;
[SerializeField] private GameObject pagePrefab;
[SerializeField] private int nonPageObjects = 3;
private int highestLevel;
private int lastLevel;
private void Start() { private void Start() {
ActivateAllPages(); InitalizeLevelSelect();
UpdateLevelSelect();
DisablePagesAfterFirst();
} }
/// <summary> /// <summary>
/// Locks all currently not unlocked levels /// Locks all currently not unlocked levels
/// </summary> /// </summary>
public void UpdateLevelSelect() { public void InitalizeLevelSelect()
int highestLevel = GameManager.Instance.HighestLevel; {
int lastLevel = GameManager.Instance.LastLevel; highestLevel = GameManager.Instance.HighestLevel;
lastLevel = GameManager.Instance.LastLevel;
int pagesNeeded = lastLevel / 6 + 1;
int buttonsOnLastPage = lastLevel % 6;
GameObject currentPage;
for (int i = 1; i <= 18; i++) { for (int i = 1; i <= pagesNeeded; i++)
string buttonName = "ButtonLevel" + i; {
if (GameObject.Find(buttonName) != null) { currentPage = GameObject.Instantiate(pagePrefab, transform.GetChild(0));
GameObject button = GameObject.Find(buttonName); currentPage.GetComponent<LevelSelectPageController>().PageNr = i;
Image image = button.transform.Find("Image").GetComponent<Image>();
// Level unlocked //Load images for buttons
if (i <= highestLevel) { for (int j = 1; j <= 6; j++)
string loadStr = i < 10 ? "LevelSelect/Level0" + i : "LevelSelect/Level" + i; {
image.sprite = Resources.Load(loadStr, typeof(Sprite)) as Sprite; String buttonName = "ButtonLevel" + j;
button.GetComponent<Button>().interactable = true; int levelNr = j + (currentPage.GetComponent<LevelSelectPageController>().PageNr-1) * 6;
}
// Level locked
else if (i <= lastLevel) {
image.sprite = Resources.Load("LevelSelect/lockedTEMP", typeof(Sprite)) as Sprite;
button.GetComponent<Button>().interactable = false;
}
// Level doesn't exist
else {
button.SetActive(false);
// Deactivates NextPageButton because there isnt' a next page if (GameObject.Find(buttonName) != null)
if (button.transform.parent.Find("ButtonNextPage") != null) {
GameObject button = currentPage.transform.Find(buttonName).gameObject;
Image image = button.transform.Find("Image").GetComponent<Image>();
// Level unlocked
if (levelNr <= highestLevel)
{ {
string loadStr = levelNr < 10 ? "LevelSelect/Level0" + levelNr : "LevelSelect/Level" + levelNr;
GameObject nextPage = button.transform.parent.Find("ButtonNextPage").gameObject; image.sprite = Resources.Load(loadStr, typeof(Sprite)) as Sprite;
button.transform.Find("Text").gameObject.GetComponent<TextMeshProUGUI>().text = levelNr + "";
nextPage.SetActive(false); button.GetComponent<Button>().interactable = true;
}
// Level locked
else if (levelNr <= lastLevel)
{
image.sprite = Resources.Load("LevelSelect/lockedTEMP", typeof(Sprite)) as Sprite;
button.GetComponent<Button>().interactable = false;
}
}
}
// Deactivate not needed NextPage- & PreviousPage-Buttons
if (i == 1)
{
currentPage.transform.Find("ButtonPrevPage").gameObject.SetActive(false);
}
if (i == pagesNeeded)
{
currentPage.transform.Find("ButtonNextPage").gameObject.SetActive(false);
// Deactivate not needed buttons
if (buttonsOnLastPage != 0)
{
for (int j = 6; j > buttonsOnLastPage; j--)
{
String buttonName = "ButtonLevel" + j;
currentPage.transform.Find(buttonName).gameObject.SetActive(false);
} }
// Next page can't be opened so buttons on it don't have to be changed
if (i % 6 == 0)
return;
} }
} }
} }
DisablePagesAfterFirst();
} }
/// <summary> /// <summary>
...@@ -79,9 +107,17 @@ public class LevelSelectController : MonoBehaviour { ...@@ -79,9 +107,17 @@ public class LevelSelectController : MonoBehaviour {
GameManager.Instance.LoadLevel(level); GameManager.Instance.LoadLevel(level);
} }
public void OpenLevelSelect() { public void ShowNextPage(int pageNr)
ActivateAllPages(); {
UpdateLevelSelect(); GameObject canvas = transform.Find("Canvas").gameObject;
DisablePagesAfterFirst(); canvas.transform.GetChild(pageNr + nonPageObjects - 1).gameObject.SetActive(false);
canvas.transform.GetChild(pageNr + nonPageObjects).gameObject.SetActive(true);
}
public void ShowPrevPage(int pageNr)
{
GameObject canvas = transform.Find("Canvas").gameObject;
canvas.transform.GetChild(pageNr + nonPageObjects - 1).gameObject.SetActive(false);
canvas.transform.GetChild(pageNr + nonPageObjects - 2).gameObject.SetActive(true);
} }
} }
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LevelSelectPageController : MonoBehaviour {
public int PageNr { get; set; }
public void LoadLevel(int level)
{
level += (PageNr-1) * 6;
Debug.Log("Load level " + level);
GameManager.Instance.LoadLevel(level);
}
public void ShowNextPage()
{
transform.parent.parent.gameObject.GetComponent<LevelSelectController>().ShowNextPage(PageNr);
}
public void ShowPrevPage()
{
transform.parent.parent.gameObject.GetComponent<LevelSelectController>().ShowPrevPage(PageNr);
}
}
fileFormatVersion: 2 fileFormatVersion: 2
guid: ccfe9bf63a9f2214db0028dccb6b6e2b guid: bdb116d84d8e7ae4ab53801430dcd6b1
folderAsset: yes MonoImporter:
DefaultImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData: userData:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:
...@@ -46,6 +46,10 @@ public class PlayerActor : MonoBehaviour, IResetable { ...@@ -46,6 +46,10 @@ public class PlayerActor : MonoBehaviour, IResetable {
[SerializeField] private Animator animator; [SerializeField] private Animator animator;
[SerializeField] private ParticleSystem deathEffect;
[SerializeField] private SpriteRenderer sprite;
[SerializeField] private float peekingDistance; [SerializeField] private float peekingDistance;
private readonly Collider2D[] contactBuffer = new Collider2D[64]; private readonly Collider2D[] contactBuffer = new Collider2D[64];
...@@ -94,7 +98,7 @@ public class PlayerActor : MonoBehaviour, IResetable { ...@@ -94,7 +98,7 @@ public class PlayerActor : MonoBehaviour, IResetable {
private void OnTriggerEnter2D(Collider2D other) { private void OnTriggerEnter2D(Collider2D other) {
// Collides with Hazard // Collides with Hazard
if (other.gameObject.layer == 11) { if (other.gameObject.layer == 11) {
Die(); StartCoroutine(Die());
} }
} }
...@@ -398,7 +402,13 @@ public class PlayerActor : MonoBehaviour, IResetable { ...@@ -398,7 +402,13 @@ public class PlayerActor : MonoBehaviour, IResetable {
UpdateOrientation(); UpdateOrientation();
} }
private static void Die() { private IEnumerator Die() {
deathEffect.Play(true);
col.enabled = false;
sprite.enabled = false;
yield return new WaitForSeconds(0.1f);
// TODO: This call is really inefficient // TODO: This call is really inefficient
IResetable[] resetables = FindObjectsOfType<MonoBehaviour>().OfType<IResetable>().ToArray(); IResetable[] resetables = FindObjectsOfType<MonoBehaviour>().OfType<IResetable>().ToArray();
foreach (IResetable r in resetables) { foreach (IResetable r in resetables) {
...@@ -412,15 +422,18 @@ public class PlayerActor : MonoBehaviour, IResetable { ...@@ -412,15 +422,18 @@ public class PlayerActor : MonoBehaviour, IResetable {
movementRoutine = null; movementRoutine = null;
} }
transform.position = startingPosition;
orientation = startingOrientation;
sprite.enabled = true;
col.enabled = true;
animator.SetBool("isFalling", false); animator.SetBool("isFalling", false);
animator.SetBool("isRunning", false); animator.SetBool("isRunning", false);
animator.SetBool("isPeeking", false); animator.SetBool("isPeeking", false);
animator.SetBool("shouldSlide", false); animator.SetBool("shouldSlide", false);
animator.Play("Idle"); animator.Play("Idle");
transform.position = startingPosition;
orientation = startingOrientation;
UpdateOrientation(); UpdateOrientation();
} }
} }
fileFormatVersion: 2
guid: 8bf6d380d1a5e664ea2336072d30002a
TextureImporter:
fileIDToRecycleName:
21300000: Bodyparts_0
21300002: Bodyparts_1
21300004: Bodyparts_2
21300006: Bodyparts_3
21300008: Bodyparts_4
21300010: Bodyparts_5
21300012: Bodyparts_6
21300014: Bodyparts_7
21300016: Bodyparts_8
21300018: Bodyparts_9
21300020: Bodyparts_10
21300022: Bodyparts_11
21300024: Bodyparts_12
21300026: Bodyparts_13
21300028: Bodyparts_14
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: -1
aniso: -1
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: -1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 2
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
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
- serializedVersion: 2
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites:
- serializedVersion: 2
name: Bodyparts_0
rect:
serializedVersion: 2
x: 2
y: 847
width: 62
height: 49
alignment: 0
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
outline:
- - {x: -24, y: 24.5}
- {x: -31, y: 13.5}
- {x: -31, y: -24.5}
- {x: -7, y: -24.5}
- {x: 31, y: 10.5}
- {x: 31, y: 24.5}
physicsShape:
- - {x: -27, y: 24.5}
- {x: -31, y: 9.5}
- {x: -31, y: -24.5}
- {x: -8, y: -24.5}
- {x: 31, y: 14.5}
- {x: 31, y: 24.5}
tessellationDetail: 0
bones: []
spriteID: 7c7260f263eae48489160acea7a2af27
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: Bodyparts_1