Пример #1
0
            public virtual Toggle GenerateTab(Toggle original)
            {
                var newUI = GameObjectUtils.InstantiateInactive(original.gameObject);

                newUI.GetComponentInChildren <XlateText>(true).key = NameKey;
                var toggle = newUI.GetComponent <Toggle>();

                toggle.onValueChanged = GetOnSelectAction();
                newUI.transform.SetParent(original.transform.parent, false);
                newUI.SetActive(true);
                return(toggle);
            }
Пример #2
0
    public GameObject SpawnTriggersTutorial(int num)
    {
        GameObject triggerPrefab = (GameObject)Resources.Load("NinjaTrigger" + num.ToString());
        Vector3    triggerLocation;

        switch (num)
        {
        case 1:
            triggerLocation = new Vector3(-4.5f, -2.7f, 0);
            break;

        case 2:
            triggerLocation = new Vector3(-3.3f, -1.4f, 0);
            break;

        case 3:
            triggerLocation = new Vector3(-1.8f, 0.25f, 0);
            break;

        case 4:
            triggerLocation = new Vector3(0.05f, 1.3f, 0);
            break;

        case 5:
            triggerLocation = new Vector3(2f, 2f, 0);
            break;

        case 6:
            triggerLocation = new Vector3(4f, 2.4f, 0);
            break;

        default:
            triggerLocation = new Vector3(0, 2.8f, 0);
            break;
        }

        //instantiate trigger
        GameObject triggerObject = GameObjectUtils.AddChild(spawnParent, triggerPrefab);

        triggerObject.transform.position         = triggerLocation;
        triggerObject.transform.localEulerAngles = triggerPrefab.transform.localEulerAngles;

        Rigidbody triggerObjectRigidbody = triggerObject.GetComponent <Rigidbody>();

        triggerObjectRigidbody.useGravity  = false;
        triggerObjectRigidbody.constraints = RigidbodyConstraints.None;
        triggerObjectRigidbody.constraints = RigidbodyConstraints.FreezePositionX |
                                             RigidbodyConstraints.FreezePositionY |
                                             RigidbodyConstraints.FreezeRotationX |
                                             RigidbodyConstraints.FreezeRotationY;

        return(triggerObject);
    }
Пример #3
0
            public GameObject InstantiatePrefab(GameObject prefabObject)
            {
                GameObject prefabInstance = null;

                if (prefabObject != null)
                {
                    prefabInstance      = GameObjectUtils.SafeInstantiate(prefabObject);
                    prefabInstance.name = prefabObject.name;
                }

                return(prefabInstance);
            }
Пример #4
0
    // Loads the prefab and inits the prefab's PopupController values
    public IEnumerator ShowPopup(string prefabName, string title, string message,
                                 PopupController.Callback specialButtonCallback)
    {
        GameObject      popupRef   = Resources.Load <GameObject>(prefabName);
        GameObject      popup      = GameObjectUtils.AddChildGUI(gameObject, popupRef);
        PopupController controller = popup.GetComponent <PopupController>();

        controller.Init(title, message, specialButtonCallback);
        yield return(0);            // Wait a frame for the popup to finish

        controller.ShowPopup();
    }
