Example #1
0
        // when the program launches, Grid will check that all the needed elements are in place
        // that's exactly what you do in the static constructor here:
        static Grid()
        {
            GameObject g;

            g = safeFind("Map");
            map = (Map)SafeComponent(g,"Map");

            g = safeFind("Controller");
            controller = (Controller)SafeComponent(g,"Controller");

            g = safeFind("Camera");
            camera = (Camera)SafeComponent(g,"Camera");

            g = safeFind("Turn Manager");
            turnManager = (TurnManager)SafeComponent(g,"TurnManager");

            g = safeFind("Game State");
            gameState = (GameState)SafeComponent(g,"GameState");

            g = safeFind("Prefab Loader");
            prefabLoader = (PrefabLoader)SafeComponent(g,"PrefabLoader");

            // PS. annoying arcane technical note - remember that really, in c# static constructors do not run
            // until the FIRST TIME YOU USE THEM.  almost certainly in any large project like this, Grid
            // would be called zillions of times by all the Awake (etc etc) code everywhere, so it is
            // a non-issue. but if you're just testing or something, it may be confusing that (for example)
            // the wake-up alert only appears just before you happen to use Grid, rather than "when you hit play"
            // you may want to call "SayHello" from the GeneralOperations.cs, just to decisively start this script.
        }
Example #2
0
 public void LoadData(string iPath, System.Action iCallback = null)
 {
     if (iCallback != null)
     {
         m_LoadedCB = iCallback;
     }
     PrefabLoader.LoadPrefabWithInstanceNOCoroutine(iPath, AddData);
 }
Example #3
0
        public static async UniTask <TDialog> CreateDialog <TDialog>(DialogType dialogType, Action <TDialog> onInitialized = null)
            where TDialog : DialogPresenterBase
        {
            RectTransform parent = UICanvasManager.Instance.DialogRoot;
            TDialog       prefab = PrefabLoader.LoadPrefab <TDialog>(dialogType);

            return(await CommonDialogManager.Instance.CreateDialog(prefab, onInitialized));
        }
Example #4
0
    BattleGuide getBTGuideUI()
    {
        Object     obj = PrefabLoader.loadFromUnPack("Ban/BattleGuide", false);
        GameObject go  = Instantiate(obj) as GameObject;

        //RED.AddChild(go, BattleCamera.Instance.Camera1.gameObject);
        return(go.GetComponent <BattleGuide>());
    }
Example #5
0
 void Awake()
 {
     if (!isLoaded && !isLoading)
     {
         isLoading = true;
         PrefabLoader.LoadPrefab("ui/prefabs.u3dassetbundle", "UICanvas", LoadCallBack, false);
     }
 }
Example #6
0
    void LoadWireframe()
    {
        var prefab = PrefabLoader.Load(string.Format("{0}/{1}/{1}_{2}", Paths.Artworks, Data.puzzleName, Paths.Wireframe));
        var go     = prefab.Instantiate <GameObject>(Data.transform);

        go.transform.position = new Vector3(0f, 0f, Config.Instance.zorder.wireframe);
        go.name = prefab.Name;
        Data.wireframeObject = go.GetComponent <PuzzleWireframe>();
    }
    public static BuildingSite InstantiateNew(BuildingBlueprint blueprint)
    {
        GameObject   prefab = PrefabLoader.GetPrefab <GameObject>(prefabPath);
        GameObject   gObj   = Instantiate(prefab) as GameObject;
        BuildingSite site   = gObj.GetComponent <BuildingSite>();

        site.data.blueprint = blueprint;
        return(site);
    }
Example #8
0
        void SyncAdd()
        {
            int index  = dropdown.value;
            var r      = resourceInfo[index];
            var handle = PrefabLoader.Load(r.path);

            r.gameObjects.Add(handle.Instantiate <GameObject>());
            UpdateInstanceCount();
        }
Example #9
0
    public static ServerList Instance()
    {
        if (_instance == null)
        {
            _instance = (Instantiate(PrefabLoader.loadFromUnPack(LIST_PATH)) as GameObject).GetComponent <ServerList>();
        }

        return(_instance);
    }
Example #10
0
 //先调用这个
 public void createGhostly()
 {
     if (_ghost == null)
     {
         Object obj = PrefabLoader.loadFromUnPack("Ban/Ghost_2D", false);
         _ghost = Instantiate(obj) as GameObject;
         Curve  = _ghost.GetComponent <BanCurveLine_Shell>();
     }
 }
