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 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; } }
// Actions private void Die() { Vector3 deathPos = transform.position; // Move to spawn, stop controls and become invincible SFXHandler.PlaySound("playerdeath"); StartCoroutine(DeathVisualEffect(1f, .6f, 80f, deathPos)); StartCoroutine(Invincibility(3f)); StartCoroutine(Paralyze(.3f)); transform.position = startPos; // Lose 35% of power and drop 30% // Drops power above death position DropPower(deathPos, power * 0.30f); ChangePower(power * 0.65f); // Kill bullets BulletHandler.BulletsToScore(); if (lives > 0) { lives--; Score.UpdatePlayer(lives); } else { // Pause and disable resuming on game over PauseMenu.TogglePause(PauseMode.GameOver); Debug.Log("Game Over"); } }
void OnTriggerEnter2D(Collider2D collider) { if (collider.CompareTag("Enemy")) { if (!invincible) { Die(); } } else if (collider.CompareTag("Pickup")) { SFXHandler.PlaySound("item_generic"); Pickup pickup = collider.GetComponent <Pickup>(); switch (pickup.type) { case PickupType.Point: float multiplier = (pickup.fixedScore == 0) ? pickup.GetScore() : pickup.fixedScore; AddScore((uint)Mathf.RoundToInt(pickup.value * multiplier)); break; case PickupType.Power: ChangePower(power + 0.03f * pickup.value); break; } } }
public void DoInitialization() { sfxHandler = SFXHandler.instance; // creates instance of audio handler damage = 25; // defaults to 25 damage active = true; //Debug.Log("Initialized Collision"); }
void Update() { if (hasAi && StageHandler.InStageBounds(transform.position)) { if (!ai.inBounds) { ai.nextFire = Time.time; ai.inBounds = true; } } else { ai.inBounds = false; } if (hitOnFrame) { SFXHandler.PlaySound("enemyhit_loop", true); hitOnFrame = false; } else { SFXHandler.StopSound("enemyhit_loop"); } }
public void Die() { // Don't accidentally spawn multiple pickups if (!dead) { dead = true; // Play death sound SFXHandler.PlaySound("enemydeath"); // Spawn pickups while (scoreValue > 0 && powerValue > 0) { if (scoreValue > 0) { StageHandler.SpawnPickup(0, transform.position, (Vector2)transform.position + (Random.insideUnitCircle + Vector2.up) * .5f, .2f); scoreValue--; } if (powerValue > 0) { StageHandler.SpawnPickup(1, transform.position, (Vector2)transform.position + (Random.insideUnitCircle + Vector2.up) * .5f, .2f); powerValue--; } } // Destroy object Destroy(gameObject); } }
public override void Demolish() { if (IsDestructible) { InteractionResponder.StartDemolish(); SFXHandler.GetInstance().PlayFX("building_collapse"); } }
/// <summary> /// Called on the very first frame of the game /// </summary> private void Start() { animController = GetComponent <AnimationController>(); // just getting a reference to our animation component on our dancer...this is behind the scenes for the dancing to occur. sfxHandler = FindObjectOfType <SFXHandler>(); // Finds a reference to our sfxHandler script that is in our scene. particleHandler = GetComponentInChildren <ParticleHandler>(); // searching through the child objects of this object to find the particle system. // We probably want to call our InitialStats function here. InitialStats(); }
public override void Shoot() { SFXHandler.PlaySound("enemyshot"); bulletData.pos = transform.position; bulletData.rot = BulletHandler.AngleToPlayer(transform.position); BulletHandler.ShootBullet(bulletData); }
public override void _Ready() { Instance = this; // GameData.Instance.Connect(nameof(GameData.ChangeGameState), this, nameof(Change)); battleMusic = ResourceLoader.Load <AudioStream>(battleMusicPath); villageMusic = ResourceLoader.Load <AudioStream>(villageMusicPath); titleScreenMusic = ResourceLoader.Load <AudioStream>(titleScreenMusicPath); SoundHolder = GetChildren().Cast <AudioStreamPlayer>().ToDictionary((player) => player.Name); }
// ensures a single instance on the bound object // SINGLETON PATTERN void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } }
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(); }
// 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(); }
private void Bomb() { if (bombs > 0) { bombs--; Score.UpdateBombs(bombs); // Start bomb visual, audio and "physical" effects SFXHandler.PlaySound("bomb"); StartCoroutine(ScaleRotateEffect(3f, .8f, 80f, bombEffect)); StartCoroutine(BombEffect(.6f)); } }
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); } } }
public override void Shoot() { SFXHandler.PlaySound("burstshot"); bulletData.pos = transform.position; bulletData.rot = BulletHandler.AngleToPlayer(transform.position); StartCoroutine(BulletHandler.ShootBurst( bulletData, burstSpread, burstCount, burstTime )); }
void Start() { // bind audio sfxHandler = SFXHandler.instance; string path = Path.Combine(Application.persistentDataPath, fileName); // create a wallet file if one doesn't already exist if (!File.Exists(path)) { Debug.Log("Creating wallet file\n"); File.Create(path); } }
// Update power value public void ChangePower(float newPower, bool silent = false) { newPower = Mathf.Clamp(newPower, 0f, 5f); if (Mathf.FloorToInt(newPower) > Mathf.FloorToInt(power) && !silent) { SFXHandler.PlaySound("powerup"); } power = newPower; Score.UpdatePower(newPower); damage = Mathf.Lerp(1f, 5f, newPower / 5); UpdateOrb(Mathf.Clamp(Mathf.FloorToInt(newPower), 0, 4)); }
// 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(); }
private void Start() { _vfx = GetComponent <VfxHandler>(); _sfx = GetComponent <SFXHandler>(); _invAnim = GetComponent <InvincibilityAnimation>(); //Set to an eventual base number _stats = GetComponent <CharacterStats>(); if (_stats != null) { _maxHealth.Value = _stats.BaseStats.MaxHealth; } UpdateCurrentHealth(_maxHealth); _isInvincible = false; _timeInvincibleLeft = 0f; }
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); }
void Awake() { instance = this; // TODO: Use list? sfx = new Dictionary <string, SFX>(soundEffects.Capacity); for (int i = 0; i < soundEffects.Capacity; i++) { GameObject obj = new GameObject(soundEffects[i].name, typeof(AudioSource)); obj.transform.SetParent(transform); AudioSource audioSource = obj.GetComponent <AudioSource>(); audioSource.clip = soundEffects[i]; audioSource.playOnAwake = false; audioSource.volume = volume[i]; audioSource.outputAudioMixerGroup = mixerGroup; sfx.Add(soundEffects[i].name, new SFX(i, audioSource)); } }
void Update() { // Handle controls focus = Input.GetButton("Focus"); focusHitbox.enabled = focus; Orb.radius = focus ? .4f : .6f; shooting = Input.GetButton("Shoot"); // Reset fire timer and play shooting sound if (Input.GetButtonDown("Shoot")) { SFXHandler.PlaySound("generic_shot", true); nextFire = Time.time; } if (Input.GetButtonUp("Shoot")) { SFXHandler.StopSound("generic_shot"); } if (Input.GetButtonDown("Bomb")) { Bomb(); } // Movement movement = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical")); movement.Normalize(); movement *= focus ? focusMovementSpeed : movementSpeed; // Animation if (paralyzed) { anim.SetFloat("Horizontal", 0); anim.SetBool("Moving", false); } else { anim.SetFloat("Horizontal", movement.x); anim.SetBool("Moving", movement.x != 0); } }
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 _Ready() { text = GetNode <SmartText>(textPath); SFXHandler.Instance.Change(GameData.GameState.None); SFXHandler.PlaySFX("Shamisen"); }
private void Awake() { Instance = this; }
public void OnCancel(BaseEventData eventData) { EventSystem.current.SetSelectedGameObject(cancelObject); SFXHandler.PlaySound("hit"); }
public void OnSelect(BaseEventData eventData) { SFXHandler.PlaySound("generic_shot"); }