예제 #1
0
    public void ShowBattleText(string mainText, Color textColor)
    {
        if (StoryEngine.Instance == null)
        {
            return;
        }

        var         hudRoot = StoryEngine.Instance.HUDRoot;
        HUDTextInfo info    = new HUDTextInfo(transform, $"{mainText}")
        {
            Color = Color.white,
            Speed = Random.Range(0.2f, 1),
            VerticalAceleration    = Random.Range(-2, 2f),
            VerticalPositionOffset = Random.Range(0, 0.8f),
            VerticalFactorScale    = Random.Range(1.2f, 10),
            Side            = (Random.Range(0, 2) == 1) ? bl_Guidance.LeftDown : bl_Guidance.RightDown,
            ExtraDelayTime  = 0.2f,
            AnimationType   = bl_HUDText.TextAnimationType.HorizontalSmall,
            FadeSpeed       = 200,
            ExtraFloatSpeed = -11
        };

        info.Color = textColor;

        info.TextPrefab = Jyx2ResourceHelper.GetCachedPrefab("Assets/Prefabs/Jyx2/AttackInfoText.prefab");
        hudRoot.NewText(info);
    }
예제 #2
0
    void ChangeAnimationController(string path, Action callback)
    {
        if (string.IsNullOrEmpty(path))
        {
            return;
        }

        //当前已经是该Controller了,不需要再修改
        if (path.Equals(m_currentAnimatorController))
        {
            callback();
            return;
        }

        var anim = GetAnimator();

        if (anim == null)
        {
            return;
        }

        //否则载入该Controller
        Jyx2ResourceHelper.LoadAsset <RuntimeAnimatorController>(path, rst =>
        {
            if (rst == null)
            {
                return;
            }
            anim.runtimeAnimatorController = rst;
            m_currentAnimatorController    = path;
            callback();
        });
    }
예제 #3
0
    void ShowInfo(string msg, float duration)
    {
        var popinfoItem = Jyx2ResourceHelper.CreatePrefabInstance("Assets/Prefabs/Popinfo.prefab");

        popinfoItem.transform.SetParent(PopInfoParent_RectTransform, false);
        popinfoItem.GetComponentInChildren <Text>().text = msg;
        Text  mainText = popinfoItem.GetComponentInChildren <Text>();
        Image mainImg  = popinfoItem.GetComponent <Image>();

        mainText.color = Color.white;
        mainImg.color  = Color.white;

        if (duration > POPINFO_FADEOUT_TIME)
        {
            HSUtilsEx.CallWithDelay(this, () =>
            {
                mainText.DOFade(0, POPINFO_FADEOUT_TIME);
                mainImg.DOFade(0, POPINFO_FADEOUT_TIME);
            }, duration - POPINFO_FADEOUT_TIME);
        }

        HSUtilsEx.CallWithDelay(this, () => {
            Jyx2ResourceHelper.ReleasePrefabInstance(popinfoItem.gameObject);
        }, duration);
    }
예제 #4
0
        public void CreateBattleGround(int xCount, int yCount, float xPivot = 0.0f, float yPivot = 0.0f)
        {
            ClearBattleGround();

            gridsCountX = xCount;
            gridsCountY = yCount;
            gridsPivotX = xPivot;
            gridsPivotX = yPivot;
            float firstPivotX = gridsPivotX - xCount / 2 * cellWidth;
            float firstPivotY = gridsPivotY - yCount / 2 * cellHeight;
            var   prefab      = Jyx2ResourceHelper.GetCachedPrefab("Assets/Prefabs/NewBattleObject/BattleGridCeil.prefab");

            for (int i = 0; i < gridsCountX; i++)
            {
                for (int j = 0; j < gridsCountY; j++)
                {
                    BattleGridsCell cell = Instantiate(prefab).GetComponent <BattleGridsCell>();
                    cell.transform.SetParent(this.transform);
                    cell.bindGrids = this;
                    cell.CellInit(cellWidth, cellHeight, i, j, firstPivotX + i * cellWidth, firstPivotY + j * cellHeight);
                    cell.SetColor(Color.white);
                    m_cellList.Add(cell);
                }
            }
        }
예제 #5
0
    public static void Create(string level, Action callback)
    {
        var loadingPanel = Jyx2ResourceHelper.CreatePrefabInstance("Assets/Prefabs/LoadingPanelCanvas.prefab").GetComponent <LoadingPanel>();

        loadingPanel.LoadLevel(level, callback);
        GameObject.DontDestroyOnLoad(loadingPanel);
    }
