Ejemplo n.º 1
0
        protected override void Build()
        {
            // Load Material
            ModelMat = CreateModelMat();

            // Get GameObjects
            Prefab      = PrefabUtils.CopyPrefab(BaseItem);
            Prefab.name = NamePrefix + Name;
            Prefab.transform.localScale = Scale;

            // Load Components
            MeshFilter       filter = Prefab.GetComponent <MeshFilter>();
            MeshRenderer     render = Prefab.GetComponent <MeshRenderer>();
            Rigidbody        body   = Prefab.GetComponent <Rigidbody>();
            Vacuumable       vac    = Prefab.GetComponent <Vacuumable>();
            Identifiable     iden   = Prefab.GetComponent <Identifiable>();
            PlortInstability inst   = Prefab.GetComponent <PlortInstability>();

            // Setup Components
            filter.sharedMesh     = Mesh;
            render.sharedMaterial = ModelMat;
            body.mass             = Mass;
            vac.size           = Size;
            iden.id            = ID;
            inst.lifetimeHours = LifetimeHours;
        }
Ejemplo n.º 2
0
        IEnumerator init()
        {
            if (inited || !(inited = true))
            {
                yield break;
            }

            AnimationHelper.init();

            //cbeams[0] = new ConstructionBeam(builderTool.beamLeft, builderTool.nozzleLeft);
            //cbeams[1] = new ConstructionBeam(builderTool.beamRight, builderTool.nozzleRight);

            GameObject beamsRoot = gameObject.getChild("terraformer_anim/Terraformer_Export_Skele/root_jnt/body_jnt/head_jnt");

            var task = PrefabUtils.getPrefabAsync(TechType.Builder);

            yield return(task);

            GameObject beamPrefab = task.GetResult().getChild("builder/builder_FP/Root/r_nozzle_root/r_nozzle/R_laser/beamRight");

            cbeams[0] = new ConstructionBeam(beamsRoot, beamPrefab, "Left", new Vector3(-0.1813f, -0.007f, 0.06f));
            cbeams[1] = new ConstructionBeam(beamsRoot, beamPrefab, "Right", new Vector3(0.1813f, -0.007f, 0.06f));
            cbeams[2] = new ConstructionBeam(beamsRoot, beamPrefab, "Center1", new Vector3(0, -0.007f, 0.06f));
            //cbeams[3] = new ConstructionBeam(beamsRoot, beamPrefab, "Center2", new Vector3(0, -0.007f, 0.06f));

            setBeamsActive(false);
        }
Ejemplo n.º 3
0
    // Use this for initialization
    void Start()
    {
        for (int i = 0; i < effects.childCount; i++)
        {
            GameObject effTemp   = effects.GetChild(i).gameObject;
            GameObject UIeffTemp = UIeffects.GetChild(i).gameObject;
            GameObject go        = PrefabUtils.AddChild(btnRoot, btnTemp.gameObject);
            Button     btn       = go.GetComponent <Button>();
            Text       btnTex    = go.GetComponentInChildren <Text>();
            btnTex.text = names[i];
            btn.onClick.AddListener(() =>
            {
                GameObject eff             = PrefabUtils.AddChild(effRoot, effTemp);
                GameObject uieff           = PrefabUtils.AddChild(UIeffRoot, UIeffTemp);
                uieff.transform.localScale = UIeffTemp.transform.localScale;
                Destroy(eff, 3);
                Destroy(uieff, 3);
            });

            //AudioClip clip = sounds[i];
            //if(null != clip)
            //{
            //    aSource.PlayOneShot(clip);
            //}
        }
    }
        /// <summary>Builds this Item</summary>
        protected override void Build()
        {
            // Get GameObjects
            Prefab      = PrefabUtils.CopyPrefab(BaseItem);
            Prefab.name = NamePrefix + Name;

            // Load Components
            SpawnResource spawn = Prefab.GetComponent <SpawnResource>();

            // Setup Components
            spawn.id                  = ID;
            spawn.ObjectsToSpawn      = GameContext.Instance.LookupDirector.GetPrefabs(ToSpawn);
            spawn.BonusObjectsToSpawn = BonusToSpawn != null?GameContext.Instance.LookupDirector.GetPrefabs(BonusToSpawn) : new GameObject[0];

            spawn.MaxObjectsSpawned         = MaxObjectsSpawned;
            spawn.MinObjectsSpawned         = MinObjectsSpawned;
            spawn.MinNutrientObjectsSpawned = MinNutrientObjectsSpawned == -1 ? MaxObjectsSpawned : MinNutrientObjectsSpawned;
            spawn.MinSpawnIntervalGameHours = MinSpawnIntervalGameHours;
            spawn.MaxSpawnIntervalGameHours = MaxSpawnIntervalGameHours;
            spawn.BonusChance        = BonusChance;
            spawn.minBonusSelections = MinBonusSelections;

            // Builds the Spawn Points
            BuildSpawnPoints(spawn);
        }
