public override void OnTick() { if (interactors.Count > 0) { if (resources.getResourceType(ResourceType.happiness) < resources.getResourceMaxType(ResourceType.happiness)) { spawn_time -= interactors.Count; if (spawn_time <= 0) { spawn_time = max_spawn_time; if (SFXHandler.GetInstance().CanPlaySpawnSFX) { SFXHandler.GetInstance().PlayRandomFX(spawnAudioClips); } resources.addResourceType(ResourceType.happiness, 1); float randomX = Random.Range(0, randomXSpawnVariance) - randomXSpawnVariance / 2f; GameObject instance = Instantiate(dwarf, this.gameObject.transform.position, this.gameObject.transform.rotation) as GameObject; var dwarfParent = GameObject.FindGameObjectWithTag("DwarfHolder"); instance.transform.parent = dwarfParent.transform; Vector3 newPosition = new Vector3(instance.transform.position.x + randomX, instance.transform.position.y, -1); instance.transform.position = newPosition; instance.GetComponent <Interactor>().Depth = gameObject.GetComponent <Interactable>().Depth; } } } if (Tracker != null) { Tracker.MaxValue = max_spawn_time; Tracker.CurrentValue = max_spawn_time - spawn_time; } }
public override void OnTick() { if (HasFightingTarget && !IsFighting) { return; } if (IsFighting) { if (damageDealer.TickAndCheckIfWeShouldAttack()) { if (FightingTarget == null) { TargetChange(); return; } if (SFXHandler.GetInstance().CanPlayAttackSFX) { SFXHandler.GetInstance().PlayFX("dwarf_attack"); } FightingTarget.DamageReceiver.OnDamage(this.gameObject, damageDealer.AttackParameter); } return; } }
public override void Demolish() { if (IsDestructible) { InteractionResponder.StartDemolish(); SFXHandler.GetInstance().PlayFX("building_collapse"); } }
// Enemy AI Loop here public override void OnTick() { // Randomly make some noises if (GruntSFX.Length > 0) { if (SFXHandler.GetInstance().CanPlayEnemyGruntSFX) { SFXHandler.GetInstance().PlayRandomFX(GruntSFX); } } EnemyLogic.OnTick(); }
public void OnStop() { SFXHandler.GetInstance().PlayFX("ui_click"); if (consistencyHandler.CurrentInteractorSelection == null) { Debug.LogWarning("This shouldn't happen, stop was clicked but no interactor was selected"); return; } consistencyHandler.CurrentInteractorSelection.OnStop(); BuildPicker.SetActive(false); consistencyHandler.SetDirty(); }
public void DisplayTutorial() { if (DataHandler.Handler.DepthReached < tutorials.Length) { if (tutorials[DataHandler.Handler.DepthReached] != "") { gameObject.SetActive(true); SFXHandler.GetInstance().PlayFX("ui_message"); text_field.text = tutorials[DataHandler.Handler.DepthReached]; Invoke("HideTutorial", DisplayTime); } } }
// Event called when the "use" button is clicked on the panel public void OnUse() { SFXHandler.GetInstance().PlayFX("ui_click"); if (consistencyHandler.CurrentInteractorSelection == null) { Debug.LogWarning("This shouldn't happen, use was clicked but no interactor was selected"); return; } if (consistencyHandler.CurrentInteractableSelection == null) { Debug.LogWarning("This shouldn't happen, use was clicked but no interactable was selected"); return; } consistencyHandler.CurrentInteractorSelection.OnUse(consistencyHandler.CurrentInteractableSelection); consistencyHandler.SetDirty(); }
public void OnDestroyButton() { SFXHandler.GetInstance().PlayFX("ui_click"); if (consistencyHandler.CurrentInteractorSelection == null) { Debug.LogWarning("This shouldn't happen, use was clicked but no interactor was selected"); return; } if (consistencyHandler.CurrentInteractableSelection == null) { Debug.LogWarning("This shouldn't happen, use was clicked but no interactable was selected"); return; } // This is like normal OnUse but instead we try to destroy consistencyHandler.CurrentInteractorSelection.OnUse(consistencyHandler.CurrentInteractableSelection, true); consistencyHandler.SetDirty(); }
public void OnSelect(GameObject obj) { SFXHandler.GetInstance().PlayFX("ui_click"); if (BuildPicker.GetComponent <PickerStatus>().build_reference) { BuildPicker.GetComponent <PickerStatus>().Build(obj); } if (consistencyHandler.CurrentInteractorSelection == null) { Debug.LogWarning("This shouldn't happen, use was clicked but no interactor was selected"); return; } if (consistencyHandler.CurrentInteractableSelection == null) { Debug.LogWarning("This shouldn't happen, use was clicked but no interactable was selected"); return; } consistencyHandler.CurrentInteractorSelection.OnUse(consistencyHandler.CurrentInteractableSelection); }
public void addResourceMaxType(string type, int quantity) { // Play tavern sound if (type == "happiness") { SFXHandler.GetInstance().PlayFX("max_tavern"); // Play mine sound } else { SFXHandler.GetInstance().PlayFX("max_ore"); } switch (type) { case "stone": max_stone += quantity; break; case "iron": max_iron += quantity; break; case "gold": max_gold += quantity; break; case "diamond": max_diamond += quantity; break; case "mithril": max_mithril += quantity; break; case "happiness": max_happiness += quantity; break; } }
public override void StopAllWork() { base.StopAllWork(); // TODO: temporary audio cue, gotta fix with the real one SFXHandler.GetInstance().PlayFX("sfx_build"); }
public override void StopAllWork() { base.StopAllWork(); SFXHandler.GetInstance().PlayFX("sfx_build"); }