예제 #1
0
    public void PreUpdateLoadSnapshot(TimeDict.TimeSlice snapshotDictionary)
    {
        Activated.LoadSnapshot(snapshotDictionary);
        Occupied.LoadSnapshot(snapshotDictionary);
        ActivatedTimeStep.LoadSnapshot(snapshotDictionary);
        Countdown.LoadSnapshot(snapshotDictionary);
        playerID.LoadSnapshot(snapshotDictionary);

        FlagDestroy = snapshotDictionary.Get <bool>(GameController.FLAG_DESTROY);

        gameObject.SetActive((!ItemForm && !FlagDestroy) || IsAnimatingFold);

        IsAnimatingOpenClose = snapshotDictionary.Get <bool>(nameof(IsAnimatingOpenClose));
        animator.SetBool(AnimateOpen, IsAnimatingOpenClose);
        IsAnimatingFold = snapshotDictionary.Get <bool>(nameof(IsAnimatingFold));
        animator.SetBool(AnimateFolding, IsAnimatingFold);
        IsAnimatingUnfold = snapshotDictionary.Get <bool>(nameof(IsAnimatingUnfold));
        animator.SetBool(AnimateUnfolding, IsAnimatingUnfold);

        int prevDoneTimeTravelPlayerID = doneTimeTravelPlayerID;

        doneTimeTravelPlayerID = snapshotDictionary.Get <int>(nameof(doneTimeTravelPlayerID));
        if (prevDoneTimeTravelPlayerID != -1 && doneTimeTravelPlayerID == -1)
        {
            // persist this value one frame locally so that player sprite order etc are updated in GameUpdate()
            doneTimeTravelPlayerID = prevDoneTimeTravelPlayerID;
        }

        Occupied.Current &= Activated.History;
    }
예제 #2
0
    public override void ForceRestoreSnapshot(TimeDict.TimeSlice snapshotDictionary)
    {
        base.ForceRestoreSnapshot(snapshotDictionary);

        movingRight = snapshotDictionary.Get <bool>(nameof(movingRight));
        toFire      = snapshotDictionary.Get <float>(nameof(toFire));
        _alertState = snapshotDictionary.Get <bool>(nameof(_alertState));
    }
예제 #3
0
    public override void ForceRestoreSnapshot(TimeDict.TimeSlice snapshotDictionary)
    {
        base.ForceRestoreSnapshot(snapshotDictionary);
        LoadActivatables(snapshotDictionary);

        distance   = snapshotDictionary.Get <float>(nameof(distance));
        spritePath = snapshotDictionary.Get <string>(nameof(spritePath));
    }
    public virtual void ForceRestoreSnapshot(TimeDict.TimeSlice snapshotDictionary)
    {
        FlagDestroy     = snapshotDictionary.Get <bool>(GameController.FLAG_DESTROY);
        prevFlagDestroy = gameController.GetSnapshotValue <bool>(this, gameController.TimeStep - 1, GameController.FLAG_DESTROY);
        ItemForm        = snapshotDictionary.Get <bool>(nameof(ItemForm));
        Position.ForceLoadSnapshot(snapshotDictionary);
        Position.Current = Position.History;

        UpdateShow();
    }
예제 #5
0
    // TODO: add fixed frame # associated with snapshot? and Lerp in update loop?!
    public void PreUpdateLoadSnapshot(TimeDict.TimeSlice snapshotDictionary)
    {
        prevItemID = ItemID;
        ItemID     = snapshotDictionary.Get <int>(nameof(ItemID));
        if (prevItemID != -1 && ItemID == -1)
        {
            ItemID     = prevItemID; // keep previous item id locally if it was dropped this frame
            prevItemID = -2;         //-2 to indicate it was removed this frame, so we don't re-save the value
        }

        Position.LoadSnapshot(snapshotDictionary);
        Velocity.LoadSnapshot(snapshotDictionary);

        if (gameController.CurrentPlayerID != ID) // we don't want the current player to revert to their history positions/velocity
        {
            Position.Current = Position.History;
            Velocity.Current = Velocity.History;
        }

        Rigidbody.rotation  = snapshotDictionary.Get <float>(nameof(Rigidbody.rotation));
        historyActivating   = snapshotDictionary.Get <bool>(nameof(isActivating));
        DidTimeTravel       = snapshotDictionary.Get <bool>(nameof(DidTimeTravel));
        facingRight         = snapshotDictionary.Get <bool>(nameof(facingRight));
        isSpriteOrderForced = snapshotDictionary.Get <bool>(nameof(isSpriteOrderForced));

        FlagDestroy = snapshotDictionary.Get <bool>(GameController.FLAG_DESTROY);
    }
