Added glider powerup

main
Ivy 4 years ago
parent e993ecb4aa
commit 8b6b2649eb

@ -6,7 +6,7 @@ AnimationClip:
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_Name: Protagonist m_Name: Protagonist Run Cycle
serializedVersion: 6 serializedVersion: 6
m_Legacy: 0 m_Legacy: 0
m_Compressed: 0 m_Compressed: 0

@ -28,7 +28,7 @@ AnimatorController:
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_Name: Protagonist Run Cycle_0 m_Name: Protagonist Run Cycle
serializedVersion: 5 serializedVersion: 5
m_AnimatorParameters: [] m_AnimatorParameters: []
m_AnimatorLayers: m_AnimatorLayers:

@ -15,6 +15,7 @@ GameObject:
- component: {fileID: 3275569032751403274} - component: {fileID: 3275569032751403274}
- component: {fileID: 4572441351392969366} - component: {fileID: 4572441351392969366}
- component: {fileID: 4796302867346557188} - component: {fileID: 4796302867346557188}
- component: {fileID: 971613887410275354}
m_Layer: 0 m_Layer: 0
m_Name: Player m_Name: Player
m_TagString: Player m_TagString: Player
@ -178,3 +179,17 @@ Animator:
m_HasTransformHierarchy: 1 m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1 m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorControllerStateOnDisable: 0 m_KeepAnimatorControllerStateOnDisable: 0
--- !u!114 &971613887410275354
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 374150667840124763}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 93764b8ff5a5045da89d2ddfc1195c97, type: 3}
m_Name:
m_EditorClassIdentifier:
m_FallSpeed: 0.7
IsGliding: 0

