示例#1
0
    public void Init(CombatCharacterController attacker, CombatCharacterController defender)
    {
        //create empty subtract operation
        if (mOperations == null || mOperations.operands.Length != opCount)
        {
            mOperations = new MixedNumberOps();

            mOperations.operands = new MixedNumberOps.Operand[opCount];
            for (int i = 0; i < mOperations.operands.Length; i++)
            {
                mOperations.operands[i] = new MixedNumberOps.Operand();
            }

            mOperations.operators = new OperatorType[opCount - 1];
            for (int i = 0; i < mOperations.operators.Length; i++)
            {
                mOperations.operators[i] = OperatorType.Subtract;
            }
        }

        //fill first operand
        if (mOperations.operands.Length > 0)
        {
            var num = GetNumber();
            mOperations.operands[0].ApplyNumber(num);
        }

        //this will reset the operation
        opsWidget.gameObject.SetActive(false);
        opsWidget.operation = mOperations;

        if (timerWidget)
        {
            timerWidget.SetActive(false);
            timerWidget.delay = GameData.instance.defendDuration;
            timerWidget.ResetValue();
        }

        if (deckWidget)
        {
            deckWidget.gameObject.SetActive(false);
            deckWidget.Clear();
        }

        mAttacker = attacker;
        mDefender = defender;
    }
示例#2
0
    public void Init(CombatCharacterController attacker, CombatCharacterController defender)
    {
        if (mAttackNumbers == null || mAttackNumbers.Capacity != attackCount)
        {
            mAttackNumbers = new M8.CacheList <MixedNumber>(attackCount);
        }
        else
        {
            mAttackNumbers.Clear();
        }

        //create empty sum operation
        if (mOperations == null || mOperations.operands.Length != opCount)
        {
            mOperations = new MixedNumberOps();

            mOperations.operands = new MixedNumberOps.Operand[opCount];
            for (int i = 0; i < mOperations.operands.Length; i++)
            {
                mOperations.operands[i] = new MixedNumberOps.Operand();
            }

            mOperations.operators = new OperatorType[opCount - 1];
            for (int i = 0; i < mOperations.operators.Length; i++)
            {
                mOperations.operators[i] = OperatorType.Add;
            }
        }

        //apply fixed numbers
        if (fixedGroups.Length > 0)
        {
            var fixedNumbers = fixedGroups[mCurFixedNumbersIndex].GetNumbers();
            mCurFixedNumbersIndex++;
            if (mCurFixedNumbersIndex == fixedGroups.Length)
            {
                mCurFixedNumbersIndex = 0;
            }

            var count = Mathf.Min(fixedNumbers.Length, mOperations.operands.Length);
            for (int i = 0; i < count; i++)
            {
                mOperations.operands[i].ApplyNumber(fixedNumbers[i]);
            }
            for (int i = count; i < mOperations.operands.Length; i++)
            {
                mOperations.operands[i].RemoveNumber();
            }
        }
        //

        //this will reset the operation
        opsWidget.gameObject.SetActive(false);
        opsWidget.operation = mOperations;

        if (timerWidget)
        {
            timerWidget.SetActive(false);
            timerWidget.delay = GameData.instance.attackDuration;
            timerWidget.ResetValue();
        }

        if (counterWidget)
        {
            counterWidget.Init(attackCount);
        }

        if (deckWidget)
        {
            deckWidget.gameObject.SetActive(false);
            deckWidget.Clear();
        }

        mAttacker = attacker;
        mDefender = defender;
    }