예제 #6
0
    public void ShowUI(string uiName, params object[] allParams)
    {
        Jyx2_UIBase uibase;

        if (m_uiDic.ContainsKey(uiName))
        {
            uibase = m_uiDic[uiName];
            if (uibase.IsOnly)//如果这个层唯一存在 那么先关闭其他
            {
                PopAllUI(uibase.Layer);
            }
            PushUI(uibase);
            uibase.Show(allParams);
        }
        else
        {
            if (_loadingUIParams.ContainsKey(uiName)) //如果正在加载这个UI 那么覆盖参数
            {
                _loadingUIParams[uiName] = allParams;
                return;
            }

            _loadingUIParams[uiName] = allParams;
            string uiPath = string.Format(GameConst.UI_PREFAB_PATH, uiName);
            Jyx2ResourceHelper.SpawnPrefab(uiPath, OnUILoaded);
        }
    }
예제 #7
0
    //播放脚步声,TODO:根据所处地貌不同改为不同的脚步声
    void PlayFootStepSoundEffect(float dist)
    {
        //屏蔽远处敌人脚步声
        if (dist > 16)
        {
            return;
        }

        if (!_initWalkSoundEffect)
        {
            _initWalkSoundEffect = true;

            Jyx2ResourceHelper.LoadAsset <AudioClip>("Assets/BuildSource/SoundEffect/walk_on_grass.mp3", audio => {
                walkSoundEffect = audio;
            });
        }

        if (walkSoundEffect == null)
        {
            return;
        }

        if (_navMeshAgent.velocity.magnitude > 0.1f)
        {
            playSoundWaitFrame += Time.deltaTime;

            if (playSoundWaitFrame > m_FootStepTimespan) //每间隔一小段时间播放一次
            {
                playSoundWaitFrame = 0;
                AudioSource.PlayClipAtPoint(walkSoundEffect, transform.position, 0.3f);
            }
        }
    }
예제 #8
0
 public static void ColdBind()
 {
     CrossplatformSetupHelper.ColdBind();
     ConfigTable.InitSync();
     DebugInfoManager.Init();
     LuaManager.Init();
     loadFinishTask = Jyx2ResourceHelper.Init();
 }
예제 #9
0
    public static RoleUIItem Create()
    {
        var obj      = Jyx2ResourceHelper.CreatePrefabInstance(string.Format(GameConst.UI_PREFAB_PATH, "RoleItem"));
        var roleItem = obj.GetComponent <RoleUIItem>();

        roleItem.InitTrans();
        return(roleItem);
    }
예제 #10
0
    private void Awake()
    {
        //实例化LevelMaster
        MapRole player = Jyx2ResourceHelper.CreatePrefabInstance(ConStr.Player).GetComponent <MapRole>();

        player.name = "Player";
        player.transform.SetParent(transform, false);
        player.transform.localPosition = Vector3.zero;
    }
예제 #11
0
 public void StartStateMechine(Action <BattleResult> cb)
 {
     if (m_roleFocusRing == null)
     {
         m_roleFocusRing = Jyx2ResourceHelper.CreatePrefabInstance("Assets/Prefabs/CurrentBattleRoleTag.prefab");
     }
     m_callback = cb;
     SwitchState(BattleManager.BattleViewStates.WaitingForNextActiveBattleRole);//选择下一个 角色
 }
예제 #12
0
    public void ShowRole(RoleInstance role)
    {
        this.gameObject.SetActive(true);

        m_NameText.text   = role.Name;
        m_DetailText.text = string.Format("体力 {0}/100\n生命 {1}/{2}\n内力 {3}/{4}", role.Tili, role.Hp, role.MaxHp, role.Mp, role.MaxMp);

        Jyx2ResourceHelper.GetRoleHeadSprite(role, m_Head);
    }
예제 #13
0
    public void Show(int id, int count)
    {
        _id = id;
        var item = GetItem();

        m_NameText.text  = item.Name;
        m_CountText.text = (count > 1 ? count.ToString() : "");

        Jyx2ResourceHelper.GetItemSprite(id, m_Image);
    }
예제 #14
0
    public static Jyx2RoleHeadUI Create(RoleInstance role, bool forceChecked, Action clickCallback)
    {
        var prefab = Jyx2ResourceHelper.GetCachedPrefab("Assets/Prefabs/Jyx2RoleHeadUI.prefab");

        var obj    = Instantiate(prefab);
        var itemUI = obj.GetComponent <Jyx2RoleHeadUI>();

        itemUI.Show(role, forceChecked, clickCallback);
        return(itemUI);
    }
