private CharacterBase GetCloseCharacter(CharacterBase ch, CharacterBase.Type chType) { float dis = Mathf.Infinity; CharacterBase closeCharacter = null; foreach (var character in characters) { if (character.CharacterType != chType) { continue; } if (character.IsDead) { continue; } var disPos = ch.transform.position - character.transform.position; if (Mathf.Abs(disPos.magnitude) < dis) { dis = Mathf.Abs(disPos.magnitude); closeCharacter = character; } } return(closeCharacter); }
public void SaveDeckCellInfos(CharacterBase.Type type) { List <DeckCell.DeckCellInfo> deckCellInfos = new List <DeckCell.DeckCellInfo>(); var deckCells = (type == CharacterBase.Type.GUARDIAN) ? heroDeckCells : enemyDeckCells; foreach (var heroDeck in deckCells) { if (heroDeck.CellCharacter != null) { deckCellInfos.Add(heroDeck.deckCellInfo); } } if (type == CharacterBase.Type.GUARDIAN) { GameManager.heroCharacters = deckCellInfos; } else { GameManager.enemyCharacters = deckCellInfos; } }