Example #1
0
 void OnServerDismissChanceCard(AnimationPb animation)
 {
     // Server dismissed the chance card, not need to respond to the
     // PromptConfirmationRequest anymore.
     PromptConfirmationRequest = null;
     EventBus.AutomaticallyDismissForeground?.Invoke();
 }
Example #2
0
 void OnOpenChanceChest(AnimationPb animation)
 {
     Debug.Log("chance card received chance chest open animation!");
     if (animation.Extra.TryUnpack(out OpenChanceChestExtra extra))
     {
         ChanceDisplay            = extra.Chance;
         OpenChanceChestAnimation = animation;
         Show();
     }
 }
Example #3
0
 void OnOpenChanceChest(AnimationPb anim)
 {
     Debug.Log("Playing chance chest");
     if (anim.Extra.TryUnpack(out Monopoly.Protobuf.OpenChanceChestExtra extra))
     {
         if (extra.ChanceChestTile.Equals(Coordinate))
         {
             Animator.PlayForLength("ChanceChest_open", anim.Length);
         }
     }
 }
Example #4
0
 private void OnTurnStart(AnimationPb anim)
 {
     if (anim.Extra.Is(TurnStartExtra.Descriptor))
     {
         var extras = anim.Extra.Unpack <TurnStartExtra>();
         if (extras.Player.Id.Equals(Id))
         {
             SetSpeedMultiplier(anim.Length);
             Animator.Play("Character Layer.Player_turn_start", Animator.GetLayerIndex("Character Layer"));
         }
     }
 }
Example #5
0
 private void OnTeleportDropoff(AnimationPb anim)
 {
     if (anim.Extra.Is(TeleportDropoffExtra.Descriptor))
     {
         var extras = anim.Extra.Unpack <TeleportDropoffExtra>();
         if (extras.Player.Id.Equals(Id))
         {
             Board.MoveToPos(this.gameObject, extras.DropoffLocation);
             SetSpeedMultiplier(anim.Length);
             Animator.Play("Character Layer.Player_dropoff", 0, 0f);
         }
     }
 }
Example #6
0
 private void OnDiceDown(AnimationPb anim)
 {
     if (anim.Extra.Is(DiceDownExtra.Descriptor))
     {
         var extras = anim.Extra.Unpack <DiceDownExtra>();
         if (extras.Player.Id.Equals(Id))
         {
             PlayingShowDiceNum = true;
             DiceNumLabel.text  = $"{extras.Steps}";
             Animator.PlayForLength("Player_dice_popup", anim.Length, Animator.GetLayerIndex("Status Layer"));
         }
     }
 }
Example #7
0
    public async Task HandleAnimation(AnimationPb anim)
    {
        List <Task> childTasks = new List <Task>();

        switch (anim.Type)
        {
        case AnimationType.Default:
            Debug.Log($"server animation {anim.Name} length: {(float)anim.Length / 1000}");
            DispatchDefaultAnimation(anim);
            ;
            await Task.Delay(anim.Length);

            break;

        case AnimationType.Sequence:
            foreach (var child in anim.Children)
            {
                await HandleAnimation(child);
            }
            break;

        case AnimationType.Race:
            foreach (var child in anim.Children)
            {
                childTasks.Add(HandleAnimation(child));
            }
            await Task.WhenAny(childTasks);

            break;

        case AnimationType.All:
            foreach (var child in anim.Children)
            {
                childTasks.Add(HandleAnimation(child));
            }
            await Task.WhenAll(childTasks);

            break;
        }
    }
Example #8
0
 private void OnMove(AnimationPb anim)
 {
     if (anim.Extra.Is(MoveExtra.Descriptor))
     {
         var extras = anim.Extra.Unpack <MoveExtra>();
         if (extras.Player.Id.Equals(Id))
         {
             if (extras.Path.Count == 0)
             {
                 // no where to go
                 Debug.LogWarning("Received animation to walk 0 tiles");
                 return;
             }
             Walk();
             EventBus.StartCameraFollow?.Invoke(this);
             List <Vector3> path = new List <Vector3>();
             foreach (var coor in extras.Path)
             {
                 path.Add(Board.GetCharacterPos(coor));
             }
             // move along path
             PathFollower.StartFollowing(path, (float)anim.Length / 1000 / extras.Path.Count, () =>
             {
                 Stop();
                 EventBus.StopCameraFollow?.Invoke();
             }, (vec) =>
             {
                 if (vec.x < 0)
                 {
                     FaceLeft();
                 }
                 if (vec.x > 0)
                 {
                     FaceRight();
                 }
             });
         }
     }
 }
Example #9
0
    private void DispatchDefaultAnimation(AnimationPb anim)
    {
        switch (anim.Name)
        {
        case "turn_start":
            OnTurnStart?.Invoke(anim);
            break;

        case "dice_roll":
            OnDiceRoll?.Invoke(anim);
            break;

        case "dice_down":
            OnDiceDown?.Invoke(anim);
            break;

        case "move":
            OnMove?.Invoke(anim);
            break;

        case "teleport_pickup":
            OnTeleportPickup?.Invoke(anim);
            break;

        case "teleport_dropoff":
            OnTeleportDropoff?.Invoke(anim);
            break;

        case "focus_land":
            OnFocusLand?.Invoke(anim);
            break;

        case "invested":
            OnInvested?.Invoke(anim);
            break;

        case "pan":
            OnPan?.Invoke(anim);
            break;

        case "pay_rent":
            OnPayRent?.Invoke(anim);
            break;

        case "player_emotion":
            OnPlayerEmotion?.Invoke(anim);
            break;

        case "open_chance_chest":
            OnOpenChanceChest?.Invoke(anim);
            break;

        case "dismiss_chance_card":
            OnDismissChanceCard?.Invoke(anim);
            break;

        case "game_start":
            OnGameStart?.Invoke(anim);
            break;

        default:
            Debug.LogWarning($"Received unrecognized animation {anim.Name}");
            break;
        }
    }