Ejemplo n.º 5
0
        private void DrawGizmos(bool isSelected)
        {
            if (Application.isPlaying)
            {
                return;
            }

            if (Wire == null || Wire.Route == null || Wire.Route.NumNodes < 2)
            {
                return;
            }

            if (!PrefabUtils.IsPartOfEditingPrefab(gameObject))
            {
                return;
            }

            var routePoints = Wire.Route.Select(routePoint => routePoint.Position).ToArray();

            var defaultColor  = Color.Lerp(Color.black, Color.white, 0.55f);
            var selectedColor = Color.Lerp(defaultColor, Color.green, 0.15f);

            m_segmentSpawner?.DrawGizmos(routePoints,
                                         Wire.Radius,
                                         isSelected ? selectedColor : defaultColor);
        }
Ejemplo n.º 6
0
    public GameObject Spawn(string name)
    {
        if (m_objectStack.ContainsKey(name))
        {
            Stack <GameObject> stack = m_objectStack[name];
            if (stack.Count > 0)
            {
                GameObject t = stack.Pop();

                if (m_resetAction != null)
                {
                    m_resetAction(t);
                }

                t.SetActive(true);
                return(t);
            }
            else
            {
                print("pool is not enough! " + this.name + " " + name);
                GameObject go    = PrefabUtils.GetPrefab(name, prefabType);
                GameObject child = PrefabUtils.AddChild(this.gameObject, go);
                child.layer = go.layer;
                child.name  = name;
                gameObjectToKey.Add(child, name);
                child.SetActive(true);
                return(child);
            }
        }
        else
        {
            Debug.LogWarningFormat("pool no name:[{0}]", name);
            return(null);
        }
    }
Ejemplo n.º 7
0
        // Methods
        protected override void Build()
        {
            // Get GameObjects
            Prefab      = PrefabUtils.CopyPrefab(BaseItem);
            Prefab.name = NamePrefix + Name;
            Prefab.transform.localScale = Scale;

            // Load Components
            Rigidbody    body = Prefab.GetComponent <Rigidbody>();
            Vacuumable   vac  = Prefab.GetComponent <Vacuumable>();
            Identifiable iden = Prefab.GetComponent <Identifiable>();

            Image front = Prefab.transform.Find("Icon Pivot/Animation Pivot/ShopIconUI/Image").GetComponent <Image>();
            Image back  = Prefab.transform.Find("Icon Pivot/Animation Pivot/ShopIconUI/Image Back").GetComponent <Image>();

            // Setup Components
            body.mass = Mass;
            vac.size  = Size;
            iden.id   = ID;

            front.sprite = Icon;
            back.sprite  = Icon;

            if (DigitalEffect)
            {
                return;
            }

            front.material = null;
            Object.Destroy(back.gameObject);
        }
