Compare commits
No commits in common. '43a50d5374df361cf9356bc43c3d53dbd3b5b1fb' and '13d5237c6b2db8619777ea2eceb1e299788067f7' have entirely different histories.
43a50d5374
...
13d5237c6b
7 changed files with 6 additions and 122 deletions
@ -1,19 +0,0 @@ |
||||
%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} |
@ -1,8 +0,0 @@ |
||||
fileFormatVersion: 2 |
||||
guid: 3237b9257f669690ea1a6f828451509e |
||||
NativeFormatImporter: |
||||
externalObjects: {} |
||||
mainObjectFileID: 11400000 |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -1,19 +0,0 @@ |
||||
%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} |
@ -1,8 +0,0 @@ |
||||
fileFormatVersion: 2 |
||||
guid: c6de04aab82eeff81894387c19ac1310 |
||||
NativeFormatImporter: |
||||
externalObjects: {} |
||||
mainObjectFileID: 11400000 |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -1,72 +1,17 @@ |
||||
using System.Collections; |
||||
using System.Linq; |
||||
using Unity.Netcode; |
||||
using UnityEngine; |
||||
|
||||
namespace Game { |
||||
public class Wormhole : NetworkBehaviour { |
||||
|
||||
public float duration = 10; |
||||
public float Size { get; set; } |
||||
|
||||
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 Start() { |
||||
transform.localScale = new Vector3(Size, Size, Size); |
||||
} |
||||
|
||||
private void FixedUpdate() { |
||||
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); |
||||
} |
||||
foreach (var ball in GameManager.Singleton.Balls) { } |
||||
} |
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue