Beispiel #1
0
    public Creature CreateNpc(int npcInfoId, Vector3 pos, Vector3 rot, Transform node, string name = "")
    {
        var npcInfo = ConfigManager.Get <NpcInfo>(npcInfoId);

        if (npcInfo == null)
        {
            return(null);
        }
        var i = ConfigManager.Get <CreatureInfo>(CREATURE_TEMPLATE).Clone <CreatureInfo>();

        i.models          = new string[] { npcInfo.mode };
        i.weaponID        = npcInfo.stateMachine;
        i.weaponItemID    = 0;
        i.offWeaponItemID = 0;
        i.gender          = 0;

        var npc = Creature.Create(i, pos, false, name, name);

        if (!npc)
        {
            return(null);
        }

        npc.transform.localEulerAngles = rot;

        var wt = npc.transform.Find("model/weapon");

        if (wt)
        {
            wt.gameObject.SetActive(false);
        }

        if (npcInfo.type == 1)
        {
            var _npc = moduleNpc.GetTargetNpc((NpcTypeID)npcInfoId);
            if (_npc != null)
            {
                CharacterEquip.ChangeNpcFashion(npc, _npc.mode);
                _npc.UpdateCurCreature(npc);
            }
        }
        Util.AddChild(node, npc.transform, true);

        DispatchEvent(EventLoadNpc, Event_.Pop(npc));

        return(npc);
    }
Beispiel #2
0
    private void LoadComplate(AsyncOperation async)
    {
        if (!async.isDone)
        {
            return;
        }

        GameObject prefab = m_Request.asset as GameObject;

        logo = Util.AddChild(LuaHelper.GetLayerManager().UIRoot, prefab);
        logo.transform.SetAsFirstSibling();
        m_Text            = Util.Find(logo.transform, "TipsText").GetComponent <Text>();
        m_Slider          = Util.Find(logo.transform, "Slider").GetComponent <Slider>();
        m_SliderText      = Util.Find(logo.transform, "Slider/Loadtext").GetComponent <Text>();
        m_Text.text       = "";
        m_SliderText.text = "";
    }
Beispiel #3
0
    public Creature CreatePlayer(PMatchProcessInfo pi, Vector3 pos, CreatureDirection direction, bool buff = false, bool skill = false)
    {
        var node = Level.current.startPos;

        var info     = modulePlayer.BuildPlayerInfo(pi, buff, skill);
        var creature = Creature.Create(info, pos, false, pi.roleId + ":" + pi.roleName);

        creature.roleId    = pi.roleId;
        creature.roleProto = pi.roleProto;
        creature.direction = direction;

        Util.AddChild(node, creature.transform, true);

        CharacterEquip.ChangeCloth(creature, pi.fashion);

        return(creature);
    }
Beispiel #4
0
 /// 创建go
 protected void CreateChildren()
 {
     if (mItemRenderer != null)
     {
         int count = CalculateChindrenCount();
         for (int i = 0; i < count; i++)
         {
             GameObject    go    = Util.AddChild(transform, mItemRenderer);
             RectTransform trans = go.GetComponent <RectTransform>();
             go.SetActive(i < mDataCount);
             mChildren.Add(trans);
             if (onCreate != null)
             {
                 onCreate.Invoke(go);
             }
         }
     }
 }
    /// <summary>
    /// Play UI effect on node
    /// </summary>
    /// <param name="node">parent node</param>
    /// <param name="effect">effect object</param>
    /// <returns></returns>
    public static void PlayEffect(RectTransform node, GameObject effect, float delay = 0, Action <GameObject> onPlay = null)
    {
        if (!node || !effect)
        {
            return;
        }

        if (delay > 0)
        {
            instance.StartCoroutine(_PlayEffect(node, effect, delay, onPlay));
        }
        else
        {
            effect.SetActive(true);
            Util.AddChild(node, effect.transform, false);

            onPlay?.Invoke(effect);
        }
    }
Beispiel #6
0
    void Kongxi()
    {
        GameObject obj = Util.AddChild(KongxiObj, transform);

        obj.SetActive(true);
        tw = obj.GetComponentInChildren <TweenPostionPlus>();
        if (Random.value <= 0.5f)
        {
            tw.from = left.transform.localPosition;
            tw.to   = Right.transform.localPosition;
        }
        else
        {
            tw.from = Right.transform.localPosition;
            tw.to   = left.transform.localPosition;
            obj.transform.localRotation = Quaternion.Euler(0, -180, 0);
        }
        tw.duration = moveTime;
        tw.enabled  = true;
    }
    private void UpdateEffectLayers()
    {
        if (!m_current)
        {
            return;
        }

        Util.AddChild(transform, m_current.transform);
        m_current.name = m_effectName;
        m_current.gameObject.SetActive(true);
        Util.SetEffectSortingLayer(m_current, m_sortingLayer, m_sortingOrder);

        if (!m_realtimeParticle && m_realtime)
        {
            m_realtimeParticle = this.GetComponentDefault <RealtimeParticle>();
        }
        if (m_realtimeParticle)
        {
            m_realtimeParticle.SetRealtime(m_realtime);
        }
    }
