Compare commits

...

2 Commits

  1. 4
      Assets/Prefabs/Collectables/Modifications/BorderBuff.asset
  2. 2
      Assets/Prefabs/Collectables/Modifications/BorderNerf.asset
  3. 4
      Assets/Prefabs/Collectables/Modifications/SpeedBuff.asset
  4. 2
      Assets/Prefabs/Collectables/Modifications/SpeedNerf.asset
  5. 4
      Assets/Prefabs/Collectables/Modifications/WidthBuff.asset
  6. 2
      Assets/Prefabs/Collectables/Modifications/WidthNerf.asset
  7. 33
      Assets/Scenes/Game.unity
  8. 39
      Assets/Scripts/Game/AIPlayer.cs
  9. 50
      Assets/Scripts/Game/GameManager.cs
  10. 4
      Assets/Scripts/Game/Player.cs
  11. 18
      Assets/Scripts/Game/RealPlayer.cs
  12. 14
      Assets/Scripts/Game/Settings.cs
  13. 2
      Assets/Scripts/GameUI.cs
  14. 10
      Assets/UI Toolkit/player_panel.uss
  15. 6
      ProjectSettings/ProjectSettings.asset

@ -14,6 +14,6 @@ MonoBehaviour:
m_EditorClassIdentifier:
type: 1
effect: 1
pickupDuration: 10
activeDuration: 10
pickupDuration: 15
activeDuration: 15
image: {fileID: 21300000, guid: 500c6690dd1efa237973d86a4232f5c0, type: 3}

@ -15,5 +15,5 @@ MonoBehaviour:
type: 0
effect: 1
pickupDuration: 10
activeDuration: 10
activeDuration: 5
image: {fileID: 21300000, guid: 555c4207622e3e429bea3c98ad8ae3f5, type: 3}

@ -14,6 +14,6 @@ MonoBehaviour:
m_EditorClassIdentifier:
type: 1
effect: 0
pickupDuration: 10
activeDuration: 10
pickupDuration: 15
activeDuration: 15
image: {fileID: 21300000, guid: c9633c24081701c6c9ce9884d6524530, type: 3}

@ -15,5 +15,5 @@ MonoBehaviour:
type: 0
effect: 0
pickupDuration: 10
activeDuration: 10
activeDuration: 5
image: {fileID: 21300000, guid: 24ca60336f20aee73b5b211b6f6e1a44, type: 3}

@ -14,6 +14,6 @@ MonoBehaviour:
m_EditorClassIdentifier:
type: 1
effect: 2
pickupDuration: 10
activeDuration: 10
pickupDuration: 15
activeDuration: 15
image: {fileID: 21300000, guid: f09eae8c0ea04254b90c5386a034a225, type: 3}

@ -15,5 +15,5 @@ MonoBehaviour:
type: 0
effect: 2
pickupDuration: 10
activeDuration: 10
activeDuration: 5
image: {fileID: 21300000, guid: f9161c6c9e06dc445ada3ee16d991f90, type: 3}

@ -1017,6 +1017,39 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 52712ba5190f247fcab14f6d688872ba, type: 3}
m_Name:
m_EditorClassIdentifier:
spawnRates:
- spawnable: 0
values:
- spawnRate: 1
baseSeconds: 20
- spawnRate: 2
baseSeconds: 10
- spawnRate: 3
baseSeconds: 5
- spawnable: 1
values:
- spawnRate: 1
baseSeconds: 30
- spawnRate: 2
baseSeconds: 20
- spawnRate: 3
baseSeconds: 10
- spawnable: 2
values:
- spawnRate: 1
baseSeconds: 10
- spawnRate: 2
baseSeconds: 7
- spawnRate: 3
baseSeconds: 3
- spawnable: 3
values:
- spawnRate: 1
baseSeconds: 40
- spawnRate: 2
baseSeconds: 30
- spawnRate: 3
baseSeconds: 15
ballPrefab: {fileID: 7041796185663956342, guid: d67d5f2db5f0b3d9d8298731f423a9b6, type: 3}
playerPrefab: {fileID: 5402279313309450415, guid: 32b3bb87d3699d314ace59ddb1674875, type: 3}
borderZonePrefab: {fileID: 4827788429173683660, guid: 50e7c76b45ba22fb18c0012e23b4b34c, type: 3}

