Exemplo n.º 1
0
        public void Init(int id, uint excelId)
        {
            List <Dictionary <string, string> > dbs = DBManager.Instance.QuerySqliteRow <string>(GlobalConfig.DBFile, "data_collection", "id", excelId.ToString());

            if (dbs.Count > 0)
            {
                mDBConfig = dbs[0];
                // 帮派BOSS火把
                mGuildBossFireComponent = null;
                if (mDBConfig["class"] == "guild_boss_fire")
                {
                    mGuildBossFireComponent = gameObject.AddComponent <GuildBossFireComponent>();
                    mGuildBossFireComponent.Init((uint)id);
                }

                UpdateModel();

                var collectionObjectBehaviour = gameObject.AddComponent <CollectionObjectBehaviour>();
                collectionObjectBehaviour.Init((uint)id, excelId);

                // 头顶名字
                if (string.IsNullOrEmpty(mDBConfig["head_name"]) == false)
                {
                    UI3DText           textComponent = gameObject.AddComponent <UI3DText>();
                    UI3DText.StyleInfo styleInfo     = new UI3DText.StyleInfo();
                    styleInfo.Offset = DBTextResource.ParseVector3(mDBConfig["head_name_pos_offset"]);
                    textComponent.ResetStyleInfo(styleInfo);
                    textComponent.Text = mDBConfig["head_name"];
                }
            }

            ClientEventMgr.GetInstance().SubscribeClientEvent((int)ClientEvent.CE_SETTING_QUALITY_CHANGED, OnSettingQualityChanged);
        }
Exemplo n.º 2
0
        void DestroyDrop(ulong id)
        {
            var dropComponent = InstanceDropManager.Instance.GetDrop(id);

            if (dropComponent == null)
            {
                return;
            }

            dropComponent.Destroy();

            var dropGameObject = dropComponent.transform.parent.gameObject;

            if (dropGameObject == null)
            {
                return;
            }

            // 清除特效
            ModelHelper.ClearChildren(dropGameObject.transform.Find("EffectGameObject"));

            // 设置物品图标隐藏
            var nameSprite3D = dropComponent.gameObject.GetComponent <Sprite3DEx>();

            if (nameSprite3D != null)
            {
                nameSprite3D.BeforeRecycle();
            }

            // 清除头顶名字
            UI3DText nameText = dropComponent.gameObject.GetComponent <UI3DText>();

            if (nameText != null)
            {
                Object.DestroyImmediate(nameText);
            }

            // 清除UIDropAffiBar组件
            UIDropAffiBar bar = dropComponent.gameObject.GetComponent <UIDropAffiBar>();

            if (bar != null)
            {
                Object.DestroyImmediate(bar);
            }

            xc.ObjCachePoolMgr.Instance.RecyclePrefab(dropGameObject, xc.instance_behaviour.DropBehaviour.DropPrefabPoolType, xc.instance_behaviour.DropBehaviour.DropObjectPrefabPoolKey);

            CommonTool.SetActive(dropComponent.gameObject, true);
        }
Exemplo n.º 3
0
        public override void UnInitBehaviors()
        {
            mOwner.UnsubscribeActorEvent(Actor.ActorEvent.AFTER_CREATE, OnAfterCreate);
            mOwner.UnsubscribeActorEvent(Actor.ActorEvent.MODEL_CHANGE, OnModelChange);
            mOwner.UnsubscribeActorEvent(Actor.ActorEvent.RES_LOADED_CHANGE, OnModelChange);
            base.UnInitBehaviors();

            if (null != mNameComponent)
            {
                UnityEngine.GameObject.Destroy(mNameComponent);
                mNameComponent = null;
            }

            m_IsActived = false;
        }
Exemplo n.º 4
0
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="data"></param>
        public OrdinaryObjectObject(Neptune.OrdinaryObject data)
            : base(data)
        {
            mLoadPrefabCoroutine = LevelObjectHelper.SetObjectPrefab(gameObject, data.PrefabInfo);

            // 头顶名字
            if (string.IsNullOrEmpty(data.HeadName) == false)
            {
                UI3DText           textComponent = gameObject.AddComponent <UI3DText>();
                UI3DText.StyleInfo styleInfo     = new UI3DText.StyleInfo();
                styleInfo.Offset = data.HeadNamePosOffset;
                textComponent.ResetStyleInfo(styleInfo);
                var str = xc.TextHelper.GetTranslateText(data.HeadName);
                textComponent.Text = str;
            }
        }
Exemplo n.º 5
0
        public void Destroy()
        {
            if (m_IsDestory)
            {
                return;
            }

            if (null != mNameComponent)
            {
                UnityEngine.GameObject.Destroy(mNameComponent);
                mNameComponent = null;
            }

            m_IsDestory = true;
            ClientEventMgr.Instance.UnsubscribeClientEvent((int)ClientEvent.CE_FINISH_SWITCHSCENE, OnSceneLoaded);
            DestroyModle();
        }
