Exemplo n.º 1
0
        /// <summary>
        /// 创建玩家结算信息
        /// </summary>
        /// <returns></returns>
        public GameObject CreateGamerContent(Gamer gamer, Identity winnerIdentity, long baseScore, int multiples, long score)
        {
            GameObject newContent = UnityEngine.Object.Instantiate(contentPrefab);

            newContent.transform.SetParent(gamerContent.transform, false);

            Identity gamerIdentity  = gamer.GetComponent <HandCardsComponent>().AccessIdentity;
            Sprite   identitySprite = CardHelper.GetCardSprite($"Identity_{Enum.GetName(typeof(Identity), gamerIdentity)}");

            newContent.Get <GameObject>("Identity").GetComponent <Image>().sprite = identitySprite;

            string nickName      = gamer.GetComponent <GamerUIComponent>().NickName;
            Text   nickNameText  = newContent.Get <GameObject>("NickName").GetComponent <Text>();
            Text   baseScoreText = newContent.Get <GameObject>("BaseScore").GetComponent <Text>();
            Text   multiplesText = newContent.Get <GameObject>("Multiples").GetComponent <Text>();
            Text   scoreText     = newContent.Get <GameObject>("Score").GetComponent <Text>();

            nickNameText.text  = nickName;
            baseScoreText.text = baseScore.ToString();
            multiplesText.text = multiples.ToString();
            scoreText.text     = score.ToString();

            if (gamer.UserID == this.GetParent <UI>().GetParent <UI>().GetComponent <GamerComponent>().LocalGamer.UserID)
            {
                nickNameText.color  = Color.red;
                baseScoreText.color = Color.red;
                multiplesText.color = Color.red;
                scoreText.color     = Color.red;
            }

            return(newContent);
        }
Exemplo n.º 2
0
 static void AddEffectCache(EffectCacheComponent effectCacheComponent, BaseBuffData buff, GameObject skillAssetsPrefabGo)
 {
     if (buff.GetBuffIdType() == BuffIdType.EmitObj)
     {
         Buff_EmitObj buff_EmitEffect = (Buff_EmitObj)buff;
         if (!string.IsNullOrEmpty(buff_EmitEffect.emitObjId) && !effectCacheComponent.Contains(buff_EmitEffect.emitObjId))
         {
             effectCacheComponent.Add(buff_EmitEffect.emitObjId, skillAssetsPrefabGo.Get <GameObject>(buff_EmitEffect.emitObjId));
         }
     }
     if (buff.GetBuffIdType() == BuffIdType.HitEffect)
     {
         Buff_HitEffect buff_HitEffect = (Buff_HitEffect)buff;
         if (!string.IsNullOrEmpty(buff_HitEffect.hitObjId) && !effectCacheComponent.Contains(buff_HitEffect.hitObjId))
         {
             effectCacheComponent.Add(buff_HitEffect.hitObjId, skillAssetsPrefabGo.Get <GameObject>(buff_HitEffect.hitObjId));
         }
     }
     if (buff.GetBuffIdType() == BuffIdType.PlayEffect)
     {
         Buff_PlayEffect buff_PlayEffect = (Buff_PlayEffect)buff;
         if (!string.IsNullOrEmpty(buff_PlayEffect.effectObjId) && !effectCacheComponent.Contains(buff_PlayEffect.effectObjId))
         {
             effectCacheComponent.Add(buff_PlayEffect.effectObjId, skillAssetsPrefabGo.Get <GameObject>(buff_PlayEffect.effectObjId));
         }
     }
 }
Exemplo n.º 3
0
        public void LoadHotfixAssembly()
        {
            AssetRequest assetRequest = Assets.LoadAsset("Assets/Bundles/Independent/Code.prefab", typeof(GameObject));
            GameObject   code         = assetRequest.asset as GameObject;

            byte[] assBytes = code.Get <TextAsset>("Hotfix.dll").bytes;
            byte[] pdbBytes = code.Get <TextAsset>("Hotfix.pdb").bytes;

#if ILRuntime
            Log.Debug($"当前使用的是ILRuntime模式");
            this.appDomain = new ILRuntime.Runtime.Enviorment.AppDomain();

            this.dllStream = new MemoryStream(assBytes);
            this.pdbStream = new MemoryStream(pdbBytes);

            this.appDomain.LoadAssembly(this.dllStream, this.pdbStream, new ILRuntime.Mono.Cecil.Pdb.PdbReaderProvider());

            this.start = new ILStaticMethod(this.appDomain, "ETHotfix.Init", "Start", 0);

            this.hotfixTypes = this.appDomain.LoadedTypes.Values.Select(x => x.ReflectionType).ToList();
#else
            Log.Debug($"当前使用的是Mono模式");

            this.assembly = Assembly.Load(assBytes, pdbBytes);

            Type hotfixInit = this.assembly.GetType("ETHotfix.Init");
            this.start = new MonoStaticMethod(hotfixInit, "Start");

            this.hotfixTypes = this.assembly.GetTypes().ToList();
#endif
            Assets.UnloadAsset(assetRequest);
        }