Ejemplo n.º 8
0
            static IEnumerator initPrefab()
            {
                if (stasisSpherePrefab)
                {
                    yield break;
                }

                if (alreadyInit || !(alreadyInit = true))                 // to avoid simultaneous initialization
                {
                    yield return(new WaitUntil(() => stasisSpherePrefab));

                    yield break;
                }
#if GAME_BZ
#pragma warning disable CS0612 // TechType.StasisRifle is obsolete in BZ
#endif
                var task = PrefabUtils.getPrefabAsync(TechType.StasisRifle);
#if GAME_BZ
#pragma warning restore CS0612
#endif
                yield return(task);

                var stasisRiflePrefab = task.GetResult();

                if (!stasisRiflePrefab)
                {
                    "StasisExplosion.initPrefab: invalid prefab for StasisRifle!".logError();
                    yield break;
                }

                stasisSpherePrefab = PrefabUtils.storePrefabCopy(stasisRiflePrefab.GetComponent <StasisRifle>()?.effectSpherePrefab);
            }
Ejemplo n.º 9
0
        // Methods
        protected override void Build()
        {
            // Get GameObjects
            Prefab      = PrefabUtils.CopyPrefab(BaseItem);
            Prefab.name = NamePrefix + Name;
            Prefab.transform.localScale = Scale;

            // Load Components
            Fashion      fash = Prefab.GetComponent <Fashion>();
            Rigidbody    body = Prefab.GetComponent <Rigidbody>();
            Vacuumable   vac  = Prefab.GetComponent <Vacuumable>();
            Identifiable iden = Prefab.GetComponent <Identifiable>();

            Image front = Prefab.transform.Find("Icon Pivot/ShopIconUI/Image").GetComponent <Image>();
            Image back  = Prefab.transform.Find("Icon Pivot/ShopIconUI/Image Back").GetComponent <Image>();

            // Setup Components
            fash.slot         = Slot;
            fash.attachPrefab = AttachPrefab ? AttachPrefab : fash.attachPrefab;

            body.mass = Mass;
            vac.size  = Size;
            iden.id   = ID;

            front.sprite = Icon;
            back.sprite  = Icon;
        }
Ejemplo n.º 10
0
        private void Render(CableRoute route, float radius)
        {
            if (m_segmentSpawner == null)
            {
                return;
            }

            // Let OnDrawGizmos handle rendering when in prefab edit mode.
            // It's not possible to use RuntimeObjects while there.
            if (PrefabUtils.IsPartOfEditingPrefab(gameObject))
            {
                return;
            }

            if (!Cable.RoutePointCurveUpToDate)
            {
                Cable.SynchronizeRoutePointCurve();
            }

            m_segmentSpawner.Begin();
            try {
                var points = Cable.GetRoutePoints();
                for (int i = 1; i < points.Length; ++i)
                {
                    m_segmentSpawner.CreateSegment(points[i - 1], points[i], radius);
                }
            }
            catch (System.Exception e) {
                Debug.LogException(e, this);
            }
            m_segmentSpawner.End();
        }
Ejemplo n.º 11
0
    public void OnGetApplyClubCallBack(ClientResponse response)
    {
        ClubAccountVO vo = JsonMapper.ToObject <ClubAccountVO>(response.message);

        if (vo.msgcode != 0)
        {
            TipsManagerScript.getInstance().setTips(vo.msgstring);
        }
        else
        {
            isagreePanelShow = true;
            agreeListPanel.SetActive(true);
            PrefabUtils.ClearChild(agreeListGrid);
            foreach (ClubAccount ac in vo.listaccount)
            {
                GameObject     child = PrefabUtils.AddChild(agreeListGrid, agreesub);
                agreeSubScript cs    = child.GetComponent <agreeSubScript>();
                cs.setValue(ac);
                cs.agreebtn.onClick.AddListener(() =>
                {
                    ClientRequest cr  = new ClientRequest();
                    cr.headCode       = APIS.AGREE_CLUB_REQUEST;
                    cr.messageContent = "{'agree':1,'uuid':" + ac.uuid + "}";
                    CustomSocket.getInstance().sendMsg(cr);
                });
                cs.nobtn.onClick.AddListener(() =>
                {
                    ClientRequest cr  = new ClientRequest();
                    cr.headCode       = APIS.AGREE_CLUB_REQUEST;
                    cr.messageContent = "{'agree':0,'uuid':" + ac.uuid + "}";
                    CustomSocket.getInstance().sendMsg(cr);
                });
            }
        }
    }
