Fixed Blocks Not Placing For Clients

This commit is contained in:
Julia Butenhoff 2022-02-04 20:02:55 -06:00
parent 215d709915
commit b278e511ff
6 changed files with 174 additions and 35 deletions

View File

@ -12,7 +12,6 @@ GameObject:
- component: {fileID: 8183403963077248726}
- component: {fileID: 8183403963077248727}
- component: {fileID: 8183403963077248720}
- component: {fileID: 8183403963077248721}
m_Layer: 5
m_Name: 'King Canvas '
m_TagString: Untagged
@ -101,27 +100,6 @@ MonoBehaviour:
m_BlockingMask:
serializedVersion: 2
m_Bits: 4294967295
--- !u!114 &8183403963077248721
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8183403963077248722}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1b197075b52c7e644a525bf0ff3f69a7, type: 3}
m_Name:
m_EditorClassIdentifier:
Thunderstorm: {fileID: 0}
Block: {fileID: 8322169750614848705, guid: 14529042a14497c499bdce8f966e884c, type: 3}
HailSprite: {fileID: 0}
HailObject: {fileID: 0}
Slime: {fileID: 0}
KingCam: {fileID: 8183403964090928733}
LayerMask:
serializedVersion: 2
m_Bits: 64
--- !u!1 &8183403963399572359
GameObject:
m_ObjectHideFlags: 0
@ -401,9 +379,9 @@ MonoBehaviour:
m_OnClick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 8183403963077248721}
- m_Target: {fileID: 4195644339311798069}
m_TargetAssemblyTypeName: KingPlace, Assembly-CSharp
m_MethodName: OnThundClicked
m_MethodName: OnThunderClicked
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
@ -428,6 +406,7 @@ GameObject:
- component: {fileID: 8183403963968820412}
- component: {fileID: -3822619241858280905}
- component: {fileID: 5428221257691747992}
- component: {fileID: 4195644339311798069}
m_Layer: 0
m_Name: King
m_TagString: Player
@ -591,6 +570,28 @@ MonoBehaviour:
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!114 &4195644339311798069
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8183403963968820413}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1b197075b52c7e644a525bf0ff3f69a7, type: 3}
m_Name:
m_EditorClassIdentifier:
Thunderstorm: {fileID: 0}
Block: {fileID: 8322169750614848705, guid: 14529042a14497c499bdce8f966e884c, type: 3}
BlockWithoutNetwork: {fileID: 5704254083382235334, guid: f56dedeb24725ab4a844690df1d5d3cd, type: 3}
HailSprite: {fileID: 0}
HailObject: {fileID: 0}
Slime: {fileID: 0}
KingCam: {fileID: 8183403964090928733}
LayerMask:
serializedVersion: 2
m_Bits: 64
--- !u!1 &8183403964090928728
GameObject:
m_ObjectHideFlags: 0
@ -874,7 +875,7 @@ MonoBehaviour:
m_OnClick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 8183403963077248721}
- m_Target: {fileID: 4195644339311798069}
m_TargetAssemblyTypeName: KingPlace, Assembly-CSharp
m_MethodName: OnBlockClicked
m_Mode: 1
@ -1043,7 +1044,7 @@ MonoBehaviour:
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: Thunderstorm
m_Text: Thunder
--- !u!1 &8183403965182652615
GameObject:
m_ObjectHideFlags: 0
@ -1165,7 +1166,7 @@ MonoBehaviour:
m_OnClick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 8183403963077248721}
- m_Target: {fileID: 4195644339311798069}
m_TargetAssemblyTypeName: KingPlace, Assembly-CSharp
m_MethodName: OnHailClicked
m_Mode: 1
@ -1298,7 +1299,7 @@ MonoBehaviour:
m_OnClick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 8183403963077248721}
- m_Target: {fileID: 4195644339311798069}
m_TargetAssemblyTypeName: KingPlace, Assembly-CSharp
m_MethodName: OnSlimeClicked
m_Mode: 1

View File