Exemplo n.º 4
0
    public static void SetToggleValue(GameObject obj, bool selected)
    {
        if (obj != null)
        {
#if USE_UI_NGUI_2_7
            if (obj.Has <UICheckbox>())
            {
                SetToggleValue(obj.Get <UICheckbox>(), selected);
            }
#endif
#if USE_UI_NGUI_3
            if (obj.Has <UIToggle>())
            {
                SetToggleValue(obj.Get <UIToggle>(), selected);
            }
#endif
            if (obj.Has <Slider>())
            {
                SetToggleValue(obj.Get <Slider>(), selected);
            }
            else if (obj.Has <Toggle>())
            {
                SetToggleValue(obj.Get <Toggle>(), selected);
            }
        }
    }
Exemplo n.º 5
0
        public void Awake()
        {
            ReferenceCollector rc = this.GetParent <UI>().GameObject.GetComponent <ReferenceCollector>();

            quitButton  = rc.Get <GameObject>("QuitButton");
            readyButton = rc.Get <GameObject>("ReadyButton");
            //GameObject multiplesObj = rc.Get<GameObject>("Multiples");
            //multiples = multiplesObj.GetComponent<Text>();

            //绑定事件
            quitButton.GetComponent <Button>().onClick.Add(OnQuit);
            readyButton.GetComponent <Button>().onClick.Add(OnReady);

            //默认隐藏UI
            //multiplesObj.SetActive(false);
            readyButton.SetActive(false);
            //rc.Get<GameObject>("Desk").SetActive(false);

            //添加玩家面板
            GameObject gamersPanel = rc.Get <GameObject>("Gamers");

            this.GamersPanel[0] = gamersPanel.Get <GameObject>("Left2");
            this.GamersPanel[1] = gamersPanel.Get <GameObject>("Left1");
            this.GamersPanel[2] = gamersPanel.Get <GameObject>("Local");
            this.GamersPanel[3] = gamersPanel.Get <GameObject>("Right1");
            this.GamersPanel[4] = gamersPanel.Get <GameObject>("Right2");


            //添加本地玩家
            User  localPlayer = ClientComponent.Instance.LocalPlayer;
            Gamer localGamer  = GamerFactory.Create(localPlayer.UserID, false);

            AddGamer(localGamer, 2);
            this.GetParent <UI>().GetComponent <GamerComponent>().LocalGamer = localGamer;
        }
Exemplo n.º 6
0
        public void Awake()
        {
            ReferenceCollector rc = this.GetEntity <UI>().GameObject.GetComponent <ReferenceCollector>();

            GameObject quitButton   = rc.Get <GameObject>("QuitButton");
            GameObject readyButton  = rc.Get <GameObject>("ReadyButton");
            GameObject multiplesObj = rc.Get <GameObject>("Multiples");

            multiples = multiplesObj.GetComponent <Text>();
            //绑定事件
            quitButton.GetComponent <Button>().onClick.Add(OnQuit);
            readyButton.GetComponent <Button>().onClick.Add(OnReady);

            //默认隐藏UI
            multiplesObj.SetActive(false);
            readyButton.SetActive(false);
            rc.Get <GameObject>("Desk").SetActive(false);

            //添加玩家面板
            GameObject gamersPanel = rc.Get <GameObject>("Gamers");

            GamersPanel.Enqueue(gamersPanel.Get <GameObject>("Local"));
            GamersPanel.Enqueue(gamersPanel.Get <GameObject>("Left"));
            GamersPanel.Enqueue(gamersPanel.Get <GameObject>("Right"));
        }