Пример #5
0
        private void InitHideItem()
        {
            GameObjectUtils.CreateChilds(this.m_content, this.m_itemGameobj.transform, this.m_childCount);
            for (int i = 0; i < this.m_childCount; i++)
            {
                GameObject gameObject = this.m_content.transform.GetChild(i).gameObject;
                gameObject.transform.localPosition = this.m_itemPosDic[i];
                gameObject.transform.localScale    = Vector3.one;
                gameObject.name = i.ToString();
                AItemHandler aBaseItemHandler = gameObject.GetComponent <AItemHandler>();
                if (aBaseItemHandler == null)
                {
                    aBaseItemHandler = (gameObject.AddComponent(this.m_handlerType) as AItemHandler);
                    aBaseItemHandler.Init();
                    aBaseItemHandler.dataType = this.m_dataType;
                }
                if (this.m_dataList != null)
                {
                    aBaseItemHandler.Show(i, this.m_dataList[i]);
                }
                else
                {
                    aBaseItemHandler.Show(i, null);
                }
                aBaseItemHandler.initPos = this.m_itemPosDic[i];
                if (!this.m_handlerDic.ContainsKey(i))
                {
                    this.m_handlerDic.Add(i, aBaseItemHandler);
                }
                else
                {
                    this.m_handlerDic[i] = aBaseItemHandler;
                }
            }
            this.ScrollRectEvent(Vector2.zero);
            int num = (this.m_itemIdIntUp - 1) * this.m_constraintCount;

            if (num > 0 && this.m_childCount > num)
            {
                for (int j = 0; j < num; j++)
                {
                    this.m_handlerDic[j].trans.gameObject.SetActive(false);
                }
            }
            num = (this.m_itemIdIntDown + 1) * this.m_constraintCount;
            if (num > 0 && this.m_childCount > num)
            {
                for (int k = num; k < this.m_childCount; k++)
                {
                    this.m_handlerDic[k].trans.gameObject.SetActive(false);
                }
            }
        }
Пример #6
0
 private void ItemStackClear()
 {
     if (this.m_itemStack.Count > 0)
     {
         for (int i = 0; i < this.m_itemStack.Count; i++)
         {
             GameObject obj = this.m_itemStack.Pop();
             UnityEngine.Object.DestroyImmediate(obj);
         }
     }
     GameObjectUtils.DestroyChilds(this.m_poolObj.transform);
 }
Пример #7
0
 void Awake()
 {
     if (instance != null)
     {
         GameObjectUtils.Destroy(gameObject);
     }
     else
     {
         instance = this;
         CreateParticleSystemPool();
     }
 }
Пример #8
0
        /// <summary>
        /// Генерация меша.
        /// </summary>
        /// <param name="worldLength">Длина мира</param>
        /// <param name="worldWidth">Высота мира</param>
        public Grid <RendererObject> GenerateMesh(int worldLength, int worldWidth)
        {
            // Поиск и очистка родительского объекта
            var tileParentTransform = transform.Find("tileParent");

            if (tileParentTransform == null)
            {
                tileParent = new GameObject("tileParent");
                tileParent.transform.parent = transform;
            }
            else
            {
                tileParent = tileParentTransform.gameObject;
            }

            // Очищение потерянных объектов
            if (tileParent.transform.childCount > 0)
            {
                GameObjectUtils.DestroyAllChildrens(tileParent.transform);
            }

            ClearGrid();

            if (TileGridVisual != null)
            {
                throw new Exception("Tile grid visual не очищен перед инициализацией");
            }

            TileGridVisual = new Grid <RendererObject>(worldLength, worldWidth,
                                                       tileSizeHorizontal, tileSizeVertical);


            if (TileGridVisual != null || TileGridVisual.Count != 0)
            {
                // Определяем базис
                SetIsoBasis();

                // Генерируем меш
                TileGridVisual.ForEachSet((x, y) =>
                {
                    var cell = MeshUtils.CreateDiamondMesh(tileSizeHorizontal, tileSizeVertical)
                               .TransformToRenderer(tileMaterial, "tileMesh");

                    cell.transform.parent   = tileParent.transform;
                    cell.transform.position = IsoBasis.GetIsoVector(x, y);

                    return(cell);
                });
            }

            return(TileGridVisual);
        }