@ -0,0 +1,111 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &5704254083382235334
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7316280474503270304}
- component: {fileID: 8193877025775761519}
- component: {fileID: 4313844460143191416}
- component: {fileID: 4855766791970369095}
- component: {fileID: 7133238326309539709}
m_Layer: 0
m_Name: KingBlockWithoutNetwork
m_TagString: destroyable
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &7316280474503270304
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5704254083382235334}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 150, y: 150, z: 150}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &8193877025775761519
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5704254083382235334}
m_Mesh: {fileID: 1360138328677090702, guid: d583fb6b27d23a849b80c1ea7d813943, type: 3}
--- !u!23 &4313844460143191416
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5704254083382235334}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 6c91995b59246b74ab6bb66d20eb7562, 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: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!65 &4855766791970369095
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5704254083382235334}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 0.129032, y: 0.129032, z: 0.129032}
m_Center: {x: 0, y: 0.064516, z: 0}
--- !u!114 &7133238326309539709
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5704254083382235334}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5fa71751031fd4542bb5ef0d2c9672cf, type: 3}
m_Name:
m_EditorClassIdentifier:
health: 3

View File

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

View File

@ -19,7 +19,6 @@ public class GridReveal : MonoBehaviour
for (int i = Rows.Length-1; i > ROSCount-1; i--) {// Disables most of the Rows that the King can't see
Rows[i].SetActive(false);
}
gameObject.SetActive(false);
}
public void GridSwitch(bool State) {//Activates or deactivates the Grid

View File

@ -15,6 +15,18 @@ public class KingMove : MonoBehaviour
Grid = GameObject.FindGameObjectWithTag("KingGrid");
}
void Start()
{
// Turn on the king grid after a couple seconds. Allows scripts to grab their reference to it before it is disabled
StartCoroutine(TurnOffGridAtStartOfMatch());
}
IEnumerator TurnOffGridAtStartOfMatch()
{
yield return new WaitForSecondsRealtime(0.5f);
Grid.GetComponent<GridReveal>().GridSwitch(false);
}
// Update is called once per frame
void Update() {
float translation = Input.GetAxis("KingMove") * speed;

View File

@ -1,9 +1,10 @@
using System.Collections;
using System.Collections.Generic;
using MLAPI;
using MLAPI.Messaging;
using UnityEngine;
public class KingPlace : MonoBehaviour
public class KingPlace : NetworkBehaviour
{
//Is called when the King clicks on the Block button
@ -23,12 +24,14 @@ public class KingPlace : MonoBehaviour
public GameObject Thunderstorm;
//Is called when the King clicks on the Thunderstorm button
public void OnThundClicked() {
public void OnThunderClicked() {
//TODO Spawn thunderstorms on the players
}
public GameObject Block;
public GameObject BlockWithoutNetwork;
public GameObject HailSprite;
public GameObject HailObject;
public GameObject Slime;
@ -53,7 +56,7 @@ public class KingPlace : MonoBehaviour
//Switch statement, ID-0 = Block,ID-1 = Hail,ID-2 = Slime
switch (ID) {//Parses in the button clicked into the right object that the King is placing
case 0:
Place = Block;
Place = BlockWithoutNetwork;
break;
case 1:
Place = HailSprite;
@ -108,7 +111,6 @@ public class KingPlace : MonoBehaviour
int Box = (int)y; //Rounds it down
int x = (RowNumb * -BoxSize) + 101;//Sets it's X to the X of the Row
int z = (Box * -BoxSize) + 906;//Sets its Z to the Z of the Box
//PlaceTemp.transform.position = new Vector3(x, PlaceTemp.transform.position.y, z);//fully snaps it to the grid
// Grid Check first for valid location
GridCheck(RowNumb, Box, ref FirstPlacing);//Makes sure the Box is a valid position
@ -116,9 +118,11 @@ public class KingPlace : MonoBehaviour
// Instantiate a networked box at the position
if (FirstPlacing == false)
{
// Calculate the position to spawn at
Vector3 spawnLoc = new Vector3(x, PlaceTemp.transform.position.y, z);
boxPlaced = Instantiate(PlaceTemp, spawnLoc, Quaternion.identity);
boxPlaced.GetComponent<NetworkObject>().Spawn(null, true);
// Have the server spawn the box
SpawnBoxServerRPC(spawnLoc);
// Remove the reference to PlaceTemp
Destroy(PlaceTemp);
@ -164,4 +168,9 @@ public class KingPlace : MonoBehaviour
}
}
[ServerRpc(RequireOwnership = false)]
private void SpawnBoxServerRPC(Vector3 spawnLoc) {
boxPlaced = Instantiate(Block, spawnLoc, Quaternion.identity);
boxPlaced.GetComponent<NetworkObject>().Spawn(null, true);
}
}