Example #11
0
    void CreateMissionReward(int length)
    {
        Object prefab = PrefabLoader.loadFromPack("ZQ/MonsterHeadcell");

        if (prefab != null)
        {
        }
        _Rewardlistroot.Reposition();
    }
Example #12
0
        /// <summary>
        /// If no "Node" instance, this method tries to create one
        /// given the Collide.Shape component in this game object.
        /// </summary>
        /// <returns>True if the node was created - otherwise false.</returns>
        private bool TryInitialize(Shape shape, DebugRenderManager manager)
        {
            if (Node != null)
            {
                return(false);
            }

            Collide.Mesh   mesh           = shape as Collide.Mesh;
            HeightField    heightField    = shape as HeightField;
            Cone           cone           = shape as Cone;
            HollowCone     hollowCone     = shape as HollowCone;
            HollowCylinder hollowCylinder = shape as HollowCylinder;

            if (mesh != null)
            {
                Node = InitializeMesh(mesh);
            }
            else if (heightField != null)
            {
                Node = InitializeHeightField(heightField);
            }
            else if (hollowCone != null)
            {
                Node = new GameObject(PrefabName);
                Node.AddComponent <MeshRenderer>().sharedMaterial = manager.ShapeRenderMaterial;
                Node.AddComponent <MeshFilter>().sharedMesh       = ShapeVisualHollowCone.GenerateMesh(shape);
            }
            else if (hollowCylinder != null)
            {
                Node = new GameObject(PrefabName);
                Node.AddComponent <MeshRenderer>().sharedMaterial = manager.ShapeRenderMaterial;
                Node.AddComponent <MeshFilter>().sharedMesh       = ShapeVisualHollowCylinder.GenerateMesh(shape);
            }
            else if (cone != null)
            {
                Node = new GameObject(PrefabName);
                Node.AddComponent <MeshRenderer>().sharedMaterial = manager.ShapeRenderMaterial;
                Node.AddComponent <MeshFilter>().sharedMesh       = ShapeVisualCone.GenerateMesh(shape);
            }
            else
            {
                Node = PrefabLoader.Instantiate <GameObject>(PrefabName);
                Node.transform.localScale = GetShape().GetScale();
            }

            if (Node != null)
            {
                var renderers = Node.GetComponentsInChildren <Renderer>();
                foreach (var renderer in renderers)
                {
                    renderer.sharedMaterial = manager.ShapeRenderMaterial;
                }
            }

            return(Node != null);
        }
    void OnGUI()
    {
        EditorGUILayout.BeginVertical();
        {
            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.BeginVertical();
                {
                    UserName    = EditorGUILayout.TextField("Name", UserName);
                    ServerKind  = (Server.Name)EditorGUILayout.EnumPopup("Server", ServerKind);
                    CampKind    = (Camp.Name)EditorGUILayout.EnumPopup("Camp", CampKind);
                    RacesKind   = (Races.Name)EditorGUILayout.EnumPopup("Races", RacesKind);
                    SexKind     = (Sex.Name)EditorGUILayout.EnumPopup("Sex", SexKind);
                    ClassesKind = (Classes.Name)EditorGUILayout.EnumPopup("Classes", ClassesKind);
                    EditorGUILayout.EndVertical();

                    if (GUILayout.Button("Clear"))
                    {
                    }
                }
            }
            EditorGUILayout.EndHorizontal();

            g = (GameObject)EditorGUILayout.ObjectField("GameObject", g, typeof(GameObject), false);
            m = (MonoBehaviour)EditorGUILayout.ObjectField("MonoBehaviour", m, typeof(MonoBehaviour), false);
            if (GUILayout.Button("Add Part of Player"))
            {
                /*
                 * foreach(KeyValuePair<> val in PartsOfPlayer)
                 * {
                 *
                 * }
                 */
            }

            if (GUILayout.Button("Make Player"))
            {
                GameObject playerObject = GameObject.Find("Player");
                if (playerObject)
                {
                    DestroyImmediate(playerObject);
                    playerObject = null;
                }

                GameObject cameraObject = GameObject.FindWithTag("MainCamera");
                if (cameraObject)
                {
                    Destroy(cameraObject);
                    cameraObject = null;
                }

                playerObject = PrefabLoader.LoadPrefab(PrefabLoader.cCharacter, "Player", new Vector3(0, 0.5f, 0));
            }
        }
        EditorGUILayout.EndVertical();
    }
Example #14
0
    public static void Open3D()
    {
        Object obj = PrefabLoader.loadFromPack("LS/pbLSEggCard", true);

        if (obj != null)
        {
            GameObject go = Instantiate(obj) as GameObject;
            _mInstance = go.GetComponent <EggCard>();
        }
    }