예제 #6
0
    public void ForceRestoreSnapshot(TimeDict.TimeSlice snapshotDictionary)
    {
        Activated.ForceLoadSnapshot(snapshotDictionary);
        Occupied.ForceLoadSnapshot(snapshotDictionary);
        ActivatedTimeStep.ForceLoadSnapshot(snapshotDictionary);
        Countdown.ForceLoadSnapshot(snapshotDictionary);
        playerID.ForceLoadSnapshot(snapshotDictionary);

        FlagDestroy = snapshotDictionary.Get <bool>(GameController.FLAG_DESTROY);
        ItemForm    = snapshotDictionary.Get <bool>(nameof(ItemForm));
        Position.ForceLoadSnapshot(snapshotDictionary);
        Position.Current = Position.History;

        IsAnimatingOpenClose = snapshotDictionary.Get <bool>(nameof(IsAnimatingOpenClose));
        animator.SetBool(AnimateOpen, IsAnimatingOpenClose);
        IsAnimatingFold = snapshotDictionary.Get <bool>(nameof(IsAnimatingFold));
        animator.SetBool(AnimateFolding, IsAnimatingFold);
        IsAnimatingUnfold = snapshotDictionary.Get <bool>(nameof(IsAnimatingUnfold));
        animator.SetBool(AnimateUnfolding, IsAnimatingUnfold);
        doneTimeTravelPlayerID = snapshotDictionary.Get <int>(nameof(doneTimeTravelPlayerID));
        isFoldable             = snapshotDictionary.Get <bool>(nameof(isFoldable));
        animator.SetBool(AnimIsFoldable, isFoldable);
        animator.SetBool(AnimIsItem, ItemForm);

        gameObject.SetActive((!ItemForm && !FlagDestroy) || IsAnimatingFold);
    }
예제 #7
0
    private void LoadActivatables(TimeDict.TimeSlice snapshotDictionary)
    {
        string newActivatableString = snapshotDictionary.Get <string>(nameof(requiredActivatableIDs));

        if (prevActivatableString != newActivatableString)
        {
            prevActivatableString = newActivatableString;

            requiredActivatables.Clear();
            requiredActivatableIDs.Clear();

            string[] activatableStringIDs = newActivatableString.Split(',');
            foreach (var stringID in activatableStringIDs)
            {
                if (int.TryParse(stringID, out int id))
                {
                    var activatableBehaviour = gameController.GetObjectByID(id) as ActivatableBehaviour;
                    Assert.IsNotNull(activatableBehaviour);
                    requiredActivatables.Add(activatableBehaviour);
                    requiredActivatableIDs.Add(id);
                }
            }
        }
    }
예제 #8
0
 public override void ForceRestoreSnapshot(TimeDict.TimeSlice snapshotDictionary)
 {
     timer = snapshotDictionary.Get <float>(nameof(timer));
 }
예제 #9
0
 public override void PreUpdateLoadSnapshot(TimeDict.TimeSlice snapshotDictionary)
 {
     timer = snapshotDictionary.Get <float>(nameof(timer));
 }
예제 #10
0
 public override void ForceRestoreSnapshot(TimeDict.TimeSlice snapshotDictionary)
 {
     base.ForceRestoreSnapshot(snapshotDictionary);
     destroyStep = snapshotDictionary.Get <int>(nameof(destroyStep));
 }
예제 #11
0
 public override void PreUpdateLoadSnapshot(TimeDict.TimeSlice snapshotDictionary)
 {
     base.PreUpdateLoadSnapshot(snapshotDictionary);
     destroyStep = snapshotDictionary.Get <int>(nameof(destroyStep));
 }
    public virtual void ForceLoadSnapshot(TimeDict.TimeSlice snapshotDictionary)
    {
        Current = snapshotDictionary.Get <T>(CurrentName);

        History = snapshotDictionary.Get <T>(HistoryName);
    }
 public virtual void LoadSnapshot(TimeDict.TimeSlice snapshotDictionary)
 {
     History = snapshotDictionary.Get <T>(HistoryName);
 }