2020-04-19 14:24:38 +00:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
2020-04-20 01:03:33 +00:00
|
|
|
|
public enum RequireCollisionMode {
|
|
|
|
|
WIN_ON_COLLISION,
|
|
|
|
|
LOSE_ON_COLLISION
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class RequireCollisionWithEnemy : MonoBehaviour
|
2020-04-19 14:24:38 +00:00
|
|
|
|
{
|
2020-04-19 15:55:44 +00:00
|
|
|
|
public float activationDelay = 0.5f;
|
2020-04-20 01:03:33 +00:00
|
|
|
|
public RequireCollisionMode mode = RequireCollisionMode.LOSE_ON_COLLISION;
|
2020-04-19 15:55:44 +00:00
|
|
|
|
|
2020-04-19 14:24:38 +00:00
|
|
|
|
private MicrogameController microgameController;
|
2020-04-19 15:55:44 +00:00
|
|
|
|
private bool active;
|
2020-04-19 14:24:38 +00:00
|
|
|
|
|
|
|
|
|
void Awake()
|
|
|
|
|
{
|
|
|
|
|
microgameController = GameObject.FindGameObjectWithTag("MicrogameController").GetComponent<MicrogameController>();
|
2020-04-19 15:55:44 +00:00
|
|
|
|
Invoke("Activate", activationDelay);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Activate() {
|
|
|
|
|
active = true;
|
2020-04-19 14:24:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-19 15:55:44 +00:00
|
|
|
|
void OnTriggerStay2D(Collider2D other) {
|
|
|
|
|
if(other.tag == "Enemy" && active) {
|
2020-04-20 01:03:33 +00:00
|
|
|
|
microgameController.victory = (mode == RequireCollisionMode.WIN_ON_COLLISION);
|
2020-04-19 14:24:38 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|