Beispiel #8
0
    protected virtual void CreatePlayerAudioListener()
    {
        if (!player)
        {
            return;
        }

        combatCamera._EnableDisableAudioListener(false);

        var pr = m_player.transform.Find("root");

        if (!pr)
        {
            pr = m_player.transform;
        }

        var listener = new GameObject("audioListener").GetComponentDefault <AudioListenerHelper>();

        listener.UpdateParams(new Vector3(0, (float)m_player.colliderSize * 2, 0), new Vector3((float)m_player.colliderSize * 2f, (float)m_player.colliderSize * 4, (float)m_player.colliderSize * 2));

        Util.AddChild(pr, listener.transform);
    }
Beispiel #9
0
 void Update()
 {
     if (queue.Count > 0)
     {
         time += Time.deltaTime;
         if (time >= Const.HurtNumEmitterTime)
         {
             time = 0;
             HurtNum    hurtNum = (HurtNum)queue.Dequeue();
             GameObject obj     = Util.AddChild(hurtLabelObj, mTrans.parent);
             obj.transform.position = mTrans.position;
             obj.SetActive(true);
             UILabel label = obj.GetComponent <UILabel>();
             label.text = hurtNum.txt;
             if (hurtNum.isHurt)
             {
                 label.color = hurtColor;
             }
             else
             {
                 label.color = cureColor;
             }
             if (hurtNum.isCrit)
             {
                 label.fontSize = critSize;
             }
             else
             {
                 label.fontSize = normalSize;
             }
         }
     }
     else if (bDestroy)
     {
         Destroy(gameObject);
     }
 }
Beispiel #10
0
    public Creature CreatePet(PetUpGradeInfo.UpGradeInfo rGradeInfo, Vector3 pos, Vector3 rot, Transform node, bool fighting, string name = "")
    {
        if (rGradeInfo == null)
        {
            return(null);
        }

        var i = ConfigManager.Get <CreatureInfo>(CREATURE_TEMPLATE).Clone <CreatureInfo>();

        i.models          = new string[] { fighting?rGradeInfo.fightMode : rGradeInfo.mode };
        i.weaponID        = fighting ? rGradeInfo.UIstateMachine : rGradeInfo.stateMachine;
        i.weaponItemID    = 0;
        i.offWeaponItemID = 0;
        i.gender          = 0;
        i.colliderSize    = Vector2_.zero;
        i.hitColliderSize = Vector2_.zero;

        var pet = Creature.Create(i, pos, rot, false, name, name, false, false);

        if (pet == null)
        {
            return(null);
        }

        var wt = pet.transform.Find("model/weapon");

        if (wt)
        {
            wt.gameObject.SetActive(false);
        }

        Util.AddChild(node, pet.transform, true);

        pet.gameObject.SetActive(ChildIsVisible(pet.name));

        return(pet);
    }
Beispiel #11
0
    public void CreatePanel(string name)
    {
        if (this.Parent.FindChild(name) != null)
        {
            return;
        }

        GameObject gameObject = Util.LoadPrefab(Const.PanelPrefabDir + name + ".prefab");

        if (gameObject == null)
        {
            return;
        }

        if (name == "MainPanel")
        {
            Util.SetBackground("MainUI/MainGround");
            GameObject go = GameObject.Instantiate(gameObject) as GameObject;
            go.transform.localPosition = new Vector3(0f, 0f, 0f);
            go.name = name;
            this.OnCreatePanel(name, go);
        }
        else
        {
            if (name != "WorldPanel" && name != "SummonPanel" && name != "SummonTipsPanel")
            {
                Util.SetBackground(null);
            }

            GameObject gameObject2 = Util.AddChild(gameObject, UIContainer.instance.transform);
            gameObject2.name = name;
            gameObject2.transform.localPosition = new Vector3(0f, 0f, -5f);

            this.OnCreatePanel(name, gameObject2);
        }
    }