Пример #9
0
        public void SetUpSlots()
        {
            GameObjectUtils.ClearChildren(container.transform);
            _slots.Clear();
            OnStackUpdate = null;

            int index = 0;

            //WeaponSlotSetup
            if (weaponItemStackSlot != null)
            {
                weaponItemStackSlot.Init(index++, _weaponInventory.GetStackAtSlot(0), this, 0, _weaponInventory);
                _slots.Add(weaponItemStackSlot);
            }

            int armorIndex = 0;

            //ArmorSlotSetup
            foreach (IItemStackSlot slot in armorItemStackSlots)
            {
                if (slot == null)
                {
                    continue;
                }

                slot.Init(index++, _armorInventory.GetStackAtSlot(armorIndex), this, armorIndex++, _armorInventory);
                _slots.Add(slot);
            }

            //ItemInventorySetup
            if (slotPrefab == null)
            {
                return;
            }
            int itemIndex = 0;

            foreach (ItemStack stack in _itemInventory.GetItemStacks())
            {
                GameObject slotObj = Instantiate(slotPrefab, container.transform);
                if (!slotObj.TryGetComponent(out IItemStackSlot slot))
                {
                    continue;
                }

                slot.Init(index++, stack, this, itemIndex++, _itemInventory);
                _slots.Add(slot);

                OnStackUpdate += slot.UpdateUi;
            }

            UpdateSlots();
        }
    // MonoBehaviour's interface

    protected override void Awake()
    {
        base.Awake();

        // Get Component.

        m_ObjectPoolController = GetComponent <ObjectPoolController>();

        // UI

        if (m_CountdownPanelPrefab != null)
        {
            tnPanel_Countdown countdownPanel = Instantiate <tnPanel_Countdown>(m_CountdownPanelPrefab);
            countdownPanel.transform.SetParent(transform, true);

            m_CountdownPanel = countdownPanel;
        }

        if (m_EndGamePanelPrefab != null)
        {
            tnPanel_EndGame endGamePanel = Instantiate <tnPanel_EndGame>(m_EndGamePanelPrefab);
            endGamePanel.transform.SetParent(transform, true);

            m_EndGamePanel = endGamePanel;
        }

        if (m_FlatBackgroundPanelPrefab != null)
        {
            tnPanel_FlatBackground flatBackgroundPanel = Instantiate <tnPanel_FlatBackground>(m_FlatBackgroundPanelPrefab);
            flatBackgroundPanel.transform.SetParent(transform, true);

            m_FlatBackgroundPanel = flatBackgroundPanel;
        }

        if (m_PauseMenuPanelPrefab != null)
        {
            tnPanel_PauseMenu pauseMenuPanel = Instantiate <tnPanel_PauseMenu>(m_PauseMenuPanelPrefab);
            pauseMenuPanel.transform.SetParent(transform, true);

            m_PauseMenuPanel = pauseMenuPanel;
        }

        if (m_InGameOptionsPanelPrefab != null)
        {
            tnPanel_InGameOptions inGameOptionsPanel = Instantiate <tnPanel_InGameOptions>(m_InGameOptionsPanelPrefab);
            inGameOptionsPanel.transform.SetParent(transform, true);

            m_InGameOptionsPanel = inGameOptionsPanel;
        }

        m_LoadingPanel = GameObjectUtils.FindObjectWithTag <UIController>(s_Loading_Tag);
    }
Пример #11
0
 private void Awake()
 {
     //SINGLETON
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         GameObjectUtils.DebugErrorStop("Multiple instances of singleton.");
     }
     //SINGLETON
 }
Пример #12
0
        static GameObject CreateIdInstanceInternal <T>(string id) where T : IdHandler
        {
            if (!idHandlerPrefabs.TryGetValue(typeof(T), out var gameObj))
            {
                return(null);
            }
            var newG = GameObjectUtils.InstantiateInactive(gameObj);

            newG.GetComponent <T>().director = GlobalIdDirector;
            GlobalIdDirector.persistenceDict[newG.GetComponent <T>()] = ModdedStringRegistry.IsModdedString(id) ? id : ModdedStringRegistry.ClaimID(GetPrefix <T>(), id);

            return(newG);
        }