Ejemplo n.º 12
0
        /// <summary>
        /// Called before GameContext.Start()
        /// </summary>
        static void Load()
        {
            if (isInitialized)
            {
                return;
            }
            isInitialized = true;

            BaseObjects.Populate();
            SRCallbacks.OnLoad();
            PrefabUtils.ProcessReplacements();
            KeyBindManager.ReadBinds();
            GameContext.Instance.gameObject.AddComponent <ModManager>();
            GameContext.Instance.gameObject.AddComponent <KeyBindManager.ProcessAllBindings>();
            try
            {
                SRModLoader.LoadMods();
            }
            catch (Exception e)
            {
                Debug.LogError(e);
                ErrorGUI.CreateError($"{e.GetType().Name}: {e.Message}");
                return;
            }
            PostLoad();
        }
Ejemplo n.º 13
0
        private void DrawGizmos(bool isSelected)
        {
            if (Application.isPlaying)
            {
                return;
            }

            if (!PrefabUtils.IsPartOfEditingPrefab(gameObject))
            {
                return;
            }

            // The conveyor belt has some rendering when selected.
            if (GetComponent <Model.ConveyorBelt>() != null)
            {
                return;
            }

            var defaultColor  = Color.Lerp(Color.black, Color.red, 0.15f);
            var selectedColor = Color.Lerp(defaultColor, Color.white, 0.15f);

            foreach (var track in Tracks)
            {
                DrawGizmosUninitialized(track, isSelected ? selectedColor : defaultColor);
            }
        }
Ejemplo n.º 14
0
    private void SetupUI()
    {
        detail.Time_Text.text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
        ClearCard();
        PrefabUtils.ClearChild(detail.Grid_GridLayoutGroup);

        if (null != RoomMgr.huSyn)
        {
            detail.Title_TextMeshProUGUI.text = MJUtils.GetHuType(RoomMgr.huSyn.resultType);

            if (RoomMgr.huSyn.resultType == MJUtils.HU_LiuJu)
            {
                foreach (GameOperPlayerSettle settle in RoomMgr.huSyn.detail)
                {
                    if (settle.position == Game.MJMgr.MyPlayer.postion)
                    {
                        SetupSub(detail.RoundAccountSub0_RoundAccountSub, settle, RoomMgr.huSyn.card);
                    }
                    else
                    {
                        GameObject      child = PrefabUtils.AddChild(detail.Grid_GridLayoutGroup, detail.RoundAccountSub1_RoundAccountSub);
                        RoundAccountSub sub   = child.GetComponent <RoundAccountSub>();
                        SetupSub(sub, settle);
                    }
                }
            }
            else
            {
                foreach (GameOperPlayerSettle settle in RoomMgr.huSyn.detail)
                {
                    if (settle.position == RoomMgr.huSyn.position)
                    {
                        SetupSub(detail.RoundAccountSub0_RoundAccountSub, settle, RoomMgr.huSyn.card);
                    }
                    else
                    {
                        GameObject      child = PrefabUtils.AddChild(detail.Grid_GridLayoutGroup, detail.RoundAccountSub1_RoundAccountSub);
                        RoundAccountSub sub   = child.GetComponent <RoundAccountSub>();
                        SetupSub(sub, settle);
                    }
                }
            }
        }

        PrefabUtils.ClearChild(detail.SingleCard_UIItem);
        SpawnCard(detail.SingleCard_UIItem.transform, Game.MJMgr.cardHui); //TODO wxd 结算界面的显示

        detail.M0_UIItem.gameObject.SetActive(MJUtils.HasWanfa(MJUtils.MODE_DAIHUI));
        detail.M1_UIItem.gameObject.SetActive(false);
        detail.M2_UIItem.gameObject.SetActive(false);
        detail.M3_UIItem.gameObject.SetActive(false);

        detail.M4_UIItem.gameObject.SetActive(false);
        detail.M5_UIItem.gameObject.SetActive(false);
        detail.M6_UIItem.gameObject.SetActive(false);
        detail.M7_UIItem.gameObject.SetActive(false);

        // TODO 结算界面
    }
