コード例 #1
0
        public override bool HandleEvent(Event e)
        {
            if (e is DiedEvent ev && ev.Who == this)
            {
                if (!GetComponent <HealthComponent>().Dead&& !died)
                {
                    died = true;
                    Done = false;

                    GetComponent <AudioEmitterComponent>().EmitRandomized("player_death");
                    RemoveComponent <PlayerInputComponent>();

                    Achievements.Unlock("bk:rip");
                    Items.Unlock("bk:dagger");

                    if (InGameState.EveryoneDied(this))
                    {
                        Audio.FadeOut();

                        ((InGameState)Engine.Instance.State).HandleDeath();

                        Camera.Instance.Targets.Clear();
                        Camera.Instance.Follow(this, 1);

                        Tween.To(0.3f, Engine.Instance.Speed, x => Engine.Instance.Speed = x, 0.5f).OnEnd = () => {
                            var t = Tween.To(1, Engine.Instance.Speed, x => Engine.Instance.Speed = x, 0.5f);

                            t.Delay = 0.8f;
                            t.OnEnd = () => ((InGameState)Engine.Instance.State).AnimateDoneScreen(this);

                            HandleEvent(e);
                            AnimateDeath(ev);

                            Done = true;
                        };
                    }
                    else
                    {
                        HandleEvent(e);
                        AnimateDeath(ev);
                    }

                    return(true);
                }
            }