Exemplo n.º 7
0
    public static float GetSliderValue(GameObject obj)
    {
        if (obj != null)
        {
#if USE_UI_NGUI_2_7 || USE_UI_NGUI_3
            if (obj.Has <UISlider>())
            {
                return(GetSliderValue(obj.Get <UISlider>()));
            }
#endif
            if (obj.Has <Slider>())
            {
                return(GetSliderValue(obj.Get <Slider>()));
            }
            else if (obj.Has <Scrollbar>())
            {
                return(GetSliderValue(obj.Get <Scrollbar>()));
            }
            else if (obj.Has <Image>())
            {
                return(GetSliderValue(obj.Get <Image>()));
            }
        }

        return(0f);
    }
Exemplo n.º 8
0
        /// <summary>
        /// 加载热更的程序集
        /// </summary>
        public void LoadHotfixAssembly()
        {
            Game.Scene.GetComponent <ResourcesComponent>().LoadBundle($"code.unity3d");
            GameObject code = (GameObject)Game.Scene.GetComponent <ResourcesComponent>().GetAsset("code.unity3d", "Code");

            byte[] assBytes = code.Get <TextAsset>("Hotfix.dll").bytes;
            byte[] pdbBytes = code.Get <TextAsset>("Hotfix.pdb").bytes;

#if ILRuntime
            Log.Debug($"当前使用的是ILRuntime模式");
            this.appDomain = new ILRuntime.Runtime.Enviorment.AppDomain();

            this.dllStream = new MemoryStream(assBytes);
            this.pdbStream = new MemoryStream(pdbBytes);
            this.appDomain.LoadAssembly(this.dllStream, this.pdbStream, new Mono.Cecil.Pdb.PdbReaderProvider());

            this.start = new ILStaticMethod(this.appDomain, "ETHotfix.Init", "Start", 0);

            this.hotfixTypes = this.appDomain.LoadedTypes.Values.Select(x => x.ReflectionType).ToList();
#else
            Log.Debug($"当前使用的是Mono模式");

            this.assembly = Assembly.Load(assBytes, pdbBytes);

            Type hotfixInit = this.assembly.GetType("ETHotfix.Init");
            this.start = new MonoStaticMethod(hotfixInit, "Start");

            this.hotfixTypes = this.assembly.GetTypes().ToList();
#endif

            Game.Scene.GetComponent <ResourcesComponent>().UnloadBundle($"code.unity3d");
        }
Exemplo n.º 9
0
        public void LoadHotfixAssembly()
        {
            Game.ResourcesComponent.LoadBundle($"code.unity3d");
#if ILRuntime
            this.appDomain = new ILRuntime.Runtime.Enviorment.AppDomain();
            GameObject code     = (GameObject)Game.Scene.GetComponent <ResourcesComponent>().GetAsset("code.unity3d", "Code");
            byte[]     assBytes = code.Get <TextAsset>("Hotfix.dll").bytes;
            byte[]     mdbBytes = code.Get <TextAsset>("Hotfix.pdb").bytes;

            using (MemoryStream fs = new MemoryStream(assBytes))
                using (MemoryStream p = new MemoryStream(mdbBytes))
                {
                    this.appDomain.LoadAssembly(fs, p, new Mono.Cecil.Pdb.PdbReaderProvider());
                }

            this.start = new ILStaticMethod(this.appDomain, "ETHotfix.Init", "Start", 0);
#else
            GameObject code     = (GameObject)Game.ResourcesComponent.GetAsset("code.unity3d", "Code");
            byte[]     assBytes = code.Get <TextAsset>("Hotfix.dll").bytes;
            byte[]     mdbBytes = code.Get <TextAsset>("Hotfix.mdb").bytes;
            this.assembly = Assembly.Load(assBytes, mdbBytes);

            Type hotfixInit = this.assembly.GetType("ETHotfix.Init");
            this.start = new MonoStaticMethod(hotfixInit, "Start");
#endif
            Game.ResourcesComponent.UnloadBundle($"code.unity3d");
        }
Exemplo n.º 10
0
        public async void Run()
        {
            GameObject code = (GameObject)Resources.Load("Code/Code");

            byte[]   assBytes = code.Get <TextAsset>("Controller.dll").bytes;
            byte[]   mdbBytes = code.Get <TextAsset>("Controller.dll.mdb").bytes;
            Assembly assembly = Assembly.Load(assBytes, mdbBytes);

            Object.ObjectManager.Register("Controller", assembly);
            Object.ObjectManager.Register("Base", typeof(Game).Assembly);

            Game.Scene.AddComponent <MessageComponent>();
            Game.Scene.AddComponent <ChildrenComponent>();

            try
            {
                S2C_FetchServerTime s2CFetchServerTime = await Game.Scene.GetComponent <MessageComponent>().CallAsync <S2C_FetchServerTime>(new C2S_FetchServerTime());

                Log.Info($"server time is: {s2CFetchServerTime.ServerTime}");
            }
            catch (RpcException e)
            {
                Log.Error(e.ToString());
            }
            catch (Exception e)
            {
                Log.Error(e.ToString());
            }
        }
