Exemplo n.º 1
0
    void StartFadeout(RoomSwitchable switcher)
    {
        Vector3 vector  = base.transform.forward;
        Vector3 vector2 = base.transform.position + vector * this._moveDist;

        if (switcher != null)
        {
            Vector3 value    = SceneDoor.WorldToScreen(base.transform.position);
            Vector3 position = base.transform.position;
            if (this._moveFromCenter)
            {
                position = switcher.transform.position;
                vector   = (vector2 - position).normalized;
            }
            if (switcher.StartLevelTransition(position, vector2, vector, this._enterAnim))
            {
                EffectFactory.Instance.PlayQuickEffect(this._enterEffect, switcher.transform.position, switcher.transform.forward, null);
                OverlayFader.StartFade(this._fadeData, true, delegate()
                {
                    this.DoLoad();
                }, new Vector3?(value));
            }
        }
        else
        {
            OverlayFader.StartFade(this._fadeData, true, delegate()
            {
                this.DoLoad();
            }, new Vector3?(Vector3.zero));
        }
    }
Exemplo n.º 2
0
        void ClickedQuit(object ctx)
        {
            base.MenuImpl.Hide();
            bool saveDone = false;
            bool fadeDone = base.Owner._fadeEffect == null;

            OverlayFader.OnDoneFunc onDone = delegate()
            {
                if (saveDone && fadeDone)
                {
                    this.DoQuit();
                }
            };
            if (base.Owner._fadeEffect != null)
            {
                OverlayFader.StartFade(base.Owner._fadeEffect, true, delegate()
                {
                    fadeDone = true;
                    onDone();
                }, null);
            }
            base.Owner._saver.SaveAll(true, delegate(bool success, string error)
            {
                saveDone = true;
                onDone();
            });
        }
Exemplo n.º 3
0
    public void DoRespawn()
    {
        this.inForceRespawn = false;
        if (this._doDeathOffset && this.levelRoot != null)
        {
            this.levelRoot.gameObject.SetActive(true);
        }
        ProjectileFactory.Instance.DeactivateAll();
        Vector3 vector = (!this.useRoomSpawn) ? this.spawnPos : this.roomSpawnPos;
        Vector3 dir    = (!this.useRoomSpawn) ? this.spawnDir : this.roomSpawnDir;

        this.ent.RealTransform.position = vector;
        this.ent.Activate();
        this.ent.TurnTo(dir, 0f);
        if (this.varOverrider != null)
        {
            this.varOverrider.Apply(this.ent);
        }
        this.RegEvents(this.ent);
        base.enabled      = false;
        this.roomSpawnPos = vector;
        this.roomSpawnDir = dir;
        this.controller.ControlEntity(this.ent);
        if (this.attachTag != null)
        {
            this.attachTag.Free();
        }
        this.attachTag = null;
        if (this.attacher != null)
        {
            this.attachTag = this.attacher.Attach(this.ent);
        }
        if (this.followCam != null)
        {
            this.followCam.ClearFollowScale();
        }
        LevelRoom roomForPosition = LevelRoom.GetRoomForPosition(vector + Vector3.up * 0.25f, null);

        if (roomForPosition != null)
        {
            roomForPosition.SetImportantPoint(vector);
            LevelRoom.SetCurrentActiveRoom(roomForPosition, true);
            if (this.levelCam != null)
            {
                this.levelCam.SetRoom(roomForPosition);
            }
        }
        if (this.hud != null)
        {
            this.hud.Observe(this.ent, this.controller);
        }
        if (this._fadeIn != null || this._fadeOut != null)
        {
            FadeEffectData data  = this._fadeIn ?? this._fadeOut;
            Vector3        value = new Vector3(0f, 0f, 0f);
            OverlayFader.StartFade(data, false, null, new Vector3?(value));
        }
        EventListener.PlayerSpawn(true);         // Invoke custom event
    }
Exemplo n.º 4
0
 void IUpdatable.UpdateObject()
 {
     if (this.waitForDespawn)
     {
         if (!this.ent.gameObject.activeInHierarchy)
         {
             base.enabled        = false;
             this.waitForDespawn = false;
             this.DoRespawn();
         }
         return;
     }
     this.timer -= Time.deltaTime;
     if (this.backCam != null && this.fadeTimer > 0f)
     {
         this.fadeTimer -= Time.deltaTime;
         float num = Mathf.Max(0f, this.fadeTimer * this.fadeTimeScale);
         this.backCam.backgroundColor = Color.Lerp(this.startFadeColor, this._bgFadeColor, num);
     }
     if (this.timer <= 0f)
     {
         if (this.backCam != null)
         {
             this.backCam.backgroundColor = this.startFadeColor;
         }
         base.enabled = false;
         if (this.ShouldChangeLevels())
         {
             this.ChangeLevelRespawn();
         }
         else if (this._fadeOut != null && !this.noFadeOut)
         {
             Vector3 value = CoordinateTransformer.ToViewport("Main Camera", this.ent.WorldPosition);
             OverlayFader.StartFade(this._fadeOut, true, new OverlayFader.OnDoneFunc(this.StartSpawnWait), new Vector3?(value));
         }
         else
         {
             this.DoRespawn();
         }
     }
 }
Exemplo n.º 5
0
 public void ForceRespawn()
 {
     if (this.inForceRespawn)
     {
         return;
     }
     this.inForceRespawn = true;
     if (this.WillChangeLevels())
     {
         this.localPauseTag = ObjectUpdater.Instance.RequestPause(null);
         Killable entityComponent = this.ent.GetEntityComponent <Killable>();
         if (entityComponent != null)
         {
             entityComponent.CurrentHp = entityComponent.MaxHp;
         }
         this.ChangeLevelRespawn();
         return;
     }
     ObjectUpdater.PauseTag  pauseTag   = ObjectUpdater.Instance.RequestPause(null);
     OverlayFader.OnDoneFunc onDoneFunc = delegate()
     {
         this.inForceRespawn = false;
         pauseTag.Release();
         Killable entityComponent2 = this.ent.GetEntityComponent <Killable>();
         if (entityComponent2 != null)
         {
             Killable.DeathData deathData = new Killable.DeathData(true);
             entityComponent2.ForceDeath(0f, deathData, true);
         }
     };
     if (this._fadeOut != null)
     {
         Vector3 value = CoordinateTransformer.ToViewport("Main Camera", this.ent.WorldPosition);
         OverlayFader.StartFade(this._fadeOut, true, onDoneFunc, new Vector3?(value));
     }
     else
     {
         onDoneFunc();
     }
 }