Exemple #1
0
        private void AddEffect(ItemType itemType, int userID)
        {
            ItemEffect itemEffect = null;

            if (itemManagerComponent.ContainEffect(ItemType.Barrier))
            {
                // Reflect to person
                client.Write(MessagePackSerializer.Serialize(new AddEffectToPlayerNetworkData {
                    UserId = userID, ItemType = itemType
                }));
            }
            else if (itemManagerComponent.ContainEffect(ItemType.Stealth))
            {
                // Nothing to do
            }
            else
            {
                switch (itemType)
                {
                case ItemType.DoubleBPM:
                    if (itemManagerComponent.ContainEffect(ItemType.DoubleBPM))
                    {
                        var effect = itemManagerComponent.GetEffect(ItemType.DoubleBPM);
                        effect.AddEffect();
                    }
                    else
                    {
                        itemEffect = new DoubleBPMEffect();
                    }
                    break;

                case ItemType.FogFilter:
                    if (itemManagerComponent.ContainEffect(ItemType.FogFilter))
                    {
                        var effect = itemManagerComponent.GetEffect(ItemType.FogFilter);
                        effect.AddEffect();
                    }
                    else
                    {
                        var fogComponent = new FogEffectComponent(device, ResourceManager);
                        itemEffect = new FogFilterEffect(fogComponent);
                        filterSprite.AddChild(fogComponent);
                    }
                    break;

                case ItemType.HalfScore:
                    itemEffect = new HalfScoreEffect();
                    break;

                case ItemType.Hidden:
                    itemEffect = new HiddenEffect();
                    break;

                case ItemType.StripeFilter:
                    if (itemManagerComponent.ContainEffect(ItemType.StripeFilter))
                    {
                        var effect = itemManagerComponent.GetEffect(ItemType.StripeFilter);
                        effect.AddEffect();
                    }
                    else
                    {
                        var stripeComponent = new StripeEffectComponent(device, ResourceManager);
                        itemEffect = new StripeFilterEffect(stripeComponent);
                        filterSprite.AddChild(stripeComponent);
                    }
                    break;

                case ItemType.Sudden:
                    itemEffect = new SuddenEffect();
                    break;

                case ItemType.PingPong:
                    if (itemManagerComponent.ContainEffect(ItemType.PingPong))
                    {
                        var effect = itemManagerComponent.GetEffect(ItemType.PingPong);
                        effect.AddEffect();
                    }
                    else
                    {
                        var pingPongComponent = new PingPongEffectComponent(device, ResourceManager);
                        itemEffect = new PingPongEffect(pingPongComponent);
                        filterSprite.AddChild(pingPongComponent);
                    }
                    break;

                case ItemType.Stealth:
                    itemEffect = new StealthEffect();
                    var userPlayState = FindUserPlayState(userID);
                    if (userPlayState != null)
                    {
                        userPlayState.IsStealth = true;
                    }
                    itemEffect.Removed += (sender, e) =>
                    {
                        userPlayState.IsStealth = false;
                    };
                    itemManagerComponent.AddOthersEffect(itemEffect);
                    itemEffect = null;
                    break;
                }
            }

            if (itemEffect != null)
            {
                itemManagerComponent.AddEffect(itemEffect);
            }

            if (expansionClient != null)
            {
                expansionClient.Send(new ItemInfo
                {
                    CurrentTime = mainGameComponent.MoviePosition,
                    ItemType    = itemType,
                    PlayerId    = userID
                });
            }
        }
Exemple #2
0
        private void UseItem(ItemType itemType)
        {
            ItemEffect itemEffect = null;

            if (IsDisturbEffect(itemType) || itemType == ItemType.Stealth)
            {
                if (itemType == ItemType.Stealth)
                {
                    itemEffect = new StealthEffect();
                }

                client.Write(MessagePackSerializer.Serialize(new AddEffectNetworkData {
                    ItemType = itemType
                }));
            }
            else
            {
                switch (itemType)
                {
                case ItemType.Auto:
                    itemEffect = new AutoEffect();
                    break;

                case ItemType.Barrier:
                    itemEffect = new BarrierEffect();
                    break;

                case ItemType.DoubleCombo:
                    itemEffect = new DoubleComboEffect();
                    break;

                case ItemType.DoubleScore:
                    itemEffect = new DoubleScoreEffect();
                    break;

                case ItemType.HatenaBox:
                    var number = r.Next(1, 4);
                    for (int i = 0; i < number; i++)
                    {
                        itemManagerComponent.AddItem();
                    }
                    break;

                case ItemType.TripleCombo:
                    itemEffect = new TripleComboEffect();
                    break;

                case ItemType.TripleScore:
                    itemEffect = new TripleScoreEffect();
                    break;
                }
            }

            if (itemEffect != null)
            {
                itemManagerComponent.AddEffect(itemEffect);
            }

            if (expansionClient != null)
            {
                expansionClient.Send(new ItemInfo
                {
                    CurrentTime = mainGameComponent.MoviePosition,
                    ItemType    = itemType,
                    PlayerId    = selfUser.ID
                });
            }
        }