@ -332,6 +332,22 @@ CompositeCollider2D:
Y: 0 Y: 0
- X: -40000000 - X: -40000000
Y: 0 Y: 0
- - X: 170000100
Y: -40000041
- X: 170000100
Y: -19999959
- X: 170000041
Y: -19999900
- X: 149999959
Y: -19999900
- X: 149999900
Y: -19999959
- X: 149999900
Y: -40000041
- X: 149999959
Y: -40000100
- X: 170000041
Y: -40000100
- - X: 70000100 - - X: 70000100
Y: -130000041 Y: -130000041
- X: 70000100 - X: 70000100
@ -454,6 +470,10 @@ CompositeCollider2D:
- {x: 42.999973, y: 13} - {x: 42.999973, y: 13}
- {x: -6.00001, y: 12.999974} - {x: -6.00001, y: 12.999974}
- {x: -5.999971, y: 0.00001} - {x: -5.999971, y: 0.00001}
- - {x: 16.999975, y: -4.00001}
- {x: 16.999975, y: -1.99999}
- {x: 14.99999, y: -2.0000253}
- {x: 15.000026, y: -4.00001}
- - {x: 6.9999743, y: -13.00001} - - {x: 6.9999743, y: -13.00001}
- {x: 7.000039, y: -12} - {x: 7.000039, y: -12}
- {x: 44, y: -11.99997} - {x: 44, y: -11.99997}
@ -3692,6 +3712,26 @@ Tilemap:
m_TileObjectToInstantiateIndex: 65535 m_TileObjectToInstantiateIndex: 65535
dummyAlignment: 0 dummyAlignment: 0
m_AllTileFlags: 1073741825 m_AllTileFlags: 1073741825
- first: {x: 15, y: -4, z: 0}
second:
serializedVersion: 2
m_TileIndex: 4
m_TileSpriteIndex: 4
m_TileMatrixIndex: 0
m_TileColorIndex: 0
m_TileObjectToInstantiateIndex: 65535
dummyAlignment: 0
m_AllTileFlags: 1073741825
- first: {x: 16, y: -4, z: 0}
second:
serializedVersion: 2
m_TileIndex: 3
m_TileSpriteIndex: 3
m_TileMatrixIndex: 0
m_TileColorIndex: 0
m_TileObjectToInstantiateIndex: 65535
dummyAlignment: 0
m_AllTileFlags: 1073741825
- first: {x: 34, y: -4, z: 0} - first: {x: 34, y: -4, z: 0}
second: second:
serializedVersion: 2 serializedVersion: 2
@ -3922,6 +3962,26 @@ Tilemap:
m_TileObjectToInstantiateIndex: 65535 m_TileObjectToInstantiateIndex: 65535
dummyAlignment: 0 dummyAlignment: 0
m_AllTileFlags: 1073741825 m_AllTileFlags: 1073741825
- first: {x: 15, y: -3, z: 0}
second:
serializedVersion: 2
m_TileIndex: 2
m_TileSpriteIndex: 2
m_TileMatrixIndex: 0
m_TileColorIndex: 0
m_TileObjectToInstantiateIndex: 65535
dummyAlignment: 0
m_AllTileFlags: 1073741825
- first: {x: 16, y: -3, z: 0}
second:
serializedVersion: 2
m_TileIndex: 1
m_TileSpriteIndex: 1
m_TileMatrixIndex: 0
m_TileColorIndex: 0
m_TileObjectToInstantiateIndex: 65535
dummyAlignment: 0
m_AllTileFlags: 1073741825
- first: {x: 25, y: -3, z: 0} - first: {x: 25, y: -3, z: 0}
second: second:
serializedVersion: 2 serializedVersion: 2
@ -7966,13 +8026,13 @@ Tilemap:
m_TileAssetArray: m_TileAssetArray:
- m_RefCount: 4 - m_RefCount: 4
m_Data: {fileID: 11400000, guid: a75fae817255147dfb5af80c89349553, type: 2} m_Data: {fileID: 11400000, guid: a75fae817255147dfb5af80c89349553, type: 2}
- m_RefCount: 3 - m_RefCount: 4
m_Data: {fileID: 11400000, guid: 06e92d3a7a0654704bc339efcb7aa6aa, type: 2} m_Data: {fileID: 11400000, guid: 06e92d3a7a0654704bc339efcb7aa6aa, type: 2}
- m_RefCount: 3 - m_RefCount: 4
m_Data: {fileID: 11400000, guid: c5c8363f80db64a66a5a8eff42e70a32, type: 2} m_Data: {fileID: 11400000, guid: c5c8363f80db64a66a5a8eff42e70a32, type: 2}
- m_RefCount: 3 - m_RefCount: 4
m_Data: {fileID: 11400000, guid: d6ba3f6ba8f5640a9874b2ccc62a69c2, type: 2} m_Data: {fileID: 11400000, guid: d6ba3f6ba8f5640a9874b2ccc62a69c2, type: 2}
- m_RefCount: 3 - m_RefCount: 4
m_Data: {fileID: 11400000, guid: cdabe21a28af4458785296fb55cb3c69, type: 2} m_Data: {fileID: 11400000, guid: cdabe21a28af4458785296fb55cb3c69, type: 2}
- m_RefCount: 11 - m_RefCount: 11
m_Data: {fileID: 11400000, guid: a9e61ac9b92cc4d7ca4efb63365c4ffe, type: 2} m_Data: {fileID: 11400000, guid: a9e61ac9b92cc4d7ca4efb63365c4ffe, type: 2}
@ -8001,13 +8061,13 @@ Tilemap:
m_TileSpriteArray: m_TileSpriteArray:
- m_RefCount: 4 - m_RefCount: 4
m_Data: {fileID: -8806091605853736217, guid: 33f7d659c72ba459ba2a9485c9501630, type: 3} m_Data: {fileID: -8806091605853736217, guid: 33f7d659c72ba459ba2a9485c9501630, type: 3}
- m_RefCount: 3 - m_RefCount: 4
m_Data: {fileID: -873322832810516204, guid: 33f7d659c72ba459ba2a9485c9501630, type: 3} m_Data: {fileID: -873322832810516204, guid: 33f7d659c72ba459ba2a9485c9501630, type: 3}
- m_RefCount: 3 - m_RefCount: 4
m_Data: {fileID: 3433671182191017847, guid: 33f7d659c72ba459ba2a9485c9501630, type: 3} m_Data: {fileID: 3433671182191017847, guid: 33f7d659c72ba459ba2a9485c9501630, type: 3}
- m_RefCount: 3 - m_RefCount: 4
m_Data: {fileID: -5521210291312998094, guid: 33f7d659c72ba459ba2a9485c9501630, type: 3} m_Data: {fileID: -5521210291312998094, guid: 33f7d659c72ba459ba2a9485c9501630, type: 3}
- m_RefCount: 3 - m_RefCount: 4
m_Data: {fileID: -4930461731810238109, guid: 33f7d659c72ba459ba2a9485c9501630, type: 3} m_Data: {fileID: -4930461731810238109, guid: 33f7d659c72ba459ba2a9485c9501630, type: 3}
- m_RefCount: 11 - m_RefCount: 11
m_Data: {fileID: 8984585068276349725, guid: 33f7d659c72ba459ba2a9485c9501630, type: 3} m_Data: {fileID: 8984585068276349725, guid: 33f7d659c72ba459ba2a9485c9501630, type: 3}
@ -8034,7 +8094,7 @@ Tilemap:
- m_RefCount: 10 - m_RefCount: 10
m_Data: {fileID: 4798128000316562087, guid: 33f7d659c72ba459ba2a9485c9501630, type: 3} m_Data: {fileID: 4798128000316562087, guid: 33f7d659c72ba459ba2a9485c9501630, type: 3}
m_TileMatrixArray: m_TileMatrixArray:
- m_RefCount: 740 - m_RefCount: 744
m_Data: m_Data:
e00: 1 e00: 1
e01: 0 e01: 0
@ -8053,7 +8113,7 @@ Tilemap:
e32: 0 e32: 0
e33: 1 e33: 1
m_TileColorArray: m_TileColorArray:
- m_RefCount: 740 - m_RefCount: 744
m_Data: {r: 1, g: 1, b: 1, a: 1} m_Data: {r: 1, g: 1, b: 1, a: 1}
m_TileObjectToInstantiateArray: [] m_TileObjectToInstantiateArray: []
m_AnimationFrameRate: 1 m_AnimationFrameRate: 1

