// Update is called once per frame void Update() { manager_data = manager.UpdateDamageEffectController(); if (manager_data == null) { actor_renderer.material.SetColor(EMISSION_MATERIAL_PROPERTY, Color.black); return; } was_active = is_active; is_active = manager_data.is_active; if (!is_active && was_active) { actor_renderer.material.SetColor(EMISSION_MATERIAL_PROPERTY, Color.black); } if (!is_active) { return; } elapsed_time += Time.deltaTime; if (elapsed_time >= FLASH_INTERVAL) { elapsed_time = 0f; is_flashing = !is_flashing; actor_renderer.material.SetColor(EMISSION_MATERIAL_PROPERTY, is_flashing ? Color.red : Color.black); } }
// Start is called before the first frame update void Start() { manager = this.gameObject.GetComponent <IActorDamageEffectManager>(); manager_data = manager.UpdateDamageEffectController(); actor_renderer = manager_data.actor_renderer; }
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(); }