Play zone + leftover spawning
This commit is contained in:
@@ -71,7 +71,7 @@ TrailRenderer:
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 1
|
||||
m_SortingOrder: 0
|
||||
m_Time: 1
|
||||
m_Parameters:
|
||||
serializedVersion: 3
|
||||
@@ -241,6 +241,7 @@ GameObject:
|
||||
- component: {fileID: 5995183602835295541}
|
||||
- component: {fileID: 3057151313563799006}
|
||||
- component: {fileID: -4779029823867914901}
|
||||
- component: {fileID: -1351644667867233305}
|
||||
m_Layer: 0
|
||||
m_Name: Player
|
||||
m_TagString: Untagged
|
||||
@@ -431,6 +432,20 @@ BoxCollider2D:
|
||||
serializedVersion: 2
|
||||
m_Size: {x: 1.5271429, y: 3.1530812}
|
||||
m_EdgeRadius: 0
|
||||
--- !u!114 &-1351644667867233305
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5431987895376475548}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 6f6b772eb5e369b4297e0ac00baf35c1, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
syncMode: 0
|
||||
syncInterval: 0.1
|
||||
--- !u!1 &5431987895404559667
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -472,7 +487,7 @@ SpriteRenderer:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5431987895404559667}
|
||||
m_Enabled: 1
|
||||
m_Enabled: 0
|
||||
m_CastShadows: 0
|
||||
m_ReceiveShadows: 0
|
||||
m_DynamicOccludee: 1
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -38,7 +38,7 @@ RenderSettings:
|
||||
m_ReflectionIntensity: 1
|
||||
m_CustomReflection: {fileID: 0}
|
||||
m_Sun: {fileID: 0}
|
||||
m_IndirectSpecularColor: {r: 0.44657874, g: 0.49641258, b: 0.5748172, a: 1}
|
||||
m_IndirectSpecularColor: {r: 0.4465791, g: 0.4964133, b: 0.57481784, a: 1}
|
||||
m_UseRadianceAmbientProbe: 0
|
||||
--- !u!157 &3
|
||||
LightmapSettings:
|
||||
@@ -148,7 +148,7 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5820110}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -70.8, y: 32.1, z: 0}
|
||||
m_LocalPosition: {x: -202, y: -89, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 945516891}
|
||||
@@ -343,7 +343,7 @@ MonoBehaviour:
|
||||
offlineScene:
|
||||
onlineScene:
|
||||
transport: {fileID: 42724090}
|
||||
networkAddress: vps.playpoolstudios.com
|
||||
networkAddress: localhost
|
||||
maxConnections: 100
|
||||
authenticator: {fileID: 0}
|
||||
playerPrefab: {fileID: 5431987895376475548, guid: e811a838f2ebb2f4fb8055331ed295e9, type: 3}
|
||||
@@ -560,7 +560,7 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 290750407}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -29.6, y: 13.9, z: 0}
|
||||
m_LocalPosition: {x: -501.6, y: -517.1, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 945516891}
|
||||
@@ -644,8 +644,6 @@ MonoBehaviour:
|
||||
maxMoons: 700
|
||||
maxStars: 1000
|
||||
pickupItemsParent: {fileID: 41572335}
|
||||
ActiveMoons: []
|
||||
ActiveStars: []
|
||||
moon: {fileID: 5339383961425506408, guid: ad54ea1b437d2b344add56c18d1efb3e, type: 3}
|
||||
star: {fileID: 8298505072154104440, guid: 8cfd89c315493e64782e167885b4b498, type: 3}
|
||||
--- !u!114 &332697611
|
||||
@@ -1002,7 +1000,7 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 494509960}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 30.7, y: -23.5, z: 0}
|
||||
m_LocalPosition: {x: -678, y: -58, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 945516891}
|
||||
@@ -1277,7 +1275,7 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 613727044}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 48.5, y: 22.2, z: 0}
|
||||
m_LocalPosition: {x: -571, y: -748, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 945516891}
|
||||
@@ -1461,6 +1459,88 @@ Transform:
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 7
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &725845372
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 725845374}
|
||||
- component: {fileID: 725845373}
|
||||
m_Layer: 0
|
||||
m_Name: zone
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!212 &725845373
|
||||
SpriteRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 725845372}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 0
|
||||
m_ReceiveShadows: 0
|
||||
m_DynamicOccludee: 1
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_RayTracingMode: 0
|
||||
m_RayTraceProcedural: 0
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
|
||||
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: 6
|
||||
m_Sprite: {fileID: 21300000, guid: b13494c371b6846459b600453cf3fe38, type: 3}
|
||||
m_Color: {r: 0.33962262, g: 0.07529369, b: 0.07529369, a: 0.4392157}
|
||||
m_FlipX: 0
|
||||
m_FlipY: 0
|
||||
m_DrawMode: 0
|
||||
m_Size: {x: 40.96, y: 40.96}
|
||||
m_AdaptiveModeThreshold: 0.5
|
||||
m_SpriteTileMode: 0
|
||||
m_WasSpriteAssigned: 1
|
||||
m_MaskInteraction: 0
|
||||
m_SpriteSortPoint: 0
|
||||
--- !u!4 &725845374
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 725845372}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 32.2, y: 32.2, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 10
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &731361769
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -1644,7 +1724,7 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 871230063}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -30.9, y: -19.5, z: 0}
|
||||
m_LocalPosition: {x: -264, y: -527, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 945516891}
|
||||
@@ -2339,7 +2419,7 @@ SpriteRenderer:
|
||||
m_FlipX: 0
|
||||
m_FlipY: 0
|
||||
m_DrawMode: 2
|
||||
m_Size: {x: 1000, y: 1000}
|
||||
m_Size: {x: 1301.0698, y: 1271.4567}
|
||||
m_AdaptiveModeThreshold: 0
|
||||
m_SpriteTileMode: 1
|
||||
m_WasSpriteAssigned: 1
|
||||
@@ -2353,7 +2433,7 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1259726041}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0.6222, y: -6.3147, z: 0}
|
||||
m_LocalPosition: {x: 3.09, y: 6.0244, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
@@ -2538,7 +2618,7 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1398901126}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 77, y: 26.7, z: 0}
|
||||
m_LocalPosition: {x: -642, y: -349, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 945516891}
|
||||
@@ -2581,7 +2661,7 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1474265870}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 43.5, y: -18.6, z: 0}
|
||||
m_LocalPosition: {x: -270, y: -746, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 945516891}
|
||||
@@ -2704,7 +2784,7 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1837953383}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 17.4, y: 2.9, z: 0}
|
||||
m_LocalPosition: {x: -356, y: -510, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 945516891}
|
||||
@@ -2747,7 +2827,7 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1853399998}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalPosition: {x: -472, y: -531, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 945516891}
|
||||
@@ -2790,7 +2870,7 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1874776082}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -60.5, y: -6.2, z: 0}
|
||||
m_LocalPosition: {x: -511, y: -347, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 945516891}
|
||||
|
||||
BIN
Assets/Game/Scenes/Minigame/gameplay/zone.png
Normal file
BIN
Assets/Game/Scenes/Minigame/gameplay/zone.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 40 KiB |
120
Assets/Game/Scenes/Minigame/gameplay/zone.png.meta
Normal file
120
Assets/Game/Scenes/Minigame/gameplay/zone.png.meta
Normal file
@@ -0,0 +1,120 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b13494c371b6846459b600453cf3fe38
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 11
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: 0
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 8
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Android
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID: 5e97eb03825dee720800000000000000
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -5,93 +5,164 @@ using Mirror;
|
||||
|
||||
public class MinigameManager : NetworkBehaviour
|
||||
{
|
||||
public static MinigameManager instance;
|
||||
public float mapRadius;
|
||||
public int maxMoons, maxStars = 100;
|
||||
public Transform pickupItemsParent;
|
||||
public List<PickupItem> ActiveMoons = new List<PickupItem>();
|
||||
public List<PickupItem> ActiveStars = new List<PickupItem>();
|
||||
private List<PickupItem> ActiveMoons = new List<PickupItem>();
|
||||
private List<PickupItem> ActiveStars = new List<PickupItem>();
|
||||
|
||||
List<PickupItem> MoonPool = new List<PickupItem>();
|
||||
List<PickupItem> StarsPool = new List<PickupItem>();
|
||||
public GameObject moon;
|
||||
public GameObject star;
|
||||
|
||||
private void Awake() {
|
||||
SceneData.GameManager=this;
|
||||
private void Awake()
|
||||
{
|
||||
SceneData.GameManager = this;
|
||||
instance = this;
|
||||
}
|
||||
|
||||
void Update(){
|
||||
void Update()
|
||||
{
|
||||
|
||||
if(!isServer){return;}
|
||||
if (!isServer) { return; }
|
||||
|
||||
HandlePickupSpawn();
|
||||
KillOutOfBoundsPlayers();
|
||||
|
||||
}
|
||||
|
||||
void KillOutOfBoundsPlayers()
|
||||
{
|
||||
SpaceshipController[] players = FindObjectsOfType<SpaceshipController>();
|
||||
foreach (SpaceshipController player in players)
|
||||
{
|
||||
if (Vector3.Distance(player.transform.position, Vector3.zero) > mapRadius)
|
||||
{
|
||||
//Out of bounds. Kill him
|
||||
player.Die("Playzone");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HandlePickupSpawn()
|
||||
{
|
||||
int moonsNeed = maxMoons - ActiveMoons.Count;
|
||||
int starsNeed = maxStars - ActiveStars.Count;
|
||||
|
||||
if(moonsNeed > 0){ // <-- We need more moons!
|
||||
for(int i =0; i < moonsNeed; i++){
|
||||
if(MoonPool.Count > 0){ // <-- Got some in the pool, no need to spawn new
|
||||
PickupItem pickedMoon = MoonPool[0];
|
||||
pickedMoon.Reposition(getRandomPositionOnMap());
|
||||
|
||||
ActiveMoons.Add(pickedMoon);
|
||||
MoonPool.RemoveAt(0);
|
||||
}else{
|
||||
GameObject newMoon = Instantiate(moon,pickupItemsParent);
|
||||
NetworkServer.Spawn(newMoon);
|
||||
newMoon.GetComponent<PickupItem>().Reposition(getRandomPositionOnMap());
|
||||
ActiveMoons.Add(newMoon.GetComponent<PickupItem>());
|
||||
}
|
||||
}
|
||||
if (moonsNeed > 0)
|
||||
{ // <-- We need more moons!
|
||||
SpawnMoons(moonsNeed);
|
||||
}
|
||||
|
||||
if(starsNeed > 0){ // <-- We need more moons!
|
||||
for(int i =0; i < starsNeed; i++){
|
||||
if(StarsPool.Count > 0){ // <-- Got some in the pool, no need to spawn new
|
||||
PickupItem pickedStar = StarsPool[0];
|
||||
pickedStar.Reposition(getRandomPositionOnMap());
|
||||
|
||||
ActiveStars.Add(pickedStar);
|
||||
StarsPool.RemoveAt(0);
|
||||
}else{
|
||||
GameObject newStar = Instantiate(star,pickupItemsParent);
|
||||
NetworkServer.Spawn(newStar);
|
||||
newStar.GetComponent<PickupItem>().Reposition(getRandomPositionOnMap());
|
||||
ActiveStars.Add(newStar.GetComponent<PickupItem>());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (starsNeed > 0)
|
||||
{ // <-- We need more moons!
|
||||
SpawnStars(starsNeed);
|
||||
}
|
||||
}
|
||||
|
||||
public void DeactivatePickupItem(PickupItem item){
|
||||
if(item.type == PickupItem.PickupType.Moon){
|
||||
public void SpawnLeftoverPickups(Vector3 position, int amount)
|
||||
{
|
||||
SpawnStars(amount, focusedPosition: position);
|
||||
}
|
||||
|
||||
void SpawnStars(int amount, Vector3? focusedPosition = null)
|
||||
{
|
||||
for (int i = 0; i < amount; i++)
|
||||
{
|
||||
Vector3 newPosition = (focusedPosition == null) ? getRandomPositionOnMap() : getRandomPointInCirlce((Vector3)focusedPosition, 10);
|
||||
if (StarsPool.Count > 0)
|
||||
{ // <-- Got some in the pool, no need to spawn new
|
||||
PickupItem pickedStar = StarsPool[0];
|
||||
pickedStar.Reposition(newPosition);
|
||||
|
||||
ActiveStars.Add(pickedStar);
|
||||
StarsPool.RemoveAt(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameObject newStar = Instantiate(star, pickupItemsParent);
|
||||
NetworkServer.Spawn(newStar);
|
||||
newStar.GetComponent<PickupItem>().Reposition(newPosition);
|
||||
ActiveStars.Add(newStar.GetComponent<PickupItem>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SpawnMoons(int amount)
|
||||
{
|
||||
for (int i = 0; i < amount; i++)
|
||||
{
|
||||
if (MoonPool.Count > 0)
|
||||
{ // <-- Got some in the pool, no need to spawn new
|
||||
PickupItem pickedMoon = MoonPool[0];
|
||||
pickedMoon.Reposition(getRandomPositionOnMap());
|
||||
|
||||
ActiveMoons.Add(pickedMoon);
|
||||
MoonPool.RemoveAt(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameObject newMoon = Instantiate(moon, pickupItemsParent);
|
||||
NetworkServer.Spawn(newMoon);
|
||||
newMoon.GetComponent<PickupItem>().Reposition(getRandomPositionOnMap());
|
||||
ActiveMoons.Add(newMoon.GetComponent<PickupItem>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void DeactivatePickupItem(PickupItem item)
|
||||
{
|
||||
if (item.type == PickupItem.PickupType.Moon)
|
||||
{
|
||||
ActiveMoons.Remove(item);
|
||||
MoonPool.Add(item);
|
||||
}else if(item.type == PickupItem.PickupType.Star){
|
||||
}
|
||||
else if (item.type == PickupItem.PickupType.Star)
|
||||
{
|
||||
ActiveStars.Remove(item);
|
||||
StarsPool.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetRespawn(GameObject player){
|
||||
public void SetRespawn(GameObject player)
|
||||
{
|
||||
StartCoroutine(setRespawn(player));
|
||||
}
|
||||
|
||||
IEnumerator setRespawn(GameObject player){
|
||||
if(isServer){
|
||||
IEnumerator setRespawn(GameObject player)
|
||||
{
|
||||
if (isServer)
|
||||
{
|
||||
player.SetActive(false);
|
||||
yield return new WaitForSeconds(3);
|
||||
Vector3 RespawnPoint = NetworkManager.startPositions[Random.Range(0, NetworkManager.startPositions.Count-1)].position;
|
||||
|
||||
Vector3 RespawnPoint = NetworkManager.startPositions[Random.Range(0, NetworkManager.startPositions.Count - 1)].position;
|
||||
|
||||
player.GetComponent<SpaceshipController>().Respawn(RespawnPoint);
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
yield return new WaitForSeconds(1);
|
||||
}
|
||||
}
|
||||
|
||||
Vector3 getRandomPositionOnMap(){
|
||||
return new Vector3(Random.Range(-mapRadius, mapRadius), Random.Range(-mapRadius,mapRadius));
|
||||
Vector3 getRandomPositionOnMap()
|
||||
{
|
||||
return getRandomPointInCirlce(Vector3.zero, mapRadius);
|
||||
}
|
||||
|
||||
void OnDrawGizmos() {
|
||||
Gizmos.DrawWireSphere(transform.position, mapRadius);
|
||||
Vector3 getRandomPointInCirlce(Vector3 center, float radius)
|
||||
{
|
||||
float r = radius * Mathf.Sqrt(Random.Range(0f, 1f));
|
||||
float theta = Random.Range(0f, 1f) * 2 * Mathf.PI;
|
||||
float x = center.x + r * Mathf.Cos(theta);
|
||||
float y = center.y + r * Mathf.Sin(theta);
|
||||
return new Vector3(x, y);
|
||||
}
|
||||
|
||||
void OnDrawGizmos()
|
||||
{
|
||||
Gizmos.DrawWireSphere(transform.position, mapRadius);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,91 +1,91 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Mirror;
|
||||
public class PickupItem : NetworkBehaviour
|
||||
{
|
||||
public PickupType type;
|
||||
public float radius=1;
|
||||
public Color gizmoColor = Color.green;
|
||||
public bool active = true;
|
||||
|
||||
|
||||
void Update()
|
||||
{
|
||||
if(!isServer){return;}
|
||||
if(!active){return;}
|
||||
|
||||
Collider2D hit = Physics2D.OverlapCircle(transform.position, radius);
|
||||
if(hit!=null && hit.GetComponent<SpaceshipController>()!=null){
|
||||
Debug.Log(hit.GetComponent<SpaceshipController>().pname +$" collected me at {transform.position}");
|
||||
hit.GetComponent<SpaceshipController>().CollectPickup(type);
|
||||
active=false;
|
||||
Deactivate();
|
||||
}
|
||||
}
|
||||
|
||||
public void Reposition(Vector3 newPosition){
|
||||
if(isServer){
|
||||
reposition(newPosition);
|
||||
|
||||
RpcReposition(newPosition);
|
||||
}else{
|
||||
CmdReposition(newPosition);
|
||||
}
|
||||
}
|
||||
|
||||
[Command]
|
||||
void CmdReposition(Vector3 newPosition){
|
||||
reposition(newPosition);
|
||||
|
||||
RpcReposition(newPosition);
|
||||
}
|
||||
|
||||
[ClientRpc]
|
||||
void RpcReposition(Vector3 newPosition){
|
||||
reposition(newPosition);
|
||||
}
|
||||
|
||||
void reposition(Vector3 newPosition){
|
||||
active=true;
|
||||
transform.position = newPosition;
|
||||
gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
public void Deactivate(){
|
||||
if(isServer){
|
||||
deactivate();
|
||||
RpcDeactivate();
|
||||
}else{
|
||||
CmdDeactivate();
|
||||
}
|
||||
}
|
||||
|
||||
void deactivate(){
|
||||
active=false;
|
||||
gameObject.SetActive(false);
|
||||
SceneData.GameManager.DeactivatePickupItem(this);
|
||||
}
|
||||
|
||||
[Command]
|
||||
void CmdDeactivate(){
|
||||
deactivate();
|
||||
RpcDeactivate();
|
||||
}
|
||||
|
||||
[ClientRpc]
|
||||
void RpcDeactivate(){
|
||||
deactivate();
|
||||
}
|
||||
|
||||
private void OnDrawGizmos() {
|
||||
Gizmos.color = gizmoColor;
|
||||
Gizmos.DrawWireSphere(transform.position,radius);
|
||||
}
|
||||
|
||||
public enum PickupType{
|
||||
Star,
|
||||
Moon
|
||||
}
|
||||
}
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Mirror;
|
||||
public class PickupItem : NetworkBehaviour
|
||||
{
|
||||
public PickupType type;
|
||||
public float radius=1;
|
||||
public Color gizmoColor = Color.green;
|
||||
public bool active = true;
|
||||
|
||||
|
||||
void Update()
|
||||
{
|
||||
if(!isServer){return;}
|
||||
if(!active){return;}
|
||||
|
||||
Collider2D hit = Physics2D.OverlapCircle(transform.position, radius);
|
||||
if(hit!=null && hit.GetComponent<SpaceshipController>()!=null){
|
||||
Debug.Log(hit.GetComponent<SpaceshipController>().pname +$" collected me at {transform.position}");
|
||||
hit.GetComponent<SpaceshipController>().CollectPickup(type);
|
||||
active=false;
|
||||
Deactivate();
|
||||
}
|
||||
}
|
||||
|
||||
public void Reposition(Vector3 newPosition){
|
||||
if(isServer){
|
||||
reposition(newPosition);
|
||||
|
||||
RpcReposition(newPosition);
|
||||
}else{
|
||||
CmdReposition(newPosition);
|
||||
}
|
||||
}
|
||||
|
||||
[Command]
|
||||
void CmdReposition(Vector3 newPosition){
|
||||
reposition(newPosition);
|
||||
|
||||
RpcReposition(newPosition);
|
||||
}
|
||||
|
||||
[ClientRpc]
|
||||
void RpcReposition(Vector3 newPosition){
|
||||
reposition(newPosition);
|
||||
}
|
||||
|
||||
void reposition(Vector3 newPosition){
|
||||
active=true;
|
||||
transform.position = newPosition;
|
||||
gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
public void Deactivate(){
|
||||
if(isServer){
|
||||
deactivate();
|
||||
RpcDeactivate();
|
||||
}else{
|
||||
CmdDeactivate();
|
||||
}
|
||||
}
|
||||
|
||||
void deactivate(){
|
||||
active=false;
|
||||
gameObject.SetActive(false);
|
||||
SceneData.GameManager.DeactivatePickupItem(this);
|
||||
}
|
||||
|
||||
[Command]
|
||||
void CmdDeactivate(){
|
||||
deactivate();
|
||||
RpcDeactivate();
|
||||
}
|
||||
|
||||
[ClientRpc]
|
||||
void RpcDeactivate(){
|
||||
deactivate();
|
||||
}
|
||||
|
||||
private void OnDrawGizmos() {
|
||||
Gizmos.color = gizmoColor;
|
||||
Gizmos.DrawWireSphere(transform.position,radius);
|
||||
}
|
||||
|
||||
public enum PickupType{
|
||||
Star,
|
||||
Moon
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
44
Assets/Game/Scripts/Minigame/PositionUnitTest.cs
Normal file
44
Assets/Game/Scripts/Minigame/PositionUnitTest.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using Mirror;
|
||||
|
||||
public class PositionUnitTest : NetworkBehaviour
|
||||
{
|
||||
Logger logger = null;
|
||||
SpaceshipController _controller;
|
||||
void Start(){
|
||||
_controller = GetComponent<SpaceshipController>();
|
||||
}
|
||||
void FixedUpdate()
|
||||
{
|
||||
if(logger == null){
|
||||
if(_controller.pname.Length>0){
|
||||
logger= new Logger(_controller.pname);
|
||||
}
|
||||
return;
|
||||
}
|
||||
logger.Log($"time: {NetworkTime.time}, pos: {transform.position}, rot: {transform.rotation}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class Logger{
|
||||
private string name;
|
||||
public string Name=> name;
|
||||
public string FileLocation => $"{Application.dataPath}/{name}.log";
|
||||
|
||||
public Logger(string _name){
|
||||
name=_name;
|
||||
if(File.Exists(FileLocation)){
|
||||
File.Delete(FileLocation);
|
||||
}
|
||||
File.WriteAllText(FileLocation, $"[{System.DateTime.Now}]Log Created\n");
|
||||
Debug.Log($"Logger initiated at {FileLocation}");
|
||||
}
|
||||
|
||||
public void Log(string newData){
|
||||
File.AppendAllText(FileLocation, $"{newData}\n");
|
||||
}
|
||||
}
|
||||
11
Assets/Game/Scripts/Minigame/PositionUnitTest.cs.meta
Normal file
11
Assets/Game/Scripts/Minigame/PositionUnitTest.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6f6b772eb5e369b4297e0ac00baf35c1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -38,6 +38,8 @@ public class SpaceshipController : NetworkBehaviour
|
||||
|
||||
public bool showDebugHUD = false;
|
||||
|
||||
public float distanceFromCenter= 0;
|
||||
|
||||
[Command]
|
||||
void CmdSetPname(string value){
|
||||
pname = value;
|
||||
@@ -118,6 +120,7 @@ public class SpaceshipController : NetworkBehaviour
|
||||
int lastClientUpdateTime = 0;
|
||||
void FixedUpdate()
|
||||
{
|
||||
distanceFromCenter = Vector3.Distance(transform.position, Vector3.zero);
|
||||
pnameTxt.rectTransform.rotation = Quaternion.Euler(Vector3.zero);
|
||||
|
||||
//Update size of trail and spaceship
|
||||
@@ -399,8 +402,7 @@ public class SpaceshipController : NetworkBehaviour
|
||||
if(deadPlayer!=null && !deadPlayer.dead){ // <-- okay we killed someone | KILLCODE
|
||||
deadPlayer.Die(pname);
|
||||
Debug.Log($"{pname} killed {deadPlayer.pname}");
|
||||
OnKill();
|
||||
|
||||
OnKill();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -436,16 +438,19 @@ public class SpaceshipController : NetworkBehaviour
|
||||
}
|
||||
|
||||
public void Die(string killer){
|
||||
|
||||
MinigameManager.instance.SpawnLeftoverPickups(transform.position, Scores);
|
||||
Debug.Log($"Sending death signal to {pname} by {killer}");
|
||||
|
||||
//Handle Respawning
|
||||
OnScaleChanged(scaleMultiplier,1);
|
||||
scaleMultiplier=1;
|
||||
dead=true;
|
||||
Scores=0;
|
||||
trailTime = 1;
|
||||
trailMgr.trail.time = trailTime;
|
||||
RpcDie(killer);
|
||||
FindObjectOfType<MinigameManager>().SetRespawn(gameObject);
|
||||
MinigameManager.instance.SetRespawn(gameObject);
|
||||
}
|
||||
|
||||
[ClientRpc]
|
||||
|
||||
17211
Assets/UserNotAlive.log
Normal file
17211
Assets/UserNotAlive.log
Normal file
File diff suppressed because it is too large
Load Diff
7
Assets/UserNotAlive.log.meta
Normal file
7
Assets/UserNotAlive.log.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 31450d7d6f348b9709a545dbc246e973
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user