예제 #15
0
    public void Show(RoleInstance role, bool forceChecked, Action clickCallback)
    {
        ForceChecked   = forceChecked;
        _role          = role;
        _clickCallback = clickCallback;

        Jyx2ResourceHelper.GetRoleHeadSprite(role, headImage);

        IsChecked = forceChecked;
    }
예제 #16
0
 public void HitVoice(string musicName)
 {
     Jyx2ResourceHelper.LoadAsset <AudioClip>($"Assets/BuildSource/SoundEffect/{musicName}", soundEffect => {
         //声源位置与摄像机Y轴一致
         float x          = Camera.main.transform.position.x - (Camera.main.transform.position.x - transform.position.x) / 5;
         float y          = Camera.main.transform.position.y;
         float z          = Camera.main.transform.position.z - (Camera.main.transform.position.z - transform.position.z) / 5;
         Vector3 voicePos = new Vector3(x, y, z);
         AudioSource.PlayClipAtPoint(soundEffect, voicePos, 1f);
     });
 }
예제 #17
0
    public static Jyx2ItemUI Create(int id, int count)
    {
        var prefab = Jyx2ResourceHelper.GetCachedPrefab("Assets/Prefabs/Jyx2ItemUI.prefab");


        var obj    = Instantiate(prefab); //TODO对象池
        var itemUI = obj.GetComponent <Jyx2ItemUI>();

        itemUI.Show(id, count);
        return(itemUI);
    }
예제 #18
0
 private void ShowCharacter(string roleHeadPath)
 {
     if (string.IsNullOrEmpty((roleHeadPath)))
     {
         roleHeadImage.gameObject.SetActive(false);
     }
     else
     {
         roleHeadImage.gameObject.SetActive(true);
         Jyx2ResourceHelper.GetRoleHeadSprite(roleHeadPath, roleHeadImage);
     }
 }
예제 #19
0
    async private void Awake()
    {
        await BeforeSceneLoad.loadFinishTask;

        //实例化LevelMaster
        LevelMaster levelMaster = Jyx2ResourceHelper.CreatePrefabInstance(ConStr.LevelMaster).GetComponent <LevelMaster>();

        DontDestroyOnLoad(levelMaster);
        levelMaster.name = "LevelMaster";
        levelMaster.transform.SetParent(transform, false);
        levelMaster.RuntimeDataSimulate = m_RuntimeDataSimulate;
        levelMaster.MobileSimulate      = m_MobileSimulate;
    }
예제 #20
0
 public void Show(string msg, Action callback)
 {
     m_MessageText.text = msg;
     m_ConfirmButton.onClick.RemoveAllListeners();
     m_ConfirmButton.onClick.AddListener(() =>
     {
         Jyx2ResourceHelper.ReleasePrefabInstance(this.gameObject);
         if (callback != null)
         {
             callback();
         }
     });
 }
예제 #21
0
        static public void PlayWave(int waveIndex)
        {
            RunInMainThrad(() =>
            {
                string path = "Assets/BuildSource/sound/e" +
                              (waveIndex < 10 ? "0" + waveIndex.ToString() : waveIndex.ToString()) + ".wav";

                Jyx2ResourceHelper.LoadAsset <AudioClip>(path, clip =>
                {
                    AudioSource.PlayClipAtPoint(clip, Camera.main.transform.position);
                });
            });
        }
예제 #22
0
    void RefreshCurrent()
    {
        if (m_currentRole == null)
        {
            Debug.LogError("has not current role");
            return;
        }
        Jyx2ResourceHelper.GetRoleHeadSprite(m_currentRole, PreImage_Image);
        NameText_Text.text = m_currentRole.Name;

        InfoText_Text.text  = GetInfoText(m_currentRole);
        SkillText_Text.text = GetSkillText(m_currentRole);
        ItemsText_Text.text = GetItemsText(m_currentRole);
    }
예제 #23
0
        private void ExecuteSoundEffect()
        {
            var display = GetDisplay();

            Jyx2ResourceHelper.LoadAsset <AudioClip>(display.AudioEft, soundEffect =>
            {
                if (soundEffect == null)
                {
                    return;
                }

                AudioSource.PlayClipAtPoint(soundEffect, Camera.main.transform.position, 1);
            });
        }
