parent
456759c6e4
commit
de502ca3de
6 changed files with 96 additions and 14 deletions
@ -1,15 +1,55 @@ |
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using Unity.Netcode; |
||||
using UnityEngine; |
||||
using UnityEngine.UIElements; |
||||
|
||||
namespace Game { |
||||
public class Modification : MonoBehaviour { |
||||
|
||||
|
||||
public enum ModType { Nerf, Buff } |
||||
public enum ModEffect { Speed, Border } |
||||
|
||||
public struct ModificationProperties { |
||||
public ModType Type { get; set; } |
||||
public ModEffect Effect { get; set; } |
||||
|
||||
public float PickupDuration { get; set; } |
||||
|
||||
public float ActiveDuration { get; set; } |
||||
} |
||||
|
||||
public class SpeedModification : Modification { |
||||
|
||||
public class ActiveModification { |
||||
public ModificationProperties Properties { get; set; } |
||||
|
||||
public IEnumerator Process(VisualElement panel, List<ActiveModification> modifications) { |
||||
modifications.Add(this); |
||||
VisualElement element = GameUI.AddModification(panel, this); |
||||
|
||||
yield return new WaitForSeconds(Properties.ActiveDuration); |
||||
|
||||
element.RemoveFromHierarchy(); |
||||
modifications.Remove(this); |
||||
} |
||||
} |
||||
|
||||
public class Modification : NetworkBehaviour { |
||||
|
||||
public class BorderModification : Modification { |
||||
|
||||
public ModificationProperties Properties { get; set; } |
||||
|
||||
private IEnumerator Start() { |
||||
yield return new WaitForSeconds(Properties.PickupDuration); |
||||
Destroy(gameObject); |
||||
} |
||||
|
||||
private void OnTriggerEnter2D(Collider2D other) { |
||||
Player p = other.GetComponent<Ball>().LastContactPlayer; |
||||
if (p != null) { |
||||
Destroy(gameObject); |
||||
ActiveModification mod = new() {Properties = Properties}; |
||||
StartCoroutine(mod.Process(p.Panel, p.Modifications)); |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
Loading…
Reference in new issue