bool MoveToLocationAndHold() { if (MoveToLocation()) { if (SelectKeyPressed) { timer += Time.deltaTime; eventTimer += Time.deltaTime; if (ShouldTriggerEvent && eventSlots.Count > 0 && Mathf.FloorToInt(eventTimer) >= eventSlots[0].GetThreshold()) { StaticDelegates.InvokeTriggerEvent(); switch (eventSlots[0].GetResult()) { case ResultType.Neutral: GameManager.UpdateFinalResult(ResultType.Neutral); break; } eventSlots.RemoveAt(0); } } } if (timer >= TimeToHold) { return(true); } return(false); }
void UpdateSpriteOnKeyWithIdle(Actions action, bool released, System.Action <Collider2D, ResultType> callback) { if (released) { if (actionsStarted.Contains(action)) { actionsStarted.Remove(action); } if (actionsStarted.Count == 0) { rend.sprite = spritesToUse[spritesToUse.Count - 1].GetSprite(); SetCollider(callback, spritesToUse.Count - 1); } else { rend.sprite = spritesToUse[actionsToMap.IndexOf(actionsStarted[actionsStarted.Count - 1])].GetSprite(); SetCollider(callback, actionsToMap.IndexOf(actionsStarted[actionsStarted.Count - 1])); } StaticDelegates.PlayAudio(false); } else { if (actionsToMap.Contains(action)) { actionsStarted.Add(action); rend.sprite = spritesToUse[actionsToMap.IndexOf(action)].GetSprite(); SetCollider(callback, actionsToMap.IndexOf(action)); StaticDelegates.PlayAudio(false); } } }
bool Collection() { if (coll.enabled == false) { return(false); } Collider2D c = Physics2D.OverlapBox(coll.bounds.center, coll.bounds.extents * 2f, this.transform.eulerAngles.z, (1 << LayerMask.NameToLayer("Item"))); if (c != null) { c.gameObject.transform.parent = this.gameObject.transform; c.gameObject.layer = LayerMask.NameToLayer("Player"); this.coll = c; StaticDelegates.PlayAudio(true); } if (this.transform.childCount == NumItemsToCollect) { return(true); } return(false); }
private void Start() { if (GameManager.NextLevel == 0) { StaticDelegates.UpdateGameState(true); } }
public static void GameFinished(ResultType result) { Debug.Log(result); finalResult = finalResult == ResultType.None ? result : (ResultType)Mathf.Min((int)finalResult, (int)result); Debug.Log("FINAL RESULT: " + finalResult.ToString()); PlayerData.UpdateData(result, level); StaticDelegates.UpdateGameState(false); }
void PlayLevel() { if (levels[currentIndex].isUnlocked()) { selectedLevel = currentIndex; StaticDelegates.PlaySpecificLevel(currentIndex + 1); } }
void CycleSprite(System.Action <Collider2D, ResultType> callback) { currentSpriteIndex = (currentSpriteIndex + 1) % spritesToUse.Count; rend.sprite = spritesToUse[currentSpriteIndex].GetSprite(); SetCollider(callback, currentSpriteIndex); StaticDelegates.PlayAudio(false); }
void OnEvent() { if (currentSpriteIndex < spritesToUse.Count) { rend.sprite = spritesToUse[currentSpriteIndex].GetSprite(); currentSpriteIndex += 1; } StaticDelegates.PlayAudio(false); }
void UpdateSpriteOnKey(Actions action, System.Action <Collider2D, ResultType> callback) { for (int i = 0; i < actionsToMap.Count; ++i) { if (actionsToMap[i] == action) { rend.sprite = spritesToUse[i].GetSprite(); SetCollider(callback, i); StaticDelegates.PlayAudio(false); } } }
private void Update() { if (movement.CanCurrentlyMove()) { if (completionFunction()) { StaticDelegates.PlayAudio(true); Debug.Log(spriteResult + " " + locationResult + " " + result); result = spriteResult != ResultType.None ? spriteResult : (locationResult != ResultType.None ? locationResult : ResultType.Win); GameManager.GameFinished(result); } } }
public void NextPanel() { if (currentIndex + 1 == panels.Count) { StaticDelegates.UpdateGameState(false); } else { Debug.Log(currentIndex); currentIndex += 1; panels[currentIndex].SetActive(true); } }
IEnumerator PostgameSequence() { if (postgame.Count > 0) { postgamePanel.SetActive(true); int i = 0; while (i < postgamePanel.transform.childCount) { postgamePanel.transform.GetChild(i).SetAsLastSibling(); i += 1; yield return(swapDelay); } } StaticDelegates.FadeOut(); }
IEnumerator PregameSequence() { int i = 0; if (pregame.Count > 0) { while (i < pregamePanel.transform.childCount) { pregamePanel.transform.GetChild(i).SetAsLastSibling(); i += 1; yield return(swapDelay); } } pregamePanel.gameObject.SetActive(false); StaticDelegates.UpdateGameState(true); }
// Start is called before the first frame update void Start() { switch (state) { case FadeState.Unset: Color c = fadeImage.color; c.a = 0f; fadeImage.color = c; state = FadeState.FadeIn; fadeImage.gameObject.SetActive(false); break; case FadeState.FadeIn: StaticDelegates.UpdateAllMovement(false); StartCoroutine(FadeFromBlack()); break; } }
void ToggleSprite(bool released, System.Action <Collider2D, ResultType> callback) { if (spritesToUse.Count < 2) { return; } if (released) { rend.sprite = spritesToUse[0].GetSprite(); SetCollider(callback, 0); } else { rend.sprite = spritesToUse[1].GetSprite(); SetCollider(callback, 1); StaticDelegates.PlayAudio(false); } }
IEnumerator FadeFromBlack() { Debug.Log("Fading"); Color c = fadeImage.color; c.a = 1f; fadeImage.color = c; while (c.a > 0f) { c.a -= fadeSpeed * Time.deltaTime; fadeImage.color = c; yield return(null); } c.a = 0f; fadeImage.color = c; state = FadeState.FadeOut; fadeImage.gameObject.SetActive(false); StaticDelegates.PlaySequence(true); }
IEnumerator FadeToBlack() { yield return(new WaitForSeconds(DelayBeforeBlack)); fadeImage.gameObject.SetActive(true); Color c = fadeImage.color; c.a = 0f; while (c.a < 1f) { c.a += fadeSpeed * Time.deltaTime; fadeImage.color = c; yield return(null); } c.a = 1f; fadeImage.color = c; state = FadeState.FadeIn; StaticDelegates.TransitionToNextLevel(); }
bool PressKeyMultipleTimes() { if (SelectKeyPressed) { counter += 1; SelectKeyPressed = false; if (ShouldTriggerEvent && eventSlots.Count > 0 && counter >= eventSlots[0].GetThreshold()) { StaticDelegates.InvokeTriggerEvent(); switch (eventSlots[0].GetResult()) { case ResultType.Neutral: GameManager.UpdateFinalResult(ResultType.Neutral); break; } } } if (counter >= NumTimes) { return(true); } return(false); }
public void StartGame() { StaticDelegates.FadeOut(); GameManager.ResetVariables(); PlayerData.NewRun(); }
void SetupControls() { controls = new Movement(); foreach (Actions d in directionsToMove) { switch (d) { case Actions.Up: controls.Move.Up.started += up => movement.UpdateInput(d, false); controls.Move.Up.canceled += up => movement.UpdateInput(d, true); controls.Move.Up.started += up => StaticDelegates.InvokeChangeSprite(d, false, SetCollider); controls.Move.Up.canceled += up => StaticDelegates.InvokeChangeSprite(d, true, SetCollider); break; case Actions.Down: controls.Move.Down.started += up => movement.UpdateInput(d, false); controls.Move.Down.canceled += up => movement.UpdateInput(d, true); controls.Move.Down.started += up => StaticDelegates.InvokeChangeSprite(d, false, SetCollider); controls.Move.Down.canceled += up => StaticDelegates.InvokeChangeSprite(d, true, SetCollider); break; case Actions.Left: controls.Move.Left.started += up => movement.UpdateInput(d, false); controls.Move.Left.canceled += up => movement.UpdateInput(d, true); controls.Move.Left.started += up => StaticDelegates.InvokeChangeSprite(d, false, SetCollider); controls.Move.Left.canceled += up => StaticDelegates.InvokeChangeSprite(d, true, SetCollider); break; case Actions.Right: controls.Move.Right.started += up => movement.UpdateInput(d, false); controls.Move.Right.canceled += up => movement.UpdateInput(d, true); controls.Move.Right.started += up => StaticDelegates.InvokeChangeSprite(d, false, SetCollider); controls.Move.Right.canceled += up => StaticDelegates.InvokeChangeSprite(d, true, SetCollider); break; case Actions.Select: controls.Move.Select.started += up => movement.UpdateInput(d, false); controls.Move.Select.canceled += up => movement.UpdateInput(d, true); controls.Move.Select.started += up => StaticDelegates.InvokeChangeSprite(d, false, SetCollider); controls.Move.Select.canceled += up => StaticDelegates.InvokeChangeSprite(d, true, SetCollider); break; } } switch (CompleteType) { case CompletionType.MoveToLocationsAndSelect: case CompletionType.MoveToLocationAndSelect: controls.Move.Select.started += up => UpdateSelectKeyState(false); controls.Move.Select.canceled += up => UpdateSelectKeyState(true); break; default: if (ShouldTriggerEvent) { goto case CompletionType.MoveToLocationAndSelect; } break; } }