|
|
@ -1,4 +1,5 @@ |
|
|
|
using System; |
|
|
|
using System; |
|
|
|
|
|
|
|
using System.Collections; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Linq; |
|
|
|
using Unity.Netcode; |
|
|
|
using Unity.Netcode; |
|
|
@ -18,7 +19,7 @@ namespace Game { |
|
|
|
|
|
|
|
|
|
|
|
public VisualElement Panel { get; private set; } |
|
|
|
public VisualElement Panel { get; private set; } |
|
|
|
|
|
|
|
|
|
|
|
public List<ActiveModification> Modifications { get; } = new(); |
|
|
|
private List<ModificationProperties> Modifications { get; } = new(); |
|
|
|
|
|
|
|
|
|
|
|
private int Score { get; set; } |
|
|
|
private int Score { get; set; } |
|
|
|
|
|
|
|
|
|
|
@ -27,8 +28,8 @@ namespace Game { |
|
|
|
private const float SpeedMultiplier = 1.5f; |
|
|
|
private const float SpeedMultiplier = 1.5f; |
|
|
|
protected float Speed { |
|
|
|
protected float Speed { |
|
|
|
get { |
|
|
|
get { |
|
|
|
return Modifications.Where(m => m.Properties.effect == ModEffect.Speed) |
|
|
|
return Modifications.Where(m => m.effect == ModEffect.Speed) |
|
|
|
.Aggregate(BaseSpeed, (current, speedMod) => current * speedMod.Properties.type switch { |
|
|
|
.Aggregate(BaseSpeed, (current, speedMod) => current * speedMod.type switch { |
|
|
|
ModType.Buff => SpeedMultiplier, |
|
|
|
ModType.Buff => SpeedMultiplier, |
|
|
|
ModType.Nerf => 1 / SpeedMultiplier, |
|
|
|
ModType.Nerf => 1 / SpeedMultiplier, |
|
|
|
_ => throw new ArgumentOutOfRangeException() |
|
|
|
_ => throw new ArgumentOutOfRangeException() |
|
|
@ -41,8 +42,8 @@ namespace Game { |
|
|
|
private readonly float borderSummand = Dimensions.Singleton.PlaySize.x / 2 * 0.1f; |
|
|
|
private readonly float borderSummand = Dimensions.Singleton.PlaySize.x / 2 * 0.1f; |
|
|
|
protected float Border { |
|
|
|
protected float Border { |
|
|
|
get { |
|
|
|
get { |
|
|
|
return Mathf.Min(Modifications.Where(m => m.Properties.effect == ModEffect.Border) |
|
|
|
return Mathf.Min(Modifications.Where(m => m.effect == ModEffect.Border) |
|
|
|
.Aggregate(baseBorder, (current, borderMod) => current + borderMod.Properties.type switch { |
|
|
|
.Aggregate(baseBorder, (current, borderMod) => current + borderMod.type switch { |
|
|
|
ModType.Buff => borderSummand, |
|
|
|
ModType.Buff => borderSummand, |
|
|
|
ModType.Nerf => -borderSummand, |
|
|
|
ModType.Nerf => -borderSummand, |
|
|
|
_ => throw new ArgumentOutOfRangeException() |
|
|
|
_ => throw new ArgumentOutOfRangeException() |
|
|
@ -70,6 +71,27 @@ namespace Game { |
|
|
|
Panel.Q<TextElement>("score").text = Score.ToString(); |
|
|
|
Panel.Q<TextElement>("score").text = Score.ToString(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public IEnumerator ProcessModification(ModificationProperties properties) { |
|
|
|
|
|
|
|
Modifications.Add(properties); |
|
|
|
|
|
|
|
VisualElement element = GameUI.AddModification(Panel, properties); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float doNothingTime = properties.activeDuration * 0.7f; |
|
|
|
|
|
|
|
float animateTime = properties.activeDuration * 0.3f; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
yield return new WaitForSeconds(doNothingTime); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float current = 0; |
|
|
|
|
|
|
|
while (current < animateTime) { |
|
|
|
|
|
|
|
current += Time.deltaTime; |
|
|
|
|
|
|
|
element.style.opacity = new StyleFloat(1 - current / animateTime); |
|
|
|
|
|
|
|
yield return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
element.RemoveFromHierarchy(); |
|
|
|
|
|
|
|
Modifications.Remove(properties); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected void ClampInsideBorders() { |
|
|
|
protected void ClampInsideBorders() { |
|
|
|
if (LeftEdge < -Border) |
|
|
|
if (LeftEdge < -Border) |
|
|
|
transform.Translate(Vector2.right * (-Border - LeftEdge), Space.World); |
|
|
|
transform.Translate(Vector2.right * (-Border - LeftEdge), Space.World); |
|
|
|