private void HandleDamageObject(GameObject damage_object) { // get the objects damage attributes (or default) // the handle moving into the damage state. damage_source = damage_object.gameObject; damage_type = damage_object.gameObject.GetComponent <ActorAttributeDamageType>()?.damage_type; if (damage_type == null) { damage_type = AttributeDamageTypeData.GetDefault(); } if (player_state != PlayerState.player_damage || damage_type.damage_is_instant) { ChangePlayerState(PlayerState.player_damage); } }
private void Start() { master = GameMasterController.GetMasterController(); // initialise state controllers. state_default = new PlayerStateDefaultController(); state_jump = new PlayerStateJumpController(); state_water_default = new PlayerStateWaterDefaultController(); state_water_jump = new PlayerStateWaterJumpController(); state_slide = new PlayerStateSlideController(); state_dive = new PlayerStateDiveController(); state_water_dive = new PlayerStateWaterDiveController(); state_attack = new PlayerStateAttackController(); state_damage = new PlayerStateDamageController(); player_state_controllers = new Dictionary <PlayerState, IPlayerStateController>(); player_state_controllers.Add(PlayerState.player_default, state_default); player_state_controllers.Add(PlayerState.player_jump, state_jump); player_state_controllers.Add(PlayerState.player_water_default, state_water_default); player_state_controllers.Add(PlayerState.player_water_jump, state_water_jump); player_state_controllers.Add(PlayerState.player_slide, state_slide); player_state_controllers.Add(PlayerState.player_dive, state_dive); player_state_controllers.Add(PlayerState.player_water_dive, state_water_dive); player_state_controllers.Add(PlayerState.player_attack, state_attack); player_state_controllers.Add(PlayerState.player_damage, state_damage); // initialise componenets. rigid_body = this.GetComponent <Rigidbody>(); player_sphere_collider = GameObject.Find (MAIN_COLLIDER_GAME_OBJECT_NAME).GetComponent <SphereCollider>(); player_animator = this.GetComponent <Animator>(); camera_object = GameObject.FindGameObjectWithTag(GameConstants.TAG_MAIN_CAMERA); player_render = GameObject.Find(PLAYER_RENDER_GAME_OBJECT_NAME); player_renderer = this.GetComponentInChildren <SkinnedMeshRenderer>(); player_direction = GameObject.Find(PLAYER_DIRECTION_GAME_OBJECT_NAME); // add listeners. master.GameStateChange += ChangeGameState; // add components. audio_source = this.gameObject.AddComponent <AudioSource>(); audio_source_loop = this.gameObject.AddComponent <AudioSource>(); audio_source_loop.loop = true; // initialise actor attributes. damage_type = new AttributeDamageTypeData(); // initialise interface. camera_audio_manager = new CameraAudioManager(); footstep_manager = new ActorFootstepManager(); splash_manager = new ActorSplashManager(); damage_effect_manager = new ActorDamageEffectManager(); // setup. InitialisePhysicalParameters(); }