// Call from FireButtonHelper public void Step4_ReleaseCharge() { if (buttonState == FireButtonState.HoldingButton) { if (fireMeterScript.IsMeterFull()) { buttonState = FireButtonState.BlowingFire; // if the meter was full on release, complete the attack! attackScript.FinishAttack(); Deactivate(); buttonState = FireButtonState.Empty; } else { // if the meter was not full, cancel the attack attackScript.Cancel(); buttonState = FireButtonState.ReadyForPress; } // regardless we want to empty the meter fireMeterScript.Reset(); } else { Debug.LogWarning("Button state error " + buttonState.ToString()); } }
// Called from FireButtonHelper public void Step3_ChargeFire() { if (buttonState == FireButtonState.ReadyForPress) { if (DataManager.Instance.GameData.PetInfo.CanBreathFire()) // if can breathe fire, attack the gate!! { buttonState = FireButtonState.HoldingButton; // kick off the attack script attackScript = PetAnimationManager.Instance.gameObject.AddComponent <AttackGate>(); attackScript.Init(currentGate); PetAnimationManager.Instance.StartFireBlow(); // turn the fire meter on fireMeterScript.StartFilling(); } // else can't breathe fire. explain why else { if (!TutorialManager.Instance.IsTutorialActive()) { GatingManager.Instance.IndicateNoFire(); } } } else { Debug.LogWarning("Button state error " + buttonState.ToString()); } }
// Called from FireButtonHelper - Fire orb is dropped onto button public void Step1_SetButtonActiveWithItem(InventoryItem itemData) { if (buttonState == FireButtonState.Empty) { bool canBreatheFire = DataManager.Instance.GameData.PetInfo.CanBreathFire(); // Only works if item is flame crystal and pet can't breathe fire yet if (itemData.ItemID == "Usable1" && !canBreatheFire) { // Check to make sure the item can be used if (ItemManager.Instance.CanUseItem(itemData.ItemID)) { // Notify inventory logic that this item is being used InventoryManager.Instance.UsePetItem(itemData.ItemID); // Pass, move on buttonState = FireButtonState.ActivatingButton; animHelper.StartFireButtonAnimation(); } } } else { Debug.LogWarning("Button state error " + buttonState.ToString()); } }
// This is called from start, and from FireButtonAnimHelper (looped back in) public void TurnFireEffectOn(bool isAnimEvent) { animHelper.FireEffectOn(isAnimEvent); buttonState = FireButtonState.ReadyForPress; if (FireButtonActive != null) // Used for tutorials { FireButtonActive(this, EventArgs.Empty); } }
// Called from FireButtonAnimHelper public void Step2_AnimationComplete() { if (buttonState == FireButtonState.ActivatingButton) { buttonState = FireButtonState.ReadyForPress; } else { Debug.LogWarning("Button state error " + buttonState.ToString()); } }
// Called when the pet reaches a smoke monster room public void Activate() { // The fire button will always be spawned at the pet's location GameObject pet = GameObject.Find("Pet"); transform.position = pet.transform.position; isActive = true; toggleParent.SetActive(true); bool canBreatheFire = DataManager.Instance.GameData.PetInfo.CanBreathFire(); if (!canBreatheFire) { TurnFireEffectOff(); } else { TurnFireEffectOn(false); buttonState = FireButtonState.ReadyForPress; } }