예제 #1
0
        override protected void _Calculate()
        {
            bool bCtrlling = CellObjCtrlUtils.IsControllingObj(_cellCtrl);

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

            modelMe._bTurnMainWeaponByEN = false;

            bool bFwdEmpty   = CellObjCtrlUtils.IsNbEmpty(_cellCtrl, 0);
            bool bFwdEnemy   = CellObjCtrlUtils.IsNbEnemy(_cellCtrl, 0);
            bool bBackToBack = CellObjCtrlUtils.IsBackToBack(_cellCtrl);
            int  en          = bBackToBack ? 3 : 1;

            if (bFwdEmpty || bFwdEnemy)
            {
                SetEN(modelMe, en);
                return;
            }

            bool bFwdFriend = CellObjCtrlUtils.IsNbSameCamp(_cellCtrl, 0);

            if (bFwdFriend)
            {
                CellObjCtrl fwdCtrl          = CellObjCtrlUtils.GetNbCellObjCtrl(_cellCtrl, 0);
                bool        bFriendFaceEnemy = CellObjCtrlUtils.IsNbEnemy(fwdCtrl, 0);
                bool        bFriendFaceEmpty = CellObjCtrlUtils.IsNbEmpty(fwdCtrl, 0);
                bool        bFriendAttack    = (bFriendFaceEnemy || bFriendFaceEmpty);
                if (bFriendAttack)
                {
                    SetEN(modelMe, en);
                }
                else
                {
                    SetEN(modelMe, 0);
                }
            }
        }
예제 #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);
                }
            }
        }