|
|
@ -1,12 +1,14 @@ |
|
|
|
using System; |
|
|
|
using System; |
|
|
|
using System.Collections; |
|
|
|
using System.Collections; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Collections.Generic; |
|
|
|
|
|
|
|
using System.Linq; |
|
|
|
using System.Transactions; |
|
|
|
using System.Transactions; |
|
|
|
using Unity.Netcode; |
|
|
|
using Unity.Netcode; |
|
|
|
using UnityEditor; |
|
|
|
using UnityEditor; |
|
|
|
using UnityEditor.UIElements; |
|
|
|
using UnityEditor.UIElements; |
|
|
|
using UnityEngine; |
|
|
|
using UnityEngine; |
|
|
|
using UnityEngine.InputSystem; |
|
|
|
using UnityEngine.InputSystem; |
|
|
|
|
|
|
|
using UnityEngine.Serialization; |
|
|
|
using UnityEngine.UIElements; |
|
|
|
using UnityEngine.UIElements; |
|
|
|
|
|
|
|
|
|
|
|
namespace Game { |
|
|
|
namespace Game { |
|
|
@ -22,15 +24,38 @@ namespace Game { |
|
|
|
public VisualElement Panel { get; private set; } |
|
|
|
public VisualElement Panel { get; private set; } |
|
|
|
|
|
|
|
|
|
|
|
public List<ActiveModification> Modifications { get; } = new(); |
|
|
|
public List<ActiveModification> Modifications { get; } = new(); |
|
|
|
|
|
|
|
|
|
|
|
[SerializeField] |
|
|
|
private int Score { get; set; } |
|
|
|
public int score = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Units per second |
|
|
|
// Units per second |
|
|
|
protected float Speed => 15; |
|
|
|
private const float BaseSpeed = 15; |
|
|
|
|
|
|
|
private const float SpeedMultiplier = 1.5f; |
|
|
|
|
|
|
|
protected float Speed { |
|
|
|
|
|
|
|
get { |
|
|
|
|
|
|
|
return Modifications.Where(m => m.Properties.effect == ModEffect.Speed) |
|
|
|
|
|
|
|
.Aggregate(BaseSpeed, (current, speedMod) => current * speedMod.Properties.type switch { |
|
|
|
|
|
|
|
ModType.Buff => SpeedMultiplier, |
|
|
|
|
|
|
|
ModType.Nerf => 1 / SpeedMultiplier, |
|
|
|
|
|
|
|
_ => throw new ArgumentOutOfRangeException() |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Unit distance from zero |
|
|
|
// Unit distance from zero |
|
|
|
protected float Border => Dimensions.Singleton.Width / 2; |
|
|
|
private readonly float baseBorder = Dimensions.Singleton.Width / 2 * 0.8f; |
|
|
|
|
|
|
|
private readonly float borderSummand = Dimensions.Singleton.Width / 2 * 0.2f; |
|
|
|
|
|
|
|
protected float Border { |
|
|
|
|
|
|
|
get { |
|
|
|
|
|
|
|
return Mathf.Min(Modifications.Where(m => m.Properties.effect == ModEffect.Border) |
|
|
|
|
|
|
|
.Aggregate(baseBorder, (current, borderMod) => current + borderMod.Properties.type switch { |
|
|
|
|
|
|
|
ModType.Buff => borderSummand, |
|
|
|
|
|
|
|
ModType.Nerf => -borderSummand, |
|
|
|
|
|
|
|
_ => throw new ArgumentOutOfRangeException() |
|
|
|
|
|
|
|
}), |
|
|
|
|
|
|
|
Dimensions.Singleton.Width / 2 |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected float Width => transform.localScale.x; |
|
|
|
protected float Width => transform.localScale.x; |
|
|
|
|
|
|
|
|
|
|
@ -42,12 +67,12 @@ namespace Game { |
|
|
|
protected float Y => transform.position.y; |
|
|
|
protected float Y => transform.position.y; |
|
|
|
|
|
|
|
|
|
|
|
public void GainScore() { |
|
|
|
public void GainScore() { |
|
|
|
score++; |
|
|
|
Score++; |
|
|
|
UpdatePanel(); |
|
|
|
UpdatePanel(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void UpdatePanel() { |
|
|
|
private void UpdatePanel() { |
|
|
|
Panel.Q<TextElement>("score").text = score.ToString(); |
|
|
|
Panel.Q<TextElement>("score").text = Score.ToString(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected void ClampInsideBorders() { |
|
|
|
protected void ClampInsideBorders() { |
|
|
|