/// <summary> /// Start the creature moving /// </summary> protected override void Start() { base.Start(); // get the speed multiplier for the current room IRoom currentRoom = Camera.main.GetComponent <RoomBuilder>().CurrentRoom; this.speedMultiplier = currentRoom.CreatureSpeedMultiplier; this.difficultyMultiplier = gameState.DifficultyMultiplier; // initialize initial movement properties switch (direction) { case MovementDirection.HORIZONTAL: rb.gravityScale = 0; // creatures are not affected by gravity // prevent all rotation, but particularly into the Z plane (i.e. around the Y axis) rb.constraints = RigidbodyConstraints2D.FreezePositionY | RigidbodyConstraints2D.FreezeRotation; walkSpeed = GameConstants.OBSTACLE_WALK_SPEED_X; // default walk speed in x direction break; case MovementDirection.VERTICAL: rb.gravityScale = 0; // creatures are not affected by gravity // prevent all rotation, but particularly into the Z plane (i.e. around the Y axis) rb.constraints = RigidbodyConstraints2D.FreezePositionX | RigidbodyConstraints2D.FreezeRotation; walkSpeed = GameConstants.OBSTACLE_WALK_SPEED_Y; // default walk speed in y direction break; case MovementDirection.CIRCLING: rotator = GetComponent <Rotater2D>(); if (rotator != null) { rotator.AngularSpeed = GameConstants.OBSTACLE_WALK_SPEED_X; // default rotation speed rotator.CentreOfRotation = new Vector3(movementConstraints.x, movementConstraints.y, 0); rotator.IsClockwise = false; // by default } break; } //define the animator attached to the player animator = this.GetComponent <Animator>(); animator.speed = 0; changeState(STATE_IDLE); // creatures can only move after the maid has given the instructions // to the player (which forces the player to seek out the instructions) if (gameState.MaidGivenInstructions) { if (direction == MovementDirection.CIRCLING && rotator != null) { rotator.enabled = true; changeState(STATE_WALK_FORWARDS); } else { changeDirection(GameConstants.FORWARD); moveObject(Time.deltaTime); changeState(STATE_WALK_FORWARDS); } } }
public void RotatePlayer(Vector2 direction) { Rotater2D.LookAt(transform, transform.position + (Vector3)direction); }
IEnumerator Coroutine_StartBattle() { SoundManager.instance.PlayIndependant(SoundManager.instance.battle_start_sound); SoundManager.instance.PlayIfDifferent(enemy_moster.battle_theme); Vector3 previous_position = CameraManager.instance.exploration_camera.transform.position; Vector3 dest_camera_position = (enemy_moster.moster_data.moster_exploration.main_renderer.transform.position + PlayerExploration.instance.main_renderer.transform.position) / 2; dest_camera_position.z = previous_position.z; float initial_exploration_camera_size = CameraManager.instance.exploration_camera.orthographicSize; Debug.LogWarning("init size: " + initial_exploration_camera_size); CameraManager.instance.SetColorToFadePlane(Color.white); yield return(StartCoroutine(Coroutine_IntroBattleExplorationFlash())); TweenPosition.Begin(CameraManager.instance.exploration_camera.gameObject, intro_battle_exploration_time / 2, dest_camera_position); StartCoroutine(CameraManager.instance.COROUTINE_LaunchExplorationCameraStartBattleAnimation(intro_battle_exploration_time / 2 - 0.1f)); yield return(StartCoroutine(CameraManager.instance.COROUTINE_MainCameraFadeToOpaque(intro_battle_exploration_time / 2 + 0.1f))); //ExplorationIntro finished foreach (var defense_FX in defenses_FX) { defense_FX.Stop(); } foreach (var attack_FX in attacks_FX) { attack_FX.Stop(); } enemy_moster.SetupForBattle(); PlayerBattle.instance.SetupForBattle(); BattleScreen.instance.SetupForBattle(); if (regular_enemy_routine == true) { StartCoroutine(Coroutine_EnemyLoop()); } StateManager.instance.current_states.Remove(StateManager.State.EXPLORATION); StateManager.instance.current_states.Remove(StateManager.State.SCRIPTED_EVENT); StateManager.instance.current_states.Remove(StateManager.State.BATTLE_INTRO); StateManager.instance.current_states.Add(StateManager.State.BATTLE); StateManager.instance.UpdateFromStates(); PlayerBattle.instance.visuals_transform.position = player_visual_transform.position; Rotater2D.LookAt(PlayerBattle.instance.visuals_transform, player_visual_transform.position + Vector3.left); enemy_moster.visuals_transform.position = enemy_visual_transform.position; Rotater2D.LookAt(enemy_moster.visuals_transform, enemy_visual_transform.position + Vector3.right); //BattleIntroStarting // float initial_battle_camera_size = CameraManager.instance.battle_camera.orthographicSize; //BattleIntro finished //ExplorationIntro cleanup yield return(new WaitForSeconds(0.1f)); CameraManager.instance.exploration_camera.orthographicSize = initial_exploration_camera_size; CameraManager.instance.exploration_camera.transform.position = previous_position; //START FADE IN yield return(StartCoroutine(CameraManager.instance.COROUTINE_MainCameraFadeToTransparent(intro_in_battle_time))); yield return(new WaitForSeconds(0.001f)); }