// Update is called once per frame
 void Update()
 {
     if (stateMachine == GameStateMachine.Prepare)
     {
         Time.timeScale = 0f;
         ResetGame();
         stateMachine = GameStateMachine.Running;
         gameController.ResetGameLevel();
     }
     else if (stateMachine == GameStateMachine.Running)
     {
         Time.timeScale = 1f;
         tmpPos         = selectedTank == null ? transform.position : selectedTank.transform.position;
         gameController.UpdateHeroPosition(tmpPos);
         camController.SetUpCam(tmpPos);
     }
     else if (stateMachine == GameStateMachine.Hold)
     {
         Time.timeScale = 0f;
     }
     else if (stateMachine == GameStateMachine.HeroDied)
     {
         Time.timeScale = 0f;
         NCenter.OnNotify(new OnEndGameNotification {
             totalKills = 123
         });
         stateMachine = GameStateMachine.Hold;
     }
 }
 void ResetStats()
 {
     selectedTank.transform.SetParent(transform, true);
     selectedTank.transform.localPosition = Vector3.zero;
     heroConditions           = selectedTank.tankStats;
     heroConditions.CurrentHP = heroConditions.HealthPoints;
     heroConditions.isAlive   = true;
     if (NCenter != null)
     {
         NCenter.OnNotify(new OnWeaponChangedNotification {
             activeWeaponIndex = selectedTank.SelectedWeaponIndext
         });
         NCenter.OnNotify(new OnHeroChangeStatsNotification {
             heroStats = heroConditions
         });
     }
 }
 public void OnNotify(INotification notification)
 {
     if (notification is OnHeroLevelUP)
     {
     }
     else if (notification is OnDealDamageToHero)
     {
         if (!heroConditions.isAlive)
         {
             return;
         }
         var n = notification as OnDealDamageToHero;
         heroConditions.CurrentHP -= calcDamage(n.DealDamage);
         NCenter.OnNotify(new OnHeroChangeStatsNotification {
             heroStats = heroConditions
         });
         if (heroConditions.CurrentHP < 0)
         {
             stateMachine           = GameStateMachine.HeroDied;
             heroConditions.isAlive = false;
         }
     }
 }
 void MoveHero(InputCommand command)
 {
     if (command is MoveCommand)
     {
         selectedTank.MoveTankCommand(command.worldDirection, .4f);
     }
     else if (command is ShootCommand)
     {
         if (selectedTank.TryShoot(ref current_bullet))
         {
             gameController.OnShoot(current_bullet);
         }
     }
     else if (command is RotateCommand)
     {
         selectedTank.RotateTurret(command.worldDirection);
     }
     else if (command is SwitchWeaponCommand)
     {
         if (command.worldDirection.x > 0)
         {
             selectedTank.SelectNextWeapon();
         }
         else
         {
             selectedTank.SelectPreviousWeapon();
         }
         NCenter.OnNotify(new OnWeaponChangedNotification {
             activeWeaponIndex = selectedTank.SelectedWeaponIndext
         });
     }
     else if (command is ResetLevelCommand)
     {
         NCenter.OnNotify(new OnRestartGameNotification());
     }
 }