wormhole and optimizations

main
Benjamin Kraft 2 years ago
parent 896ab23c09
commit 2f1d19c094
  1. 6
      Assets/Materials/M_Wood3.mat
  2. 59
      Assets/Materials/Wormhole.mat
  3. 8
      Assets/Materials/Wormhole.mat.meta
  4. 116
      Assets/Prefabs/Wormhole.prefab
  5. 7
      Assets/Prefabs/Wormhole.prefab.meta
  6. 1
      Assets/Scenes/Game.unity
  7. 19
      Assets/Scripts/Game/GameManager.cs
  8. 3
      Assets/Scripts/Game/Modification.cs
  9. 4
      Assets/Scripts/Game/ModificationProperties.cs
  10. 41
      Assets/Scripts/Game/Player.cs
  11. 49
      Assets/Scripts/Game/RealPlayer.cs
  12. 3
      Assets/Scripts/Game/RealPlayer.cs.meta
  13. 21
      Assets/Scripts/Game/Wormhole.cs
  14. 3
      Assets/Scripts/Game/Wormhole.cs.meta
  15. 2272
      Assets/Shaders/GradientSprite.shadergraph
  16. 10
      Assets/Shaders/GradientSprite.shadergraph.meta

@ -22,9 +22,7 @@ Material:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_Name: M_Wood3 m_Name: M_Wood3
m_Shader: {fileID: 4800000, guid: 8d2bb70cbf9db8d4da26e15b26e74248, type: 3} m_Shader: {fileID: 4800000, guid: 8d2bb70cbf9db8d4da26e15b26e74248, type: 3}
m_ValidKeywords: m_ValidKeywords: []
- _GLOSSINESS_FROM_BASE_ALPHA
- _SPECULAR_COLOR
m_InvalidKeywords: [] m_InvalidKeywords: []
m_LightmapFlags: 4 m_LightmapFlags: 4
m_EnableInstancingVariants: 0 m_EnableInstancingVariants: 0
@ -61,7 +59,7 @@ Material:
m_Scale: {x: 1, y: 1} m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0} m_Offset: {x: 0, y: 0}
- _MainTex: - _MainTex:
m_Texture: {fileID: 0} m_Texture: {fileID: 2800000, guid: 3c63e2e318876fc4ebc6ba149de82007, type: 3}
m_Scale: {x: 1, y: 1} m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0} m_Offset: {x: 0, y: 0}
- _MetallicGlossMap: - _MetallicGlossMap:

@ -0,0 +1,59 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Wormhole
m_Shader: {fileID: -6465566751694194690, guid: 5e68bbedda3b17858b070612ad890c40, type: 3}
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _AlphaTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: 47e353a78c92b9838963e533e37462e5, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MaskTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _NormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_Lightmaps:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_LightmapsInd:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_ShadowMasks:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _Circular: 1
- _EnableExternalAlpha: 0
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _Flip: {r: 1, g: 1, b: 1, a: 1}
- _RendererColor: {r: 1, g: 1, b: 1, a: 1}
m_BuildTextureStacks: []

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

@ -0,0 +1,116 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &7486271855853268360
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7486271855853268358}
- component: {fileID: 7486271855853268361}
- component: {fileID: 7486271855853268356}
- component: {fileID: 7486271855853268359}
m_Layer: 0
m_Name: Wormhole
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &7486271855853268358
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7486271855853268360}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 1
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &7486271855853268361
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7486271855853268360}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 0
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: d6f2bc558df4da55ea47f9c60de7afd2, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 1
m_Sprite: {fileID: 21300000, guid: 47e353a78c92b9838963e533e37462e5, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 1, y: 1}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!114 &7486271855853268356
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7486271855853268360}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: cb6d62361e0d4241a3a06744500d9d9f, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &7486271855853268359
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7486271855853268360}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3}
m_Name:
m_EditorClassIdentifier:
GlobalObjectIdHash: 951099334
AlwaysReplicateAsRoot: 0
DontDestroyWithOwner: 0
AutoObjectParentSync: 1

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: bf48a6813e1f5a2f7a63fc5c413808cb
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -1025,6 +1025,7 @@ MonoBehaviour:
- {fileID: 11400000, guid: ae5a83823d492d27bbb84006f6e0e8c2, type: 2} - {fileID: 11400000, guid: ae5a83823d492d27bbb84006f6e0e8c2, type: 2}
- {fileID: 11400000, guid: df0f24b538b5fed02a7faa3a5e0f121b, type: 2} - {fileID: 11400000, guid: df0f24b538b5fed02a7faa3a5e0f121b, type: 2}
- {fileID: 11400000, guid: 73dc3bbc93cba37b1b989a9497b680e7, type: 2} - {fileID: 11400000, guid: 73dc3bbc93cba37b1b989a9497b680e7, type: 2}
wormholePrefab: {fileID: 0}
--- !u!4 &2109945868 --- !u!4 &2109945868
Transform: Transform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