@ -1978,7 +1978,9 @@ MonoBehaviour:
spriteToFade: {fileID: 874186942} spriteToFade: {fileID: 874186942}
events: {fileID: 1051066022} events: {fileID: 1051066022}
player: {fileID: 1370635947} player: {fileID: 1370635947}
sceneToLoad: obtainedPowerups:
powerupStatus:
sceneToLoad: Spike Scene
--- !u!4 &637676178 --- !u!4 &637676178
Transform: Transform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

@ -2375,6 +2375,8 @@ GameObject:
m_Component: m_Component:
- component: {fileID: 219367236} - component: {fileID: 219367236}
- component: {fileID: 219367235} - component: {fileID: 219367235}
- component: {fileID: 219367237}
- component: {fileID: 219367238}
m_Layer: 0 m_Layer: 0
m_Name: Powerup placeholder m_Name: Powerup placeholder
m_TagString: Untagged m_TagString: Untagged
@ -2447,6 +2449,70 @@ Transform:
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 2 m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &219367237
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 219367234}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3405314fa73da438982268d433fbbc2f, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!60 &219367238
PolygonCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 219367234}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IsTrigger: 1
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: 0.8828125, y: 1}
newSize: {x: 0.8828125, y: 1}
adaptiveTilingThreshold: 0.5
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
m_Points:
m_Paths:
- - {x: 0.4375, y: -0.265625}
- {x: 0.44140625, y: -0.2578125}
- {x: 0.44140625, y: 0.2578125}
- {x: 0.4375, y: 0.265625}
- {x: 0.390625, y: 0.29296875}
- {x: 0.36328125, y: 0.30859375}
- {x: 0.26171875, y: 0.3671875}
- {x: 0.21484375, y: 0.39453125}
- {x: 0.16015625, y: 0.42578125}
- {x: 0.05859375, y: 0.484375}
- {x: 0.02734375, y: 0.5}
- {x: -0.03125, y: 0.5}
- {x: -0.05859375, y: 0.484375}
- {x: -0.1875, y: 0.41015625}
- {x: -0.36328125, y: 0.30859375}
- {x: -0.4375, y: 0.265625}
- {x: -0.44140625, y: 0.2578125}
- {x: -0.44140625, y: -0.2578125}
- {x: -0.4375, y: -0.265625}
- {x: -0.31640625, y: -0.3359375}
- {x: -0.26171875, y: -0.3671875}
- {x: -0.21484375, y: -0.39453125}
- {x: -0.11328125, y: -0.453125}
- {x: -0.03125, y: -0.5}
- {x: 0.03125, y: -0.5}
- {x: 0.0859375, y: -0.46875}
- {x: 0.2421875, y: -0.37890625}
--- !u!1 &563510750 --- !u!1 &563510750
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

