/// <summary> /// OnTapLocation - call this to handle distributing and processing taps across a synchronized network game session /// Responds to taps and decides what to do /// </summary> /// <param name="tapLocation">location where tap/click took place</param> private void OnTapLocation(TSVector tapLocation) { // Handle powerup taps GameObject tlsc = TrueSyncManager.SyncedInstantiate(Resources.Load("Prefabs/TapLocationSphereCheck") as GameObject, tapLocation, TSQuaternion.identity); tlsc.GetComponent <TapLocationSphereCheck>().Owner = localOwner; // Find any status effect that may have been tapped FP shortestDistance = 1000; StatusEffect nearestSe = null; foreach (StatusEffect se in StatusEffectSystem.spawnedStatusEffects) { FP dist = TSVector.Distance(se.tsTransform.position, tapLocation); if (dist <= se.GetComponent <TSSphereCollider>().radius&& dist < shortestDistance) { shortestDistance = dist; nearestSe = se; } } if (nearestSe != null) // Found a status effect to handle { return; // exit this method to handle status effect within its own framework } // Shows where click took place (position marker): GameObject positionMarker = TrueSyncManager.SyncedInstantiate(PositionMarkerGO, tapLocation, TSQuaternion.identity); positionMarker.transform.position = tapLocation.ToVector(); positionMarker.name = "Position Marker"; // Identify this marker game object in unity editor TSTransform tst = positionMarker.GetComponent <TSTransform>(); tst.scale = TSVector.one * PlayerConfig.Instance.MinTapDistance; Renderer rend = positionMarker.GetComponent <Renderer>(); if (TSVector.Distance(lastValidTapLocation, tapLocation) >= PlayerConfig.Instance.MinTapDistanceFromPrevious) { TapNearLine(tapLocation); rend.material.color = Color.black; } else { rend.material.color = Color.red; } DOTween.ToAlpha(() => rend.material.color, x => rend.material.color = x, 0, 5f).OnComplete(() => { TrueSyncManager.Destroy(positionMarker); }); lastValidTapLocation = tapLocation; }
public void OnSyncedTriggerExit(TSCollision other) { TrueSyncManager.Destroy(other.gameObject); }