//Checks if a Swork is out-of-bounds and moves it to the holding area public static void CollectOutOfBoundsSworks(Transform holdingArea) { for (int i = 0; i < AllSworks.Length; i++) { if (AllSworks[i].InStandby) { continue; } //dead if 'Out-of-Bounds' if (OutOfBounds(AllSworks[i].SwkTran.position)) //check if out-of-bounds { if (CurrentTargetSwork != null && //if it's 'Target' AllSworks[i].GetInstanceID() == CurrentTargetSwork.GetInstanceID()) { StoredTarget = CurrentTargetSwork; CurrentTargetSwork.CurrentState = SwkSwork.SworkStates.TargetOutOfBounds; CurrentCamera.Focused = false; CurrentTargetSwork = null; } else { StandBySworksQueue.Enqueue(AllSworks[i]); } AllSworks[i].MakeStandby(holdingArea.position); } } }
//Spawns 'StoredTarget' after focusing public static void SpawnStoredWhenFocused(Transform spawnPoint) { _startTime = Time.time; if (CurrentCamera.Focused) { CurrentTargetSwork = StoredTarget; //set as target CurrentTargetSwork.SpawnLocal(spawnPoint.position); CurrentTargetSwork.CurrentState = SwkSwork.SworkStates.TargetInPlay; } }
//explode swork public static void ExplodeTargetSwork(Transform holdingArea) { //explode targer if (CurrentTargetSwork.Carrying) { if (CurrentTargetSwork.OnGround) { } //drop carrying else { } //float carrying } CurrentGameState.CurrentControlState = GameState.ControlState.ManualControl; CurrentCamera.Focused = false; //explode nearby sworks foreach (SwkSwork swork in AllSworks) { if (swork.CurrentState != SwkSwork.SworkStates.TargetInPlay) { continue; //check if possible for swork to explode } if (Vector3.Distance(CurrentTargetSwork.SwkTran.position, swork.SwkTran.position) > SwkGame.Tweaks.Swork.SworkExplosionEffectRange) { continue; //check if within range } if (swork.GetInstanceID() == CurrentTargetSwork.GetInstanceID()) { continue; //chat that 'isn't' target swork } if (swork.Carrying) { //drop carrying } swork.MakeStandby(holdingArea.position); } //explode nearby jumppads foreach (SwkJumpPad jumpPad in AllJumpPads) { if (jumpPad.CurrentState == SwkJumpPad.JumpPadStates.Floating) { continue; } if (Vector3.Distance(CurrentTargetSwork.SwkTran.position, jumpPad.JmpPTran.position) > SwkGame.Tweaks.Swork.SworkExplosionEffectRange) { continue; } jumpPad.MakeFloating(); StoredJumpPad = jumpPad; CurrentGameState.CurrentControlState = GameState.ControlState.WaitingForNextPickup; } StandBySworksQueue.Enqueue(CurrentTargetSwork); CurrentTargetSwork.MakeStandby(holdingArea.position); CurrentTargetSwork = null; }