Exemplo n.º 11
0
        public void Awake()
        {
            ReferenceCollector rc = this.GetParent <UI>().GameObject.GetComponent <ReferenceCollector>();

            this.changeTableBtn = rc.Get <GameObject>("ChangeTableBtn").GetComponent <Button>();
            this.readyBtn       = rc.Get <GameObject>("ReadyBtn").GetComponent <Button>();
            this.weChatBtn      = rc.Get <GameObject>("WeChat").GetComponent <Button>();
            this.roomIdObj      = rc.Get <GameObject>("RoomId");

            this.head         = rc.Get <GameObject>("Head");
            this.readyTimeout = rc.Get <GameObject>("ReadyTimeout");
            this.timeText     = this.readyTimeout.transform.Find("timeText").GetComponent <Text>();

            HeadPanel[0] = head.Get <GameObject>("Bottom");
            HeadPanel[1] = head.Get <GameObject>("Right");
            HeadPanel[2] = head.Get <GameObject>("Top");
            HeadPanel[3] = head.Get <GameObject>("Left");

            this.changeTableBtn.onClick.Add(OnChangeTable);
            this.readyBtn.onClick.Add(OnReady);
            weChatBtn.onClick.Add(OnInviteWeChat);

            CommonUtil.SetTextFont(this.GetParent <UI>().GameObject);

            timeOut = 20;
            SetTimeOut();

            UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);

            this.uiRoomComponent = uiRoom.GetComponent <UIRoomComponent>();
        }
Exemplo n.º 12
0
        public void Awake()
        {
            ReferenceCollector rc = this.GetParent <UI>().GameObject.GetComponent <ReferenceCollector>();

            GameObject quitButton  = rc.Get <GameObject>("Quit");
            GameObject readyButton = rc.Get <GameObject>("Ready");

            prompt = rc.Get <GameObject>("MatchPrompt").GetComponent <Text>();

            multiples = rc.Get <GameObject>("Multiples").GetComponent <Text>();

            readyButton.SetActive(false); //默认隐藏
            Matching = true;              //进入房间后取消匹配状态

            //绑定事件
            quitButton.GetComponent <Button>().onClick.Add(OnQuit);
            readyButton.GetComponent <Button>().onClick.Add(OnReady);

            //添加玩家面板
            GameObject gamersPanel = rc.Get <GameObject>("Gamers");

            this.GamersPanel[0] = gamersPanel.Get <GameObject>("Left");
            this.GamersPanel[1] = gamersPanel.Get <GameObject>("Local");
            this.GamersPanel[2] = gamersPanel.Get <GameObject>("Right");

            //添加本地玩家
            Gamer gamer = ETModel.ComponentFactory.Create <Gamer, long>(GamerComponent.Instance.MyUser.UserID);

            AddGamer(gamer, 1);
            LocalGamer = gamer;
        }
        public GameObject CreateSprite(string name, string group, Vector2 position, Texture2D texture)
        {
            GameObject sprite = CreateObject(name, group, typeof(BasicSpriteComponent));

            sprite.Get <TransformComponent>().Position = position;
            sprite.Get <TextureComponent>().Texture    = texture;

            return(sprite);
        }
Exemplo n.º 14
0
        public void GetTest()
        {
            ubv.http.HTTPClient client = new GameObject().AddComponent <ubv.http.HTTPClient>();

            CreateMockHTTPServer();

            client.Get("products/1", (message) => { Assert.IsTrue(message.StatusCode.Equals(System.Net.HttpStatusCode.OK)); });
            client.Get("products/1", (message) => { Assert.IsTrue(message.StatusCode.Equals(System.Net.HttpStatusCode.NotFound)); });
        }
Exemplo n.º 15
0
        public void CreateParticles(GameObject obj)
        {
            var collision  = obj.Get <CollisionComponent>();
            var explodable = obj.Get <ExplodableComponent>();

            var spawnArea = collision.Box.ToRectangle();

            for (int i = 0; i < explodable.MaxParticles; i++)
            {
                AddParticle(explodable.ParticleFactory.CreateParticle(spawnArea, random));
            }
        }
