ForeSight VFX Fix Cursor Addition, Ability UI, Platform Shapes

dev-main
Ali Sharoz 6 days ago
parent dd209dd3da
commit 33363da571

@ -2,19 +2,25 @@
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
serializedVersion: 8
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: WindS
m_Shader: {fileID: 4800000, guid: 60ebdfbe66389c449a414da5266da8e6, type: 3}
m_ShaderKeywords: _SIDEOPACITY_ON
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords:
- _SIDEOPACITY_ON
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
@ -26,6 +32,7 @@ Material:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _CullMode: 0
- _Depthpower: 1
@ -45,3 +52,4 @@ Material:
- _EmissionRGB: {r: 1, g: 0.4, b: 0.4, a: 1}
- _NoisespeedXY: {r: 0, g: 0, b: 0, a: 0}
- _TintColor: {r: 1, g: 1, b: 1, a: 1}
m_BuildTextureStacks: []

@ -70,15 +70,15 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 4185353098247508, guid: 2c925d5a2a53b164facec46c461cbf08, type: 3}
propertyPath: m_LocalScale.x
value: 0.2
value: 0.6
objectReference: {fileID: 0}
- target: {fileID: 4185353098247508, guid: 2c925d5a2a53b164facec46c461cbf08, type: 3}
propertyPath: m_LocalScale.y
value: 0.3
value: 0.90000004
objectReference: {fileID: 0}
- target: {fileID: 4185353098247508, guid: 2c925d5a2a53b164facec46c461cbf08, type: 3}
propertyPath: m_LocalScale.z
value: 0.2
value: 0.6
objectReference: {fileID: 0}
- target: {fileID: 4185353098247508, guid: 2c925d5a2a53b164facec46c461cbf08, type: 3}
propertyPath: m_LocalPosition.x
@ -122,23 +122,31 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 4185353098247508, guid: 2c925d5a2a53b164facec46c461cbf08, type: 3}
propertyPath: m_ConstrainProportionsScale
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4607482767239554, guid: 2c925d5a2a53b164facec46c461cbf08, type: 3}
propertyPath: m_LocalScale.x
value: 0.1
value: 0.3
objectReference: {fileID: 0}
- target: {fileID: 4607482767239554, guid: 2c925d5a2a53b164facec46c461cbf08, type: 3}
propertyPath: m_LocalScale.y
value: 0.2
value: 0.6
objectReference: {fileID: 0}
- target: {fileID: 4607482767239554, guid: 2c925d5a2a53b164facec46c461cbf08, type: 3}
propertyPath: m_LocalScale.z
value: 0.1
value: 0.3
objectReference: {fileID: 0}
- target: {fileID: 4607482767239554, guid: 2c925d5a2a53b164facec46c461cbf08, type: 3}
propertyPath: m_LocalPosition.x
value: -1.31
objectReference: {fileID: 0}
- target: {fileID: 4607482767239554, guid: 2c925d5a2a53b164facec46c461cbf08, type: 3}
propertyPath: m_ConstrainProportionsScale
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 198937496368903046, guid: 2c925d5a2a53b164facec46c461cbf08, type: 3}
propertyPath: InitialModule.startColor.maxColor.a
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []

@ -59,6 +59,10 @@ MonoBehaviour:
cursorSprite: {fileID: 21300000, guid: 95df65ca6b071bc46abc311e5df6c825, type: 3}
- state: 5
cursorSprite: {fileID: 21300000, guid: dd87f236e3b9ed340981d46ddd4c4b4d, type: 3}
- state: 6
cursorSprite: {fileID: 21300000, guid: c06f03bfa5a475d4e8369a8da969bf27, type: 3}
- state: 7
cursorSprite: {fileID: 21300000, guid: 51426df4432f6414899c4bef10e4687a, type: 3}
cursorObject: {fileID: 3100281247147120253}
--- !u!1 &3100281247147120253
GameObject:

@ -29,7 +29,7 @@ Transform:
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_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -129,7 +129,7 @@ LineRenderer:
numCornerVertices: 0
numCapVertices: 0
alignment: 0
textureMode: 0
textureMode: 1
textureScale: {x: 1, y: 1}
shadowBias: 0.5
generateLightingData: 0
@ -152,4 +152,4 @@ MonoBehaviour:
lineRenderer: {fileID: 9057376229307534297}
scrollingMaterial: {fileID: 2100000, guid: 77e5ea3a019674146a9f2b3ed629b386, type: 2}
speed: 1
tiling: 0.28
tiling: 0.5

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

File diff suppressed because it is too large Load Diff