Beispiel #12
0
    public static RectTransform AddUINode(this Transform root, string name, Vector2 anchorMin, Vector2 anchorMax, Vector2 pivot, Vector2 offsetMin, Vector2 offsetMax)
    {
        var rc = root as RectTransform;

        if (!rc)
        {
            Logger.LogWarning("Transform::AddUINode: root is {0}", root ? "not an UI element" : "null");
            return(null);
        }

        var node = new GameObject(name ?? "uiNode");

        var t = node.GetComponentDefault <RectTransform>();

        Util.AddChild(root, t);

        t.pivot     = pivot;
        t.anchorMin = anchorMin;
        t.anchorMax = anchorMax;
        t.offsetMin = offsetMin;
        t.offsetMax = offsetMax;

        return(t);
    }
Beispiel #13
0
    private void UpdateWeaponEffects(GameObject w, WeaponInfo.Weapon wi, WeaponInfo.SingleWeapon sw)
    {
        var effs = m_weaponEffects.GetDefault(w.GetInstanceID());
        var es   = Util.ParseString <string>(sw.effects);

        foreach (var e in es)
        {
            var eff = Level.GetPreloadObjectFromPool(e);
            if (!eff)
            {
                Logger.LogError("Could not load weapon effect [{0}] in weapon [{1}:{2}]", e, wi.weaponID, sw.index);
            }
            else
            {
                var i = eff.GetComponent <EffectInvertHelper>();
                if (!i)
                {
                    Logger.LogError("Invalid weapon effect [{0}] in weapon [{1}:{2}]", e, wi.weaponID, sw.index);
                    Level.BackEffect(eff);
                    continue;
                }

                eff.name = e;
                eff.SetActive(true);

                var ad = GetComponent <AutoDestroy>();
                if (ad)
                {
                    ad.enabled = false;
                }

                effs.Add(i);
                Util.AddChild(w.transform, eff.transform);
            }
        }
    }
