Esempio n. 1
0
    void AppendChessToCell(IChessUnit chess, CellUnit cell)
    {
        var to = cell.Layout.Transform;

        chess.Layout.AppendTo(to);
        chess.Index = cell.Index;
    }
Esempio n. 2
0
 public void Attack(CellUnit target)
 {
     if (Attacks < 1 || Cell.Distance(target.currentCell.cubePoint, currentCell.cubePoint) > AttackRange)
     {
         return;
     }
     StartCoroutine(CO_Attack(target));
 }
Esempio n. 3
0
    public void RemoveUnitFromArmy(CellUnit unitToRemove)
    {
        army.Remove(unitToRemove);

        if (army.Count < 1)
        {
            onArmyLost?.Invoke();
        }
    }
Esempio n. 4
0
    public CellList()
    {
        mCells = new CellUnit[Options.CellCount];

        for (var i = 0; i < Options.CellCount; i++)
        {
            var cell = new CellUnit();
            mCells[i] = cell;
        }
    }
Esempio n. 5
0
    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);  // 遞迴下去
        }
    }
Esempio n. 6
0
    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);
    }
Esempio n. 7
0
 public override void SelectUnit(CellUnit unit)
 {
     if (unit.CompareTag(tag))
     {
         selectedUnit = unit;
     }
     else
     {
         selectedUnit.Attack(unit, out attackRoutine);
     }
 }
Esempio n. 8
0
 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));
     }
 }
Esempio n. 9
0
    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;
    }
Esempio n. 10
0
    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);
        }
    }
Esempio n. 11
0
    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);
    }
Esempio n. 12
0
 //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));
             }
         }
     }
 }
Esempio n. 13
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);
    }
Esempio n. 14
0
    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();
        }
    }
Esempio n. 15
0
    // 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();
            }
        };
    }
Esempio n. 16
0
 protected CellBase(CellUnit unit)
 {
     this.Unit = unit;
 }
Esempio n. 17
0
 public abstract void SelectUnit(CellUnit unit);
Esempio n. 18
0
 protected CellBase(CellUnit unit)
 {
     this.Unit = unit;
 }
Esempio n. 19
0
 public void AppendToArmy(CellUnit cellUnit)
 {
     army.Add(cellUnit);
 }
Esempio n. 20
0
 void LinkCell(CellUnit cell, LinkDirection direction, int x, int y)
 {
     cell.Neighbors[direction] = GetCellByPos(x, y);
 }
Esempio n. 21
0
 private void ClearHealthBar(CellUnit unit)
 {
     Destroy(unitHealthMap[unit].gameObject);
     unitHealthMap.Remove(unit);
 }
Esempio n. 22
0
 public CellScalar(CellUnit unit)
     : base(unit)
 {
 }
Esempio n. 23
0
 private void InitializeUnit(CellUnit unit)
 {
     unit.onDeath.AddListener(RemoveUnitFromArmy);
     DiageticUi.Instance.AddUnitHPBar(unit);
 }