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); }
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); } } }
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); }
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); }
/// <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); }
/// <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); }
public static Jyx2RoleSelector Create(IEnumerable <RoleInstance> roles, Func <RoleInstance, bool> mustRoles, Action <List <RoleInstance> > callback) { var prefab = Jyx2ResourceHelper.GetCachedPrefab("Assets/Prefabs/Jyx2RoleSelector.prefab"); var obj = Instantiate(prefab); var parent = GameObject.Find("MainUI").transform; obj.transform.SetParent(parent); var rt = obj.GetComponent <RectTransform>(); rt.localPosition = Vector3.zero; rt.localScale = Vector3.one; var panel = obj.GetComponent <Jyx2RoleSelector>(); panel.Show(roles, mustRoles, callback); return(panel); }
public override void ShowDamage() { //JYX2逻辑,不存在MISS if (_showDamage <= 0) { return; } if (StoryEngine.Instance == null) { return; } var hudRoot = StoryEngine.Instance.HUDRoot; string damageText = ""; if (_showDamage > 0) { damageText = $"-{Math.Max(_showDamage, 1)}"; } else { damageText = "MISS"; } HUDTextInfo info = new HUDTextInfo(transform, $"{damageText}") { Color = Color.white, //Size = Random.Range(1, 12), 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.TextPrefab = Jyx2ResourceHelper.GetCachedPrefab("Assets/Prefabs/Jyx2/AttackInfoText.prefab"); hudRoot.NewText(info); CheckDeath(); }