Beispiel #14
0
    protected override void OnOpen()
    {
        #region Initialize

        m_behaviour.globalLock = false;

        m_isPvP   = Level.current && Level.current.isPvP;
        m_isTrain = !m_isPvP && Level.currentLevel == GeneralConfigInfo.sTrainLevel;
        m_isPvE   = !m_isPvP && !m_isTrain && Level.current && Level.current.isPvE;

        moduleGlobal.ShowGlobalLayer(false);

        Level.current.AddEventListener(LevelEvents.BATTLE_TIMER, OnBattleTimer);
        Level.current.AddEventListener(LevelEvents.PREPARE, OnBattlePrepare);
        Level.current.AddEventListener(LevelEvents.BATTLE_ENTER_WATCH_STATE, OnBattleEnterWatchState);

        EventManager.AddEventListener(CreatureEvents.PLAYER_ADD_TO_SCENE, OnPlayerAddToScene);

        if (m_isPvE)
        {
            EventManager.AddEventListener(Level_PVE.EventInitPVERightAvatar, InitPVERightAvatar);
        }

        #endregion

        #region Avatar

        m_avatarLeft  = GetComponent <AvatarCombat>("left");
        m_avatarRight = GetComponent <AvatarCombat>("right");

        #endregion

        #region Buttons & Infos

        m_btnShoot     = GetComponent <Button>("qiangji");
        m_btnBurst     = GetComponent <Button>("baoqi");
        m_btnBurstInfo = GetComponent <Text>("baoqi/Text");
        m_awakeRoot    = GetComponent <Transform>("awakeRoot")?.gameObject;
        m_btnAwake     = GetComponent <Button>("awakeRoot/awake");
        m_awakeBar     = GetComponent <Image>("awakeRoot/awake/progressbar");
        m_awakeCR      = GetComponent <CanvasRenderer>("awakeRoot/awake");
        m_awakeBarCR   = GetComponent <CanvasRenderer>("awakeRoot/awake/progressbar");

        m_awakeRoot?.SetActive(showAwakeButton);

        moduleBattle.SetKeyState("E", m_btnAwake.gameObject.activeSelf);

        m_effectNode = GetComponent <RectTransform>("effectNode");

        m_battleTimer     = GetComponent <Text>("jishi_pai/number");
        m_btnPause        = GetComponent <Button>("jishi_pai/pause");
        m_timeInfinityObj = transform.Find("jishi_pai/endless").gameObject;

        m_btnShoot.onClick.AddListener(OnBtnShoot);
        m_btnBurst.onClick.AddListener(OnBtnBurst);
        m_btnAwake.onClick.AddListener(OnBtnAwake);

        m_info          = GetComponent <Text>("info");
        m_infoTween     = GetComponent <TweenColor>("info");
        m_state499Info  = GetComponent <Text>("state499/Text");
        m_state499Bar   = GetComponent <Image>("state499/progressbar");
        m_state499Tween = GetComponent <TweenAlpha>("state499");

        m_state499CD = 0;
        m_state10CD  = 0;

        m_btnBurstInfo.enabled = false;

        m_state499Tween.gameObject.SetActive(false);

        m_btnPause.interactable = true;
        m_btnPause.onClick.AddListener(OnBtnPause);

        var now = Level.current is Level_Battle ? (Level.current as Level_Battle).battleTimeSec : CombatConfig.sdefaultTimeLimit / 1000;
        OnBattleTimer(Event_.Pop(now));

        #endregion

        #region Movement & Touch

        m_movementPad = GetComponent <UIMovementPad>("movementPad");
        m_touchGuard  = GetComponent <RectTransform>("touchGuard");
        m_moveCR      = m_movementPad.GetComponent <CanvasRenderer>();
        m_touchPad    = GetComponent <UITouchPad>("touchPad");
        m_btnLeft     = GetComponent <CanvasRenderer>("movementPad/left");
        m_btnRight    = GetComponent <CanvasRenderer>("movementPad/right");

        m_movementPad.onTouchBegin.AddListener(OnMovementPadBegin);
        m_movementPad.onTouchMove.AddListener(OnMovementPadMove);
        m_movementPad.onTouchEnd.AddListener(OnMovementPadEnd);
        m_touchPad.onTouchBegin.AddListener(OnTouchPadBegin);
        m_touchPad.onTouchEnd.AddListener(OnTouchPadEnd);
        m_touchPad.onTouchMove.AddListener(OnTouchPadMove);
        m_touchPad.onTouchStay.AddListener(OnTouchPadStay);

        m_movementPos = m_movementPad.rectTransform().anchoredPosition;
        m_guardSize   = m_touchGuard.sizeDelta;

        InitTouchAndMoveAlpha();
        UpdateInputSettings();

        EventManager.AddEventListener(Events.INPUT_SETTINGS_CHANGED, UpdateInputSettings);

        #endregion

        #region Combo

        m_comboObj = transform.Find("lianji").gameObject;
        m_comboNum = GetComponent <ComboNumber>("lianji/number");
        m_comboObj.SetActive(false);

        #endregion

        #region Camera Shot

        m_shotShowHide = 0;
        EventManager.AddEventListener(Events.CAMERA_SHOT_STATE, OnCameraShotState);
        EventManager.AddEventListener(Events.CAMERA_SHOT_UI_STATE, OnCameraShotUIState);

        #endregion

        #region Creatures

        ObjectManager.Foreach <Creature>(c =>
        {
            if (m_isPvP && c.teamIndex == 0 || !m_isPvP && c.isPlayer)
            {
                m_hero1 = c;
                return(!m_hero2);
            }

            if (!c.visible)
            {
                return(true);
            }

            if ((moduleMatch.isMatchRobot || moduleLabyrinth.lastSneakPlayer != null) && c.isRobot ||
                m_isPvP && c.teamIndex > 0 || !m_isPvP && c.creatureCamp == CreatureCamp.MonsterCamp && (!(c is MonsterCreature) || !(c as MonsterCreature).isDestructible))
            {
                m_hero2 = c;
                return(!m_hero1);
            }

            return(true);
        });

        InitCreature(0, m_hero1);
        InitCreature(1, m_hero2);

        UpdateBurstButtonState();
        UpdateShootButtonState();
        UpdateAwakeButtonState();

        #endregion

        #region Debug

        #if DEVELOPMENT_BUILD || UNITY_EDITOR
        var btnKillMe = Object.Instantiate(Resources.Load <GameObject>("ui_button")).rectTransform();
        btnKillMe.name = "btnKillMe";
        btnKillMe.GetComponent <Text>("label").text = "Kill Self";
        Util.AddChild(transform, btnKillMe.transform);

        btnKillMe.pivot            = btnKillMe.anchorMax = btnKillMe.anchorMin = new Vector2(1, 0.5f);
        btnKillMe.sizeDelta        = new Vector2(90, 50);
        btnKillMe.anchoredPosition = new Vector2(0, 55);

        if (Level.current is Level_Test || Level.current is Level_PVP)
        {
            btnKillMe.GetComponent <Button>().onClick.AddListener(() => { ObjectManager.enableUpdate = true; Game.GoHome(); });
        }
        else
        {
            btnKillMe.GetComponent <Button>().onClick.AddListener(() => { if (m_player)
                                                                          {
                                                                              m_player.Kill();
                                                                          }
                                                                  });
        }

        RectTransform btnVictory = null, randomInput = null;

        if (!(Level.current is Level_Test || Level.current is Level_PVP))
        {
            btnVictory      = Object.Instantiate(Resources.Load <GameObject>("ui_button")).rectTransform();
            btnVictory.name = "btnVictory";
            btnVictory.GetComponent <Text>("label").text = "Victory!";
            Util.AddChild(transform, btnVictory.transform);

            btnVictory.pivot            = btnVictory.anchorMax = btnVictory.anchorMin = new Vector2(1, 0.5f);
            btnVictory.sizeDelta        = new Vector2(90, 50);
            btnVictory.anchoredPosition = new Vector2(0, 0);

            btnVictory.GetComponent <Button>().onClick.AddListener(() =>
            {
                modulePVE.DebugPveGameData();
                modulePVE.SendPVEState(PVEOverState.Success, m_player);
                modulePVEEvent.ClearAll();
            });

            randomInput      = Object.Instantiate(Resources.Load <GameObject>("ui_button")).rectTransform();
            randomInput.name = "randomInput";
            randomInput.GetComponent <Text>("label").text = InputManager.instance.randomKey ? "cancel random" : "random Input";
            Util.AddChild(transform, randomInput.transform);

            randomInput.pivot            = randomInput.anchorMax = randomInput.anchorMin = new Vector2(1, 0.5f);
            randomInput.sizeDelta        = new Vector2(90, 50);
            randomInput.anchoredPosition = new Vector2(0, 165);

            randomInput.GetComponent <Button>().onClick.AddListener(() =>
            {
                InputManager.instance.randomKey = !InputManager.instance.randomKey;
                randomInput.GetComponent <Text>("label").text = InputManager.instance.randomKey ? "cancel random" : "random Input";
            });
        }

        btnKillMe.SafeSetActive(!Root.simulateReleaseMode);
        randomInput.SafeSetActive(!Root.simulateReleaseMode);
        btnVictory.SafeSetActive(!Root.simulateReleaseMode);

        EventManager.AddEventListener("EditorSimulateReleaseMode", () =>
        {
            btnKillMe.SafeSetActive(!Root.simulateReleaseMode);
            randomInput.SafeSetActive(!Root.simulateReleaseMode);
            btnVictory.SafeSetActive(!Root.simulateReleaseMode);
        });

        #if UNITY_EDITOR
        EventManager.AddEventListener("EditorReloadConfig", OnEditorReloadConfig);
        #endif
        #endif

        #endregion
    }