@ -1,5 +1,6 @@
using System.Linq;
using UnityEngine;
using UnityEngine.UIElements;
namespace Game {
@ -10,6 +11,8 @@ namespace Game {
private bool isApproaching;
private float lastDirection;
private bool lastGoingLeft, lastGoingRight;
private Label leftButton, rightButton;
public Difficulty Difficulty { get; set; }
@ -19,25 +22,51 @@ namespace Game {
private float DistortAmount => 1 - 1 / ((float) Difficulty + 1);
protected new void Start() {
base.Start();
leftButton = GameUI.Singleton.GetGoButton(Side, "left");
rightButton = GameUI.Singleton.GetGoButton(Side, "right");
}
private void FixedUpdate() {
var dt = Time.fixedDeltaTime;
var target = GetTargetPosition();
var h = Mathf.Max(Speed * dt, Width / 2);
goingLeft = target < X - h;
goingRight = target > X + h;
if (goingLeft || goingRight) {
goingLeftLinear = target < X - h;
goingRightLinear = target > X + h;
if (goingLeftLinear || goingRightLinear) {
isApproaching = false;
lastDirection = goingLeft ? -1 : 1;
lastDirection = goingLeftLinear ? -1 : 1;
TryLinearMove(dt);
} else {
if (!isApproaching) {
isApproaching = true;
currentSmoothV = Speed * lastDirection;
}
ApproachPosition(target);
}
bool goingLeft = isApproaching ? currentSmoothV < 0 : goingLeftLinear;
bool goingRight = isApproaching ? currentSmoothV > 0 : goingRightLinear;
switch (lastGoingLeft) {
case false when goingLeft:
break;
case true when !goingLeft:
break;
}
switch (lastGoingRight) {
case false when goingRight:
break;
case true when !goingRight:
break;
}
lastGoingLeft = goingLeft;
lastGoingRight = goingRight;
}
// True if ball y velocity points towards player

@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Unity.Netcode;
using Unity.VisualScripting;
using UnityEngine;
@ -10,6 +11,19 @@ using Random = UnityEngine.Random;
namespace Game {
public class GameManager : NetworkBehaviour {
[Serializable]
public struct SpawnRatesValue {
public SpawnRate spawnRate;
public float baseSeconds;
}
[Serializable]
public struct SpawnableSpawnRates {
public Spawnable spawnable;
public SpawnRatesValue[] values;
}
public SpawnableSpawnRates[] spawnRates;
public Object ballPrefab;
public Object playerPrefab;
public Object borderZonePrefab;
@ -28,7 +42,6 @@ namespace Game {
private void Awake() {
SetupPlayers();
SpawnBall(Player1, true);
}
private void OnEnable() {
@ -39,17 +52,38 @@ namespace Game {
QualitySettings.vSyncCount = 0;
}
private IEnumerator Start() {
private IEnumerator SpawnLoop(Spawnable spawnable) {
SpawnRate required = SpawnRate.Normal; //Settings.SpawnRates[spawnable];
if (required == SpawnRate.Never)
yield break;
float baseSeconds = spawnRates.First(s => s.spawnable == spawnable).values.First(v => v.spawnRate == required).baseSeconds;
while (Application.isPlaying) {
yield return new WaitForSeconds(1);
yield return new WaitForSeconds(baseSeconds);
switch (spawnable) {
case Spawnable.NewBallTemporary:
SpawnNewBall(false);
break;
case Spawnable.NewBallPermanent:
SpawnNewBall(true);
break;
case Spawnable.Modification:
SpawnModification();
yield return new WaitForSeconds(2);
break;
case Spawnable.Wormhole:
SpawnWormhole();
yield return new WaitForSeconds(1);
SpawnNewBall();
break;
}
}
}
private void Start() {
SpawnBall(Player1, true);
StartCoroutine(SpawnLoop(Spawnable.NewBallTemporary));
StartCoroutine(SpawnLoop(Spawnable.NewBallPermanent));
StartCoroutine(SpawnLoop(Spawnable.Modification));
StartCoroutine(SpawnLoop(Spawnable.Wormhole));
}
private void SetupPlayers() {
Settings.Type = Type.Hybrid;
Settings.AIDifficulty = Difficulty.VeryHard;
@ -95,9 +129,9 @@ namespace Game {
p1.borderZonePrefab = p2.borderZonePrefab = borderZonePrefab;
}
private void SpawnNewBall() {
private void SpawnNewBall(bool permanent) {
var pos = new Vector2(Random.Range(0, Dimensions.Singleton.PlaySize.x) - Dimensions.Singleton.PlaySize.x / 2, Random.Range(-5, 5));
Instantiate(newBallPrefab, pos, Quaternion.identity).GetComponent<NewBall>().IsPermanent = Random.value > 0.8f;
Instantiate(newBallPrefab, pos, Quaternion.identity).GetComponent<NewBall>().IsPermanent = permanent;
}
private void SpawnWormhole() {

@ -27,7 +27,7 @@ namespace Game {
private const float BaseWidth = 6;
private const float WidthMultiplier = 1.5f;
protected bool goingLeft, goingRight;
protected bool goingLeftLinear, goingRightLinear;
public Side Side { get; set; }
@ -145,7 +145,7 @@ namespace Game {
}
protected void TryLinearMove(float h) {
var trans = new Vector2((goingLeft ? -1 : 0) + (goingRight ? 1 : 0), 0);
var trans = new Vector2((goingLeftLinear ? -1 : 0) + (goingRightLinear ? 1 : 0), 0);
trans *= Speed * h;
transform.Translate(trans, Space.World);
ClampInsideBorders();

@ -7,21 +7,23 @@ namespace Game {
private new void Start() {
base.Start();
if (!isThisClient)
return;
GameUI.Singleton.buttonDown += (side, direction) => {
if (!side.Equals(Side))
return;
if (direction == "left")
goingLeft = true;
goingLeftLinear = true;
else
goingRight = true;
goingRightLinear = true;
};
GameUI.Singleton.buttonUp += (side, direction) => {
if (!side.Equals(Side))
return;
if (direction == "left")
goingLeft = false;
goingLeftLinear = false;
else
goingRight = false;
goingRightLinear = false;
};
}
@ -33,12 +35,12 @@ namespace Game {
var keyboard = Keyboard.current;
switch (Side) {
case Side.Top:
goingLeft = keyboard.leftArrowKey.isPressed;
goingRight = keyboard.rightArrowKey.isPressed;
goingLeftLinear = keyboard.leftArrowKey.isPressed;
goingRightLinear = keyboard.rightArrowKey.isPressed;
break;
case Side.Bottom:
goingLeft = keyboard.aKey.isPressed;
goingRight = keyboard.dKey.isPressed;
goingLeftLinear = keyboard.aKey.isPressed;
goingRightLinear = keyboard.dKey.isPressed;
break;
}
}

@ -1,10 +1,20 @@
using System;
using System.Collections.Generic;
namespace Game {
public enum Type { RealOnline, RealOffline, Hybrid, AI }
public enum Type { RealOnline, RealOffline, Hybrid, AI, RealOnlineRanked }
public enum Difficulty { VeryEasy, Easy, Medium, Hard, VeryHard }
[Serializable]
public enum SpawnRate {Never, Few, Normal, Many}
[Serializable]
public enum Spawnable {NewBallTemporary, NewBallPermanent, Modification, Wormhole}
public enum WinScore {Default, Custom}
public struct Settings {
public static Type Type;
public static Difficulty AIDifficulty;
public static Dictionary<Spawnable, SpawnRate> SpawnRates;
public static WinScore WinScore;
public static int CustomWinScore;
}
}

@ -62,7 +62,7 @@ public class GameUI : MonoBehaviour {
SetupGoButton(Side.Bottom, "right");
}
private Label GetGoButton(Side sideVertical, string sideHorizontal) {
public Label GetGoButton(Side sideVertical, string sideHorizontal) {
return PlayerPanel(sideVertical).Q<Label>("go_" + sideHorizontal);
}

@ -6,10 +6,10 @@
border-right-color: rgb(141, 157, 255);
border-top-color: rgb(141, 157, 255);
border-bottom-color: rgb(141, 157, 255);
border-left-width: 3px;
border-right-width: 3px;
border-top-width: 3px;
border-bottom-width: 3px;
border-left-width: 7px;
border-right-width: 7px;
border-top-width: 7px;
border-bottom-width: 7px;
border-top-left-radius: 15px;
border-bottom-left-radius: 15px;
border-top-right-radius: 15px;
@ -18,7 +18,7 @@
margin-right: 10px;
margin-top: 10px;
margin-bottom: 10px;
background-color: rgb(91, 91, 91);
background-color: rgba(91, 91, 91, 0.49);
flex-grow: 1;
}

@ -134,7 +134,7 @@ PlayerSettings:
16:10: 1
16:9: 1
Others: 1
bundleVersion: 1.0.2
bundleVersion: 1.0.3
preloadedAssets: []
metroInputSource: 0
wsaTransparentSwapchain: 0
@ -165,8 +165,8 @@ PlayerSettings:
iPhone: 0
tvOS: 0
overrideDefaultApplicationIdentifier: 0
AndroidBundleVersionCode: 10
AndroidMinSdkVersion: 24
AndroidBundleVersionCode: 11
AndroidMinSdkVersion: 26
AndroidTargetSdkVersion: 33
AndroidPreferredInstallLocation: 1
aotOptions:

Loading…
Cancel
Save