@ -371,10 +371,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Platforms: []
numberOfPlayers: 5
platforms: []
platformTransforms: []
centerPoint: {fileID: 0}
centerPoint: {fileID: 286165427}
shapeRadius: 5
--- !u!114 &286165429
MonoBehaviour:
@ -1853,6 +1850,7 @@ GameObject:
- component: {fileID: 249976107358570841}
- component: {fileID: 249976107358570840}
- component: {fileID: 249976107358570842}
- component: {fileID: 249976107358570843}
m_Layer: 0
m_Name: SM_Env_Hell_Circle_01 (1)
m_TagString: Untagged
@ -1984,6 +1982,37 @@ MonoBehaviour:
m_EditorClassIdentifier:
outlineMaterial: {fileID: 2100000, guid: 7d59a0e48d5e5a34bbc8919ff8e3cecd, type: 2}
outlineWidth: 0.1
--- !u!114 &249976107358570843
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 248836275302926266}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e96cb6065543e43c4a752faaa1468eb1, type: 3}
m_Name:
m_EditorClassIdentifier:
UseUnreliableDeltas: 0
SyncPositionX: 1
SyncPositionY: 1
SyncPositionZ: 1
SyncRotAngleX: 1
SyncRotAngleY: 1
SyncRotAngleZ: 1
SyncScaleX: 1
SyncScaleY: 1
SyncScaleZ: 1
PositionThreshold: 0.001
RotAngleThreshold: 0.01
ScaleThreshold: 0.01
UseQuaternionSynchronization: 0
UseQuaternionCompression: 0
UseHalfFloatPrecision: 0
InLocalSpace: 0
Interpolate: 1
SlerpPosition: 0
--- !u!33 &1189011597376318600
MeshFilter:
m_ObjectHideFlags: 0
@ -2066,6 +2095,7 @@ GameObject:
- component: {fileID: 1223475210011116505}
- component: {fileID: 1223475210011116504}
- component: {fileID: 1223475210011116506}
- component: {fileID: 1223475210011116507}
m_Layer: 0
m_Name: SM_Env_Hell_Circle_01 (3)
m_TagString: Untagged
@ -2197,6 +2227,37 @@ MonoBehaviour:
m_EditorClassIdentifier:
outlineMaterial: {fileID: 2100000, guid: 7d59a0e48d5e5a34bbc8919ff8e3cecd, type: 2}
outlineWidth: 0.1
--- !u!114 &1223475210011116507
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1222362877196586298}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e96cb6065543e43c4a752faaa1468eb1, type: 3}
m_Name:
m_EditorClassIdentifier:
UseUnreliableDeltas: 0
SyncPositionX: 1
SyncPositionY: 1
SyncPositionZ: 1
SyncRotAngleX: 1
SyncRotAngleY: 1
SyncRotAngleZ: 1
SyncScaleX: 1
SyncScaleY: 1
SyncScaleZ: 1
PositionThreshold: 0.001
RotAngleThreshold: 0.01
ScaleThreshold: 0.01
UseQuaternionSynchronization: 0
UseQuaternionCompression: 0
UseHalfFloatPrecision: 0
InLocalSpace: 0
Interpolate: 1
SlerpPosition: 0
--- !u!1 &1245558867416036815
GameObject:
m_ObjectHideFlags: 0
@ -2280,6 +2341,7 @@ GameObject:
- component: {fileID: 1326862948614608683}
- component: {fileID: 1326862948614608682}
- component: {fileID: 1326862948614608684}
- component: {fileID: 1326862948614608685}
m_Layer: 0
m_Name: SM_Env_Hell_Circle_01 (5)
m_TagString: Untagged
@ -2411,6 +2473,37 @@ MonoBehaviour:
m_EditorClassIdentifier:
outlineMaterial: {fileID: 2100000, guid: 7d59a0e48d5e5a34bbc8919ff8e3cecd, type: 2}
outlineWidth: 0.1
--- !u!114 &1326862948614608685
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1325723386991991240}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e96cb6065543e43c4a752faaa1468eb1, type: 3}
m_Name:
m_EditorClassIdentifier:
UseUnreliableDeltas: 0
SyncPositionX: 1
SyncPositionY: 1
SyncPositionZ: 1
SyncRotAngleX: 1
SyncRotAngleY: 1
SyncRotAngleZ: 1
SyncScaleX: 1
SyncScaleY: 1
SyncScaleZ: 1
PositionThreshold: 0.001
RotAngleThreshold: 0.01
ScaleThreshold: 0.01
UseQuaternionSynchronization: 0
UseQuaternionCompression: 0
UseHalfFloatPrecision: 0
InLocalSpace: 0
Interpolate: 1
SlerpPosition: 0
--- !u!33 &3136216454265548515
MeshFilter:
m_ObjectHideFlags: 0
@ -2478,6 +2571,7 @@ GameObject:
- component: {fileID: 3169561862507413956}
- component: {fileID: 3169561862507413955}
- component: {fileID: 3169561862507413957}
- component: {fileID: 3169561862507413958}
m_Layer: 0
m_Name: SM_Env_Hell_Circle_01 (6)
m_TagString: Untagged
@ -2609,6 +2703,37 @@ MonoBehaviour:
m_EditorClassIdentifier:
outlineMaterial: {fileID: 2100000, guid: 7d59a0e48d5e5a34bbc8919ff8e3cecd, type: 2}
outlineWidth: 0.1
--- !u!114 &3169561862507413958
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3166196630092877649}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e96cb6065543e43c4a752faaa1468eb1, type: 3}
m_Name:
m_EditorClassIdentifier:
UseUnreliableDeltas: 0
SyncPositionX: 1
SyncPositionY: 1
SyncPositionZ: 1
SyncRotAngleX: 1
SyncRotAngleY: 1
SyncRotAngleZ: 1
SyncScaleX: 1
SyncScaleY: 1
SyncScaleZ: 1
PositionThreshold: 0.001
RotAngleThreshold: 0.01
ScaleThreshold: 0.01
UseQuaternionSynchronization: 0
UseQuaternionCompression: 0
UseHalfFloatPrecision: 0
InLocalSpace: 0
Interpolate: 1
SlerpPosition: 0
--- !u!1 &5194562349502858591
GameObject:
m_ObjectHideFlags: 0
@ -2626,6 +2751,7 @@ GameObject:
- component: {fileID: 5215249593494578418}
- component: {fileID: 5215249593494578417}
- component: {fileID: 5215249593494578419}
- component: {fileID: 5215249593494578420}
m_Layer: 0
m_Name: SM_Env_Hell_Circle_01 (2)
m_TagString: Untagged
@ -2807,6 +2933,37 @@ MonoBehaviour:
m_EditorClassIdentifier:
outlineMaterial: {fileID: 2100000, guid: 7d59a0e48d5e5a34bbc8919ff8e3cecd, type: 2}
outlineWidth: 0.1
--- !u!114 &5215249593494578420
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5194562349502858591}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e96cb6065543e43c4a752faaa1468eb1, type: 3}
m_Name:
m_EditorClassIdentifier:
UseUnreliableDeltas: 0
SyncPositionX: 1
SyncPositionY: 1
SyncPositionZ: 1
SyncRotAngleX: 1
SyncRotAngleY: 1
SyncRotAngleZ: 1
SyncScaleX: 1
SyncScaleY: 1
SyncScaleZ: 1
PositionThreshold: 0.001
RotAngleThreshold: 0.01
ScaleThreshold: 0.01
UseQuaternionSynchronization: 0
UseQuaternionCompression: 0
UseHalfFloatPrecision: 0
InLocalSpace: 0
Interpolate: 1
SlerpPosition: 0
--- !u!4 &5590359088119101749
Transform:
m_ObjectHideFlags: 0
@ -2840,6 +2997,7 @@ GameObject:
- component: {fileID: 5615547279758710382}
- component: {fileID: 5615547279758710381}
- component: {fileID: 5615547279758710383}
- component: {fileID: 5615547279758710384}
m_Layer: 0
m_Name: SM_Env_Hell_Circle_01
m_TagString: Untagged
@ -3005,6 +3163,37 @@ MonoBehaviour:
m_EditorClassIdentifier:
outlineMaterial: {fileID: 2100000, guid: 7d59a0e48d5e5a34bbc8919ff8e3cecd, type: 2}
outlineWidth: 0.1
--- !u!114 &5615547279758710384
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5591479862615341019}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e96cb6065543e43c4a752faaa1468eb1, type: 3}
m_Name:
m_EditorClassIdentifier:
UseUnreliableDeltas: 0
SyncPositionX: 1
SyncPositionY: 1
SyncPositionZ: 1
SyncRotAngleX: 1
SyncRotAngleY: 1
SyncRotAngleZ: 1
SyncScaleX: 1
SyncScaleY: 1
SyncScaleZ: 1
PositionThreshold: 0.001
RotAngleThreshold: 0.01
ScaleThreshold: 0.01
UseQuaternionSynchronization: 0
UseQuaternionCompression: 0
UseHalfFloatPrecision: 0
InLocalSpace: 0
Interpolate: 1
SlerpPosition: 0
--- !u!1 &6995672694789591046
GameObject:
m_ObjectHideFlags: 0
@ -3022,6 +3211,7 @@ GameObject:
- component: {fileID: 7017483914677023161}
- component: {fileID: 7017483914677023160}
- component: {fileID: 7017483914677023162}
- component: {fileID: 7017483914677023163}
m_Layer: 0
m_Name: SM_Env_Hell_Circle_01 (4)
m_TagString: Untagged
@ -3203,6 +3393,37 @@ MonoBehaviour:
m_EditorClassIdentifier:
outlineMaterial: {fileID: 2100000, guid: 7d59a0e48d5e5a34bbc8919ff8e3cecd, type: 2}
outlineWidth: 0.1
--- !u!114 &7017483914677023163
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6995672694789591046}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e96cb6065543e43c4a752faaa1468eb1, type: 3}
m_Name:
m_EditorClassIdentifier:
UseUnreliableDeltas: 0
SyncPositionX: 1
SyncPositionY: 1
SyncPositionZ: 1
SyncRotAngleX: 1
SyncRotAngleY: 1
SyncRotAngleZ: 1
SyncScaleX: 1
SyncScaleY: 1
SyncScaleZ: 1
PositionThreshold: 0.001
RotAngleThreshold: 0.01
ScaleThreshold: 0.01
UseQuaternionSynchronization: 0
UseQuaternionCompression: 0
UseHalfFloatPrecision: 0
InLocalSpace: 0
Interpolate: 1
SlerpPosition: 0
--- !u!1660057539 &9223372036854775807
SceneRoots:
m_ObjectHideFlags: 0