Beispiel #15
0
    private void CreateGM()
    {
#if DEVELOPMENT_BUILD || UNITY_EDITOR
        var t = transform.Find(StoryConst.THEATRE_GM_ASSET_NAME);
        if (t)
        {
            m_theatreGmPanel = t.gameObject;
        }
        else
        {
            m_theatreGmPanel = Level.GetPreloadObject <GameObject>(StoryConst.THEATRE_GM_ASSET_NAME, true);
            Util.AddChild(transform, m_theatreGmPanel.transform);
            m_theatreGmPanel.rectTransform().anchoredPosition = new Vector2(0, 0);
        }

        m_gmTfGmPanel = m_theatreGmPanel.GetComponent <RectTransform>("panel");
        Button btnOpenGm     = m_theatreGmPanel.GetComponent <Button>("btnOpenGmPanel");
        Text   btnOpenGmText = m_theatreGmPanel.GetComponent <Text>("btnOpenGmPanel/Text");
        btnOpenGm.onClick.AddListener(() =>
        {
            m_gmTfGmPanel.SafeSetActive(!m_gmTfGmPanel.gameObject.activeSelf);
            if (m_gmTfGmPanel.gameObject.activeSelf)
            {
                btnOpenGmText.text = "隐藏Gm面板";
            }
            else
            {
                btnOpenGmText.text = "显示Gm面板";
            }
        });

        Button quitDatingScene = m_theatreGmPanel.GetComponent <Button>("panel/quitDatingScene");
        quitDatingScene.onClick.AddListener(() => Module_NPCDating.instance.GM_DatingCommand(DatingGmType.QuitScene));

        //踢出图书馆
        Button kickoutLib = m_theatreGmPanel.GetComponent <Button>("panel/btnLibWrongAnswer");
        kickoutLib.onClick.AddListener(() => Module_NPCDating.instance.GM_DatingCommand(DatingGmType.KickOutLib));

        //结束并退出当前约会场景
        Button overDatingScene = m_theatreGmPanel.GetComponent <Button>("panel/overDatingScene");
        overDatingScene.onClick.AddListener(() => Module_NPCDating.instance.GM_DatingCommand(DatingGmType.QuitScene));

        //执行约会事件
        m_tfGmInputPanel = m_theatreGmPanel.GetComponent <RectTransform>("panel/oneInputParamPanel");
        m_inputGmInput   = m_theatreGmPanel.GetComponent <InputField>("panel/oneInputParamPanel/input");
        m_gmTextInputTip = m_theatreGmPanel.GetComponent <Text>("panel/oneInputParamPanel/text/Text");
        Button btnForceQuitScene = m_theatreGmPanel.GetComponent <Button>("panel/quitDatingScene");
        btnForceQuitScene.onClick.AddListener(() => Module_NPCDating.instance.GM_DatingCommand(DatingGmType.ForceQuitScene));

        Button btnSure = m_theatreGmPanel.GetComponent <Button>("panel/oneInputParamPanel/sure");
        btnSure.onClick.AddListener(() =>
        {
            switch (m_inputType)
            {
            case GMTheaterInputType.SetDiviResult:
                int[] dResultId = GMGetInputText(m_inputGmInput);
                if (dResultId.Length > 0 && dResultId[0] > 0)
                {
                    Module_NPCDating.instance.GM_DatingCommand(DatingGmType.SetDivinationResult, dResultId[0]);
                }
                else
                {
                    Module_NPCDating.instance.GM_DatingCommand(DatingGmType.SetDivinationResult, -1);
                }
                m_gmTfGmPanel.SafeSetActive(false);
                break;

            case GMTheaterInputType.SetRandom:
                int[] dRandomId = GMGetInputText(m_inputGmInput);
                Module_NPCDating.instance.GM_DatingCommand(DatingGmType.SetRandomValue, m_gmRanGroupId, dRandomId[0]);
                m_gmTfGmPanel.SafeSetActive(false);
                break;

            default:
                break;
            }
            m_tfGmInputPanel.SafeSetActive(false);
        });
        Button btnUnSure = m_theatreGmPanel.GetComponent <Button>("panel/oneInputParamPanel/unSure");
        btnUnSure.onClick.AddListener(() =>
        {
            switch (m_inputType)
            {
            case GMTheaterInputType.SetDiviResult:
                Module_NPCDating.instance.GM_DatingCommand(DatingGmType.SetDivinationResult, -1);
                break;

            case GMTheaterInputType.SetRandom:
                Module_NPCDating.instance.GM_DatingCommand(DatingGmType.SetRandomValue, -1, -1);
                break;

            default:
                break;
            }
            m_gmTfGmPanel.SafeSetActive(false);
            m_tfGmInputPanel.SafeSetActive(false);
        });
        m_theatreGmPanel.SafeSetActive(!Root.simulateReleaseMode && (storyType == EnumStoryType.NpcTheatreStory || storyType == EnumStoryType.None));

        EventManager.AddEventListener("EditorSimulateReleaseMode", () => m_theatreGmPanel.SafeSetActive(!Root.simulateReleaseMode));
#endif
    }
