Import 2D Level

This commit is contained in:
2026-04-30 00:53:30 +02:00
parent c67979c7cf
commit 5797038baf
479 changed files with 430785 additions and 0 deletions
@@ -0,0 +1,39 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Reflection;
[RequireComponent(typeof(ParticleSystem))]
public class EmitParticlesOnLand : MonoBehaviour
{
public bool emitOnLand = true;
public bool emitOnEnemyDeath = true;
#if UNITY_TEMPLATE_PLATFORMER
ParticleSystem p;
void Start()
{
p = GetComponent<ParticleSystem>();
if (emitOnLand) {
Platformer.Gameplay.PlayerLanded.OnExecute += PlayerLanded_OnExecute;
void PlayerLanded_OnExecute(Platformer.Gameplay.PlayerLanded obj) {
p.Play();
}
}
if (emitOnEnemyDeath) {
Platformer.Gameplay.EnemyDeath.OnExecute += EnemyDeath_OnExecute;
void EnemyDeath_OnExecute(Platformer.Gameplay.EnemyDeath obj) {
p.Play();
}
}
}
#endif
}
@@ -0,0 +1,58 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Jiggler : MonoBehaviour
{
[Range(0, 1)]
public float power = .1f;
[Header("Position Jiggler")]
public bool jigPosition = true;
public Vector3 positionJigAmount;
[Range(0, 120)]
public float positionFrequency = 10;
float positionTime;
[Header("Rotation Jiggler")]
public bool jigRotation = true;
public Vector3 rotationJigAmount;
[Range(0, 120)]
public float rotationFrequency = 10;
float rotationTime;
[Header("Scale Jiggler")]
public bool jigScale = true;
public Vector3 scaleJigAmount = new Vector3(.1f, -.1f, .1f);
[Range(0, 120)]
public float scaleFrequency = 10;
float scaleTime;
Vector3 basePosition;
Quaternion baseRotation;
Vector3 baseScale;
void Start(){
basePosition = transform.localPosition;
baseRotation = transform.localRotation;
baseScale = transform.localScale;
}
// Update is called once per frame
void Update()
{
var dt = Time.deltaTime;
positionTime += dt * positionFrequency;
rotationTime += dt * rotationFrequency;
scaleTime += dt * scaleFrequency;
if (jigPosition)
transform.localPosition = basePosition + positionJigAmount * Mathf.Sin(positionTime) * power;
if (jigRotation)
transform.localRotation = baseRotation * Quaternion.Euler(rotationJigAmount * Mathf.Sin(positionTime) * power);
if (jigScale)
transform.localScale = baseScale + scaleJigAmount * Mathf.Sin(scaleTime) * power;
}
}
@@ -0,0 +1,21 @@
using UnityEngine;
using Platformer.Mechanics;
public class PlatformerJumpPad : MonoBehaviour
{
public float verticalVelocity;
void OnTriggerEnter2D(Collider2D other)
{
var rb = other.attachedRigidbody;
if (rb == null) return;
var player = rb.GetComponent<PlayerController>();
if (player == null) return;
AddVelocity(player);
}
void AddVelocity(PlayerController player)
{
player.velocity.y = verticalVelocity;
}
}
@@ -0,0 +1,27 @@
using System.Collections;
using UnityEngine;
using Platformer.Mechanics;
public class PlatformerSpeedPad : MonoBehaviour
{
public float maxSpeed;
[Range (0, 5)]
public float duration = 1f;
void OnTriggerEnter2D(Collider2D other){
var rb = other.attachedRigidbody;
if (rb == null) return;
var player = rb.GetComponent<PlayerController>();
if (player == null) return;
player.StartCoroutine(PlayerModifier(player, duration));
}
IEnumerator PlayerModifier(PlayerController player, float lifetime){
var initialSpeed = player.maxSpeed;
player.maxSpeed = maxSpeed;
yield return new WaitForSeconds(lifetime);
player.maxSpeed = initialSpeed;
}
}
@@ -0,0 +1,22 @@
using UnityEngine;
using UnityEngine.Events;
public class SimpleTrigger : MonoBehaviour
{
public Rigidbody2D triggerBody;
public UnityEvent onTriggerEnter;
void OnTriggerEnter2D(Collider2D other){
//do not trigger if there's no trigger target object
if (triggerBody == null) return;
//only trigger if the triggerBody matches
var hitRb = other.attachedRigidbody;
if (hitRb == triggerBody){
onTriggerEnter.Invoke();
}
}
}