Exemplo n.º 16
0
        public async void Awake()
        {
            ReferenceCollector rc = this.GetParent <UI>().GameObject.GetComponent <ReferenceCollector>();

            GameObject quitButton  = rc.Get <GameObject>("Quit");
            GameObject readyButton = rc.Get <GameObject>("Ready");

            mJewelQuantityText = rc.Get <GameObject>("JewelQuantityText").GetComponent <Text>();
            mBeansQuantityText = rc.Get <GameObject>("BeansQuantityText").GetComponent <Text>();
            mNameText          = rc.Get <GameObject>("NameText").GetComponent <Text>();
            mIdText            = rc.Get <GameObject>("IdText").GetComponent <Text>();
            mBesansON          = rc.Get <GameObject>("BesansON");
            mBesansOFF         = rc.Get <GameObject>("BesansOFF");
            mJewelON           = rc.Get <GameObject>("JewelON");
            mJewelOFF          = rc.Get <GameObject>("JewelOFF");

            mJewelBtn  = rc.Get <GameObject>("JewelBtn");
            mBesansBtn = rc.Get <GameObject>("BesansBtn");
            mJewelBtn.GetComponent <Button>().onClick.Add(() => JewelShop());
            mBesansBtn.GetComponent <Button>().onClick.Add(() => BeansShop());


            rc.Get <GameObject>("BeansGetBtn").GetComponent <Button>().onClick.Add(() => BeansShop());
            rc.Get <GameObject>("JewelGetBtn").GetComponent <Button>().onClick.Add(() => JewelShop());
            rc.Get <GameObject>("ExitBtn").GetComponent <Button>().onClick.Add(() => ExitBtnOnClick());

            //添加商品版面
            BesansGroup           = rc.Get <GameObject>("BesansGroupGo");
            this.BesansGroupGo[0] = BesansGroup.Get <GameObject>("CommodityItemGo1");
            this.BesansGroupGo[1] = BesansGroup.Get <GameObject>("CommodityItemGo2");
            this.BesansGroupGo[2] = BesansGroup.Get <GameObject>("CommodityItemGo3");
            this.BesansGroupGo[3] = BesansGroup.Get <GameObject>("CommodityItemGo4");
            this.BesansGroupGo[4] = BesansGroup.Get <GameObject>("CommodityItemGo5");
            this.BesansGroupGo[5] = BesansGroup.Get <GameObject>("CommodityItemGo6");
            this.BesansGroupGo[6] = BesansGroup.Get <GameObject>("CommodityItemGo7");
            this.BesansGroupGo[7] = BesansGroup.Get <GameObject>("CommodityItemGo8");

            JewlGroup           = rc.Get <GameObject>("JewlGroupGo");
            this.JewlGroupGo[0] = JewlGroup.Get <GameObject>("CommodityItemGo1");
            this.JewlGroupGo[1] = JewlGroup.Get <GameObject>("CommodityItemGo2");
            this.JewlGroupGo[2] = JewlGroup.Get <GameObject>("CommodityItemGo3");
            this.JewlGroupGo[3] = JewlGroup.Get <GameObject>("CommodityItemGo4");
            this.JewlGroupGo[4] = JewlGroup.Get <GameObject>("CommodityItemGo5");
            this.JewlGroupGo[5] = JewlGroup.Get <GameObject>("CommodityItemGo6");
            this.JewlGroupGo[6] = JewlGroup.Get <GameObject>("CommodityItemGo7");
            this.JewlGroupGo[7] = JewlGroup.Get <GameObject>("CommodityItemGo8");

            //获取玩家数据
            A1001_GetUserInfo_C2G GetUserInfo_Req = new A1001_GetUserInfo_C2G();
            A1001_GetUserInfo_G2C GetUserInfo_Ack = (A1001_GetUserInfo_G2C)await SessionComponent.Instance.Session.Call(GetUserInfo_Req);

            //显示用户名和用户等级
            mJewelQuantityText.text = GetUserInfo_Ack.Jwel.ToString();
            mBeansQuantityText.text = GetUserInfo_Ack.Douzi.ToString();
            mNameText.text          = GetUserInfo_Ack.UserName;
            mIdText.text            = GetUserInfo_Ack.UserInfoId;
            Debug.Log("显示信息成功");
        }
