Пример #1
0
    private void LoadSpecialStageBackground()
    {
        // Get the background it should be
        IIdkyKeyValuePair <string, GameObject> backgroundKeyValuePair = this.SpecialStageBackgroundMappings.GetPair(
            this.SpecialStage.StageId);
        GameObject newBackground = backgroundKeyValuePair.GetValue();

        // Set the background music
        IIdkyKeyValuePair <string, AudioClip> musicKeyValuePair = this.SpecialStageMusicMappings.GetPair(this.SpecialStage.StageId);

        SoundManager.Instance.PlayBackgroundMusic(musicKeyValuePair.GetValue(), true);

        if (this.currentBackground == null)
        {
            // Set the anchors of the background
            UIWidget uiWidget = newBackground.GetComponent <UIWidget>();
            if (uiWidget != null)
            {
                uiWidget.SetAnchor(this.ParentPanel.gameObject, -10, -10, 10, 10);
            }

            // The background hasn't been set before, so create it
            this.currentBackground = NGUITools.AddChild(this.ParentGameBoard, newBackground);
        }
        else if (this.SpecialStage.StageId != this.currentSpecialStageId)
        {
            // The stage has been set before, so remove the old one
            if (this.currentBackground != null)
            {
                NGUITools.Destroy(this.currentBackground);
            }

            // Set the anchors of the background
            UIWidget uiWidget = newBackground.GetComponent <UIWidget>();
            if (uiWidget != null)
            {
                uiWidget.SetAnchor(this.ParentPanel.gameObject, -10, -10, 10, 10);
            }

            this.currentBackground = NGUITools.AddChild(this.ParentGameBoard, newBackground);
        }

        this.currentSpecialStageId = this.SpecialStage.StageId;
    }
Пример #2
0
    public void SetSpecialStageInitialMappings()
    {
        VirtualGood[] specialStages = GnomeStoreAssets.GetGoodsStatic();

        // Initialize mappings
        List <IdkyKeyValuePairGameObject> backgrounds = this.SpecialStageMappings != null
                                                           ? new List <IdkyKeyValuePairGameObject>(this.SpecialStageMappings)
                                                           : new List <IdkyKeyValuePairGameObject>();

        if (this.SpecialStageMappings == null)
        {
            this.SpecialStageMappings = new IdkyKeyValuePairGameObject[specialStages.Length];

            foreach (VirtualGood specialStage in specialStages)
            {
                backgrounds.Add(new IdkyKeyValuePairGameObject {
                    Key = specialStage.ItemId
                });
            }
        }
        else
        {
            foreach (VirtualGood specialStage in specialStages)
            {
                IIdkyKeyValuePair <string, GameObject> idkyKeyValuePair = this.SpecialStageMappings.GetPair(specialStage.ItemId);

                if (idkyKeyValuePair == null)
                {
                    backgrounds.Add(new IdkyKeyValuePairGameObject {
                        Key = specialStage.ItemId
                    });
                }
            }
        }

        this.SpecialStageMappings = backgrounds.ToArray();
    }