Esempio n. 1
0
        private bool ShouldAid()
        {
            CellObjCtrl FwdCtrl =
                CellObjCtrlUtils.GetFwdCellObjCtrl(_cellCtrl);
            bool bFwdCtrlling = CellObjCtrlUtils.IsControllingObj(FwdCtrl);

            if (!bFwdCtrlling)
            {
                return(false);
            }

            MiroV1ModelSetting MyMSetting =
                _cellCtrl._TgtObj.GetComponent <MiroV1ModelSetting> ();
            MiroV1ModelSetting FwdMSetting =
                FwdCtrl._TgtObj.GetComponent <MiroV1ModelSetting> ();
            bool bFwdFriend = MyMSetting.IsSameCamp(FwdMSetting);

            MiroModelV1 modelMe = CellObjCtrlUtils.GetMiroModelFromCell(_cellCtrl);
            bool        bAlive  = modelMe.IsAlive();

            bool bAid = bFwdFriend && bAlive;

            if (bAid)
            {
                //print (_cellCtrl + " bAid?" + bAid + "    FwdObj:" + FwdCtrl._TgtObj);
            }

            return(bAid);
        }
Esempio n. 2
0
        public static bool IsNbAlive(CellObjCtrl cctrl, int relativeDir)
        {
            CellObjCtrl nbCtrl = CellObjCtrlUtils.GetNbCellObjCtrl(cctrl, relativeDir);

            if (nbCtrl == null)
            {
                return(false);
            }

            if (!CellObjCtrlUtils.IsControllingObj(nbCtrl))
            {
                return(false);
            }

            MiroModelV1 nbModel  = CellObjCtrlUtils.GetMiroModelFromCell(nbCtrl);
            bool        bNbAlive = nbModel.IsAlive();

            return(bNbAlive);
        }
Esempio n. 3
0
        public static bool IsNbAidingMe(CellObjCtrl cctrl, int relativeDir)
        {
            bool bSameCamp = IsNbSameCamp(cctrl, relativeDir);

            if (!bSameCamp)
            {
                return(false);
            }

            //MiroModelV1 modelMe = CellObjCtrlUtils.GetMiroModelFromCell (cctrl);

            CellObjCtrl nbCtrl =
                CellObjCtrlUtils.GetNbCellObjCtrl(cctrl, relativeDir);

            MiroModelV1 nbModel  = CellObjCtrlUtils.GetMiroModelFromCell(nbCtrl);
            bool        bNbAlive = nbModel.IsAlive();

            CellObjCtrl nbFwdCtrl = CellObjCtrlUtils.GetFwdCellObjCtrl(nbCtrl);

            bool bAiding = (nbFwdCtrl == cctrl) && bNbAlive;

            return(bAiding);
        }
Esempio n. 4
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);
                }
            }
        }
Esempio n. 5
0
        public static bool ShouldBeingAbsorbedToDir(CellObjCtrl cctrl, int relativeDir)
        {
            if (cctrl == null)
            {
                return(false);
            }

            bool bAttacking = CellObjCtrlUtils.ShouldAttacking(cctrl);
            bool bAssisting = CellObjCtrlUtils.ShouldAssistingAttacking(cctrl);

            if (!(bAttacking || bAssisting))
            {
                return(false);
            }


            CellObjCtrl nbCtrl = CellObjCtrlUtils.GetNbCellObjCtrl(cctrl, relativeDir);

            if (nbCtrl == null)
            {
                return(false);
            }

            bool bIsEnemy = CellObjCtrlUtils.IsNbEnemy(cctrl, relativeDir);

            if (!bIsEnemy)
            {
                return(false);
            }

            CellObjCtrl nbBwdCtrl = CellObjCtrlUtils.GetNbCellObjCtrl(nbCtrl, 3);

            if (nbBwdCtrl == null)
            {
                return(false);
            }

            bool bNbBackToMe = (nbBwdCtrl == cctrl);

            if (!bNbBackToMe)
            {
                return(false);
            }

            MiroModelV1 nbModel  = CellObjCtrlUtils.GetMiroModelFromCell(nbCtrl);
            bool        bNbAlive = nbModel.IsAlive();

            if (!bNbAlive)
            {
                return(false);
            }

            bool bNbFaceToFace = CellObjCtrlUtils.IsFaceToFace(nbCtrl);

            if (!bNbFaceToFace)
            {
                return(false);
            }

            CellObjCtrl nbFwdCtrl  = CellObjCtrlUtils.GetFwdCellObjCtrl(nbCtrl);
            MiroModelV1 nbFwdModel = CellObjCtrlUtils.GetMiroModelFromCell(nbFwdCtrl);

            if (!nbFwdModel.IsAlive())
            {
                return(false);
            }


            return(true);
        }