Beispiel #16
0
    private void SetSingleComboSpell(Transform g, ComboInputInfo.SpellGroup gg)
    {
        Util.SetText(g.GetComponent <Text>("group"), 9207, 1, gg.group);

        var ss     = g.Find("spells");
        var spells = gg.spells;
        var hh     = 35;

        for (int i = 0, c = Mathf.Max(spells.Length, ss.childCount); i < c; ++i)
        {
            if (i >= spells.Length)
            {
                ss.GetChild(i).gameObject.SetActive(false);
                continue;
            }
            var s = i < ss.childCount ? ss.GetChild(i) : Object.Instantiate(ss.GetChild(0)).transform;
            s.name = i.ToString();
            s.gameObject.SetActive(true);
            Util.AddChild(ss, s);
            s.rectTransform().anchoredPosition = new Vector2(0, -i * 50);

            var spell = spells[i];
            Util.SetText(s.GetComponent <Text>("spellName"), 9207, 2, "<color=" + spell.textColor.ToXml() + ">" + spell.spellName + "</color>");
            var r = s.GetComponent <Text>("rage");
            r.gameObject.SetActive(spell.rage > 0);
            if (spell.rage > 0)
            {
                Util.SetText(r, 9207, 3, spell.rage);
            }
            s.GetComponent <Image>().color = spell.backColor;
            var icons = s.Find("icons");
            Util.ClearChildren(icons, true);

            if (m_comboIcons == null)
            {
                m_comboIcons = new Image[10];
                for (var j = 0; j < m_comboIcons.Length; ++j)
                {
                    m_comboIcons[j] = GetComponent <Image>("panel/3/des/i" + j);
                }
            }

            var sss = spell.inputs;
            for (int j = 0; j < sss.Length; ++j)
            {
                var iid  = sss[j];
                var icon = iid < 1 || iid >= m_comboIcons.Length ? null : m_comboIcons[iid];
                if (!icon)
                {
                    continue;
                }
                var io = Object.Instantiate(icon.gameObject);
                io.name = iid.ToString();
                io.gameObject.SetActive(true);
                Util.AddChild(icons, io.transform, false);
                io.transform.localEulerAngles = icon.transform.localEulerAngles;
            }
            hh += 50;
        }
        g.GetComponentDefault <LayoutElement>().minHeight = hh;
    }
