private string GetGridUnitBuffStr(GridUnitBuff buff, GridUnitBuffType convertInfoType) { if (buff == null) { return(string.Empty); } else if (buff.buffType != convertInfoType) { return(string.Empty); } else { switch (buff.buffType) { case GridUnitBuffType.Atk: return(string.Format("<color=#FF0000>(+{0})</color>", buff.addition)); case GridUnitBuffType.Def: return(string.Format("<color=#0000FF>(+{0})</color>", buff.addition)); default: return(string.Empty); } } }
public static GridUnitBuff CreateInstance(GridUnitBuffType gridBuffType, int addition) { GridUnitBuff buff = new GridUnitBuff(); buff.buffType = gridBuffType; buff.addition = addition; return(buff); }
private void GenerateBuff(int buffCount) { int randomCount = Mathf.Min(buffCount, normalGrids.Count); if (randomCount <= 0) { return; } List <GridUnit> tempGrids = new List <GridUnit>(normalGrids); for (int i = 0; i < randomCount; i++) { //随机一种类型 int randomType = Random.Range(1, (int)GridUnitBuffType.Range + 1); int randomIdx = Random.Range(0, tempGrids.Count); int randomAddition = 0; GridUnitBuffType gridUnitBuffType = (GridUnitBuffType)randomType; //不同类型不同随机范围 switch (gridUnitBuffType) { case GridUnitBuffType.None: case GridUnitBuffType.Atk: case GridUnitBuffType.Def: randomAddition = Random.Range(1, 5); break; case GridUnitBuffType.Range: randomAddition = Random.Range(1, 2); break; } GridUnitBuff randoBuff = GridUnitBuff.CreateInstance(gridUnitBuffType, randomAddition); if (randoBuff != null) { tempGrids[randomIdx].gridUnitBuff = randoBuff; tempGrids.RemoveAt(randomIdx); } } }