コード例 #1
0
    IEnumerator DoOpen()
    {
        //setup ops
        var ops = new MixedNumberOps();

        ops.operands = new MixedNumberOps.Operand[] { new MixedNumberOps.Operand(), new MixedNumberOps.Operand() };

        ops.operands[0].ApplyNumber(items[mItemInd].number);

        ops.operators = new OperatorType[] { OperatorType.Subtract };

        opsWidget.operation = ops;

        deckWidget.Clear();

        //open widgets
        opsWidget.Show();
        deckWidget.Show();

        while (deckWidget.isBusy)
        {
            yield return(null);
        }

        //setup deck
        PopulateDeck();

        StartCoroutine(DoHintNegativeWatch());
    }
コード例 #2
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;
    }
コード例 #3
0
    public MixedNumberOps Clone(int operandCount)
    {
        var ret = new MixedNumberOps();

        int _operandCount  = Mathf.Min(operandCount, operands.Length);
        int _operatorCount = _operandCount > 1 ? Mathf.Min(_operandCount - 1, operators.Length) : 0;

        ret.operands = new Operand[_operandCount];
        for (int i = 0; i < _operandCount; i++)
        {
            ret.operands[i] = operands[i].Clone();
        }

        ret.operators = new OperatorType[_operatorCount];
        System.Array.Copy(operators, ret.operators, _operatorCount);

        return(ret);
    }
コード例 #4
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;
    }