Пример #13
0
 static public int constructor(IntPtr l)
 {
     try {
         GameObjectUtils o;
         o = new GameObjectUtils();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Пример #14
0
 static public int StopMovieShow_s(IntPtr l)
 {
     try {
         UnityEngine.GameObject a1;
         checkType(l, 1, out a1);
         GameObjectUtils.StopMovieShow(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Пример #15
0
    public void ShowRetentionPet(bool isFlipped, Vector3 position)
    {
        RemoveRetentionPet();

        GameObject goResource = Resources.Load("TutorialRetentionPet") as GameObject;

        goRetentionPet = GameObjectUtils.AddChildGUI(TutorialManager.Instance.UICanvasParent, goResource);
        goRetentionPet.transform.localPosition = position;
        if (isFlipped)
        {
            goRetentionPet.transform.localScale = new Vector3(-1f, 1f, 1f);
        }
    }
Пример #16
0
        protected override void UpdateView()
        {
            if (m_model == null)
            {
                return;
            }
            ChapterNoText.text = string.Format("第{0}章", m_model.ChapterNo);

            // 根据是否解锁了来展示不同的视图
            GameObjectUtils.SetActiveRecursively(LockPanel, !m_model.IsUnlocked);

            GetComponent <Button>().enabled = m_model.IsUnlocked;
        }
    private void OpenAsEndGameMenu(RecordedScore recordedScore)
    {
        if (!recordedScore.IsWinningScoreReached())
        {
            Debug.LogError($"Opening ingame menu as triggered by event `WinningScoreReached`, " +
                           $"but no players have met or surpassed the score: {recordedScore}");
        }
        title.text    = recordedScore.IsLeftPlayerWinning() ? "Game Won" : "Game Lost";
        subtitle.text = recordedScore.LeftPlayerScore.ToString() + " - " + recordedScore.RightPlayerScore.ToString();

        GameObjectUtils.SetButtonActiveAndEnabled(resumeButton, false);
        ToggleMenuVisibility(true);
    }
Пример #18
0
    private void HideMaterialList()
    {
        // destroy list items
        foreach (RectTransform t in MaterialList.GetComponentInChildren <RectTransform>())
        {
            if (t != MaterialList)
            {
                Destroy(t.gameObject);
            }
        }

        GameObjectUtils.SetActiveForChildren(gameObject, false);
    }
Пример #19
0
 // shoots a smog ball at the player
 void ShootSmogBall()
 {
     if (!isDead)
     {
         AudioManager.Instance.PlayClip("shooterEnemySpit");
         animator.SetBool("Spit", true);
         animator.SetBool("IsSpitMode", false);
         bulletAux = GameObjectUtils.AddChild(null, bulletPrefab);
         bulletAux.transform.position = transform.position;
         LeanTween.moveX(bulletAux, player.transform.position.x, 2.0f);
         StartCoroutine(WaitASecond());
     }
 }
Пример #20
0
        public static void Create()
        {
            Camera c = GameObject.FindObjectOfType <Camera>();

            if (c != null)
            {
                GameObjectUtils.EnsureComponent <GameCamera>(c.gameObject);
            }
            else
            {
                MyLogger.LogError("GameCamera", "Create()", "Cannot Find Camera In Scene!");
            }
        }
Пример #21
0
 public virtual System.Collections.IEnumerator Execute()
 {
     ActionNode176_obj   = Group.gameObject;
     ActionNode176_state = BoolNode177;
     // ActionNode
     while (this.DebugInfo("8cb82bb7-2d9d-452b-ba92-12398c02e1b6", "9cbc95df-ea2c-4181-9c07-104f64e2c26c", this) == 1)
     {
         yield return(null);
     }
     // Visit GameObjectUtils.setActive
     GameObjectUtils.setActive(ActionNode176_obj, ActionNode176_state);
     yield break;
 }
Пример #22
0
 // in each case we are going to listen to events that tell us to move along
 protected override void ProcessStep(int nStep)
 {
     switch (nStep)
     {
     //runs for about 4 sec then starts the game the timer is in the memory game manager
     case 0:
         MemoryGameManager.Instance.proceed += MoveAlong;
         //prompt user to shoot
         memoryCards = (GameObject)Resources.Load("MemoryTut");
         tutBoards   = GameObjectUtils.AddChildGUI(GameObject.Find("Canvas"), memoryCards);
         break;
     }
 }
Пример #23
0
        /// <summary>
        /// 用来加速的按钮
        /// </summary>
        //private ETCButton m_speedUpBtn;


#if !UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS
        /// <summary>
        /// 初始化,用来在当前场景添加GameInput对象
        /// </summary>
        public static void Create()
        {
            if (m_instance != null)
            {
                throw new Exception("GameInput 不能重复初始化");
            }

            // 实例化GameInput的prefab
            GameObject prefab = Resources.Load <GameObject>("GameInputForPC");
            GameObject go     = GameObject.Instantiate(prefab);

            m_instance = GameObjectUtils.EnsureComponent <GameInput>(go);
        }
 public virtual System.Collections.IEnumerator Execute()
 {
     ActionNode178_obj   = Group.gameObject;
     ActionNode178_state = BoolNode179;
     // ActionNode
     while (this.DebugInfo("afbc5001-5e11-44c9-bc89-603a26360905", "e0a55816-3c04-4cb8-9bd7-bf22eecabf3f", this) == 1)
     {
         yield return(null);
     }
     // Visit GameObjectUtils.setActive
     GameObjectUtils.setActive(ActionNode178_obj, ActionNode178_state);
     yield break;
 }
Пример #25
0
 static public int ResetSpin2DAnim_s(IntPtr l)
 {
     try {
         UnityEngine.GameObject a1;
         checkType(l, 1, out a1);
         GameObjectUtils.ResetSpin2DAnim(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Пример #26
0
 public virtual System.Collections.IEnumerator Execute()
 {
     ActionNode180_obj   = Group.gameObject;
     ActionNode180_state = BoolNode181;
     // ActionNode
     while (this.DebugInfo("b2ad6fce-fbce-434c-85b3-e9976fbed7a4", "fa8d044e-dfc4-489d-a365-7c4b08bc0a19", this) == 1)
     {
         yield return(null);
     }
     // Visit GameObjectUtils.setActive
     GameObjectUtils.setActive(ActionNode180_obj, ActionNode180_state);
     yield break;
 }
Пример #27
0
    void Awake()
    {
        buttonsToHideWhenPanelIsOpen = GameObjectUtils.FindAllObjectsWithTags <Button>(tagsOfButtonsToHideWhenPanelIsOpen);
        labelsToHideWhenPanelIsOpen  = GameObjectUtils.FindAllObjectsWithTags <TMPro.TextMeshProUGUI>(tagsOfLabelsToHideWhenPanelIsOpen);

        mainMenuPanelController.SetActionOnStartPressed(() => LoadGame());
        mainMenuPanelController.SetActionOnPanelOpen(() => ToggleMenuVisibility(true));
        mainMenuPanelController.SetActionOnPanelClose(() => ToggleMenuVisibility(false));

        #if UNITY_WEBGL
        GameObjectUtils.SetButtonActiveAndEnabled(quitButton, false);
        #endif
    }
Пример #28
0
    void CreatePacmanLayer()
    {
        pacmanLayer = new Layer("PacmanLayer", gameObject.transform.position, Width, Height);
        GameObjectUtils.AppendChild(gameObject, pacmanLayer.LayerGameObject);
        pacmanLayer.LayerGameObject.transform.position = Vector3.zero;

        int pacmanX = Random.Range(0, Width);
        int pacmanY = Random.Range(0, Height);

        pacmanLayer.AddTileFromPrefab(PacmanPrefab, pacmanX, pacmanY);

        CreatePacdot();
    }
Пример #29
0
 void Awake()
 {
     if (_instance == null)
     {
         _instance = this;
         SetPosition();
     }
     else
     {
         Debug.LogWarning("Instance of CameraController already exists. Destroying duplicate.");
         GameObjectUtils.Destroy(gameObject);
     }
 }
Пример #30
0
 public virtual System.Collections.IEnumerator Execute()
 {
     ActionNode146_obj   = Group.gameObject;
     ActionNode146_state = BoolNode147;
     // ActionNode
     while (this.DebugInfo("291ffeaa-dbda-403c-b412-a656b50143bf", "62210118-65dd-4da2-ab94-1e4f97490b50", this) == 1)
     {
         yield return(null);
     }
     // Visit GameObjectUtils.setActive
     GameObjectUtils.setActive(ActionNode146_obj, ActionNode146_state);
     yield break;
 }