12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- using System.Collections.Generic;
- using UnityEngine;
- using Random = System.Random;
- namespace Game
- {
- public class AttackRandomUtil
- {
- private static readonly Dictionary<int, int[]> CockAttackDict = new Dictionary<int, int[]>()
- {
- { 1, new int[] { 1, 2, 3, -1 } },
- { 2, new int[] { 2, 3, 4, -1 } },
- { 3, new int[] { 3, 4, 5, -1 } },
- { 4, new int[] { 1, 2, 4, -1 } },
- { 5, new int[] { 1, 2, 5, -1 } },
- { 6, new int[] { 2, 4, 5, -1 } },
- { 7, new int[] { 1, 3, 4, -1 } },
- };
- private static readonly Dictionary<int, float[]> CockJumpDict = new Dictionary<int, float[]>()
- {
- { 1, new float[] { 2.4f, 2f } }, // 高跳速度,低跳速度
- { 2, new float[] { 2.7f, 2.3f } },
- { 3, new float[] { 2.3f, 2.1f } },
- { 4, new float[] { 2.6f, 2.2f } },
- { 5, new float[] { 2.8f, 2.4f } },
- { 6, new float[] { 2.2f, 1.8f } },
- { 7, new float[] { 2.9f, 2.5f } },
- };
- public static int GetRandomNumberFromDict(int cockId)
- {
- if (CockAttackDict.ContainsKey(cockId))
- {
- var numbers = CockAttackDict[cockId];
- var random = new Random();
- var randomIndex = random.Next(0, numbers.Length);
- return numbers[randomIndex];
- }
- // 如果 key 不存在,可以返回一个默认值或抛出异常等处理方式
- return -1;
- }
- public static float GetHighJumpSpeed(int cockId)
- {
- if (CockAttackDict.ContainsKey(cockId))
- {
- var numbers = CockJumpDict[cockId];
- return numbers[0] * 1.5f;
- }
- // 如果 key 不存在,可以返回一个默认值或抛出异常等处理方式
- return 2.4f;
- }
-
- public static float GetLowJumpSpeed(int cockId)
- {
- if (CockAttackDict.ContainsKey(cockId))
- {
- var numbers = CockJumpDict[cockId];
- return numbers[1] * 1.5f;
- }
- // 如果 key 不存在,可以返回一个默认值或抛出异常等处理方式
- return 2f;
- }
- }
- }
|