void MoveToTile() { Vector3 global_pos = transform.GetGlobalPosition(); bool in_x = false; bool in_y = false; //Displace barrel in X if (Mathf.Abs(target_pos_x - global_pos.x) > error_margin) { float displacement; if (target_pos_x - global_pos.x < 0) { displacement = -1; } else { displacement = 1; } transform.SetGlobalPosition(new Vector3(global_pos.x + (Time.deltaTime * speed * displacement), global_pos.y, global_pos.z)); } else { in_x = true; } //Displace barrel in Y if (in_x == true && Mathf.Abs(target_pos_y - global_pos.z) > error_margin) { float displacement; if (target_pos_y - global_pos.z < 0) { displacement = -1; } else { displacement = 1; } transform.SetGlobalPosition(new Vector3(global_pos.x, global_pos.y, global_pos.z + (Time.deltaTime * speed * displacement))); } else { in_y = true; } if (in_x && in_y) { //If arrived to tile in_tile = true; audio.PlayEvent("RopeCut"); } }
public void OpenDoor() { current_open_calls++; if (current_open_calls == needed_open_calls) { current_open_calls = 0; go_open = true; audio.PlayEvent("DoorLoop"); Input.RumblePlay(0.3f, 5000); } }
public override bool ActionStart() { anim_comp = GetComponent <CompAnimation>(); audio_comp = GetComponent <CompAudio>(); anim_comp.PlayAnimationNode("Die"); //TODO_AI: Die audio audio_comp.PlayEvent("Enemy_SwordDrop"); //PLAY COMBAT MUSIC Audio.ChangeState("MusicState", "None"); GetLinkedObject("event_manager").GetComponent <PerceptionManager>().player_seen = false; Debug.Log("COMBAT OFF", Department.PLAYER, Color.BLUE); StatsScore.KillEnemy(); //Play Dead Audio if (GetComponent <EnemyShield_BT>() != null) { audio_comp.PlayEvent("Enemy3_Dead"); } else if (GetComponent <EnemySpear_BT>() != null) { audio_comp.PlayEvent("Enemy2_Dead"); } else if (GetComponent <EnemySword_BT>() != null) { audio_comp.PlayEvent("Enemy1_Dead"); } //Deactivate Listener if (GetComponent <SpearGuard_Listener>() != null) { GetComponent <SpearGuard_Listener>().SetEnabled(false); } else if (GetComponent <ShieldGuard_Listener>() != null) { GetComponent <ShieldGuard_Listener>().SetEnabled(false); } else if (GetComponent <SwordGuard_Listener>() != null) { GetComponent <SwordGuard_Listener>().SetEnabled(false); } anim_comp.SetClipDuration("Die", duration); GetComponent <CompCollider>().CollisionActive(false); return(true); }
public override bool ActionStart() { player = GetLinkedObject("target").GetComponent <CharactersManager>(); if (player == null) { Debug.Log("[error] Attack Action Start: Player is null!"); } anim_comp = GetComponent <CompAnimation>(); audio_comp = GetComponent <CompAudio>(); if (player.dying == false) { anim_comp.SetClipDuration("Attack", attack_duration); anim_comp.PlayAnimationNode("Attack"); Debug.Log("Back to Attack", Department.IA); audio_comp.PlayEvent("Enemy1_Slash"); } damage_done = false; shield_attack = false; //Interrupt player action return(true); }
void OnContact() { Debug.Log("CONTACT", Department.STAGE, Color.RED); CompCollider col = GetComponent <CompCollider>(); GameObject collided_obj = col.GetCollidedObject(); if (collided_obj != null && destroyed == false) { if (collided_obj.CompareTag("player")) { CharactersManager cm = collided_obj.GetComponent <CharactersManager>(); if (cm != null) { cm.GetDamageProjectile(damage); } } Debug.Log(collided_obj.GetTag().ToString(), Department.STAGE); } else { Debug.Log("Collided obj NULL", Department.STAGE, Color.ORANGE); } if (!destroyed) { destroyed = true; col.CollisionActive(false); audio.PlayEvent("DaenerysFireballImpact"); Destroy(gameObject); } }
void Start() { level_map = GetLinkedObject("map_obj").GetComponent <LevelMap>(); char_manager = GetComponent <CharactersManager>(); characters_camera = GetLinkedObject("characters_camera"); player_enemies_manager = GetLinkedObject("player_enemies_manager"); Audio.StopAllSounds(); audio = GetComponent <CompAudio>(); audio.PlayEvent("PlayMusic"); Audio.ChangeState("MusicState", "None"); curr_dir = (Direction)start_direction; update_rotation = false; map_width = Map.GetWidthMap(); map_height = Map.GetHeightMap(); endPosition = GetComponent <Transform>().local_position; endRotation = GetComponent <Transform>().local_rotation; //SET PLAYER INTO THE CORRECT MAP TILE level_map.GetPositionByeValue(out curr_x, out curr_y, 2); //2 = player start position level_map.UpdateMap(curr_x, curr_y, 0); MovePositionInitial(new Vector3((float)curr_x * distanceToMove, GetComponent <Transform>().local_position.y, (float)curr_y * distanceToMove)); drowning = false; }
public override ACTION_RESULT ActionUpdate() { if (player.dying) { Debug.Log("DON'T ATTACK PLAYER", Department.PLAYER, Color.ORANGE); return(ACTION_RESULT.AR_FAIL); //Player is dead, don't attack } if (state == BWA_STATE.PRE_APPLY && GetComponent <CompAnimation>().IsAnimOverXTime(apply_damage_point)) { anim.SetClipDuration("WideAttack", (attack_duration / (1.0f - apply_damage_point))); state = BWA_STATE.POST_APPLY; int enemy_tile_x = move.GetCurrentTileX(); int enemy_tile_y = move.GetCurrentTileY(); movement_ctrl.GetPlayerPos(out int player_tile_x, out int player_tile_y); audio.PlayEvent("BossSwordSwing"); switch (move.GetDirection()) { case Movement_Action.Direction.DIR_WEST: if ((enemy_tile_x - 1 == player_tile_x || enemy_tile_x == player_tile_x) && (player_tile_y == enemy_tile_y || player_tile_y == enemy_tile_y - 1 || player_tile_y == enemy_tile_y + 1)) { characters_manager.GetDamage(damage); } break; case Movement_Action.Direction.DIR_EAST: if ((enemy_tile_x + 1 == player_tile_x || enemy_tile_x == player_tile_x) && (player_tile_y == enemy_tile_y || player_tile_y == enemy_tile_y - 1 || player_tile_y == enemy_tile_y + 1)) { characters_manager.GetDamage(damage); } break; case Movement_Action.Direction.DIR_NORTH: if ((enemy_tile_y - 1 == player_tile_y || enemy_tile_y == player_tile_y) && (player_tile_x == enemy_tile_x || player_tile_x == enemy_tile_x - 1 || player_tile_x == enemy_tile_x + 1)) { characters_manager.GetDamage(damage); } break; case Movement_Action.Direction.DIR_SOUTH: if ((enemy_tile_y + 1 == player_tile_y || enemy_tile_y == player_tile_y) && (player_tile_x == enemy_tile_x || player_tile_x == enemy_tile_x - 1 || player_tile_x == enemy_tile_x + 1)) { characters_manager.GetDamage(damage); } break; } } else if (state == BWA_STATE.POST_APPLY && anim.IsAnimationStopped("WideAttack")) { state = BWA_STATE.WAITING; return(ACTION_RESULT.AR_SUCCESS); } return(ACTION_RESULT.AR_IN_PROGRESS); }
void Update() { if (curr_state != 0) { if (curr_state == CHANGE_STATE.MOVING_DOWN) { Vector3 pos = GetComponent <Transform>().GetPosition(); if (pos.y > min_height) { pos.y -= speed_down * Time.deltaTime; GetComponent <Transform>().SetPosition(pos); } else { pos.y = min_height; GetComponent <Transform>().SetPosition(pos); curr_state = CHANGE_STATE.TRAP_IDLE; LevelMap map_level = map.GetComponent <LevelMap>(); if (map_level != null) { map_level.UpdateMap(tile_x, tile_z, value); } audio.PlayEvent("DoorEnd"); Input.RumblePlay(1.0f, 500); } } else { Vector3 pos = GetComponent <Transform>().GetPosition(); if (pos.y < max_height) { pos.y += speed_up * Time.deltaTime; GetComponent <Transform>().SetPosition(pos); } else { pos.y = max_height; GetComponent <Transform>().SetPosition(pos); curr_state = CHANGE_STATE.TRAP_IDLE; audio.PlayEvent("DoorEnd"); Input.RumblePlay(1.0f, 500); } } } }
void Start() { rb = GetComponent <CompRigidBody>(); audio = GetComponent <CompAudio>(); Shoot(); collision = true; audio.PlayEvent("DaenerysFireballImpact"); }
public void StartCountdown() { current_time = initial_time; active = true; state = 1; Audio.ChangeState("PuzzleCountDownState", "State1"); audio = GetComponent <CompAudio>(); audio.PlayEvent("StartPuzzleCountdown"); }
public override ACTION_RESULT ActionUpdate() { if (comp_animation.IsAnimOverXTime(0.2f) && play_audio == false && GetComponent <EnemySpear_BT>() == null) { comp_audio.PlayEvent("Enemy_SwordDraw"); play_audio = true; } if (comp_animation.IsAnimationStopped("Draw")) { return(ACTION_RESULT.AR_SUCCESS); } return(ACTION_RESULT.AR_IN_PROGRESS); }
//2D coordinates, y=z in 3D coordinates void Start() { Audio.StopAllSounds(); audio = GetComponent <CompAudio>(); audio.PlayEvent("PlayMusic"); curr_dir = (Direction)start_direction; map_width = Map.GetWidthMap(); map_height = Map.GetHeightMap(); array2Da = new int[map_width, map_height]; for (int y = 0; y < map_height; y++) { for (int x = 0; x < map_width; x++) { array2Da[x, y] = 0; } } //array2Da[0,0] = 1; endPosition = GetComponent <Transform>().local_position; endRotation = GetComponent <Transform>().local_rotation; string map = Map.GetMapString(); int t = 0; for (int y = 0; y < map_height; y++) { for (int x = 0; x < map_width; x++) { array2Da[x, y] = int.Parse(map[t].ToString()); t += 1; } } //Search player position for (int y = 0; y < map_height; y++) { for (int x = 0; x < map_width; x++) { if (array2Da[x, y] == 2) { curr_x = x; curr_y = y; array2Da[x, y] = 0; MovePositionInitial(new Vector3((float)curr_x * distanceToMove, GetComponent <Transform>().position.y, (float)curr_y * distanceToMove)); } } } }
public override ACTION_RESULT ActionUpdate() { if (player.dying) { Debug.Log("DON'T ATTACK PLAYER", Department.PLAYER, Color.YELLOW); return(ACTION_RESULT.AR_FAIL); //Player is dead, don't attack } if (GetComponent <CompAnimation>().IsAnimOverXTime(damage_point) && damage_done == false) { damage_done = true; if (shield_attack) { player.ApplyFatigue(fatigue); } else { if (player.GetDamage(damage) == true) { audio_comp.PlayEvent("SwordHit"); anim_comp.SetFirstActiveBlendingClipWeight(0.0f); } else { anim_comp.SetFirstActiveBlendingClipWeight(1.0f); } } } if (anim_comp.IsAnimationStopped("Attack")) { return(ACTION_RESULT.AR_SUCCESS); } return(ACTION_RESULT.AR_IN_PROGRESS); }
public virtual bool ApplyDamage(float damage, ENEMY_GET_DAMAGE_TYPE damage_type) { if (current_action.action_type != Action.ACTION_TYPE.PUSHBACK_ACTION) { Debug.Log("Yes push hit", Department.PHYSICS, Color.BLUE); if (GetComponent <EnemySpear_BT>() != null) { audio_comp.PlayEvent("Enemy2_Hurt"); } if (GetComponent <EnemySword_BT>() != null) { audio_comp.PlayEvent("Enemy1_Hurt"); } next_action = GetComponent <GetHit_Action>(); GetComponent <GetHit_Action>().SetHitType(damage_type); // if (GetComponent<EnemySpear_BT>() == null) // InterruptAction(); } else { Debug.Log("Not push hit", Department.STAGE, Color.PINK); } if (current_action.action_type == Action.ACTION_TYPE.MOVE_ACTION || current_action.action_type == Action.ACTION_TYPE.INVESTIGATE_ACTION) { Debug.Log("TIME TO FIGHT", Department.PHYSICS, Color.PINK); current_action.Interupt(); next_action = GetComponent <Engage_Action>(); MovementController temp_move = player.GetComponent <MovementController>(); GetComponent <PerceptionEmitter>().TriggerPlayerSeenEvent(10.0f, temp_move.curr_x, temp_move.curr_y, this.gameObject, GetComponent <Movement_Action>().GetCurrentTileX(), GetComponent <Movement_Action>().GetCurrentTileY()); } current_hp -= damage; //ChangeTexturesToDamaged(); current_interpolation = current_hp / total_hp; dmg_alpha += 0.2f; if (current_hp <= 0) { //GetComponent<CompAnimation>().SetClipsSpeed(anim_speed); state = AI_STATE.AI_DEAD; life_state = ENEMY_STATE.ENEMY_DEAD; if (gameObject.GetComponent <CompCollider>() != null) { gameObject.GetComponent <CompCollider>().CollisionActive(false); } next_action = GetComponent <Die_Action>(); current_action.Interupt(); if (GetComponent <EnemySword_BT>() != null) { enemies_manager.GetComponent <EnemiesManager>().DeleteSwordEnemy(GetComponent <EnemySword_BT>().gameObject); } else if (GetComponent <EnemyShield_BT>() != null) { enemies_manager.GetComponent <EnemiesManager>().DeleteShieldEnemy(GetComponent <EnemyShield_BT>().gameObject); } else if (GetComponent <EnemySpear_BT>() != null) { enemies_manager.GetComponent <EnemiesManager>().DeleteLanceEnemy(GetComponent <EnemySpear_BT>().gameObject); } } else if (life_state != ENEMY_STATE.ENEMY_DAMAGED && current_hp < total_hp * damaged_limit) { life_state = ENEMY_STATE.ENEMY_DAMAGED; //ChangeTexturesToDamaged(); } UpdateHUD(); return(true); }
public override bool ApplyDamage(float damage, ENEMY_GET_DAMAGE_TYPE damage_type) { base.ActivateHUD(shield_name); switch (life_state) { case ENEMY_STATE.ENEMY_ALIVE: if (GetComponent <ShieldBlock_Action>().IsBlocking() == true || GetComponent <ChasePlayer_Action>().IsBlocking() == true) { if (damage_type == ENEMY_GET_DAMAGE_TYPE.FIREWALL) { audio_comp.PlayEvent("Enemy3_Hurt"); return(base.ApplyDamage(damage, damage_type)); } else if (damage_type == ENEMY_GET_DAMAGE_TYPE.FIREBALL) { Debug.Log("FIREBALL BLOCKED!", Department.PLAYER, Color.RED); audio_comp.PlayEvent("Enemy3_Hurt"); return(base.ApplyDamage(damage * fireball_pen, damage_type)); } else if (damage_type == ENEMY_GET_DAMAGE_TYPE.ARROW) { Debug.Log("ARROW BLOCKED!", Department.PLAYER, Color.RED); audio_comp.PlayEvent("Enemy3_Hurt"); return(base.ApplyDamage(damage * arrow_pen, damage_type)); } else if (damage_type == ENEMY_GET_DAMAGE_TYPE.FIREBREATH) { Debug.Log("FIREBREATH BLOCKED!", Department.PLAYER, Color.RED); audio_comp.PlayEvent("Enemy3_Hurt"); return(base.ApplyDamage(damage * firebreath_pen, damage_type)); } else { GetComponent <ShieldBlock_Action>().DecreaseBlockTime(); audio_comp.PlayEvent("Enemy3_ShieldBlock"); base.UpdateHUD(); return(false); } } else { return(base.ApplyDamage(damage, damage_type)); } break; case ENEMY_STATE.ENEMY_DAMAGED: if (GetComponent <ShieldBlock_Action>().IsBlocking() == true || GetComponent <ChasePlayer_Action>().IsBlocking() == true) { if (damage_type == ENEMY_GET_DAMAGE_TYPE.FIREWALL) { audio_comp.PlayEvent("Enemy3_Hurt"); return(base.ApplyDamage(damage, damage_type)); } else if (damage_type == ENEMY_GET_DAMAGE_TYPE.FIREBALL) { Debug.Log("FIREBALL BLOCKED!", Department.PLAYER, Color.RED); audio_comp.PlayEvent("Enemy3_Hurt"); return(base.ApplyDamage(damage * fireball_pen, damage_type)); } else if (damage_type == ENEMY_GET_DAMAGE_TYPE.ARROW) { Debug.Log("ARROW BLOCKED!", Department.PLAYER, Color.RED); audio_comp.PlayEvent("Enemy3_Hurt"); return(base.ApplyDamage(damage * arrow_pen, damage_type)); } else if (damage_type == ENEMY_GET_DAMAGE_TYPE.FIREBREATH) { Debug.Log("FIREBREATH BLOCKED!", Department.PLAYER, Color.RED); audio_comp.PlayEvent("Enemy3_Hurt"); return(base.ApplyDamage(damage * firebreath_pen, damage_type)); } else { GetComponent <ShieldBlock_Action>().DecreaseBlockTime(); GetComponent <CompAnimation>().PlayAnimationNode("Block"); audio_comp.PlayEvent("Enemy3_ShieldBlock"); base.UpdateHUD(); return(false); } } else { audio_comp.PlayEvent("Enemy3_Hurt"); return(base.ApplyDamage(damage, damage_type)); } break; case ENEMY_STATE.ENEMY_STUNNED: audio_comp.PlayEvent("Enemy3_Hurt"); return(base.ApplyDamage(damage, damage_type)); break; case ENEMY_STATE.ENEMY_DEAD: default: break; } return(true); }
void Update() { int tile_mov_x = 0; int tile_mov_y = 0; start_direction = (int)curr_dir; CheckIsWalkable(); if (GetComponent <Transform>().local_position == endPosition && rotating == false) { if (Input.GetKeyDown(KeyCode.Q)) //Left { actual_angle = 0; angle = -10; rotating = true; ModificateCurrentDirection(true); } if (Input.GetKeyDown(KeyCode.E)) //Right { actual_angle = 0; angle = 10; rotating = true; ModificateCurrentDirection(false); } if (Input.GetKeyDown(KeyCode.A)) //Left { audio = GetComponent <CompAudio>(); audio.PlayEvent("Footsteps"); MoveLeft(out tile_mov_x, out tile_mov_y); } else if (Input.GetKeyDown(KeyCode.D)) //Right { audio = GetComponent <CompAudio>(); audio.PlayEvent("Footsteps"); MoveRight(out tile_mov_x, out tile_mov_y); } else if (Input.GetKeyDown(KeyCode.W)) //Up { audio = GetComponent <CompAudio>(); audio.PlayEvent("Footsteps"); MoveForward(out tile_mov_x, out tile_mov_y); } else if (Input.GetKeyDown(KeyCode.S)) //Down { audio = GetComponent <CompAudio>(); audio.PlayEvent("Footsteps"); MoveBackward(out tile_mov_x, out tile_mov_y); } //Calculate endPosition if ((tile_mov_x != 0 || tile_mov_y != 0) && array2Da[curr_x + tile_mov_x, curr_y + tile_mov_y] == 0) { endPosition = new Vector3(GetComponent <Transform>().local_position.x + distanceToMove * (float)tile_mov_x, GetComponent <Transform>().local_position.y, GetComponent <Transform>().local_position.z + distanceToMove * (float)tile_mov_y); curr_x += tile_mov_x; curr_y += tile_mov_y; } } else if (rotating) { GetComponent <Transform>().RotateAroundAxis(Vector3.Up, angle * speed_rotation * Time.deltaTime); float moved_angle = (float)angle * speed_rotation * Time.deltaTime; if (angle < 0) { actual_angle += (moved_angle * -1); } else { actual_angle += moved_angle; } if (actual_angle >= 90) { rotating = false; if (actual_angle > 90) { float marge = actual_angle - 90; if (angle < 0) { GetComponent <Transform>().RotateAroundAxis(Vector3.Up, marge); } else { GetComponent <Transform>().RotateAroundAxis(Vector3.Up, -marge); } } } } else { GetComponent <Transform>().local_position = Vector3.MoveTowards(GetComponent <Transform>().local_position, endPosition, movSpeed * Time.deltaTime); } }
void Update() { start_direction = (int)curr_dir; //Update Forward Vector for rotations if (update_rotation) { update_rotation = false; char_manager.SetCurrentPosition(); } if (Input.GetKeyRepeat(KeyCode.Num9) && Input.GetKeyRepeat(KeyCode.Num8) && Input.GetKeyRepeat(KeyCode.Q) && Input.GetKeyRepeat(KeyCode.E) && Input.GetKeyRepeat(KeyCode.Space)) { Audio.prank = true; } CheckIsWalkable(); if (GetComponent <Transform>().local_position == endPosition && rotating == false && face_rotating == false && char_manager.GetManagerState() != CharactersManager.State.DROWNING && push == false) { moving = false; // CHECK ROTATION -------------------------- if (!CheckRotation()) { // CHECK MOVEMENT -------------------------- CheckMovement(); } // CHECK FACING -------------------------- //CheckFacingRotation(); //Calculate endPosition if ((tile_mov_x != 0 || tile_mov_y != 0)) { Debug.Log("GOING TO MOVE", Department.PLAYER, Color.RED); if (level_map[curr_x + tile_mov_x, curr_y + tile_mov_y] == 0) { audio = GetComponent <CompAudio>(); audio.PlayEvent("Footsteps"); endPosition = new Vector3(GetComponent <Transform>().local_position.x + distanceToMove * (float)tile_mov_x, GetComponent <Transform>().local_position.y, GetComponent <Transform>().local_position.z + distanceToMove * (float)tile_mov_y); curr_x += tile_mov_x; curr_y += tile_mov_y; char_manager.SetCurrentPosition(); moving = true; } else if (level_map[curr_x + tile_mov_x, curr_y + tile_mov_y] == 3) //Valryian Fire! { audio = GetComponent <CompAudio>(); audio.PlayEvent("Footsteps"); endPosition = new Vector3(GetComponent <Transform>().local_position.x + distanceToMove * (float)tile_mov_x, GetComponent <Transform>().local_position.y, GetComponent <Transform>().local_position.z + distanceToMove * (float)tile_mov_y); curr_x += tile_mov_x; curr_y += tile_mov_y; char_manager.SetCurrentPosition(); moving = true; if (GetLinkedObject("player_obj").GetComponent <CharactersManager>().god_mode == false) { GetComponent <CompRigidBody>().UnLockMotion(); GetComponent <CompRigidBody>().ApplyImpulse(new Vector3(0.0f, -50.0f, 0.0f)); //char_manager.Drown(); drowning = true; } } } tile_mov_x = 0; tile_mov_y = 0; } else if (push == true) { GetComponent <Transform>().local_position = Vector3.MoveTowards(GetComponent <Transform>().local_position, endPosition, movSpeed * Time.deltaTime); if (GetComponent <Transform>().local_position == endPosition) { push = false; } } else if (rotating) { moving = false; GetComponent <Transform>().RotateAroundAxis(Vector3.Up, angle * speed_rotation * Time.deltaTime); float moved_angle = (float)angle * speed_rotation * Time.deltaTime; if (angle < 0) { actual_angle += (moved_angle * -1); } else { actual_angle += moved_angle; } if (actual_angle >= 90) { rotating = false; if (actual_angle > 90) { float marge = actual_angle - 90; if (angle < 0) { GetComponent <Transform>().RotateAroundAxis(Vector3.Up, marge); } else { GetComponent <Transform>().RotateAroundAxis(Vector3.Up, -marge); } } update_rotation = true; } } else if (face_rotating) { moving = false; GetComponent <Transform>().RotateAroundAxis(Vector3.Left, face_angle * face_speed_rotation * Time.deltaTime); float moved_angle = (float)face_angle * face_speed_rotation * Time.deltaTime; if (angle < 0) { actual_facing_angle += (moved_angle * -1); } else { actual_facing_angle += moved_angle; } if (curr_fac == Facing.UP) { if (actual_facing_angle >= up_angle) { face_rotating = false; if (actual_facing_angle > up_angle) { float marge = actual_facing_angle - up_angle; GetComponent <Transform>().RotateAroundAxis(Vector3.Left, -marge); } } } else if (curr_fac == Facing.STRAIGHT) { if (actual_facing_angle >= -1.0f && actual_facing_angle <= 1) { face_rotating = false; } } else if (curr_fac == Facing.DOWN) { if (actual_facing_angle <= down_angle) { face_rotating = false; if (actual_facing_angle < down_angle) { float marge = actual_facing_angle - down_angle; GetComponent <Transform>().RotateAroundAxis(Vector3.Left, marge); } } } } else if (moving) { GetComponent <Transform>().local_position = Vector3.MoveTowards(GetComponent <Transform>().local_position, endPosition, movSpeed * Time.deltaTime); GetComponent <Transform>().local_rotation = Vector3.Lerp(new Vector3(GetComponent <Transform>().local_rotation.x, GetComponent <Transform>().local_rotation.y, GetComponent <Transform>().local_rotation.z), new Vector3(GetComponent <Transform>().local_rotation.x, GetComponent <Transform>().local_rotation.y, GetComponent <Transform>().local_rotation.z), (endPosition.Length - GetComponent <Transform>().local_position.Length)); } if (!moving && characters_camera.GetComponent <CompAnimation>().IsAnimationStopped("Idle") && GetLinkedObject("player_obj").GetComponent <CharactersManager>().GetCurrCharacterState() == 0) { characters_camera.GetComponent <CompAnimation>().PlayAnimationNode("Idle"); } }
void Update() { //-- TMP: Debug ----- /* if(on_lever_animation && anim_controller.IsAnimationStopped(lever_animation_name)) * { * OnLeverAnimFinish(); * }*/ //-- Lever Triggered ----- if (on_lever_range && !active_lever && !on_lever_animation) { //TODO: Change to GetKey_Action if (Input.GetInput_KeyDown("Interact", "Player")) { //Reset other puzzles if exists to avoid audio conflicts if (other_lever_1 != null) { other_lever_1.GetComponent <Lever>().ResetPuzzle(); other_lever_1.GetComponent <PuzzleCountdown>().StopCountdown(); } if (other_lever_2 != null) { other_lever_2.GetComponent <Lever>().ResetPuzzle(); other_lever_2.GetComponent <PuzzleCountdown>().StopCountdown(); } SetOrientationVectors(); OnLeverActivated(); GetComponent <CompAudio>().PlayEvent("Lever"); lever_interact.SetActive(false); } } //--------------------- if (on_lever_animation) { anim_controller = lever_go.GetComponent <CompAnimation>(); if (anim_controller != null) { if (anim_controller.IsAnimationStopped(lever_animation_name)) { // The lever animation has stopped so puzzle must start. OnLeverAnimFinish(); } } } if (active_lever) { if (!phase1) // Set info all barrels { SetInfo(line1, 0); SetInfo(line2, 1); SetInfo(line3, 2); SetInfo(line4, 3); SetInfo(line5, 4); SetInfo(line6, 5); phase1 = true; } if (!phase2) // Move barrels mode.PUZZLE { MoveBarrels(line1); MoveBarrels(line2); MoveBarrels(line3); MoveBarrels(line4); MoveBarrels(line5); MoveBarrels(line6); phase3 = true; phase2 = true; phase_wait = true; time = Time.realtimeSinceStartup + delay_second_mode; audio.PlayEvent("Chain"); MoveChains(true); } if (phase_wait) // wait to move the other mode { // Wait delay to move other barrels float time_transcured = Time.realtimeSinceStartup; if (time_transcured >= time) { phase3 = false; phase_wait = false; } } if (!phase3) // Move barrels mode.FILLING { MoveBarrels(line1, true); MoveBarrels(line2, true); MoveBarrels(line3, true); MoveBarrels(line4, true); MoveBarrels(line5, true); MoveBarrels(line6, true); phase3 = true; editmap = true; } if (fill_barrel != null && fill_barrel.IsPlaced() == true) { if (editmap) { audio.StopEvent("Chain"); SetPathWalkable(0, 3); editmap = false; countdown.StartCountdown(); MoveChains(false); } else if (countdown.IsCountdownOver()) { ResetPuzzle(); } } } }
void OnTriggerEnter() { audio.PlayEvent("SwitchOn"); SwitchTraps(); }
public void PlayFx(string name) { audio.PlayEvent(name); }