void AppendChessToCell(IChessUnit chess, CellUnit cell) { var to = cell.Layout.Transform; chess.Layout.AppendTo(to); chess.Index = cell.Index; }
public void Attack(CellUnit target) { if (Attacks < 1 || Cell.Distance(target.currentCell.cubePoint, currentCell.cubePoint) > AttackRange) { return; } StartCoroutine(CO_Attack(target)); }
public void RemoveUnitFromArmy(CellUnit unitToRemove) { army.Remove(unitToRemove); if (army.Count < 1) { onArmyLost?.Invoke(); } }
public CellList() { mCells = new CellUnit[Options.CellCount]; for (var i = 0; i < Options.CellCount; i++) { var cell = new CellUnit(); mCells[i] = cell; } }
void ShowJumpableCell(CellUnit cell, LinkDirection direction) { var jumpableCell = GetJumpableCell(cell, direction); if (jumpableCell != null) { jumpableCell.Args = direction; // 將來源cell & 方向存進 cell 中 ShowHintAt(jumpableCell, HintType.Confirm); // 傳入來源格 ShowJumpableCell(jumpableCell, direction); // 遞迴下去 } }
public void AddUnitHPBar(CellUnit cellUnit) { var newhealthbarInstance = Instantiate(healthBarPrefab, sliderParent); newhealthbarInstance.maxValue = cellUnit.MaxHealth; newhealthbarInstance.value = cellUnit.MaxHealth; unitHealthMap.Add(cellUnit, newhealthbarInstance); cellUnit.onHealthAltered.AddListener((unit) => unitHealthMap[unit].value = unit.CurrentHealth); cellUnit.onDeath.AddListener(ClearHealthBar); }
public override void SelectUnit(CellUnit unit) { if (unit.CompareTag(tag)) { selectedUnit = unit; } else { selectedUnit.Attack(unit, out attackRoutine); } }
public void Attack(CellUnit target, out Coroutine attackRoutine) { if (Attacks < 1 || Cell.Distance(target.currentCell.cubePoint, currentCell.cubePoint) > AttackRange) { attackRoutine = null; } else { attackRoutine = StartCoroutine(CO_Attack(target)); } }
void ShowHintAt(CellUnit cell, HintType type) { // add to functional set mFunctionalCells.Add(cell.Index); var hint = mHintPool.CreateOrGetHint(); hint.Layout.HintType = type; hint.Layout.AppendTo(cell.Layout.Transform); hint.Index = cell.Index; }
void KillBetween(CellUnit startCell, CellUnit endCell, LinkDirection direction) { var nextCell = startCell.Neighbors[direction]; KillChess(nextCell.Index); var nextNextCell = nextCell.Neighbors[direction]; if (nextNextCell != endCell) { KillBetween(nextNextCell, endCell, direction); } }
private IEnumerator CO_Attack(CellUnit target) { while (animator.IsInTransition(0)) { yield return(null); } animator.SetTrigger("Attack"); while (!animator.GetCurrentAnimatorStateInfo(0).IsName("Attack")) { yield return(null); } Attacks--; target.AlterHealth(-AttackDamage); }
//Initializes the level array private void InitializeArray() { for (int i = 0; i < level.GetLength(0); i++) { for (int j = 0; j < level.GetLength(1); j++) { if (i == 0 || i == level.GetLength(0) - 1 || j == 0 || j == level.GetLength(1) - 1) { level[i, j] = new CellUnit(new Vector3(i, j, 0f), false); } else { level[i, j] = new CellUnit(new Vector3(i, j, 0f), probability(62.0)); } } } }
CellUnit GetJumpableCell(CellUnit cell, LinkDirection direction) { // 第一步要有格子且有棋子 var cellStep1 = cell.Neighbors[direction]; if (cellStep1 != null && mChessPool.Get(cellStep1.Index) != null) { // 第二步要有格子但不能有棋子 var cellStep2 = cellStep1.Neighbors[direction]; if (cellStep2 != null && mChessPool.Get(cellStep2.Index) == null) { return(cellStep2); } } // 除此之外都NG return(null); }
public override void SelectUnit(CellUnit unit) { //selected ally unity if (unit.tag == tag) { (selectedUnit as CubeWarrior).UnHighlight(); selectedUnit = unit; (selectedUnit as CubeWarrior).Highlight(); FindAndShowActionableCells(); } else { selectedUnit.Attack(unit); FindAndShowActionableCells(); } }
// Start is called before the first frame update void Start() { if (attr == StatusAttribute.Default) { return; } cell = GetComponent <CellUnit>(); cell.OnChanged += item => { if (item == null) { return; } if (item.HaveAttribute(attr)) { cell.OnSuccess(); } else { cell.OnError(); } }; }
protected CellBase(CellUnit unit) { this.Unit = unit; }
public abstract void SelectUnit(CellUnit unit);
public void AppendToArmy(CellUnit cellUnit) { army.Add(cellUnit); }
void LinkCell(CellUnit cell, LinkDirection direction, int x, int y) { cell.Neighbors[direction] = GetCellByPos(x, y); }
private void ClearHealthBar(CellUnit unit) { Destroy(unitHealthMap[unit].gameObject); unitHealthMap.Remove(unit); }
public CellScalar(CellUnit unit) : base(unit) { }
private void InitializeUnit(CellUnit unit) { unit.onDeath.AddListener(RemoveUnitFromArmy); DiageticUi.Instance.AddUnitHPBar(unit); }