Exemplo n.º 6
0
        /// <summary>
        /// 创建角色头顶的名字组件
        /// </summary>
        void Start(GameObject bind_object)
        {
            if (mNameComponent == null)
            {
                mNameComponent = bind_object.AddComponent <UI3DText>();
            }

            if (m_StyleInfo != null)
            {
                mNameComponent.ResetStyleInfo(m_StyleInfo);
            }

            if (mHeadTrans != null)
            {
                mNameComponent.SetHeadTrans(mHeadTrans);
            }

            mNameComponent.HeadOffset = m_HeadOffset;
            mNameComponent.Text       = mName;
            SetGuildName(mTextNameStruct.GuildNameText);
            SetHangUp(mTextNameStruct.HangUpText);
            SetHonor(mTextNameStruct.Honor);
            SetTitle(mTextNameStruct.Title);

            DBInstance.InstanceInfo instanceInfo = InstanceManager.Instance.InstanceInfo;
            if (instanceInfo != null)
            {
                if (DBInstanceTypeControl.Instance.HideHpBar(instanceInfo.mWarType, instanceInfo.mWarSubType))
                {
                    HideHpBar();
                }
                if (DBInstanceTypeControl.Instance.HideCamp(instanceInfo.mWarType, instanceInfo.mWarSubType))
                {
                    HideCamp();
                }
            }
        }
