// Update is called once per frame protected override void Update() { base.Update(); if (p != null && p.id != 0) { kalman.addObservation(new Vector4(player.transform.position.x, 0, player.transform.position.y, 0)); } addInterpretedPosition(kalman.PosInterp); if (isEnd) { if (Time.time - initEndTimer >= 2) { isEnd = false; EventManager <bool, int> .Raise(EnumEvent.SPACESHIPDESTROYED, false, 5 *scoreMult); } } #if UNITY_EDITOR /* DEBUG : Moving points around */ //target.transform.position = kalman.interpolation(60); //target.transform.position = kalman.PosInterp; target.transform.position = interpolation(60); noisedPosition.transform.position = kalman.PosBruit; imprecision.transform.position = kalman.PosImprecise; #endif if (p == null) { return; } // IA State management switch (p.id) { case 0: // IA Aléatoire { if (Time.time - stateTimer > stateChangeTimer) { stateTimer = Time.time; actionNumber = 0; changeRandomState(); } switch (IAState) { case SWIAState.RANDOM: { moveRandomly(); attackRandomly(); } break; case SWIAState.MOVE_RANDOMLY: { moveRandomly(); } break; case SWIAState.ATTACK_RANDOMLY: { attackRandomly(); } break; case SWIAState.DODGE_ATTACKS: { IAState = SWIAState.RANDOM; moveRandomly(); attackRandomly(); } break; } } break; case 1: case 2: { switch (IAState) { case SWIAState.MOVE_TOWARDS_PLAYER: { if (dodgeAttacks()) { moveTowardsPlayer(); } } break; case SWIAState.ATTACK_PLAYER: { attackPlayer(); } break; case SWIAState.DODGE_ATTACKS: { if (dodgeAttacks()) { moveIntelligently(); } } break; } } break; } }