@ -1,5 +1,9 @@
using System;
using System.Collections; using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine; using UnityEngine;
using UnityEngine.Assertions.Must;
using UnityEngine.SceneManagement; using UnityEngine.SceneManagement;
using UnityEngine.UI; using UnityEngine.UI;
@ -12,6 +16,9 @@ public class GameManager : MonoBehaviour
public GameObject events; public GameObject events;
public GameObject player; public GameObject player;
public List<Powerup> obtainedPowerups = new List<Powerup>{ };
public List<bool> powerupStatus = new List<bool>{ };
public string sceneToLoad = ""; public string sceneToLoad = "";
void Awake() void Awake()
@ -38,14 +45,14 @@ public class GameManager : MonoBehaviour
{ {
if (sceneToLoad != "") if (sceneToLoad != "")
{ {
LoadLevel(sceneToLoad, new Vector3(0,0,0)); LoadLevel(sceneToLoad, new Vector3(0, 0, 0));
} }
} }
// Update is called once per frame // Update is called once per frame
void Update() void Update()
{ {
doGliderButtonCheck();
} }
public void LoadLevel(string levelName, Vector3 whereTo) public void LoadLevel(string levelName, Vector3 whereTo)
@ -84,5 +91,29 @@ public class GameManager : MonoBehaviour
spriteToFade.SetActive(false); spriteToFade.SetActive(false);
} }
private void doGliderButtonCheck()
{
if (obtainedPowerups.Contains(Powerup.Glider))
{
if (Input.GetKeyDown("1"))
{
var index = Array.IndexOf(obtainedPowerups.ToArray(), Powerup.Glider);
var status = powerupStatus[index];
if (!status)
{
player.GetComponent<Glider>().IsGliding = true;
powerupStatus[index] = true;
}
else
{
player.GetComponent<Glider>().IsGliding = false;
powerupStatus[index] = false;
}
}
}
}
} }
// }
//}
//}