Ejemplo n.º 15
0
                static IEnumerator _dumpPrefab(TechType techType)
                {
                    var task = PrefabUtils.getPrefabAsync(techType);

                    yield return(task);

                    task.GetResult()?.dump(techType.AsString());
                }
Ejemplo n.º 16
0
            static IEnumerator _deathEffect()             // multiple ?
            {
                var task = PrefabUtils.getPrefabAsync(TechType.BlueCluster);

                yield return(task);

                deathEffect = task.GetResult().GetComponent <LiveMixin>().data.deathEffect;
            }
Ejemplo n.º 17
0
    public void TriggerElectronJourney()
    {
        EPathNode firstNode = edges[0].start;
        Vector3   iniPos    = firstNode.transform.position;

        (GameObject go, Electron el)electron = PrefabUtils.InstantiatePrefab <Electron>(electronPrefab, null, iniPos, Quaternion.identity);
        electron.el.Initialize(edges);
    }
Ejemplo n.º 18
0
    void OnClickChiBtn()
    {
        Game.SoundManager.PlayClick();

        if (MJUtils.Chi() || MJUtils.TingChi())
        {
            List <GameOperChiArg> list = RoomMgr.actionNotify.chiArg;
            //List<int[]> list = Game.MJMgr.MyPlayer.GetChiList (Game.MJMgr.lastDropCard);
            if (null != list && list.Count > 0)
            {
                detail.CtrlPanel_UIItem.gameObject.SetActive(false);

                if (list.Count == 1)
                {
                    GameOperChiArg chiArg = list[0];

                    Game.MJMgr.MyPlayer.Chi(chiArg);
                    //Game.SoundManager.PlayChi ();
                    //detail.DropButton_Button.gameObject.SetActive(true);
                }
                else
                {
                    ClearSelectPanel();
                    detail.SelectPanel_UIItem.gameObject.SetActive(true);
                    List <int> sortTemp = new List <int> ();
                    for (int i = list.Count - 1; i >= 0; i--)
                    //for (int i = 0; i < list.Count; i++)
                    {
                        GameOperChiArg chiArg = list[i];

                        GameObject selectGroup = PrefabUtils.AddChild(detail.SelectRoot_HorizontalLayoutGroup, detail.GroupButton_Button.gameObject);
                        selectGroup.SetActive(true);

                        sortTemp.Clear();
                        sortTemp.Add(chiArg.myCard1);
                        sortTemp.Add(chiArg.myCard2);
                        sortTemp.Add(chiArg.targetCard);
                        sortTemp.Sort();

                        foreach (int card in sortTemp)
                        {
                            GameObject card0 = Game.PoolManager.MjPool.Spawn(card.ToString());
                            card0.transform.SetParent(selectGroup.transform);
                            card0.transform.localScale    = Vector3.one;
                            card0.transform.localRotation = Quaternion.identity;
                        }

                        Button btn = selectGroup.GetComponent <Button> ();
                        btn.onClick.AddListener(() => {
                            Game.MJMgr.MyPlayer.Chi(chiArg);
                            detail.SelectPanel_UIItem.gameObject.SetActive(false);
                            //detail.DropButton_Button.gameObject.SetActive(true);
                        });
                    }
                }
            }
        }
    }