Beispiel #17
0
    private bool UpdateWeaponModel(bool off)
    {
        var weaponID = off ? m_creature.offWeaponID : m_creature.weaponID;
        var itemId   = off ? m_creature.offWeaponItemID : m_creature.weaponItemID;

        var weapon = WeaponInfo.GetWeapon(weaponID, itemId);

        if (!off && weapon.isEmpty && weaponID < Creature.MAX_WEAPON_ID) // Only main weapon need error log
        {
            Logger.LogError("Could not find weapon config [{0}:{1}]", weaponID, itemId);
            return(false);
        }

        if (off)
        {
            m_offWeaponInfo = weapon;
        }
        else
        {
            m_weaponInfo = weapon;
        }

        var ws = off ? m_offWeapons : m_mainWeapons;

        foreach (var w in ws)
        {
            w.Value?.transform.SetParent(m_weapon, false);
            m_weapons.Remove(w.Value);
        }
        ws.Clear();

        Util.DisableAllChildren(m_weapon);

        var sws = weapon.singleWeapons;

        if (sws.Length < 1)
        {
            return(true);
        }

        var visible = !m_creature.currentState || !off || m_creature.currentState.showOffWeapon;

        foreach (var sw in sws)
        {
            if (string.IsNullOrEmpty(sw.model))
            {
                Logger.LogError("Invalid weapon config [weapon:{0}, itemID:{1}, index:{2}, name:{3}]", weapon.weaponID, weapon.weaponItemId, sw.index, weapon.name);
                continue;
            }

            var t = m_weapon.Find(sw.model);
            var w = t?.gameObject;

            if (!w)
            {
                w = Level.GetPreloadObject(sw.model);
                if (!w)
                {
                    Logger.LogError("Could not load weapon model [{0}]", sw.model);
                }
                else
                {
                    w.name = sw.model;
                    UpdateWeaponEffects(w, weapon, sw);
                }
            }

            if (w)
            {
                w.SetActive(visible);
                Util.AddChild(m_weapon, w.transform);

                ws.Set(sw.index, w);
                m_weapons.Add(w);
            }
        }

        if (off)
        {
            var sm = ConfigManager.Get <StateMachineInfoOff>(1);
            if (sm)
            {
                SetWeaponBind(sm.defaultWeaponBinds, true);
            }
        }
        else if (m_creature.currentState)
        {
            SetWeaponBind(m_creature.currentState.bindInfo);
        }

        Logger.LogInfo("{2}eapon changed to [{0}: {3}:{1}]", weapon.weaponID, weapon.weaponItemId, off ? "Off W" : "W", weapon.name);

        return(true);
    }