Example #15
0
    static public void LoadPrefabWithInstanceNOCoroutine(string iFilename, AsyncLoadingPrefabComplete iCallback = null, string iObjname = "Load Prefab", bool iIsFromResources = true)
    {
        GameObject   _Loader = new GameObject(iObjname);
        PrefabLoader _Script = _Loader.AddComponent <PrefabLoader>();

        if (_Script)
        {
            _Script.LoadPrfab(iFilename, iCallback, true, iIsFromResources);
        }
    }
Example #16
0
    /*
     * 載入Prefab
     * @parameter 1. 檔名. 2. 資料夾或路徑. 3. Callback函式. 4. 物件名稱,用來辨識
     */
    static public void LoadPrefab(string iFilename, AsyncLoadingPrefabComplete iCallback = null, string iObjname = "Load Prefab", bool iIsFromResources = true)
    {
        GameObject   _Loader = new GameObject(iObjname);
        PrefabLoader _Script = _Loader.AddComponent <PrefabLoader>();

        if (_Script != null)
        {
            _Script.LoadPrfabByAsync(iFilename, iCallback, false, iIsFromResources);
        }
    }
Example #17
0
            public void Unload()
            {
                _prefab = null;

                if (_loader != null)
                {
                    _loader.Unload();
                    _loader = null;
                }
            }
Example #18
0
    public static void OpenUI()
    {
        Object obj = PrefabLoader.loadFromPack("LS/pbLSCardPointFx", true);

        if (obj != null)
        {
            GameObject go = Instantiate(obj) as GameObject;
            _Instance = go.GetComponent <UICardPointFx>();
        }
    }
Example #19
0
    public void RefreshData()
    {
        List <SkillConfigContainer> skillPrefabs = PrefabLoader.LoadAllPrefabsOfType <SkillConfigContainer>("Assets/Resources/Prefabs/Skills", SearchOption.AllDirectories);

        SkillConfigContainers = skillPrefabs;

        List <SkillConfigContainer> startSkillPrefabs = PrefabLoader.LoadAllPrefabsOfType <SkillConfigContainer>("Assets/Resources/Prefabs/Skills/StartSkills");

        StartSkillConfigContainers = startSkillPrefabs;
    }
Example #20
0
 void CreateSecretShopTag()
 {
     UnityEngine.Object obj = PrefabLoader.loadFromPack("LS/pbLSScrectShopTag");
     if (obj != null)
     {
         GameObject go = RUIMonoBehaviour.Instantiate(obj) as GameObject;
         _UISecretShopTag = go.GetComponent <UISecretShopTag>();
         RED.AddChild(go.gameObject, DBUIController.mDBUIInstance._TopRoot);
     }
 }
Example #21
0
    /// <summary>
    /// Initialises the map to be drawn. You need to call DrawMap tp actually draw it.
    /// </summary>
    /// <param name="map"> The <c>Map</c> to be drawn.</param>
    public void Init(Map map)
    {
        this.map  = map;
        grassTile = PrefabLoader.GetTile(Tile.Ground.Grass);
        sandTile  = PrefabLoader.GetTile(Tile.Ground.Sand);
        waterTile = PrefabLoader.GetTile(Tile.Ground.Water);

        treeProp  = PrefabLoader.GetTile(Tile.Object.Tree);
        stoneProp = PrefabLoader.GetTile(Tile.Object.Stone);
    }
Example #22
0
    private void DrawHuman()
    {
        GameObject body = Instantiate(PrefabLoader.GetHumanBody(human.Gender, human.BodyType), Vector2.zero,
                                      Quaternion.identity) as GameObject;
        GameObject hair = Instantiate(PrefabLoader.GetHumanHair(human.Gender, human.HairType), Vector2.zero,
                                      Quaternion.identity) as GameObject;

        body.transform.SetParent(transform, false);
        hair.transform.SetParent(transform, false);
    }
Example #23
0
    public static void OpenUI()
    {
        Object prefab = PrefabLoader.loadFromPack("JC/JCCreateRole");

        if (prefab != null)
        {
            GameObject obj = Instantiate(prefab) as GameObject;
            RED.AddChild(obj, DBUIController.mDBUIInstance._TopRoot);
        }
    }