예제 #24
0
    void ShowRole()
    {
        if (m_currentRole == null)
        {
            CurrentRole_RectTransform.gameObject.SetActive(false);
            AutoBattle_Toggle.gameObject.SetActive(false);
            return;
        }
        AutoBattle_Toggle.gameObject.SetActive(true);
        CurrentRole_RectTransform.gameObject.SetActive(true);
        NameText_Text.text   = m_currentRole.Name;
        DetailText_Text.text = string.Format("体力 {0}/100\n生命 {1}/{2}\n内力 {3}/{4}", m_currentRole.Tili, m_currentRole.Hp, m_currentRole.MaxHp, m_currentRole.Mp, m_currentRole.MaxMp);

        Jyx2ResourceHelper.GetRoleHeadSprite(m_currentRole, PreImage_Image);
    }
예제 #25
0
    public static void Create(RoleInstance role, List <RoleInstance> roles, Transform parent)
    {
        var obj = Jyx2ResourceHelper.CreatePrefabInstance("Assets/Prefabs/XiakePanel.prefab");

        obj.transform.SetParent(parent);

        var rt = obj.GetComponent <RectTransform>();

        rt.localPosition = Vector3.zero;
        rt.localScale    = Vector3.one;

        var xiakePanelUI = obj.GetComponent <XiakePanelUI>();

        xiakePanelUI.Show(role, roles);
    }
예제 #26
0
    /// <summary>
    /// 通过已有数据实例在地图中创建角色
    /// </summary>
    /// <param name="role"></param>
    public static MapRole CreateRoleView(this RoleInstance role, string tag = "NPC")
    {
        var roleViewPre = Jyx2ResourceHelper.GetCachedPrefab("Assets/Prefabs/MapRole.prefab");
        var roleView    = GameObject.Instantiate(roleViewPre).GetComponent <MapRole>();

        role.View             = roleView;
        roleView.DataInstance = role;
        roleView.m_RoleKey    = role.Key;
        roleView.name         = role.Key;
        roleView.tag          = tag;
        if (MapRuntimeData.Instance != null)
        {
            MapRuntimeData.Instance.AddMapRole(role);
        }
        return(roleView);
    }
예제 #27
0
    public void ShowRole(RoleInstance role, List <int> pros = null)
    {
        m_role = role;
        if (pros != null)
        {
            m_showPropertyIds = pros;
        }

        string nameText = role.Name + " Lv." + role.Level;

        m_roleName.text = nameText;

        ShowProperty();

        Jyx2ResourceHelper.GetRoleHeadSprite(role, m_roleHead);
    }
예제 #28
0
    /// <summary>
    /// 创建背包面板
    /// </summary>
    /// <param name="parent"></param>
    /// <param name="items"></param>
    /// <param name="selectCallback">如果取消,则返回-1</param>
    public static void Create(Transform parent, SaveableNumberDictionary <int> items, Action <int> selectCallback = null, Func <Jyx2Item, bool> filter = null)
    {
        var prefab = Jyx2ResourceHelper.GetCachedPrefab("Assets/Prefabs/BagPanel.prefab");
        var obj    = Instantiate(prefab);

        obj.transform.SetParent(parent);

        var rt = obj.GetComponent <RectTransform>();

        rt.localPosition = Vector3.zero;
        rt.localScale    = Vector3.one;

        var bagPanel = obj.GetComponent <BagPanel>();

        bagPanel.Show(items, selectCallback, filter);
    }
예제 #29
0
        private void DisplayCastEft()
        {
            var display = GetDisplay();

            //播放特效
            Jyx2ResourceHelper.LoadPrefab(display.CastEft, prefab => {
                var duration = HSUnityTools.ParticleSystemLength(prefab.transform);

                Vector3 offset = Vector3.zero;
                if (!string.IsNullOrEmpty(display.CastOffset))
                {
                    offset = UnityTools.StringToVector3(display.CastOffset, ',');
                }
                CastEffectAndWaitSkill(prefab, duration, Source.gameObject.transform, offset); //默认预留三秒
            });
        }
예제 #30
0
    public void Refresh(Jyx2ShopItem shopItem, int index, int hasBuyNum)
    {
        this.index    = index;
        this.shopItem = shopItem;
        Jyx2Item item = ConfigTable.Get <Jyx2Item>(shopItem.Id);

        if (item == null)
        {
            GameUtil.LogError("查询不到物品配置,id =" + shopItem.Id);
            return;
        }
        Jyx2ResourceHelper.GetItemSprite(int.Parse(item.Id), iconImg);
        desText.text = $"{item.Name}\n价格:{shopItem.Price}";
        leftNum      = shopItem.Count - hasBuyNum;
        leftNum      = Tools.Limit(leftNum, 0, shopItem.Count);
        itemNum.text = leftNum.ToString();
    }