Beispiel #18
0
    public void ShowPage(BasePage page, AnimationType type = AnimationType.NULL)
    {
        Debug.Log("show page");

        //切换页面把当前的对话框关闭
        HideDialog();

        Tweener tweener = null;

        m_nextPage = page;
        Util.AddChild(page.gameObject, this.gameObject);
        //Plane panel = page.GetComponent<Plane>();
        //panel.clipOffset = new Vector2(0, 0);
        //panel.SetRect(0, 0, Screen.width, Screen.height);
        if (m_currentPage)
        {
            m_currentPage.PageWillDisappear();
            //Plane currntpanel = m_currentPage.GetComponent<Plane>();
            //currntpanel.clipOffset = new Vector2(0, 0);
        }
        page.PageWillAppear();
        switch (type)
        {
        case AnimationType.NULL:
            if (m_currentPage)
            {
                m_currentPage.transform.localPosition = new Vector3(0, -Screen.height, 0);
            }
            page.transform.localPosition = new Vector3(0, 0, 0);
            AnimationFinish();
            break;

        case AnimationType.LeftToRight:
            if (m_currentPage)
            {
                m_currentPage.transform.localPosition = new Vector3(0, 0, 0);
                m_currentPage.transform.DOLocalMoveX(Screen.width, AnimationDuration);
            }
            page.transform.localPosition = new Vector3(-Screen.width, 0, 0);
            tweener = page.transform.DOLocalMoveX(0, AnimationDuration);

            break;

        case AnimationType.RightToLeft:
            if (m_currentPage)
            {
                m_currentPage.transform.localPosition = new Vector3(0, 0, 0);
                m_currentPage.transform.DOLocalMoveX(-Screen.width, AnimationDuration);
            }
            page.transform.localPosition = new Vector3(Screen.width, 0, 0);
            tweener = page.transform.DOLocalMoveX(0, AnimationDuration);
            break;

        case AnimationType.TopToBottom:
            if (m_currentPage)
            {
                m_currentPage.transform.localPosition = new Vector3(0, 0, 0);
                m_currentPage.transform.DOLocalMoveY(Screen.height, AnimationDuration);
            }
            page.transform.localPosition = new Vector3(0, -Screen.height, 0);
            tweener = page.transform.DOLocalMoveY(0, AnimationDuration);
            break;

        case AnimationType.BottomToTop:
            if (m_currentPage)
            {
                m_currentPage.transform.localPosition = new Vector3(0, 0, 0);
                m_currentPage.transform.DOLocalMoveY(-Screen.height, AnimationDuration);
            }
            page.transform.localPosition = new Vector3(0, Screen.height, 0);
            tweener = page.transform.DOLocalMoveY(0, AnimationDuration);
            break;

        case AnimationType.MiddleZoomIn:
            if (m_currentPage)
            {
                m_currentPage.transform.localPosition = new Vector3(0, -Screen.height, 0);
            }
            page.transform.localPosition = new Vector3(0, 0, 0);
            page.transform.localScale    = new Vector3(AnimationScaleZoomIn, AnimationScaleZoomIn, 1);
            tweener = page.transform.DOScale(new Vector3(1, 1, 1), AnimationDuration);
            break;

        case AnimationType.MiddleZoomOut:
            if (m_currentPage)
            {
                m_currentPage.transform.localPosition = new Vector3(0, -Screen.height, 0);
            }
            page.transform.localPosition = new Vector3(0, 0, 0);
            page.transform.localScale    = new Vector3(AnimationScaleZoomOut, AnimationScaleZoomOut, 1);
            tweener = page.transform.DOScale(new Vector3(1, 1, 1), AnimationDuration);
            break;

        default:
            break;
        }
        if (tweener != null)
        {
            tweener.OnComplete(AnimationFinish);
        }
    }
Beispiel #19
0
    public Tweener ShowDialog(BasePage dialog, AnimationType type = AnimationType.NULL)
    {
        Tweener tweener = null;

        m_nextDialog = dialog;

        //屏蔽page点击事件
        dialog.gameObject.AddComponent <BoxCollider>();
        BoxCollider collider = dialog.gameObject.GetComponent <BoxCollider>();

        collider.size = new Vector3(Screen.width, Screen.height, 1);

        Util.AddChild(dialog.gameObject, this.gameObject);
        if (m_currentDialog)
        {
            m_currentDialog.PageWillDisappear();
            m_currentDialog.transform.localPosition = new Vector3(0, -Screen.height, 0);
            m_currentDialog.PageDidDisappear();
        }
        dialog.PageWillAppear();

        switch (type)
        {
        case AnimationType.NULL:
            dialog.transform.localPosition = new Vector3(0, 0, 0);
            DialogAnimationFinish();
            break;

        case AnimationType.LeftToRight:
            dialog.transform.localPosition = new Vector3(-Screen.width, 0, 0);
            tweener = dialog.transform.DOLocalMoveX(0, AnimationDuration);
            break;

        case AnimationType.RightToLeft:
            dialog.transform.localPosition = new Vector3(Screen.width, 0, 0);
            tweener = dialog.transform.DOLocalMoveX(0, AnimationDuration);
            break;

        case AnimationType.TopToBottom:
            dialog.transform.localPosition = new Vector3(0, -Screen.height, 0);
            tweener = dialog.transform.DOLocalMoveY(0, AnimationDuration);
            break;

        case AnimationType.BottomToTop:
            dialog.transform.localPosition = new Vector3(0, Screen.height, 0);
            tweener = dialog.transform.DOLocalMoveY(0, AnimationDuration);
            break;

        case AnimationType.MiddleZoomIn:
            dialog.transform.localPosition = new Vector3(0, 0, 0);
            dialog.transform.localScale    = new Vector3(AnimationScaleZoomIn, AnimationScaleZoomIn, 1);
            tweener = dialog.transform.DOScale(new Vector3(1, 1, 1), AnimationDuration);
            break;

        case AnimationType.MiddleZoomOut:
            dialog.transform.localPosition = new Vector3(0, 0, 0);
            dialog.transform.localScale    = new Vector3(AnimationScaleZoomOut, AnimationScaleZoomOut, 1);
            tweener = dialog.transform.DOScale(new Vector3(1, 1, 1), AnimationDuration);
            break;

        default:
            break;
        }

        if (tweener != null)
        {
            tweener.OnComplete(DialogAnimationFinish);
        }

        return(tweener);
    }