Exemplo n.º 17
0
        public void LoadHotfixAssembly()
        {
            //         if (Game.Scene == null) return;
            //         if (Game.Scene.GetComponent<ResourcesComponent>() == null) return;
            //await Game.Scene.GetComponent<ResourcesComponent>().LoadBundleAsync($"code.unity3d");

            Game.Scene.GetComponent <ResourcesComponent>().LoadBundle($"code.unity3d");
            GameObject code = (GameObject)Game.Scene.GetComponent <ResourcesComponent>().GetAsset("code.unity3d", "Code");

            byte[] assBytes = code.Get <TextAsset>("Hotfix.dll").bytes;
            byte[] pdbBytes = code.Get <TextAsset>("Hotfix.pdb").bytes;

#if ILRuntime
            //            this.appDomain = new ILRuntime.Runtime.Enviorment.AppDomain();
            //#if ILRuntimeDebug
            //            this.appDomain.DebugService.StartDebugService(56000);
            //#endif
            //            GameObject code = (GameObject)Game.Scene.GetComponent<ResourcesComponent>().GetAsset("code.unity3d", "Code");
            //			byte[] assBytes = code.Get<TextAsset>("Hotfix.dll").bytes;
            //			byte[] mdbBytes = code.Get<TextAsset>("Hotfix.pdb").bytes;

            //			using (MemoryStream fs = new MemoryStream(assBytes))
            //			using (MemoryStream p = new MemoryStream(mdbBytes))
            //			{
            //				this.appDomain.LoadAssembly(fs, p, new Mono.Cecil.Pdb.PdbReaderProvider());
            //			}
            //            ILHelper.InitILRuntime(this.appDomain);
            //            this.start = new ILStaticMethod(this.appDomain, "ETHotfix.Init", "Start", 0);

            Log.Debug($"当前使用的是ILRuntime模式");
            this.appDomain = new ILRuntime.Runtime.Enviorment.AppDomain();

            this.dllStream = new MemoryStream(assBytes);
            this.pdbStream = new MemoryStream(pdbBytes);
            this.appDomain.LoadAssembly(this.dllStream, this.pdbStream, new Mono.Cecil.Pdb.PdbReaderProvider());

            this.start = new ILStaticMethod(this.appDomain, "ETHotfix.Init", "Start", 0);

            this.hotfixTypes = this.appDomain.LoadedTypes.Values.Select(x => x.ReflectionType).ToList();
#else
            this.assembly = Assembly.Load(assBytes, pdbBytes);

            Type hotfixInit = this.assembly.GetType("ETHotfix.Init");
            this.start       = new MonoStaticMethod(hotfixInit, "Start");
            this.hotfixTypes = this.assembly.GetTypes().ToList();
#endif
            Game.Scene.GetComponent <ResourcesComponent>().UnloadBundle($"code.unity3d");
        }
Exemplo n.º 18
0
    public static void SetInputValue(GameObject obj, string val)
    {
        if (obj != null)
        {
#if USE_UI_NGUI_2_7 || USE_UI_NGUI_3
            if (obj.Has <UIInput>())
            {
                SetInputValue(obj.Get <UIInput>(), val);
            }
#endif
            if (obj.Has <InputField>())
            {
                SetInputValue(obj.Get <InputField>(), val);
            }
        }
    }
Exemplo n.º 19
0
 public void PutFacedownOnTop(GameObject card)
 {
     card.Get <Card>().FaceUp = false;
     _cards.Insert(0, card);
     card.IsEnabled = false;
     UpdateSprite();
 }
Exemplo n.º 20
0
    public void ShowOverview()
    {
        HideStates();

        containerOverview.Show();

        ShowCamera();

        ShowLoaderSpinner();

        UpdateOverviewWorld();

        if (containerLoader.Has <GameObjectImageFill>())
        {
            GameObjectImageFill fill = containerLoader.Get <GameObjectImageFill>();
            fill.Reset();
        }

        // Update team display

        //LogUtil.Log("ShowOverview:");

        flowState = AppOverviewFlowState.GeneralTips;

        UIPanelDialogBackground.ShowDefault();

        UIUtil.SetLabelValue(labelOverviewType, AppContentStates.Current.display_name);

        AnimateInBottom(containerOverview);

        UIColors.UpdateColors();

        InvokeRepeating("ShowOverviewTip", 0, 15);
    }