Exemplo n.º 7
0
        public void SetModel(GameObject model)
        {
            m_Model = model;

            Transform model_trans = model.transform;

            model_trans.parent        = m_ModelParent.transform;
            model_trans.localPosition = Vector3.zero;
            model_trans.localRotation = Quaternion.identity;
            model_trans.localScale    = Vector3.one;

            if (mNameComponent == null)
            {
                mNameComponent = m_Model.AddComponent <UI3DText>();
            }

            if (m_StyleInfo != null)
            {
                mNameComponent.ResetStyleInfo(m_StyleInfo);
            }

            Transform mHeadTrans = ModelHelper.FindChildInHierarchy(model_trans, Actor.SlotHeadName);

            mNameComponent.SetHeadTrans(mHeadTrans);

            SetNameLabel(m_name_label);

            //石化效果
            Renderer[] renderes = m_Model.GetComponentsInChildren <Renderer>();
            foreach (Renderer r in renderes)
            {
                if (r.sharedMaterial == null)
                {
                    continue;
                }

                string tag_name = r.gameObject.tag;// 只有标记tag的节点才替换材质
                if (tag_name.ToLower() != "matreplace")
                {
                    continue;
                }
                Material tmp_r = r.material;
                r.material             = MaterialEffectCtrl.MAT_TOMB_STONE; // 将原始材质修改为STONE的材质
                r.material.mainTexture = tmp_r.mainTexture;                 // texture赋值
                if (r.material.HasProperty("_Normal") && tmp_r.HasProperty("_Normal"))
                {
                    r.material.SetTexture("_Normal", tmp_r.GetTexture("_Normal"));// normalmap texture
                }
                r.material.SetFloat("_StoneProgress", 0);
            }

            List <GameObject> ef_link_array;

            ui.ugui.UIHelper.FindAllChildrenInHierarchy_out(m_ModelParent.transform, "EF_BOSS_LINK", out ef_link_array);
            for (int index = 0; index < ef_link_array.Count; ++index)
            {
                if (ef_link_array[index] != null)
                {
                    ef_link_array[index].gameObject.SetActive(false);
                }
            }

            //xc.ui.ugui.UIHelper.SetLayer(m_ModelParent.transform, LayerMask.NameToLayer("InterObject"));
            ResetLayer();
            IsVisible = m_isVisible;
        }
        void OnModelChange(CEventBaseArgs param)
        {
            WorshipModel owner = mOwner as WorshipModel;

            if (owner == null)
            {
                return;
            }

            // 头顶名字
            if (mTextComponent != null)
            {
                UnityEngine.Object.DestroyImmediate(mTextComponent);
            }
            mTextComponent = mOwner.GetModelParent().AddComponent <UI3DText>();
            UI3DText.StyleInfo styleInfo = new UI3DText.StyleInfo();
            float modelScale             = GameConstHelper.GetFloat("GAME_DUNGEON_WORSHIP_MODEL_SCALE");

            styleInfo.HeadOffset   = new Vector3(0f, mOwner.Height * modelScale, 0f);
            styleInfo.ScreenOffset = UI3DText.NameTextScreenOffset * modelScale;
            mTextComponent.SetHeadTrans(mOwner.GetModelParent().transform);
            mTextComponent.ResetStyleInfo(styleInfo);
            string text = "<color=#ffc319>" + owner.Rank.ToString();

            if (owner.Rank == 1)
            {
                text = text + DBConstText.GetText("ANSWER_WORSHIP_1"); // "st雕像";
            }
            else if (owner.Rank == 2)
            {
                text = text + DBConstText.GetText("ANSWER_WORSHIP_2");  //"nd雕像";
            }
            else if (owner.Rank == 3)
            {
                text = text + DBConstText.GetText("ANSWER_WORSHIP_3");  //"rd雕像";
            }
            else
            {
                text = text + DBConstText.GetText("ANSWER_WORSHIP_4");  //"th雕像";
            }
            text = text + "</color>";
            mTextComponent.RankTextLabel = text;
            mTextComponent.FontSize      = 22;
            if (string.IsNullOrEmpty(owner.GuildName) == false)
            {
                mTextComponent.GuildNameTextLabel = "<color=#4ef269><" + owner.GuildName + "></color>";
            }
            mTextComponent.Text = "<color=#5ec4ff>" + owner.UserName + "</color>";

            // 膜拜按钮
            if (mWorshipButtonComponent != null)
            {
                UnityEngine.Object.DestroyImmediate(mWorshipButtonComponent);
            }
            mWorshipButtonComponent = mOwner.GetModelParent().AddComponent <UI3DText>();
            styleInfo              = new UI3DText.StyleInfo();
            modelScale             = GameConstHelper.GetFloat("GAME_DUNGEON_WORSHIP_MODEL_SCALE");
            styleInfo.HeadOffset   = Vector3.zero;
            styleInfo.ScreenOffset = Vector3.zero;
            mWorshipButtonComponent.SetHeadTrans(ModelHelper.FindChildInHierarchy(mOwner.GetModelParent().transform, "root_node"));
            mWorshipButtonComponent.ResetStyleInfo(styleInfo);
            mWorshipButtonComponent.SetButtonStyle("MainWindow_New@Chatting@Praisebtn", DBConstText.GetText("WORSHIP"), 24, new Color(0.2f, 0.2f, 0.2f), new Vector3(0f, -9f, 0f));
            UnityEngine.UI.Image buttonImage = mWorshipButtonComponent.ButtonImage;
            if (buttonImage != null)
            {
                buttonImage.sprite = mWorshipButtonComponent.LoadSprite("MainWindow_New@Chatting@Hands");
                buttonImage.SetNativeSize();
                buttonImage.transform.localPosition = new Vector3(75, 40, 0);
                xc.ui.ugui.TweenPosition tween = xc.ui.ugui.TweenPosition.Begin(buttonImage.gameObject, 0.8f, new Vector3(100, 55, 0));
                tween.style = ui.ugui.UITweener.Style.PingPong;
                buttonImage.gameObject.SetActive(false);
            }
            mWorshipButtonComponent.SetClickCallback(() =>
            {
                mWorshipButtonComponent.ShowButton(false);
                if (buttonImage != null)
                {
                    buttonImage.gameObject.SetActive(false);
                }

                var data  = new C2SPlayerWorship();
                data.rank = owner.Rank;
                NetClient.GetBaseClient().SendData <C2SPlayerWorship>(NetMsg.MSG_PLAYER_WORSHIP, data);

                Actor localPlayer = Game.Instance.GetLocalPlayer();
                if (localPlayer != null)
                {
                    localPlayer.AttackCtrl.Attack(GameConstHelper.GetUint("GAME_DUNGEON_WORSHIP_SKILL_ID"));
                }
            });
            mWorshipButtonComponent.ShowButton(false);

            mTextComponent.Honor = mOwner.Honor;
            mTextComponent.Title = mOwner.Title;
        }
