public void Update(float deltaTime) { timer -= deltaTime; if (timer <= 0f) { enemyManager.Spawn(EnemyFactory.GetEnemy($"Enemy{random.Next(1, 5)}")); timer = maxTimer; //tot++; } if (!Enabled) { Moldels.Enemy.ExtraDepth = 0; } }
public void CreateEntity(MsgSCLoadscene msg) { if (msg.GetKind() == MsgSCLoadscene.MSG_KIND_ENEMY) enemymanager.Spawn(msg.GetID(), msg.GetEntityID(), msg.GetPosition(), msg.GetQuat()); if (msg.GetKind() == MsgSCLoadscene.MSG_KIND_TRAP) trapmanager.CreateTrap(msg.GetID(), msg.GetEntityID(), msg.GetPosition(), msg.GetQuat()); if (msg.GetKind() == MsgSCLoadscene.MSG_KIND_PLAYER) { if (msg.GetID() == this.userID) playermanager.CreatePlayer(msg.GetID(), msg.GetEntityID(),msg.GetPosition(), msg.GetQuat(), true); else playermanager.CreatePlayer(msg.GetID(), msg.GetEntityID() ,msg.GetPosition(), msg.GetQuat(), false); } if (msg.GetEntityID() == MsgSCLoadscene.MSG_KIND_TRAP) { trapmanager.CreateTrap(msg.GetID(), msg.GetEntityID(), msg.GetPosition(), msg.GetQuat()); } }
// Update is called once per frame void Update() { em.Spawn(); }
void Update() { if (selectedDevice == null) { return; } if (!hasStartGame) { if (Input.GetMouseButtonDown(0)) { hasStartGame = true; TitleText.gameObject.SetActive(false); EnemyManager.DeadMonsterCount = 0; m_EnemyManager.Spawn(); } return; } if (CurrentLevel == "level1") { if (!IsWin) { if (BalloonManager.BrokenBalloonCount > 9) { IsWin = true; StartCoroutine(loadNextLevel()); } } } else if (CurrentLevel == "level2") { if (!IsWin) { if (EnemyManager.DeadMonsterCount >= 24) { IsWin = true; StartCoroutine(loadNextLevel()); } } } else if (CurrentLevel == "level3") { if (!IsWin) { if (EnemyManager.DeadMonsterCount >= 40) { IsWin = true; StartCoroutine(loadNextLevel()); } } } if (IsWin) { return; } GetComponent <AudioSource>().GetOutputData(data, 0); float sum = 0f; for (int i = 0; i < data.Length; i++) { sum += data[i] * data[i]; } float rmsValue = Mathf.Sqrt(sum / data.Length); float dbValue = 20f * Mathf.Log10(rmsValue / refValue); string noteText = null; if (dbValue < minVolumeDB) { //Sound too low noteText = null; NoteTextUI.text = ""; return; } //PITCH DTECTED!! pitchDetector.DetectPitch(data); int midiant = pitchDetector.lastMidiNote(); int midi = findMode(); noteText = pitchDetector.midiNoteToString(midi); detectionsMade [detectionPointer++] = midiant; detectionPointer %= cumulativeDetections; if (noteText == null) { noteTimer [0] = 0; noteTimer [1] = 0; noteTimer [2] = 0; noteTimer [3] = 0; noteTimer [4] = 0; noteTimer [5] = 0; noteTimer [6] = 0; } else if (noteText == "C 3") { noteTimer [0] += 1; noteTimer [1] = 0; noteTimer [2] = 0; noteTimer [3] = 0; noteTimer [4] = 0; noteTimer [5] = 0; noteTimer [6] = 0; if (noteTimer [0] > triggerFrames) { m_ArcherManager.Archers [6].ShootArrow(); Vector3 pos = m_ArcherManager.Archers [6].transform.position; pos.x = UI_x; NoteTextUI.transform.position = pos; } } else if (noteText == "D 3") { noteTimer [0] = 0; noteTimer [1] += 1; noteTimer [2] = 0; noteTimer [3] = 0; noteTimer [4] = 0; noteTimer [5] = 0; noteTimer [6] = 0; if (noteTimer [1] > triggerFrames) { m_ArcherManager.Archers [5].ShootArrow(); Vector3 pos = m_ArcherManager.Archers [5].transform.position; pos.x = UI_x; NoteTextUI.transform.position = pos; } } else if (noteText == "E 3") { noteTimer [0] = 0; noteTimer [1] = 0; noteTimer [2] += 1; noteTimer [3] = 0; noteTimer [4] = 0; noteTimer [5] = 0; noteTimer [6] = 0; if (noteTimer [2] > triggerFrames) { m_ArcherManager.Archers [4].ShootArrow(); Vector3 pos = m_ArcherManager.Archers [4].transform.position; pos.x = UI_x; NoteTextUI.transform.position = pos; } } else if (noteText == "F 3") { noteTimer [0] = 0; noteTimer [1] = 0; noteTimer [2] = 0; noteTimer [3] += 1; noteTimer [4] = 0; noteTimer [5] = 0; noteTimer [6] = 0; if (noteTimer [3] > triggerFrames) { m_ArcherManager.Archers [3].ShootArrow(); Vector3 pos = m_ArcherManager.Archers [3].transform.position; pos.x = UI_x; NoteTextUI.transform.position = pos; } } else if (noteText == "G 3") { noteTimer [0] = 0; noteTimer [1] = 0; noteTimer [2] = 0; noteTimer [3] = 0; noteTimer [4] += 1; noteTimer [5] = 0; noteTimer [6] = 0; if (noteTimer [4] > triggerFrames) { m_ArcherManager.Archers [2].ShootArrow(); Vector3 pos = m_ArcherManager.Archers [2].transform.position; pos.x = UI_x; NoteTextUI.transform.position = pos; } } else if (noteText == "A 3") { noteTimer [0] = 0; noteTimer [1] = 0; noteTimer [2] = 0; noteTimer [3] = 0; noteTimer [4] = 0; noteTimer [5] += 1; noteTimer [6] = 0; if (noteTimer [5] > triggerFrames) { m_ArcherManager.Archers [1].ShootArrow(); Vector3 pos = m_ArcherManager.Archers [1].transform.position; pos.x = UI_x; NoteTextUI.transform.position = pos; } } else if (noteText == "B 3") { noteTimer [0] = 0; noteTimer [1] = 0; noteTimer [2] = 0; noteTimer [3] = 0; noteTimer [4] = 0; noteTimer [5] = 0; noteTimer [6] += 1; if (noteTimer [6] > triggerFrames) { m_ArcherManager.Archers [0].ShootArrow(); Vector3 pos = m_ArcherManager.Archers [0].transform.position; pos.x = UI_x; NoteTextUI.transform.position = pos; } } else { noteTimer [0] = 0; noteTimer [1] = 0; noteTimer [2] = 0; noteTimer [3] = 0; noteTimer [4] = 0; noteTimer [5] = 0; noteTimer [6] = 0; } NoteTextUI.text = noteText; //Debug.Log (noteText); }
// Update is called once per frame void Update() //once the mystery item is activated, this function will update the player stats { if (mysteryItemActive == true) { mysteryItemLengthCounter -= Time.deltaTime; Debug.Log("delta time: " + mysteryItemLengthCounter); if (increaseSpeed) //increase player's speed by 1.5 { thePlayerControlManager.PlayerMovementSpeed = normalMovementSpeed * 1.5f; } if (superJump) //increase player's jump force by 1.5 { thePlayerControlManager.PlayerJumpForce = normalJumpForce * 1.5f; } if (decreaseSpeed) // decrease player's speed by half { thePlayerControlManager.PlayerMovementSpeed = normalMovementSpeed * .5f; } if (cantJump) // decrease player's jump by half { thePlayerControlManager.PlayerJumpForce = 0; } if (increaseHealth) // increase the player's health by a random number between 25-74 { int randNum = Random.Range(25, 75); PlayerControl.currentPlayer.Health += randNum; if (PlayerControl.currentPlayer.Health > 100) { PlayerControl.currentPlayer.Health = 100; } mysteryItemActive = false; } if (decreaseHealth) // decrease the player's health by a random number between 10-29 { int randNum = Random.Range(10, 30); if (immortality == false) { PlayerControl.currentPlayer.Health -= randNum; } //PlayerControl.currentPlayer.Health = -5; if (PlayerControl.currentPlayer.Health <= 0) { PlayerControl.currentPlayer.Health = 1; //thePlayerControlManager.PlayerTakeDamage(); //thePlayerControlManager.WhenPlayerIsDead(); } mysteryItemActive = false; } if (shield) // increase player's shield by a random number between 10-49 { int randNum = Random.Range(10, 50); PlayerControl.currentPlayer.Shield += randNum; if (PlayerControl.currentPlayer.Shield > 50) { PlayerControl.currentPlayer.Shield = 50; } mysteryItemActive = false; } if (gainWeapon) // player gains a weapon { thePlayerControlManager.IsPlayerGunAttack = true; mysteryItemActive = false; } if (loseWeapon) // player loses a weapon { thePlayerControlManager.IsPlayerGunAttack = false; } if (moreEnemies) // spawn more enemy { spawnEnemies.Spawn(); //EnemyManager.Spawn(); mysteryItemActive = false; } if (immortality) // the player becomes an immortal for a short time { thePlayerControlManager.IsPlayerImmortal = true; } if (mysteryItemLengthCounter <= 0) { // return the player's stat back to normal thePlayerControlManager.PlayerJumpForce = normalJumpForce; thePlayerControlManager.PlayerMovementSpeed = normalMovementSpeed; thePlayerControlManager.IsPlayerImmortal = false; thePlayerControlManager.IsPlayerGunAttack = false; mysteryItemActive = false; // set the mystery item active to false to exit the loop } } }