Exemplo n.º 21
0
    private void Start()
    {
        if (Sounds.Length > 0)
        {
            AudioSource.PlayClipAtPoint(Sounds[Random.Range(0, Sounds.Length)], transform.position,
                                        (float)GameProfiles.Current.GetAudioEffectsVolume());
        }
        if (Prefab)
        {
            for (int i = 0; i < Num; i++)
            {
                float      scaleHalf = Scale / 2;
                Vector3    pos       = new Vector3(Random.Range(-scaleHalf, scaleHalf), Random.Range(-scaleHalf, Scale), Random.Range(-scaleHalf, scaleHalf)) / scaleHalf;
                GameObject obj       = GameObjectHelper.CreateGameObject(Prefab, transform.position + pos, transform.rotation, true);
                GameObjectHelper.DestroyGameObject(obj, LifeTimeObject, true);

                float scale = Scale;
                if (RandomScale)
                {
                    scale = Random.Range(1, Scale);
                }

                if (scale > 0)
                {
                    obj.transform.localScale = new Vector3(scale, scale, scale);
                }
                if (obj.Has <Rigidbody>())
                {
                    Vector3 force = new Vector3(Random.Range(-Force.x, Force.x), Random.Range(-Force.y, Force.y), Random.Range(-Force.z, Force.z));
                    obj.Get <Rigidbody>().AddForce(force);
                }
            }
        }
    }
Exemplo n.º 22
0
 public void GetObjs()
 {
     for (int i = 0; i < numberToCreateOnPress; i++)
     {
         _createdObjs.Add(poolablePrefab.Get());
     }
 }