@ -26,12 +26,13 @@ namespace Game {
public Object playerPrefab; public Object playerPrefab;
public Object modificationPrefab; public Object modificationPrefab;
public ModificationProperties[] modifications; public ModificationProperties[] modifications;
public Object wormholePrefab;
public List<Ball> Balls { get; } = new(); public List<Ball> Balls { get; } = new();
public Player Player1 { get; private set; } public Player Player1 { get; private set; }
public Player Player2 { get; private set; } public Player Player2 { get; private set; }
private void Awake() { private void SetupPlayers() {
Settings.Type = Type.Hybrid; Settings.Type = Type.Hybrid;
Settings.AIDifficulty = Difficulty.Hard; Settings.AIDifficulty = Difficulty.Hard;
@ -51,6 +52,12 @@ namespace Game {
p2 = p2Obj.AddComponent<RealPlayer>(); p2 = p2Obj.AddComponent<RealPlayer>();
((RealPlayer) p1).isThisClient = true; ((RealPlayer) p1).isThisClient = true;
break; break;
case Type.RealOffline:
p1 = p1Obj.AddComponent<RealPlayer>();
p2 = p2Obj.AddComponent<RealPlayer>();
((RealPlayer) p1).isThisClient = true;
((RealPlayer) p2).isThisClient = true;
break;
case Type.Hybrid: case Type.Hybrid:
p1 = p1Obj.AddComponent<RealPlayer>(); p1 = p1Obj.AddComponent<RealPlayer>();
p2 = p2Obj.AddComponent<AIPlayer>(); p2 = p2Obj.AddComponent<AIPlayer>();
@ -65,15 +72,15 @@ namespace Game {
Player1 = p1; Player1 = p1;
Player2 = p2; Player2 = p2;
}
private void Awake() {
SetupPlayers();
SpawnBall(Player1, true); SpawnBall(Player1, true);
} }
private IEnumerator Start() { private void SpawnWormhole() {
while (Application.isPlaying) {
yield return new WaitForSeconds(1);
SpawnModification();
}
} }
private void SpawnModification() { private void SpawnModification() {

@ -7,9 +7,6 @@ using UnityEngine.UIElements;
namespace Game { namespace Game {
public enum ModType { Nerf, Buff }
public enum ModEffect { Speed, Border }
public class Modification : Collectable { public class Modification : Collectable {
public ModificationProperties Properties { get; set; } public ModificationProperties Properties { get; set; }

@ -2,6 +2,10 @@ using UnityEngine;
using UnityEngine.Serialization; using UnityEngine.Serialization;
namespace Game { namespace Game {
public enum ModType { Nerf, Buff }
public enum ModEffect { Speed, Border }
[CreateAssetMenu(fileName = "Data", menuName = "ScriptableObjects/ModificationProperties", order = 0)] [CreateAssetMenu(fileName = "Data", menuName = "ScriptableObjects/ModificationProperties", order = 0)]
public class ModificationProperties : ScriptableObject { public class ModificationProperties : ScriptableObject {
public ModType type; public ModType type;

@ -17,7 +17,7 @@ namespace Game {
protected bool goingLeft, goingRight; protected bool goingLeft, goingRight;
public VisualElement Panel { get; private set; } private VisualElement Panel { get; set; }
private List<ModificationProperties> Modifications { get; } = new(); private List<ModificationProperties> Modifications { get; } = new();
@ -38,8 +38,8 @@ namespace Game {
} }
// Unit distance from zero // Unit distance from zero
private readonly float baseBorder = Dimensions.Singleton.PlaySize.x / 2 * 0.9f; private readonly float baseBorder = Dimensions.Singleton.PlaySize.x / 2 * 0.85f;
private readonly float borderSummand = Dimensions.Singleton.PlaySize.x / 2 * 0.1f; private readonly float borderSummand = Dimensions.Singleton.PlaySize.x / 2 * 0.15f;
protected float Border { protected float Border {
get { get {
return Mathf.Min(Modifications.Where(m => m.effect == ModEffect.Border) return Mathf.Min(Modifications.Where(m => m.effect == ModEffect.Border)
@ -106,7 +106,7 @@ namespace Game {
ClampInsideBorders(); ClampInsideBorders();
} }
private void Start() { protected void Start() {
float y = Side switch { float y = Side switch {
Side.Bottom => -Dimensions.Singleton.PlaySizeBoards.y / 2, Side.Bottom => -Dimensions.Singleton.PlaySizeBoards.y / 2,
Side.Top => Dimensions.Singleton.PlaySizeBoards.y / 2, Side.Top => Dimensions.Singleton.PlaySizeBoards.y / 2,
@ -117,39 +117,6 @@ namespace Game {
transform.Rotate(transform.forward, 180); transform.Rotate(transform.forward, 180);
Panel = GameUI.Singleton.PlayerPanel(Side); Panel = GameUI.Singleton.PlayerPanel(Side);
UpdatePanel(); UpdatePanel();
GameUI.Singleton.buttonDown += (side, direction) => {
if (!side.Equals(Side))
return;
if (direction == "left")
goingLeft = true;
else
goingRight = true;
};
GameUI.Singleton.buttonUp += (side, direction) => {
if (!side.Equals(Side))
return;
if (direction == "left")
goingLeft = false;
else
goingRight = false;
};
}
}
public class RealPlayer : Player {
public bool isThisClient;
private void FixedUpdate() {
if (!isThisClient)
return;
if (Application.isEditor) {
var keyboard = Keyboard.current;
goingLeft = keyboard.aKey.isPressed;
goingRight = keyboard.dKey.isPressed;
}
TryLinearMove(Time.fixedDeltaTime);
} }
} }
} }

@ -0,0 +1,49 @@
using UnityEngine;
using UnityEngine.InputSystem;
namespace Game {
public class RealPlayer : Player {
public bool isThisClient;
private new void Start() {
base.Start();
GameUI.Singleton.buttonDown += (side, direction) => {
if (!side.Equals(Side))
return;
if (direction == "left")
goingLeft = true;
else
goingRight = true;
};
GameUI.Singleton.buttonUp += (side, direction) => {
if (!side.Equals(Side))
return;
if (direction == "left")
goingLeft = false;
else
goingRight = false;
};
}
private void FixedUpdate() {
if (!isThisClient)
return;
if (Application.isEditor) {
var keyboard = Keyboard.current;
switch (Side) {
case Side.Top:
goingLeft = keyboard.aKey.isPressed;
goingRight = keyboard.dKey.isPressed;
break;
case Side.Bottom:
goingLeft = keyboard.leftArrowKey.isPressed;
goingRight = keyboard.rightArrowKey.isPressed;
break;
}
}
TryLinearMove(Time.fixedDeltaTime);
}
}
}

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 770f63511b4544668a55d469469156ef
timeCreated: 1681545400

@ -0,0 +1,21 @@
using System;
using Unity.Netcode;
using UnityEngine;
namespace Game {
public class Wormhole : NetworkBehaviour {
public float Size { get; set; }
private void Start() {
transform.localScale = new Vector3(Size, Size, Size);
}
private void FixedUpdate() {
foreach (var ball in GameManager.Singleton.Balls) {
}
}
}
}

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: cb6d62361e0d4241a3a06744500d9d9f
timeCreated: 1681541658

File diff suppressed because it is too large Load Diff

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 5e68bbedda3b17858b070612ad890c40
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}
Loading…
Cancel
Save