Esempio n. 1
0
    public void TriggerFx(int tValue)          // seperate control for effects. positive tValue turns on, negative tValue turns off
    {
        bool tValueNegative = tValue < 0 ? true : false;

        tValue = Mathf.Abs(tValue);
        FxItem item = null;

        for (int i = 0; i < fxList.Length; i++)
        {
            item = fxList[i];
            bool result         = false;
            bool dontCheckBegin = false;        // checks for: will not run begin while already begun
            bool dontDoEnd      = false;        // checks for: will not run end while ended
            if (item.active == FxState.Trigger)
            {
                if (item.op != FxOp.Increases && item.op != FxOp.Decreases && item.op != FxOp.Changes)                     // increase, decrease, change: don't work with trigger
                {
                    result = Evaluate((float)tValue, item.op, item.percent);
                }
            }
            if (result == true)
            {
                // change if don't need to check, or check is ok to change
                if (tValueNegative == false)
                {
                    if (dontCheckBegin == true || fxList[i].beginFlag == false)
                    {
                        item.Begin();
                    }
                }
                else
                {
                    if (dontDoEnd == false && fxList[i].endFlag == false)
                    {
                        item.End();
                    }
                }
            }
        }
    }
Esempio n. 2
0
    public void CheckUnit()
    {
        if (gameObject.activeInHierarchy == false)
        {
            return;
        }
        if (statsScript && statsScript.initialized == false)
        {
            return;
        }
        if (statsScript)
        {
            oldShield = shield;
            oldArmor  = armor;
            oldHealth = health;
            oldEnergy = energy;
            oldStage  = stage;
            shield    = statsScript.shield / statsScript.shieldMax;
            armor     = statsScript.armor / statsScript.armorMax;
            health    = statsScript.health / statsScript.healthMax;
        }
        if (munitionScript)
        {
            stage = (float)munitionScript.stage;
        }
        oldMonitor = monitor;
        monitor    = GetMonitorValue();      // can be from a different script
        FxItem item = null;

        for (int i = 0; i < fxList.Length; i++)
        {
            item = fxList[i];
            if (item.active == FxState.Trigger)
            {
                continue;
            }                                   // skip trigger
            bool result         = false;
            bool dontCheckBegin = false;        // checks for: will not run begin while already begun
            bool dontDoEnd      = false;        // checks for: will not run end while ended
            if (item.active == FxState.Alive || item.active == FxState.Dying || item.active == FxState.Dead)
            {
                result = GetStateBool(item.active);
            }
            else if (item.op == FxOp.Increases || item.op == FxOp.Decreases || item.op == FxOp.Changes)
            {
                dontCheckBegin = true; dontDoEnd = true;
                if (fxList[i].alive == true && GetUnitActive() == false)
                {
                    result = false;
                }
                else
                {
                    result = GetStatChange(item.active, item.op);
                }
            }
            else                 // all stat vales, monitor, and stage
            {
                if (fxList[i].alive == true && GetUnitActive() == false)
                {
                    result = false;
                }
                else
                {
                    result = Evaluate(GetStatValue(item.active), item.op, item.percent);
                }
            }

            if (fxList[i].sendValue == true)
            {
                float sValue = 0f;
                if (item.active == FxState.Shield)
                {
                    sValue = shield;
                }
                else if (item.active == FxState.Armor)
                {
                    sValue = armor;
                }
                else if (item.active == FxState.Health)
                {
                    sValue = health;
                }
                else if (item.active == FxState.Energy)
                {
                    sValue = energy;
                }
                else if (item.active == FxState.Monitor)
                {
                    sValue = monitor;
                }
                fxList[i].Monitor(sValue);
            }

            if (result == true)
            {
                // change if don't need to check, or check is ok to change
                if (dontCheckBegin == true || fxList[i].beginFlag == false)
                {
                    item.Begin();
                }
            }
            else
            {
                // change if don't need to check, or check is ok to change
                if (dontDoEnd == false && fxList[i].endFlag == false)
                {
                    item.End();
                }
            }
        }
    }