Example #24
0
        private void InstantiateUnit(Unit unit)
        {
            Hex        hex        = CGM.Battle.GetHex(unit);
            GameObject prefab     = new PrefabLoader().Load(unit);
            Vector3    position   = GetPosition(hex);
            GameObject gameObject = Instantiate(prefab, position, Quaternion.identity, unitRoot);

            gameObject.name = prefab.name;
            unitGOs.Add(unit, gameObject);
        }
 void InitRankCheckInfoPanel()
 {
     UnityEngine.Object obj = PrefabLoader.loadFromPack("LS/pbLSDragonBallRankCheckInfo");
     if (obj != null)
     {
         GameObject go = RUIMonoBehaviour.Instantiate(obj) as GameObject;
         mUIDragonBallRankCheckInfo = go.GetComponent <UIDragonBallRankCheckInfo>();
         RED.AddChild(go.gameObject, DBUIController.mDBUIInstance._bottomRoot);
     }
 }
Example #26
0
 // information  tag...  include delete, add friend, receive gift, send message and so on
 void CreateMessageTag()
 {
     UnityEngine.Object obj = PrefabLoader.loadFromPack("LS/pbLSInformationTag");
     if (obj != null)
     {
         GameObject go = RUIMonoBehaviour.Instantiate(obj) as GameObject;
         mUIMessageTag = go.GetComponent <UIMessageTag>();
         RED.AddChild(go.gameObject, DBUIController.mDBUIInstance._bottomRoot);
     }
 }
Example #27
0
 void CreateSecretShop()
 {
     UnityEngine.Object obj = PrefabLoader.loadFromPack("LS/pbLSDragonBallSecretMall");
     if (obj != null)
     {
         GameObject go = RUIMonoBehaviour.Instantiate(obj) as GameObject;
         _UISecretShop = go.GetComponent <UISecretShop>();
         RED.AddChild(go.gameObject, DBUIController.mDBUIInstance._bottomRoot);
     }
 }
 public static void OpenUI()
 {
     UnityEngine.Object obj = PrefabLoader.loadFromPack("LS/pbLSMailAndBattleRoot");
     if (obj != null)
     {
         GameObject go = RUIMonoBehaviour.Instantiate(obj) as GameObject;
         _instance = go.GetComponent <UIMailAndBattleMain>();
         RED.AddChild(go.gameObject, DBUIController.mDBUIInstance._bottomRoot);
     }
 }
Example #29
0
    private void CreateSlot(int index)
    {
        var slotPrefab = PrefabLoader.LoadPrefab("Prefabs/InventorySlot");
        var slot       = Instantiate(slotPrefab, _options.contentTransform).GetComponent <InventorySlot>();

        slot.Init(index);
        _slots.Add(index, slot);

        slot.OnItemDropEvent += OnItemDrop;
    }
Example #30
0
    public static void Open(string strText = "", float maskAlpha = 0.5f)
    {
        if (_instance == null)
        {
            Object     pro    = PrefabLoader.loadFromPack("Comload/pbComLoading");
            GameObject prefab = GameObject.Instantiate(pro) as GameObject;

            GameObject parent = null;
            if (DBUIController.mDBUIInstance != null)
            {
                parent = DBUIController.mDBUIInstance._TopRoot;
            }
            else
            {
                Behaviour uic = UICamera.currentCamera;
                if (uic == null)                  //空的情况下,可以再次去战斗场景里面去相机
                {
                    uic = BattleCamera.Instance.Camera1;
                }

                if (uic == null)
                {
                    return;
                }
                parent = uic.gameObject;
            }

            RED.AddChild(prefab, parent);
            if (Core.SM.CurScenesName == SceneName.GAME_BATTLE)
            {
                prefab.layer = LayerMask.NameToLayer("UI");
            }
            else
            {
                prefab.layer = LayerMask.NameToLayer("UITop");
            }
            prefab.name = "ComloadingUI";

            _instance = prefab.GetComponent <ComLoading>();
        }
        else
        {
            RED.SetActive(true, _instance.gameObject);
        }
        if (_instance != null)
        {
            if (strText == "")
            {
                strText = Core.Data.stringManager.getString(9125);
            }
            _instance._txtDesp.text = strText;
            _instance.Init();
            _instance.maskAlpha = maskAlpha;
        }
    }
 public static CRLuo_ShowStage CreateMonsterComeShowStage()
 {
     UnityEngine.Object obj = PrefabLoader.loadFromPack("CRLuo/System/ShowMonsterStage", false);
     if (obj != null)
     {
         GameObject      go = Instantiate(obj) as GameObject;
         CRLuo_ShowStage ss = go.GetComponent <CRLuo_ShowStage>();
         return(ss);
     }
     return(null);
 }