@ -0,0 +1,45 @@
using UnityEngine;
//http://answers.unity.com/answers/1778449/view.html
public class Glider : MonoBehaviour
{
/// <summary>
/// The speed when falling
/// </summary>
[SerializeField]
private float m_FallSpeed = 0f;
/// <summary>
///
/// </summary>
private Rigidbody2D m_Rigidbody2D = null;
// Awake is called before Start function
void Awake()
{
m_Rigidbody2D = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update()
{
if (IsGliding && m_Rigidbody2D.velocity.y < 0f && Mathf.Abs(m_Rigidbody2D.velocity.y) > m_FallSpeed)
m_Rigidbody2D.velocity = new Vector2(m_Rigidbody2D.velocity.x, Mathf.Sign(m_Rigidbody2D.velocity.y) * m_FallSpeed);
}
public void StartGliding()
{
IsGliding = true;
}
public void StopGliding()
{
IsGliding = false;
}
/// <summary>
/// Flag to check if gliding
/// </summary>
///
public bool IsGliding { get; set; } = false;
}

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 93764b8ff5a5045da89d2ddfc1195c97
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,26 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GliderPowerupPickup : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
private void OnTriggerEnter2D(Collider2D collision)
{
Debug.Log("Test");
GameManager.Instance.obtainedPowerups.Add(Powerup.Glider);
GameManager.Instance.powerupStatus.Add(false);
Destroy(gameObject);
}
}

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3405314fa73da438982268d433fbbc2f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,5 @@
using System;
public enum Powerup
{
Glider
}

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9af10219a8237432585dcf45948fe641
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -15,22 +15,22 @@ EditorUserSettings:
value: 22424703114646680e0b0227036c6c111b07142f1f2b233e2867083debf42d value: 22424703114646680e0b0227036c6c111b07142f1f2b233e2867083debf42d
flags: 0 flags: 0
RecentlyUsedScenePath-3: RecentlyUsedScenePath-3:
value: 22424703114646680e0b0227036c7b151b18342f3a2d2a23621a0d3ae9e5740be1e238eca92f31352d1b value: 22424703114646680e0b0227036c7b151b18342f3a2d2a23621d1224e7f27a2decee22f0
flags: 0 flags: 0
RecentlyUsedScenePath-4: RecentlyUsedScenePath-4:
value: 22424703114646680e0b0227036c7b151b18342f3a2d2a23621d1224e7f27a2decee22f0 value: 22424703114646680e0b0227036c7b151b18342f3a2d2a23620b1132eceb7414e7f133e5a92f31352d1b
flags: 0 flags: 0
RecentlyUsedScenePath-5: RecentlyUsedScenePath-5:
value: 22424703114646680e0b0227036c7b151b18342f3a2d2a23620b1132eceb7414e7f133e5a92f31352d1b value: 22424703114646680e0b0227036c7b151b18342f3a2d2a23620c1336eff9002dece933e5a92f31352d1b
flags: 0 flags: 0
RecentlyUsedScenePath-6: RecentlyUsedScenePath-6:
value: 22424703114646680e0b0227036c7b151b18342f3a2d2a23620c1336eff9002dece933e5a92f31352d1b value: 22424703114646680e0b0227036c7b151b18342f3a2d2a23621b1226f6e50037d6e821ecf5742a323016f6
flags: 0 flags: 0
RecentlyUsedScenePath-7: RecentlyUsedScenePath-7:
value: 22424703114646680e0b0227036c7b151b18342f3a2d2a2362191c27ead43b1aedf425a7f234362820 value: 22424703114646680e0b0227036c7b151b18342f3a2d2a2362191c27ead43b1aedf425a7f234362820
flags: 0 flags: 0
RecentlyUsedScenePath-8: RecentlyUsedScenePath-8:
value: 22424703114646680e0b0227036c7b151b18342f3a2d2a23621b1226f6e50037d6e821ecf5742a323016f6 value: 22424703114646680e0b0227036c7b151b18342f3a2d2a23621a0d3ae9e5740be1e238eca92f31352d1b
flags: 0 flags: 0
RecentlyUsedScenePath-9: RecentlyUsedScenePath-9:
value: 22424703114646680e0b0227036c7b151b18342f3a2d2a23621a0d32f5ee7a2decee22f0 value: 22424703114646680e0b0227036c7b151b18342f3a2d2a23621a0d32f5ee7a2decee22f0

Loading…
Cancel
Save