Compare commits

...

2 Commits

  1. 19
      Assets/Prefabs/Modifications/WidthBuff.asset
  2. 8
      Assets/Prefabs/Modifications/WidthBuff.asset.meta
  3. 19
      Assets/Prefabs/Modifications/WidthNerf.asset
  4. 8
      Assets/Prefabs/Modifications/WidthNerf.asset.meta
  5. 4
      Assets/Scenes/Game.unity
  6. 7
      Assets/Scripts/Game/GameManager.cs
  7. 63
      Assets/Scripts/Game/Wormhole.cs

@ -0,0 +1,19 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4453d1448ec14f5fa81aae3c54f78010, type: 3}
m_Name: WidthBuff
m_EditorClassIdentifier:
type: 1
effect: 2
pickupDuration: 10
activeDuration: 10
image: {fileID: 21300000, guid: f09eae8c0ea04254b90c5386a034a225, type: 3}

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3237b9257f669690ea1a6f828451509e
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,19 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4453d1448ec14f5fa81aae3c54f78010, type: 3}
m_Name: WidthNerf
m_EditorClassIdentifier:
type: 0
effect: 2
pickupDuration: 10
activeDuration: 10
image: {fileID: 21300000, guid: f9161c6c9e06dc445ada3ee16d991f90, type: 3}

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c6de04aab82eeff81894387c19ac1310
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

@ -1025,7 +1025,9 @@ MonoBehaviour:
- {fileID: 11400000, guid: ae5a83823d492d27bbb84006f6e0e8c2, type: 2}
- {fileID: 11400000, guid: df0f24b538b5fed02a7faa3a5e0f121b, type: 2}
- {fileID: 11400000, guid: 73dc3bbc93cba37b1b989a9497b680e7, type: 2}
wormholePrefab: {fileID: 0}
- {fileID: 11400000, guid: 3237b9257f669690ea1a6f828451509e, type: 2}
- {fileID: 11400000, guid: c6de04aab82eeff81894387c19ac1310, type: 2}
wormholePrefab: {fileID: 7486271855853268360, guid: bf48a6813e1f5a2f7a63fc5c413808cb, type: 3}
--- !u!4 &2109945868
Transform:
m_ObjectHideFlags: 0

@ -41,6 +41,8 @@ namespace Game {
while (Application.isPlaying) {
yield return new WaitForSeconds(1);
SpawnModification();
yield return new WaitForSeconds(2);
SpawnWormhole();
}
}
@ -87,7 +89,10 @@ namespace Game {
Player2 = p2;
}
private void SpawnWormhole() { }
private void SpawnWormhole() {
var pos = new Vector2(Random.Range(0, Dimensions.Singleton.PlaySize.x) - Dimensions.Singleton.PlaySize.x / 2, Random.Range(-5, 5));
Instantiate(wormholePrefab, pos, Quaternion.identity);
}
private void SpawnModification() {
var pos = new Vector2(Random.Range(0, Dimensions.Singleton.PlaySize.x) - Dimensions.Singleton.PlaySize.x / 2, Random.Range(-2, 2));

@ -1,17 +1,72 @@
using System.Collections;
using System.Linq;
using Unity.Netcode;
using UnityEngine;
namespace Game {
public class Wormhole : NetworkBehaviour {
public float Size { get; set; }
public float duration = 10;
private void Start() {
transform.localScale = new Vector3(Size, Size, Size);
private const float MaxSize = 10;
private float size;
public float Size {
get => size;
set {
size = value;
transform.localScale = new Vector3(size, size, 1);
}
}
private float Radius => Size / 2;
private static float CubicEaseInOut(float t, float b, float c, float d) {
if ((t /= d / 2) < 1) return c / 2 * t * t * t + b;
return c / 2 * ((t -= 2) * t * t + 2) + b;
}
private static float CircleEaseInOut(float t, float b, float c, float d) {
if ((t /= d / 2) < 1) return -c / 2 * (Mathf.Sqrt(1 - t * t) - 1) + b;
return c / 2 * (Mathf.Sqrt(1 - (t -= 2) * t) + 1) + b;
}
private IEnumerator Grow(float growTime) {
float currentTime = 0;
while (currentTime <= growTime) {
Size = CircleEaseInOut(currentTime, 0, MaxSize, growTime);
yield return new WaitForFixedUpdate();
currentTime += Time.fixedDeltaTime;
}
}
private IEnumerator Shrink(float shrinkTime) {
float currentTime = 0;
while (currentTime <= shrinkTime) {
Size = CubicEaseInOut(currentTime, MaxSize, -MaxSize, shrinkTime);
yield return new WaitForFixedUpdate();
currentTime += Time.fixedDeltaTime;
}
}
private IEnumerator Start() {
Size = 0;
yield return Grow(duration * 0.2f);
yield return new WaitForSeconds(duration * 0.7f);
yield return Shrink(duration * 0.1f);
}
private void FixedUpdate() {
foreach (var ball in GameManager.Singleton.Balls) { }
Vector2 thisPos = new Vector2(transform.position.x, transform.position.y);
foreach (var ball in GameManager.Singleton.Balls) {
Vector2 diff = thisPos - ball.Rb.position;
if (diff.sqrMagnitude > Radius * Radius)
continue;
float dist = diff.magnitude;
Vector2 force = diff.normalized / dist * (Size * 5);
force = Vector2.ClampMagnitude(force, 15);
ball.Rb.AddForce(force);
}
}
}
}

Loading…
Cancel
Save