Exemplo n.º 23
0
        /// <summary>
        /// 玩家出牌
        /// </summary>
        /// <param name="mahjong"></param>
        /// <param name="messageIndex"></param>
        /// <param name="messageWeight"></param>
        public async void PlayCard(MahjongInfo mahjong, int index, GameObject currentItem)
        {
            try
            {
                for (int i = 0; i < handCards.Count; i++)
                {
                    if (handCards[i].weight == mahjong.weight)
                    {
                        GameObject gameObject = this.GetSprite(i);
                        GameObject.Destroy(gameObject);
                        handCards.RemoveAt(i);
                        playCards.Add(mahjong);
                        ItemCards.RemoveAt(i);
                        break;
                    }
                }

                UpdateCards();

                //显示出牌
                GameObject obj  = (GameObject)this.resourcesComponent.GetAsset("Item_Vertical_Card.unity3d", "Item_Vertical_Card");
                GameObject obj2 = (GameObject)this.resourcesComponent.GetAsset("Image_Top_Card.unity3d", "Image_Top_Card");
                this.currentPlayCardObj = GameObject.Instantiate(obj, this.cardDisplay.transform);

                currentPlayCardObj.GetComponent <Image>().sprite = obj2.Get <Sprite>("card_" + mahjong.weight);
                currentPlayCardObj.layer = LayerMask.NameToLayer("UI");

                currentItem = currentPlayCardObj;

                ShowCard(mahjong.weight);

                //出了几张一样的牌
                int playCount = 0;
                foreach (var card in playCards)
                {
                    if (card.weight == mahjong.weight)
                    {
                        playCount++;
                    }
                }
                if (playCount == 3)
                {
                    UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
                    UIRoomComponent uiRoomComponent = uiRoom.GetComponent <UIRoomComponent>();
                    uiRoomComponent.tip.SetActive(true);
                    uiRoomComponent.tip.GetComponentInChildren <Image>().sprite = CommonUtil.getSpriteByBundle("Image_Desk_Card", "foursame_tip");
                    await ETModel.Game.Scene.GetComponent <TimerComponent>().WaitAsync(3000);

                    if (this.IsDisposed)
                    {
                        return;
                    }
                    uiRoomComponent?.tip?.SetActive(false);
                }
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
Exemplo n.º 24
0
 static Akau()
 {
     UIRoot = GameObject.Find("AkaUI");
     Mask   = UIRoot.Get("Mask");
     SettingMask();
     Object.DontDestroyOnLoad(UIRoot);
 }
Exemplo n.º 25
0
        private void OnGameStateChange(State state)
        {
            switch (_runtimeData.GameState.State)
            {
            case State.Menu:
                _sceneData.UI.MenuScreen.PlayerNickname.SetText(_playerData.Nickname);
                break;

            case State.Loading:
                _sceneData.UI.GameScreen.PlayerNickname.SetText(_playerData.Nickname);
                var nicknameGenerator = new GameObject().AddComponent <NicknameGenerator>();
                nicknameGenerator.Get(nickname =>
                {
                    if (string.IsNullOrEmpty(nickname))
                    {
                        _runtimeData.GameState.State = State.InternetConnectionError;
                    }
                    else
                    {
                        _sceneData.UI.GameScreen.BotNickname.SetText(nickname);
                        _runtimeData.GameState.State = State.Game;
                    }
                });
                break;
            }
        }
Exemplo n.º 26
0
    public static void SetLabelColor(GameObject obj, Color colorTo)
    {
        if (obj != null)
        {
#if USE_UI_NGUI_2_7 || USE_UI_NGUI_3
            if (obj.Has <UILabel>())
            {
                SetLabelColor(obj.Get <UILabel>(), colorTo);
            }
#endif
            if (obj.Has <Text>())
            {
                SetLabelColor(obj.Get <Text>(), colorTo);
            }
        }
    }
Exemplo n.º 27
0
    public static void SetButtonColor(GameObject obj, Color colorTo)
    {
        if (obj != null)
        {
#if USE_UI_NGUI_2_7 || USE_UI_NGUI_3
            if (obj.Has <UIButton>())
            {
                SetButtonColor(obj.Get <UIButton>(), colorTo);
            }
#endif
            if (obj.Has <Button>())
            {
                SetButtonColor(obj.Get <Button>(), colorTo);
            }
        }
    }
Exemplo n.º 28
0
    public static void SetLabelValue(GameObject obj, string val)
    {
        if (obj != null)
        {
#if USE_UI_NGUI_2_7 || USE_UI_NGUI_3
            if (obj.Has <UILabel>())
            {
                SetLabelValue(obj.Get <UILabel>(), val);
            }
#endif
            if (obj.Has <Text>())
            {
                SetLabelValue(obj.Get <Text>(), val);
            }
        }
    }
Exemplo n.º 29
0
 private void AddSprite(GameObject bundle, string iconName)
 {
     icon = bundle.Get <Sprite>(iconName);
     //texture = bundle.Get<Texture2D>(iconName);
     //icon = CreateSprite(texture);
     AddSprite(iconName, icon);
 }
Exemplo n.º 30
0
        public static Bullet Create(Tank tank)
        {
            ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>();

            Game.Scene.GetComponent <ResourcesComponent>().LoadBundle($"Unit.unity3d");
            GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset("Unit.unity3d", "Unit");

            Game.Scene.GetComponent <ResourcesComponent>().UnloadBundle($"Unit.unity3d");
            GameObject prefab = bundleGameObject.Get <GameObject>("Bullet");

            BulletComponent bulletComponent = tank.GetComponent <BulletComponent>();


            Bullet bullet = ComponentFactory.CreateWithId <Bullet, Tank>(IdGenerater.GenerateId(), tank);



            bullet.GameObject = resourcesComponent.NewObj(PrefabType.Bullet, prefab);

            GameObject parent = tank.GameObject.FindChildObjectByPath("bullets");

            bullet.GameObject.transform.SetParent(parent.transform, false);

            bulletComponent.Add(bullet);

            BulletCollision bulletCollision = bullet.GameObject.AddComponent <BulletCollision>();

            // 子弹添加飞行
            bulletCollision.BulletFly = bullet.AddComponent <BulletFlyComponent>();


            return(bullet);
        }
        public void CreateParticles(GameObject obj)
        {
            var collision = obj.Get<CollisionComponent>();
            var explodable = obj.Get<ExplodableComponent>();

            var spawnArea = collision.Box.ToRectangle();

            for (int i = 0; i < explodable.MaxParticles; i++)
            {
                AddParticle(explodable.ParticleFactory.CreateParticle(spawnArea, random));
            }
        }
Exemplo n.º 32
0
 /// <summary>
 /// Resets the soldier
 /// </summary>
 /// <param name="soldier">Soldier to reset</param>
 private void ResetSoldier(GameObject soldier)
 {
     soldier.Get<HealthComponent>().Life = HealthComponent.MaxLife;
     soldier.Get<ShieldComponent>().Power = ShieldComponent.MaxPower;
     soldier.Remove<PoisonComponent>();
 }
        private bool ExplodesWith(GameObject object1, GameObject object2)
        {
            var explodable = object1.Get<ExplodableComponent>();

            if (explodable.explodesWith.Count == 0 || explodable.explodesWith.Contains(object2.GroupName))
                return true;

            return false;
        }
Exemplo n.º 34
0
        private bool GetsDestroyed(GameObject object1, GameObject object2)
        {
            var destroy = object1.Get<DestroyableComponent>();

            if (destroy.getsDestroyedBy.Count == 0 || destroy.getsDestroyedBy.Contains(object2.GroupName))
                return true;

            return false;
        }