Ejemplo n.º 1
0
        void CreateAdvEngile()
        {
            GameObject go     = new GameObject("AdvEngine");
            AdvEngine  engine = go.AddComponent <AdvEngine>();

            //レイヤーマネージャー
            AdvLayerManager layerManager       = UtageToolKit.AddChildGameObjectComponent <AdvLayerManager>(engine.transform, "LayerManager");
            Node2D          node2dLayerManager = layerManager.GetComponent <Node2D>();

            node2dLayerManager.SortKey = "LayerManager";

            //トランジションマネージャー
            AdvTransitionManager transitionManager = UtageToolKit.AddChildGameObjectComponent <AdvTransitionManager>(engine.transform, "TransitionManager");

            transitionManager.GetComponent <Node2D>().SortKey = "Transition";
            Sprite2D transtionBg = UtageToolKit.AddChildGameObjectComponent <Sprite2D>(transitionManager.transform, "Bg");

            transtionBg.Sprite   = transitionFadeBg;
            transtionBg.SizeType = Sprite2D.SpriteSizeType.StrechBoth;

            //UIマネージャー
            AdvUiManager uiManager = UtageToolKit.AddChildGameObjectComponent <AdvUiManager>(engine.transform, "UI");

            //インプットマネージャー
            AdvLegacyInputManager input = UtageToolKit.AddChildGameObjectComponent <AdvLegacyInputManager>(uiManager.transform, "InputManager");

            input.InitOnCreate(engine, 1.0f / 100 * gameScreenWidth, 1.0f / 100 * gameScreenHeight);
            input.GetComponent <Node2D>().SortKey = "InputManager";

            //メッセージウィンドウ
            float fontSize               = 30;
            float windowWidth            = msgWindowSprite.rect.width;
            float windowHeight           = msgWindowSprite.rect.height;
            AdvUiMessageWindow msgWindow = UtageToolKit.AddChildGameObjectComponent <AdvUiMessageWindow>(uiManager.transform, "MessageWindow");

            msgWindow.GetComponent <Node2D>().SortKey = "MessageWindow";
            GameObject windowRootChildren = UtageToolKit.AddChildGameObject(msgWindow.transform, "RootChildren");
            TextArea2D messageText        = UtageToolKit.AddChildGameObjectComponent <TextArea2D>(windowRootChildren.transform, "MessageText");

            messageText.Type       = TextArea2D.ViewType.Outline;
            messageText.Font       = font;
            messageText.text       = "Message";
            messageText.Size       = fontSize;
            messageText.LayoutType = TextArea2D.Layout.TopLeft;
            messageText.MaxWidth   = (int)(windowWidth - fontSize * 4);
            messageText.MaxHeight  = (int)(windowHeight - (fontSize * 2 + 50));
            messageText.transform.localPosition = new Vector3(-(float)messageText.MaxWidth / 2 / 100, (windowHeight / 2 - (fontSize + 40)) / 100, 0);
            messageText.LetterSpace             = 2;
            messageText.LineSpace         = 8;
            messageText.WordWrapType      = TextArea2D.WordWrap.Default | TextArea2D.WordWrap.JapaneseKinsoku;
            messageText.LocalOrderInLayer = 10;

            //名前表示
            TextArea2D nameText = UtageToolKit.AddChildGameObjectComponent <TextArea2D>(windowRootChildren.transform, "NameText");

            nameText.Type       = TextArea2D.ViewType.Outline;
            nameText.Font       = font;
            nameText.text       = "Name";
            nameText.Size       = 30;
            nameText.LayoutType = TextArea2D.Layout.TopLeft;
            nameText.transform.localPosition = new Vector3(-(float)messageText.MaxWidth / 2 / 100, (windowHeight / 2 - 25) / 100, 0);
            nameText.LocalOrderInLayer       = 10;

            //閉じるボタン
            if (isEnableCloseButton)
            {
                LegacyUiButton closeButton   = UtageToolKit.AddChildGameObjectComponent <LegacyUiButton>(windowRootChildren.transform, "CloseButton");
                Sprite2D       closeButtonBg = UtageToolKit.AddChildGameObjectComponent <Sprite2D>(closeButton.transform, "Bg");
                closeButtonBg.Sprite = closeButtonSprite;
                closeButton.transform.localPosition = new Vector3(((windowWidth - closeButtonSprite.rect.width) / 2 - 10) / 100, ((windowHeight - closeButtonSprite.rect.height) / 2 - 5) / 100, -0.01f);
                closeButton.Target       = msgWindow.gameObject;
                closeButton.FunctionName = "OnTapCloseWindow";
                closeButton.Se           = clickSe;
            }

            //メッセージウィンドウ背景
            Node2D   windowBgRoot = UtageToolKit.AddChildGameObjectComponent <Node2D>(windowRootChildren.transform, "WindowRoot");
            Sprite2D windowBg     = UtageToolKit.AddChildGameObjectComponent <Sprite2D>(windowBgRoot.transform, "Bg");

            windowBg.Sprite = msgWindowSprite;

            msgWindow.InitOnCreate(engine, messageText, nameText, windowRootChildren, windowBgRoot);
            msgWindow.transform.localPosition = new Vector3(0, (-gameScreenHeight + windowHeight) / 2 / 100, 0);

            //選択肢
            AdvUiSelectionManager selection = UtageToolKit.AddChildGameObjectComponent <AdvUiSelectionManager>(uiManager.transform, "Selection");

            selection.InitOnCreate(engine, selectionItemPrefab);
            selection.GetComponent <Node2D>().SortKey = "Selection";
            selection.ListView.ClipWidthPx            = Mathf.Max(gameScreenWidth / 2, gameScreenWidth - 100);
            selection.ListView.ClipHeightPx           = Mathf.Max(gameScreenHeight / 2, gameScreenHeight - 100);
            selection.ListView.Type = LegacyUiListView.LitViewType.Vertical;

            //バックログ
            AdvUiBacklogManager backLogManger = null;

            if (isEnableBackLog)
            {
                LegacyUiButton openButton = UtageToolKit.AddChildGameObjectComponent <LegacyUiButton>(windowRootChildren.transform, "BackLogButton");
                UtageToolKit.AddChildGameObjectComponent <Sprite2D>(openButton.transform, "Bg").Sprite = backLogButtonSprite;
                TextArea2D text = UtageToolKit.AddChildGameObjectComponent <TextArea2D>(openButton.transform, "Text");
                text.Font = font;
                text.text = "Log";
                text.LocalOrderInLayer             = 10;
                openButton.transform.localPosition = new Vector3(((windowWidth - backLogButtonSprite.rect.width) / 2 - closeButtonSprite.rect.width - 20) / 100, ((windowHeight - closeButtonSprite.rect.height) / 2 - 5) / 100, -0.01f);
                openButton.Target       = msgWindow.gameObject;
                openButton.FunctionName = "OnTapBackLog";
                openButton.Se           = clickSe;

                backLogManger = UtageToolKit.AddChildGameObjectComponent <AdvUiBacklogManager>(uiManager.transform, "BackLog");
                backLogManger.InitOnCreate(engine, backLogItemPrefab);
                backLogManger.GetComponent <Node2D>().SortKey = "BackLog";
                backLogManger.ListView.ClipWidthPx            = Mathf.Max(gameScreenWidth / 2, gameScreenWidth - 100);
                backLogManger.ListView.ClipHeightPx           = Mathf.Max(gameScreenHeight / 2, gameScreenHeight - 100);
                backLogManger.ListView.Type = LegacyUiListView.LitViewType.Vertical;
                backLogManger.ListView.IsRepositionReverse = true;

                Sprite2D filter = UtageToolKit.AddChildGameObjectComponent <Sprite2D>(backLogManger.transform, "filter");
                filter.Sprite     = backLogFilterSprite;
                filter.SizeType   = Sprite2D.SpriteSizeType.StrechBoth;
                filter.LocalColor = Color.black;
                filter.LocalAlpha = 0.5f;

                float    arrowY   = (float)backLogManger.ListView.ClipHeightPx / 100 / 2;
                Sprite2D minArrow = UtageToolKit.AddChildGameObjectComponent <Sprite2D>(backLogManger.transform, "MinArrow");
                minArrow.Sprite                  = backLogScrollUpArrow;
                minArrow.LocalOrderInLayer       = 30;
                minArrow.transform.localPosition = new Vector3(0, arrowY);
                backLogManger.ListView.MinArrow  = minArrow.gameObject;
                Sprite2D maxArrow = UtageToolKit.AddChildGameObjectComponent <Sprite2D>(backLogManger.transform, "MaxArrow");
                maxArrow.Sprite                     = backLogScrollUpArrow;
                maxArrow.LocalOrderInLayer          = 30;
                maxArrow.transform.localPosition    = new Vector3(0, -arrowY);
                maxArrow.transform.localEulerAngles = new Vector3(0, 0, 180);
                backLogManger.ListView.MaxArrow     = maxArrow.gameObject;

                LegacyUiButton closeButton   = UtageToolKit.AddChildGameObjectComponent <LegacyUiButton>(backLogManger.transform, "CloseButton");
                Sprite2D       closeButtonBg = UtageToolKit.AddChildGameObjectComponent <Sprite2D>(closeButton.transform, "Bg");
                closeButtonBg.Sprite = backLogCloseButtonSprite;
                closeButton.transform.localPosition = new Vector3((-1.0f * (gameScreenWidth - backLogCloseButtonSprite.rect.width) / 2 + 5) / 100, ((gameScreenHeight - backLogCloseButtonSprite.rect.height) / 2 - 5) / 100, -0.01f);
                closeButton.Target       = backLogManger.gameObject;
                closeButton.FunctionName = "OnTapBack";
                closeButton.Se           = clickSe;
                TextArea2D textClose = UtageToolKit.AddChildGameObjectComponent <TextArea2D>(closeButton.transform, "Text");
                textClose.Font = font;
                textClose.text = "";
                textClose.LocalOrderInLayer = 10;
                LegacyLocalize localize = textClose.gameObject.AddComponent <LegacyLocalize>();
                localize.Key = SystemText.Back.ToString();
            }


            engine.InitOnCreate(layerManager, transitionManager, uiManager);

            AdvLegacyUiManager legacyUiManager = uiManager as AdvLegacyUiManager;

            if (legacyUiManager != null)
            {
                legacyUiManager.InitOnCreate(engine, msgWindow, selection, backLogManger);
            }
            Selection.activeGameObject = go;
            Undo.RegisterCreatedObjectUndo(go, "CreateAdvEngile");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 初期化
        /// </summary>
        /// <param name="type">Tweenのデータ</param>
        /// <param name="hashObjects">Tweenのパラメーター</param>
        /// <param name="loopCount">ループ回数</param>
        /// <param name="pixelsToUnits">座標1.0単位辺りのピクセル数</param>
        /// <param name="skipSpeed">スキップ中の演出速度の倍率。0ならスキップなし</param>
        /// <param name="callbackComplete">終了時に呼ばれるコールバック</param>
        public void Init(iTweenData data, float pixelsToUnits, float skipSpeed, Action <iTweenPlayer> callbackComplete)
        {
            this.data = data;
            if (data.Type == iTweenType.Stop)
            {
                return;
            }

            this.callbackComplete = callbackComplete;

            hashTbl = iTween.Hash(data.HashObjects.ToArray());

            //2D座標にあわせる
            if (iTweenData.IsPostionType(data.Type))
            {
                if (hashTbl.ContainsKey("x"))
                {
                    hashTbl["x"] = (float)hashTbl["x"] / pixelsToUnits;
                }
                if (hashTbl.ContainsKey("y"))
                {
                    hashTbl["y"] = (float)hashTbl["y"] / pixelsToUnits;
                }
                if (hashTbl.ContainsKey("z"))
                {
                    hashTbl["z"] = (float)hashTbl["z"] / pixelsToUnits;
                }
            }
            //スキップ中なら演出時間を調整
            if (skipSpeed > 0)
            {
                bool isSpeed = hashTbl.ContainsKey("speed");
                if (isSpeed)
                {
                    hashTbl["speed"] = (float)hashTbl["speed"] * skipSpeed;
                }

                bool isTime = hashTbl.ContainsKey("time");
                if (isTime)
                {
                    hashTbl["time"] = (float)hashTbl["time"] / skipSpeed;
                }
                else if (!isSpeed)
                {
                    hashTbl["time"] = 1.0f / skipSpeed;
                }
            }

            //カラーの処理を2D仕様に
            if (data.Type == iTweenType.ColorTo || data.Type == iTweenType.ColorFrom)
            {
                this.node2D = this.gameObject.GetComponent <Node2D>() as Node2D;
                if (node2D != null)
                {
                    if (data.Type == iTweenType.ColorTo)
                    {
                        hashTbl["from"] = node2D.LocalColor;
                        hashTbl["to"]   = ParaseTargetColor(hashTbl, node2D.LocalColor);
                    }
                    else if (data.Type == iTweenType.ColorFrom)
                    {
                        hashTbl["from"] = ParaseTargetColor(hashTbl, node2D.LocalColor);
                        hashTbl["to"]   = node2D.LocalColor;
                    }
                    hashTbl["onupdate"] = "OnColorUpdate";
                    isColorSprite       = true;
                }
            }

            //終了時に呼ばれるメッセージを登録
            hashTbl["oncomplete"]       = "OnComplete";
            hashTbl["oncompletetarget"] = this.gameObject;
            hashTbl["oncompleteparams"] = this;

            //停止処理用に名前を設定
            tweenName       = this.GetHashCode().ToString();
            hashTbl["name"] = tweenName;
        }
Ejemplo n.º 3
0
		/// <summary>
		/// 子ノードを追加
		/// </summary>
		/// <param name="child">追加する子ノード</param>
		void AddChildNode(Node2D child)
		{
			if (!nodeChidren.Contains(child)) nodeChidren.Add(child);
		}
Ejemplo n.º 4
0
		/// <summary>
		/// 子ノードを削除
		/// </summary>
		/// <param name="child">削除する子ノード</param>
		void RemoveChildNode(Node2D child)
		{
			if (nodeChidren.Contains(child)) nodeChidren.Remove(child);
		}
Ejemplo n.º 5
0
		/// <summary>
		/// ノード構成を更新
		/// </summary>
		void RefreshNode()
		{
			Node2D newParentNode = UtageToolKit.FindParentComponent<Node2D>(this.transform);
			if (newParentNode != parentNode)
			{
				if (parentNode != null) parentNode.RemoveChildNode(this);
				parentNode = newParentNode;
				if (parentNode != null) parentNode.AddChildNode(this);
			}
		}