Exemplo n.º 9
0
        void HandleServerData(ushort pro, byte[] data)
        {
            switch (pro)
            {
            case NetMsg.MSG_MWAR_DEBUG_BULLET:     // 响应服务端的子弹位置调试的消息
            {
                if (TestUnit.DisplayDebugDraw == false)
                {
                    return;
                }
            }
            break;

            case NetMsg.MSG_MWAR_DEBUG_WORD:     // 绘制服务端发来的文字
            {
                if (TestUnit.DisplayDebugDraw == false)
                {
                    return;
                }

                S2CMwarDebugWord debugWord = S2CPackBase.DeserializePack <S2CMwarDebugWord>(data);

                Vector3    pos    = PhysicsHelp.GetPosition(debugWord.px / 100.0f, debugWord.py / 100.0f);
                Object     prefab = Resources.Load("core/prefabs/AttackSphere");
                GameObject testGo = GameObject.Instantiate(prefab, pos, Quaternion.identity) as GameObject;
                testGo.transform.localScale = Vector3.one * (1.0f) / 100.0f * 2;
                testGo.transform.parent     = MainGame.CoreObject.transform;

                Color col = GetColor(debugWord.color);
                testGo.GetComponent <Renderer>().material.SetColor("_Color", col);

                testGo.AddComponent <DelayDestroyComponent>().DelayTime = debugWord.time;

                UI3DText ui3dText = testGo.AddComponent <UI3DText>();
                ui3dText.Text      = System.Text.Encoding.UTF8.GetString(debugWord.word);
                ui3dText.TextColor = col;
                ui3dText.FontSize  = (int)debugWord.size;
                ui3dText.UpdatePosition(pos, Vector3.zero, Vector3.zero);
                //ui3dText.SetOwnerTrans(null);

                break;
            }

            case NetMsg.MSG_MWAR_DEBUG_POS:     // 绘制服务端发送过来的位置
            {
                if (TestUnit.DisplayDebugDraw == false)
                {
                    return;
                }

                var debugPos = S2CPackBase.DeserializePack <S2CMwarDebugPos>(data);

                Vector3    pos    = PhysicsHelp.GetPosition(debugPos.px / 100.0f, debugPos.py / 100.0f);
                Object     prefab = Resources.Load("core/prefabs/AttackSphere");
                GameObject testGo = GameObject.Instantiate(prefab, pos, Quaternion.identity) as GameObject;
                testGo.transform.localScale = Vector3.one * debugPos.radius / 100.0f * 2;
                testGo.transform.parent     = MainGame.CoreObject.transform;

                Color col = GetColor(debugPos.color);
                testGo.GetComponent <Renderer>().material.SetColor("_Color", col);

                testGo.AddComponent <DelayDestroyComponent>().DelayTime = 0.5f;
            }
            break;

            case NetMsg.MSG_MWAR_DEBUG_LINE:     // 绘制服务端发送过来的线段
            {
                if (TestUnit.DisplayDebugDraw == false)
                {
                    return;
                }

                S2CMwarDebugLine debugLine = S2CPackBase.DeserializePack <S2CMwarDebugLine>(data);

                float   height    = PhysicsHelp.GetHeight(debugLine.px1 / 100.0f, debugLine.py1 / 100.0f);
                Vector3 pos1      = new Vector3(debugLine.px1 / 100.0f, height, debugLine.py1 / 100.0f);
                Vector3 pos2      = new Vector3(debugLine.px2 / 100.0f, height, debugLine.py2 / 100.0f);
                Vector3 dir       = (pos2 - pos1);
                Vector3 dirNormal = dir.normalized;
                if (dirNormal == Vector3.zero)
                {
                    return;
                }

                Vector3 middlePos = (pos1 + pos2) / 2.0f;

                Object     prefab = Resources.Load("core/prefabs/AttackCube");
                GameObject testGo = GameObject.Instantiate(prefab, middlePos, Quaternion.identity) as GameObject;

                testGo.transform.localScale = new Vector3(debugLine.radius * 2.0f / 100.0f, debugLine.radius * 2.0f / 100.0f, (pos2 - pos1).magnitude);
                testGo.transform.rotation   = Quaternion.LookRotation(dirNormal, Vector3.up);
                testGo.transform.parent     = MainGame.CoreObject.transform;

                Color col = GetColor(debugLine.color);
                testGo.GetComponent <Renderer>().material.SetColor("_Color", col);

                testGo.AddComponent <DelayDestroyComponent>().DelayTime = debugLine.time;
            }
            break;

            case NetMsg.MSG_MWAR_DEBUG_CIRCLE:    // 绘制服务端发送过来的圆环
            {
                if (TestUnit.DisplayDebugDraw == false)
                {
                    return;
                }

                var     debugCircle = S2CPackBase.DeserializePack <S2CMwarDebugCircle>(data);
                float   height      = PhysicsHelp.GetHeight(debugCircle.px / 100.0f, debugCircle.py / 100.0f);
                Vector3 pos         = new Vector3(debugCircle.px / 100.0f, height, debugCircle.py / 100.0f);

                Object     prefab = Resources.Load("Core/Prefabs/AttackCircle");
                GameObject testGo = GameObject.Instantiate(prefab, pos, Quaternion.identity) as GameObject;

                testGo.transform.localScale = new Vector3(debugCircle.size / 100.0f, 1.0f, debugCircle.size / 100.0f);
                testGo.transform.rotation   = Quaternion.identity;
                testGo.transform.parent     = MainGame.CoreObject.transform;

                Color col = GetColor(debugCircle.color);
                testGo.GetComponentInChildren <Renderer>().material.SetColor("Tint Color", col);
                testGo.AddComponent <DelayDestroyComponent>().DelayTime = debugCircle.time * GlobalConst.MilliToSecond;
            } break;
            }
        }