// Update is called once per frame
        void Update()
        {
            if (_beatingState != _beatingStatePrev)
            {
                UpdateBeatingState();
                _beatingStatePrev = _beatingState;
            }

            if (_sp != _spPrev)
            {
                _PipeWdStartCtrl._SP = _sp;
                _EnCtrl._sp          = _sp;
                _spPrev = _sp;
            }

            if (_modelAider == null)
            {
                Lyu.KeepOffset kepOffset
                            = _AnchorA.GetComponent <Lyu.KeepOffset> ();
                _modelAider = kepOffset._Anchor.GetComponentInParent <MiroModelV1> ();
            }
            if (_keepSPAsEN && _modelAider != null)
            {
                //_model.Get
                if (_modelAider.IsAttacking())
                {
                    _sp = 0;
                }
                else
                {
                    _sp = _modelAider._ENGenerator._EN;
                }
            }
        }
Example #2
0
        void ConfigAttack()
        {
            bool bCtrlling = CellObjCtrlUtils.IsControllingObj(_cellCtrl);

            if (!bCtrlling)
            {
                return;
            }
            MiroModelV1 modelMe = _cellCtrl._TgtObj.GetComponent <MiroModelV1> ();

            modelMe.ResetEmitterTrigger();
            // to avoid petrification 防止固化
            //modelMe._bTurnMainWeaponByEN = false;

            /*
             * int mhp = modelMe.GetMaxHP ();
             * bool bAlive = true;
             * if (mhp > 0) {
             *      int atkrCnt = modelMe.GetAttackersCount ();
             *      bAlive = (atkrCnt < mhp);
             * }*/

            bool bAlive = modelMe.IsAlive();

            bool bFwdEmpty        = CellObjCtrlUtils.IsNbEmpty(_cellCtrl, 0);
            bool bFwdEnemy        = CellObjCtrlUtils.IsNbEnemy(_cellCtrl, 0);
            bool bShouldAttacking = (bFwdEmpty || bFwdEnemy) && bAlive;

            if (bShouldAttacking)
            {
                //Debug.Log (_cellCtrl + " should attacking!");
            }
            bool bAttacking = modelMe.IsAttacking();

            if (bAttacking)
            {
                //Debug.Log (_cellCtrl + " is attacking!");
            }
            // main weapon
            bool StartAttacking = (bShouldAttacking && !bAttacking);
            bool StopAttacking  = (bAttacking && !bShouldAttacking);
            bool IsAttacking    = bAttacking && bShouldAttacking;
            int  atMain         = bShouldAttacking ? modelMe._ENGenerator._EN : 0;

            if (StartAttacking)
            {
                //Debug.Log ("StartAttacking at=" + atMain + " of " +  _cellCtrl._TgtObj);
                modelMe._WeaponSlots [0].ActivateImmediate();
                SetWeaponAT(modelMe, 0, atMain);
            }
            else
            if (StopAttacking)
            {
                //Debug.Log ("StopAttacking: at=" + atMain+ " of " +  _cellCtrl._TgtObj);
                SetWeaponAT(modelMe, 0, atMain);
                modelMe._WeaponSlots [0].Shrink();;
            }
            else
            if (IsAttacking)
            {
                //Debug.Log ("IsAttacking: at=" + atMain+ " of " +  _cellCtrl._TgtObj);
                SetWeaponAT(modelMe, 0, atMain);
            }
            else
            {
                //print ("Not Attack! " + " ShouldAtt" +  bShouldAttacking + " Atting" + bAttacking + " " + _cellCtrl._TgtObj);
                //print ("Dir:" + _cellCtrl._Dir);

                /*
                 * if (_cellCtrl._Dir == 5) {
                 * bFwdEmpty = CellObjCtrlUtils.IsNbEmpty (_cellCtrl,0);
                 * bFwdEnemy = CellObjCtrlUtils.IsNbEnemy (_cellCtrl,0);
                 * }*/}
            // sub weapons
            for (int dir = 1; dir < 6; dir++)
            {
                bool bAssistingAT = CellObjCtrlUtils.IsNbAssistingAT(_cellCtrl, dir);
                //bool bNbAlive = CellObjCtrlUtils.IsNb
                bAssistingAT = bAssistingAT && bAlive;
                MiroModelV1 nbModel = CellObjCtrlUtils.GetNbModel(_cellCtrl, dir);
                int         en      = 0;
                if (nbModel != null)
                {
                    en = nbModel._ENGenerator._EN;                     // Change to Support;
                }
                if (bAssistingAT)
                {
                    modelMe._WeaponSlots [dir].ActivateImmediate();
                    SetWeaponAT(modelMe, dir, en);
                }
                else
                {
                    modelMe._WeaponSlots [dir].Shrink();
                    SetWeaponAT(modelMe, dir, 0);
                }
            }
        }