@ -47,7 +47,11 @@ public class AbilitySystem : NetworkBehaviour
{
{ GameDataSource.Instance.DashNCrashAbilityKey, CursorState.Dash },
{ GameDataSource.Instance.FreezeThrowAbilityKey, CursorState.Freeze },
{ GameDataSource.Instance.VectorWallAbilityKey, CursorState.VectorWall }
{ GameDataSource.Instance.VectorWallAbilityKey, CursorState.VectorWall },
{ GameDataSource.Instance.TheExecutionerKey, CursorState.Executioner },
{ GameDataSource.Instance.CrowsForesightKey, CursorState.Foresight },
};
}
private void Awake()

@ -185,7 +185,7 @@ public class CrowManager : NetworkBehaviour
/// <summary>
/// Ensures the players list is updated when a player is spawned or despawned.
/// </summary>
/// </summary>
/// <param name="character">The ServerCharacter to track.</param>
public void OnPlayerSpawned(ServerCharacter character)
{

@ -133,11 +133,10 @@ public class CrowsForesightPrefab : NetworkBehaviour
private LineRenderer CreateLine()
{
//GameObject lineObj = new GameObject("ForesightLine");
GameObject lineObj = Instantiate(LinePrefab);
LineRenderer line = lineObj.AddComponent<LineRenderer>();
line.startWidth = 0.7f;
line.endWidth = 0.7f;
LineRenderer line = lineObj.GetComponent<LineRenderer>();
line.startWidth = 1f;
line.endWidth = 1f;
//line.material = new Material(Shader.Find("Sprites/Default"));
line.transform.SetParent(transform);
return line;

@ -6,4 +6,6 @@ public enum CursorState
VectorWall,
Dash,
Freeze,
Executioner,
Foresight,
}

@ -11,7 +11,8 @@ namespace Unity.Multiplayer.Samples.BossRoom
{
public static PlatformManager Instance;
public List<Platform> m_Platforms;
public int numberOfPlayers = 2; // Number of players (n)
public Transform centerPoint;
public float shapeRadius = 5f;
private void Awake()
{
@ -31,220 +32,80 @@ namespace Unity.Multiplayer.Samples.BossRoom
{
InitializePlatforms();
StartCoroutine(DelayedServerSetup());
}
}
#region DistancePlatform
public List<Platform> platforms; // Assign all platforms in the Inspector
private List<Platform> activePlatforms = new List<Platform>(); // Stores only active platforms
private Dictionary<string, float> platformDistances = new Dictionary<string, float>(); // Stores distances
private List<float> sortedUniqueDistances = new List<float>(); // Stores unique sorted distances
public List<Transform> platformTransforms; // Assign platform GameObjects here
public Transform centerPoint; // Center position where the shape will form
public float shapeRadius = 5f;
void Starter()
{
UpdateActivePlatforms();
PrecomputeDistances();
}
public void ArrangePlatforms()
private void InitializePlatforms()
{
// Get only active platforms
List<Transform> activePlatforms = platformTransforms.Where(p => p.gameObject.activeSelf).ToList();
int count = activePlatforms.Count;
if (count < 3)
m_Platforms = GetComponentsInChildren<Platform>(true).ToList();
for (int i = 0; i < m_Platforms.Count; i++)
{
Debug.LogWarning("Not enough platforms to form a shape!");
return;
m_Platforms[i].AssignID(i + 1);
}
}
// Arrange them in a regular polygon shape
PlacePlatformsInShape(activePlatforms, count);
private IEnumerator DelayedServerSetup()
{
yield return new WaitForSeconds(0.5f);
PlatformSelection();
}
private void PlacePlatformsInShape(List<Transform> platforms, int count)
public void ArrangePlatforms()
{
float angleStep = 360f / count; // Equal angles for each platform
float startAngle = 90f; // Start from the top (adjust if needed)
List<Platform> activePlatforms = m_Platforms.Where(p => p.gameObject.activeSelf).ToList();
int platformCount = activePlatforms.Count;
Debug.Log("Count of Active Platforms is: " + platformCount);
if (platformCount < 3) return; // Minimum 3 platforms for a shape
for (int i = 0; i < count; i++)
float angleStep = 360f / platformCount;
float startAngle = 90f; // Start from top
for (int i = 0; i < platformCount; i++)
{
float angle = startAngle + (i * angleStep);
float radians = angle * Mathf.Deg2Rad;
// Calculate new position using circle formula
Vector3 newPosition = new Vector3(
centerPoint.position.x + shapeRadius * Mathf.Cos(radians),
centerPoint.position.y,
centerPoint.position.z + shapeRadius * Mathf.Sin(radians)
);
// Move platform to its new position
platforms[i].position = newPosition;
}
}
public void UpdateActivePlatforms()
{
// Refresh the active platforms list
activePlatforms = platforms.Where(p => p.gameObject.activeSelf).ToList();
}
private void PrecomputeDistances()
{
platformDistances.Clear();
sortedUniqueDistances.Clear();
if (activePlatforms.Count < 2)
{
Debug.LogWarning("Not enough active platforms to calculate distances.");
return;
}
HashSet<float> uniqueDistances = new HashSet<float>();
// Compute and store distances between all active platform pairs
for (int i = 0; i < activePlatforms.Count; i++)
{
for (int j = i + 1; j < activePlatforms.Count; j++)
{
Platform platformA = activePlatforms[i];
Platform platformB = activePlatforms[j];
float rawDistance = Vector3.Distance(platformA.transform.position, platformB.transform.position);
float roundedDistance = Mathf.Round(rawDistance * 100f) / 100f; // Rounds to 2 decimal places
uniqueDistances.Add(roundedDistance);
string key = GetPlatformKey(platformA, platformB);
platformDistances[key] = roundedDistance;
}
}
// Convert unique distances into a sorted list
sortedUniqueDistances = uniqueDistances.OrderBy(d => d).ToList();
Debug.Log("Sorted unique distances: " + string.Join(", ", sortedUniqueDistances));
}
public float CalculateScore(Platform platformA, Platform platformB)
{
if(platformA== null)
{
Debug.Log("platformA is null");
}
if(platformB == null)
{
Debug.Log("platformB is null");
}
if (!platformA.gameObject.activeSelf || !platformB.gameObject.activeSelf)
{
Debug.Log("One or both selected platforms are not active.");
return -1;
}
Debug.Log("PlatformKey getter");
string key = GetPlatformKey(platformA, platformB);
Debug.Log("PlatformKey getter2");
if (!platformDistances.ContainsKey(key))
{
Debug.LogError("Distance for selected platforms not found!");
return -1;
}
float distance = platformDistances[key];
float scoreMultiplier = GetMultiplier(distance);
Debug.Log($"Platforms {platformA.name} & {platformB.name} selected. Distance: {distance:F2}, Score Multiplier: {scoreMultiplier}");
return scoreMultiplier;
}
private float GetMultiplier(float distance)
{
if (sortedUniqueDistances.Count == 0)
{
return 1.0f; // Default if no distances are calculated
activePlatforms[i].transform.position = newPosition;
}
// Find the index of the selected distance in the sorted list
int index = sortedUniqueDistances.IndexOf(distance);
// Multiplier starts from 1.0 and increases by 0.1 per step
return 1.0f + (index * 0.1f);
}
private string GetPlatformKey(Platform platformA, Platform platformB)
{
return platformA.name + "_" + platformB.name;
}
#endregion
/// <summary>
/// Initializes platform list and assigns unique IDs.
/// </summary>
private void InitializePlatforms()
{
m_Platforms = GetComponentsInChildren<Platform>(true).ToList();
for (int i = 0; i < m_Platforms.Count; i++)
{
m_Platforms[i].AssignID(i + 1); // Assign unique IDs to platforms
}
}
/// <summary>
/// Delayed server setup to allow other components to initialize.
/// </summary>
private IEnumerator DelayedServerSetup()
{
yield return new WaitForSeconds(0.5f);
PlatformSelection();
}
/// <summary>
/// Server-side logic to select and enable platforms based on player count.
/// </summary>
private void PlatformSelection()
{
//int platformsToSpawn = 5;
int platformsToSpawn = PlayerPrefs.GetInt("NumberOfLobbyPlayers", 1) - 1;
int platformsToSpawn = PlayerPrefs.GetInt("NumberOfLobbyPlayers",1) - 1;
//int platformsToSpawn = 2;
// Disable all platforms initially
foreach (var platform in m_Platforms)
{
platform.gameObject.SetActive(false);
}
// Enable required number of platforms
for (int i = 0; i < platformsToSpawn; i++)
{
Debug.Log(m_Platforms[i].gameObject.name + " is activated");
m_Platforms[i].gameObject.SetActive(true);
}
m_Platforms = m_Platforms.Where(platform => platform.gameObject.activeSelf).ToList();
int[] platformIDs = m_Platforms.Select(p => p.PlatformID.Value).ToArray();
// Notify clients to enable corresponding platforms
ClientEnablePlatformClientRpc(platformIDs);
ArrangePlatforms();
}
/// <summary>
/// ClientRpc to enable platforms on the client side.
/// </summary>
[ClientRpc]
private void ClientEnablePlatformClientRpc(int[] platformIDs)
{
m_Platforms = GetComponentsInChildren<Platform>(true).ToList();
// Disable all platforms initially
foreach (var platform in m_Platforms)
{
platform.gameObject.SetActive(false);
}
// Enable specified platforms
foreach (int id in platformIDs)
{
var platformToEnable = m_Platforms.FirstOrDefault(p => p.PlatformID.Value == id);
@ -255,22 +116,12 @@ namespace Unity.Multiplayer.Samples.BossRoom
}
m_Platforms = m_Platforms.Where(platform => platform.gameObject.activeSelf).ToList();
Starter();
}
/// <summary>
/// Finds the nearest unoccupied platform to a given position.
/// Server-only method.
/// </summary>
public Platform FindNearestUnoccupiedPlatform(Vector3 position)
{
if (!IsServer)
{
Debug.LogError("FindNearestUnoccupiedPlatform should only be called on the server.");
return null;
}
if (!IsServer) return null;
return m_Platforms
.Where(platform => !platform.IsOccupied)
@ -278,42 +129,27 @@ namespace Unity.Multiplayer.Samples.BossRoom
.FirstOrDefault();
}
/// <summary>
/// Checks if all platforms are occupied.
/// </summary>
public bool AreAllPlatformsOccupied()
{
return m_Platforms.All(platform => platform.IsOccupied);
}
/// <summary>
/// Gets the platform occupied by a specific player.
/// </summary>
public Platform GetPlatformOccupiedByPlayer(ServerCharacter player)
{
return m_Platforms.FirstOrDefault(p => p.IsOccupied && p.GetOccupierId() == player.OwnerClientId);
}
/// <summary>
/// Checks if a platform is occupied.
/// </summary>
public bool IsPlatformOccupied(Platform platform)
{
return platform.IsOccupied;
}
/// <summary>
/// Gets the position of a platform by its ID.
/// </summary>
public Vector3 GetPlatformPosition(int platformId)
{
var platform = m_Platforms.FirstOrDefault(p => p.PlatformID.Value == platformId);
return platform ? platform.transform.position : Vector3.zero;
}
/// <summary>
/// Gets a platform by its ID.
/// </summary>
public Platform GetPlatformById(int platformId)
{
return m_Platforms.FirstOrDefault(p => p.PlatformID.Value == platformId);
@ -322,6 +158,7 @@ namespace Unity.Multiplayer.Samples.BossRoom
}
//using System.Collections;
//using System.Collections.Generic;
//using System.Linq;
@ -336,7 +173,6 @@ namespace Unity.Multiplayer.Samples.BossRoom
// public static PlatformManager Instance;
// public List<Platform> m_Platforms;
// public int numberOfPlayers = 2; // Number of players (n)
// public float planeRadius = 4f; // Radius of the circular plane
// private void Awake()
// {
@ -354,86 +190,241 @@ namespace Unity.Multiplayer.Samples.BossRoom
// {
// if (IsServer)
// {
// m_Platforms = GetComponentsInChildren<Platform>(true).ToList();
// for (int i = 0; i < m_Platforms.Count; i++)
// InitializePlatforms();
// StartCoroutine(DelayedServerSetup());
// }
// }
// #region DistancePlatform
// public List<Platform> platforms; // Assign all platforms in the Inspector
// private List<Platform> activePlatforms = new List<Platform>(); // Stores only active platforms
// private Dictionary<string, float> platformDistances = new Dictionary<string, float>(); // Stores distances
// private List<float> sortedUniqueDistances = new List<float>(); // Stores unique sorted distances
// public List<Transform> platformTransforms; // Assign platform GameObjects here
// public Transform centerPoint; // Center position where the shape will form
// public float shapeRadius = 5f;
// void Starter()
// {
// UpdateActivePlatforms();
// PrecomputeDistances();
// }
// public void ArrangePlatforms()
// {
// // Get only active platforms
// List<Transform> activePlatforms = platformTransforms.Where(p => p.gameObject.activeSelf).ToList();
// int count = activePlatforms.Count;
// if (count < 3)
// {
// Debug.LogWarning("Not enough platforms to form a shape!");
// return;
// }
// // Arrange them in a regular polygon shape
// PlacePlatformsInShape(activePlatforms, count);
// }
// private void PlacePlatformsInShape(List<Transform> platforms, int count)
// {
// float angleStep = 360f / count; // Equal angles for each platform
// float startAngle = 90f; // Start from the top (adjust if needed)
// for (int i = 0; i < count; i++)
// {
// float angle = startAngle + (i * angleStep);
// float radians = angle * Mathf.Deg2Rad;
// // Calculate new position using circle formula
// Vector3 newPosition = new Vector3(
// centerPoint.position.x + shapeRadius * Mathf.Cos(radians),
// centerPoint.position.y,
// centerPoint.position.z + shapeRadius * Mathf.Sin(radians)
// );
// // Move platform to its new position
// platforms[i].position = newPosition;
// }
// }
// public void UpdateActivePlatforms()
// {
// // Refresh the active platforms list
// activePlatforms = platforms.Where(p => p.gameObject.activeSelf).ToList();
// }
// private void PrecomputeDistances()
// {
// platformDistances.Clear();
// sortedUniqueDistances.Clear();
// if (activePlatforms.Count < 2)
// {
// Debug.LogWarning("Not enough active platforms to calculate distances.");
// return;
// }
// HashSet<float> uniqueDistances = new HashSet<float>();
// // Compute and store distances between all active platform pairs
// for (int i = 0; i < activePlatforms.Count; i++)
// {
// for (int j = i + 1; j < activePlatforms.Count; j++)
// {
// m_Platforms[i].AssignID(i + 1); // Initialize platforms with unique IDs
// Platform platformA = activePlatforms[i];
// Platform platformB = activePlatforms[j];
// float rawDistance = Vector3.Distance(platformA.transform.position, platformB.transform.position);
// float roundedDistance = Mathf.Round(rawDistance * 100f) / 100f; // Rounds to 2 decimal places
// uniqueDistances.Add(roundedDistance);
// string key = GetPlatformKey(platformA, platformB);
// platformDistances[key] = roundedDistance;
// }
// StartCoroutine(DelayedServerSetup());
// }
// else
// // Convert unique distances into a sorted list
// sortedUniqueDistances = uniqueDistances.OrderBy(d => d).ToList();
// Debug.Log("Sorted unique distances: " + string.Join(", ", sortedUniqueDistances));
// }
// public float CalculateScore(Platform platformA, Platform platformB)
// {
// if(platformA== null)
// {
// Debug.Log("platformA is null");
// }
// if(platformB == null)
// {
// Debug.Log("platformB is null");
// }
// if (!platformA.gameObject.activeSelf || !platformB.gameObject.activeSelf)
// {
// StartCoroutine(DelayedClientSetup()); // Delay to give time to load
// Debug.Log("One or both selected platforms are not active.");
// return -1;
// }
// Debug.Log("PlatformKey getter");
// string key = GetPlatformKey(platformA, platformB);
// Debug.Log("PlatformKey getter2");
// if (!platformDistances.ContainsKey(key))
// {
// Debug.LogError("Distance for selected platforms not found!");
// return -1;
// }
// float distance = platformDistances[key];
// float scoreMultiplier = GetMultiplier(distance);
// Debug.Log($"Platforms {platformA.name} & {platformB.name} selected. Distance: {distance:F2}, Score Multiplier: {scoreMultiplier}");
// return scoreMultiplier;
// }
// private float GetMultiplier(float distance)
// {
// if (sortedUniqueDistances.Count == 0)
// {
// return 1.0f; // Default if no distances are calculated
// }
// // Find the index of the selected distance in the sorted list
// int index = sortedUniqueDistances.IndexOf(distance);
// // Multiplier starts from 1.0 and increases by 0.1 per step
// return 1.0f + (index * 0.1f);
// }
// private string GetPlatformKey(Platform platformA, Platform platformB)
// {
// return platformA.name + "_" + platformB.name;
// }
// #endregion
// /// <summary>
// /// Coroutine to delay server-side setup.
// /// Initializes platform list and assigns unique IDs.
// /// </summary>
// private IEnumerator DelayedServerSetup()
// private void InitializePlatforms()
// {
// yield return new WaitForSeconds(0.5f); // Delay for 0.5 seconds
// PlatformSelection(); // Call ServerRpc after delay
// m_Platforms = GetComponentsInChildren<Platform>(true).ToList();
// for (int i = 0; i < m_Platforms.Count; i++)
// {
// m_Platforms[i].AssignID(i + 1); // Assign unique IDs to platforms
// }
// }
// /// <summary>
// /// Coroutine to delay client-side setup.
// /// Delayed server setup to allow other components to initialize.
// /// </summary>
// private IEnumerator DelayedClientSetup()
// private IEnumerator DelayedServerSetup()
// {
// yield return new WaitForSeconds(0.5f);
// m_Platforms = GetComponentsInChildren<Platform>(true).ToList(); // Populate client platform list
// Debug.Log($"Client platform list initialized. Platform count: {m_Platforms.Count}");
// PlatformSelection();
// }
// /// <summary>
// /// Server-side logic to select and enable platforms based on player count.
// /// </summary>
// private void PlatformSelection()
// {
// int platformsToSpawn = PlayerPrefs.GetInt("NumberOfLobbyPlayers") - 1;
// m_Platforms.ForEach(platform => platform.gameObject.SetActive(false));
// Debug.Log("Disabled all platforms on the server.");
// int platformsToSpawn = PlayerPrefs.GetInt("NumberOfLobbyPlayers",1) - 1;
// //int platformsToSpawn = 2;
// if (platformsToSpawn > 0)
// // Disable all platforms initially
// foreach (var platform in m_Platforms)
// {
// for (int i = 0; i < platformsToSpawn; i++)
// {
// m_Platforms[i].gameObject.SetActive(true);
// Debug.Log($"Enabled platform with ID {m_Platforms[i].PlatformID.Value} on server.");
// }
// platform.gameObject.SetActive(false);
// }
// // Enable required number of platforms
// for (int i = 0; i < platformsToSpawn; i++)
// {
// Debug.Log(m_Platforms[i].gameObject.name + " is activated");
// m_Platforms[i].gameObject.SetActive(true);
// }
// m_Platforms = m_Platforms.Where(platform => platform.gameObject.activeSelf).ToList();
// int[] platformIDs = m_Platforms.Select(p => p.PlatformID.Value).ToArray();
// // Notify clients to enable corresponding platforms
// ClientEnablePlatformClientRpc(platformIDs);
// }
// /// <summary>
// /// ClientRpc to enable platforms on the client side.
// /// </summary>
// [ClientRpc]
// private void ClientEnablePlatformClientRpc(int[] platformIDs)
// {
// m_Platforms = GetComponentsInChildren<Platform>(true).ToList(); // Ensure the platform list is refreshed
// Debug.Log($"Client received platform IDs: {string.Join(",", platformIDs)}");
// Debug.Log($"Client platform list count: {m_Platforms.Count}");
// m_Platforms = GetComponentsInChildren<Platform>(true).ToList();
// // Disable all platforms initially
// foreach (var platform in m_Platforms)
// {
// platform.gameObject.SetActive(false);
// Debug.Log($"Disabled platform with ID: {platform.PlatformID.Value}");
// }
// // Enable specified platforms
// foreach (int id in platformIDs)
// {
// var platformToEnable = m_Platforms.FirstOrDefault(p => p.PlatformID.Value == id);
// if (platformToEnable != null)
// {
// platformToEnable.gameObject.SetActive(true);
// Debug.Log($"Enabled platform with ID: {id}");
// }
// else
// {
// Debug.LogError($"Platform with ID {id} not found on client.");
// }
// }
// m_Platforms = m_Platforms.Where(platform => platform.gameObject.activeSelf).ToList();
// Starter();
// }
// /// <summary>
// /// Finds the nearest unoccupied platform to a given position.
// /// Server-only method.
// /// </summary>
// public Platform FindNearestUnoccupiedPlatform(Vector3 position)
// {
// if (!IsServer)
@ -448,46 +439,42 @@ namespace Unity.Multiplayer.Samples.BossRoom
// .FirstOrDefault();
// }
// /// <summary>
// /// Checks if all platforms are occupied.
// /// </summary>
// public bool AreAllPlatformsOccupied()
// {
// return m_Platforms.All(platform => platform.IsOccupied);
// }
// /*public bool AssignPlayerToPlatform(ServerCharacter player)
// {
// if (!IsServer)
// {
// Debug.LogError("AssignPlayerToPlatform should only be called on the server.");
// return false;
// }
// var platform = m_Platforms.FirstOrDefault(p => !p.IsOccupied);
// if (platform != null)
// {
// platform.Occupy(player);
// return true;
// }
// Debug.LogWarning($"No unoccupied platforms available for {player.name}.");
// return false;
// }*/
// /// <summary>
// /// Gets the platform occupied by a specific player.
// /// </summary>
// public Platform GetPlatformOccupiedByPlayer(ServerCharacter player)
// {
// return m_Platforms.FirstOrDefault(p => p.IsOccupied && p.GetOccupierId() == player.OwnerClientId);
// }
// /// <summary>
// /// Checks if a platform is occupied.
// /// </summary>
// public bool IsPlatformOccupied(Platform platform)
// {
// return platform.IsOccupied;
// }
// /// <summary>
// /// Gets the position of a platform by its ID.
// /// </summary>
// public Vector3 GetPlatformPosition(int platformId)
// {
// var platform = m_Platforms.FirstOrDefault(p => p.PlatformID.Value == platformId);
// return platform ? platform.transform.position : Vector3.zero;
// }
// /// <summary>
// /// Gets a platform by its ID.
// /// </summary>
// public Platform GetPlatformById(int platformId)
// {
// return m_Platforms.FirstOrDefault(p => p.PlatformID.Value == platformId);

@ -26,6 +26,12 @@ namespace Unity.BossRoom.Gameplay.UI
[SerializeField]
[Tooltip("The button that activates the hero's second special move")]
UIHUDButton m_SpecialAction2Button;
[SerializeField]
[Tooltip("The button that activates the hero's thid special move")]
UIHUDButton m_SpecialAction3Button;
[SerializeField]
[Tooltip("The button that activates the hero's fourth special move")]
UIHUDButton m_SpecialAction4Button;
[SerializeField]
[Tooltip("The button that opens/closes the Emote bar")]
@ -49,6 +55,9 @@ namespace Unity.BossRoom.Gameplay.UI
Special1,
Special2,
EmoteBar,
Special3,
Special4,
}
/// <summary>
@ -171,6 +180,8 @@ namespace Unity.BossRoom.Gameplay.UI
[ActionButtonType.BasicAction] = new ActionButtonInfo(ActionButtonType.BasicAction, m_BasicActionButton, this),
[ActionButtonType.Special1] = new ActionButtonInfo(ActionButtonType.Special1, m_SpecialAction1Button, this),
[ActionButtonType.Special2] = new ActionButtonInfo(ActionButtonType.Special2, m_SpecialAction2Button, this),
[ActionButtonType.Special3] = new ActionButtonInfo(ActionButtonType.Special3, m_SpecialAction3Button, this),
[ActionButtonType.Special4] = new ActionButtonInfo(ActionButtonType.Special4, m_SpecialAction4Button, this),
[ActionButtonType.EmoteBar] = new ActionButtonInfo(ActionButtonType.EmoteBar, m_EmoteBarButton, this),
};

@ -12,8 +12,8 @@ public class ScrollingLineRenderer : MonoBehaviour
if (scrollingMaterial == null) return;
// Scroll texture over time
float offset = Time.time * -speed;
float offset = Time.time * speed;
scrollingMaterial.SetFloat("_Speed", speed);
scrollingMaterial.SetFloat("_Tiling", tiling);
scrollingMaterial.SetFloat("_Tiling", -tiling);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

@ -50,7 +50,7 @@ Material:
- _SrcBlend: 5
- _SrcBlendAlpha: 1
- _Surface: 1
- _Tiling: 1
- _Tiling: -0.5
- _ZWrite: 0
m_Colors:
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
Loading…
Cancel
Save