Ejemplo 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);
        }
Ejemplo n.º 2
0
        public static bool DetectRingFrom(CellObjCtrl cctrl, ref List <CellObjCtrl> ringObjs)
        {
            bool bRing     = false;
            bool bCtrlling = CellObjCtrlUtils.IsControllingObj(cctrl);

            if (!bCtrlling)
            {
                return(false);
            }
            ringObjs.Add(cctrl);

            CellObjCtrl ctrlNxt = CellObjCtrlUtils.GetFwdCellObjCtrl(cctrl);

            ringObjs.Add(ctrlNxt);

            int  count   = 0;
            bool bReturn = false;



            while (CellObjCtrlUtils.IsControllingSameCampS(cctrl, ctrlNxt))
            {
                ctrlNxt = CellObjCtrlUtils.GetFwdCellObjCtrl(ctrlNxt);
                if (ctrlNxt == cctrl)
                {
                    bReturn = true;
                    break;
                }

                if (ringObjs.Contains(ctrlNxt))
                {
                    int id = ringObjs.IndexOf(ctrlNxt);
                    ringObjs.RemoveRange(0, id + 1);
                    ringObjs.Add(ctrlNxt);
                    bReturn = true;
                    break;
                }

                ringObjs.Add(ctrlNxt);
                count++;

                if (count > 100)
                {
                    break;
                }
            }

            if (bReturn && ringObjs.Count >= 3)
            {
                bRing = true;
            }

            return(bRing);
        }
Ejemplo n.º 3
0
        void ControlHighlightAnim()
        {
            bool bEnabled     = _DragRoter.enabled;
            bool bControlling = CellObjCtrlUtils.IsControllingObj(_CCtrl);
            bool bON          = bEnabled && bControlling;

            //print (gameObject.name + " bON:" + bON);

            if (bON)
            {
                _HighlightAnim.gameObject.SetActive(true);
            }
            else if (!bON)
            {
                _HighlightAnim.gameObject.SetActive(false);
            }
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
        override protected void _Calculate()
        {
            bool bCtrlling = CellObjCtrlUtils.IsControllingObj(_cellCtrl);

            if (!bCtrlling)
            {
                return;
            }
            HexCoord hc = _cellCtrl.GetComponent <HexCoord> ();

            MiroV1ModelSetting mSetThis =
                _cellCtrl._TgtObj.GetComponent <MiroV1ModelSetting> ();
            MiroModelV1 model = mSetThis.GetComponent <MiroModelV1> ();

            OperateFwdAnteller(hc, mSetThis, model);
            OperateBwdAnteller(hc, mSetThis, model);

            MiroV1PlacementMgr.ConfigAbsorbingSrcForTF(_cellCtrl.transform);
        }
Ejemplo n.º 6
0
        private bool GetCellObjCtrlPair(out CellObjCtrl ctrlA, out CellObjCtrl ctrlB)
        {
            ctrlA = null;
            ctrlB = null;
            int cellCnt =
                _gridCtrl._Cells.Count;

            int rId = (int)Random.Range(0, (float)cellCnt - 1.0f);

            GameObject gb = _gridCtrl._Cells [rId];

            ctrlA = gb.GetComponent <CellObjCtrl> ();
            bool bPlacableA = !ctrlA.IsBlocked();
            bool bOccupiedA = CellObjCtrlUtils.IsControllingObj(ctrlA) && bPlacableA;

            if (bOccupiedA)
            {
                return(false);
            }

            HexCoord hc = gb.GetComponent <HexCoord> ();

            if (hc._hex.q == 0 && hc._hex.r == 0 && hc._hex.s == 0)
            {
                return(false);
            }

            Hex hA = hc._hex;
            Hex h0 = new Hex(0, 0, 0);
            Hex hB = Hex.Subtract(h0, hA);

            ctrlB = _gridCtrl.GetCellCtrlAt(hB);
            bool bPlacableB = !ctrlB.IsBlocked();
            bool bOccupiedB = CellObjCtrlUtils.IsControllingObj(ctrlB) && bPlacableB;

            if (bOccupiedB)
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 7
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);
                }
            }
        }
Ejemplo n.º 8
0
        private bool GetRandomEmptyCellObjCtrl(
            List <CellObjCtrl> epCtrls, out CellObjCtrl ctrlA)
        {
            ctrlA = null;

            int cellCnt =
                epCtrls.Count;

            int rId = (int)Random.Range(0, (float)cellCnt - 1.0f);

            ctrlA = epCtrls [rId];
            bool bPlacableA = !ctrlA.IsBlocked();
            bool bOccupiedA = CellObjCtrlUtils.IsControllingObj(ctrlA) && bPlacableA;

            if (bOccupiedA)
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 9
0
        public void TrySpawnAt(Transform cellTf)
        {
            CellObjCtrl ctrl         = cellTf.GetComponent <CellObjCtrl> ();
            bool        bControlling = CellObjCtrlUtils.IsControllingObj(ctrl);

            if (bControlling)
            {
                return;
            }

            if (_cctrl == null)
            {
                _cctrl = ctrl;
                Sow();
            }
            else
            {
                if (_cctrl != ctrl)
                {
                    Move(ctrl);
                }
            }
        }
Ejemplo n.º 10
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);
                }
            }
        }
Ejemplo n.º 11
0
        void TryAid(CellObjCtrl ctrl)
        {
            bool bCtrlling = CellObjCtrlUtils.IsControllingObj(ctrl);

            if (!bCtrlling)
            {
                return;
            }
            //bool bFwdCtrlling = CellObjCtrlUtils.IsNbCellControllingObj (_cellCtrl, 0);
            bool        bShouldAid   = ShouldAid();
            MiroModelV1 model        = ctrl._TgtObj.GetComponent <MiroModelV1> ();
            bool        bHasPump     = model.HasPump();
            bool        bAiding      = model.IsAiding();
            CellObjCtrl fwdCtrl      = CellObjCtrlUtils.GetFwdCellObjCtrl(ctrl);
            bool        bAidingRight = false;

            if (fwdCtrl._TgtObj != null)
            {
                //bAidingRight = model.IsAiding (modelTgt);
                //MiroModelV1 modelTgt = fwdCtrl._TgtObj.GetComponent<MiroModelV1> ();
                if (model.HasPump() && model._Pump.IsGrown())
                {
                    int         AidingDir = model._Pump.GetAidingRDir();
                    CellObjCtrl nbCtrl    = CellObjCtrlUtils.GetNbCellObjCtrl(fwdCtrl, AidingDir);
                    if (nbCtrl == ctrl)
                    {
                        bAidingRight = true;
                    }
                }
            }
            if (bShouldAid)
            {
                bool bRight = _mgr.IsPumpingRight(ctrl);
                if (bRight)
                {
                    //Debug.Log ("Aid Right");
                }
                else
                if (!bHasPump)
                {
                    _mgr.CreatePumpForAB(ctrl.transform, fwdCtrl.transform);
                }
                else
                {
                    if (!bAidingRight)
                    {
                        _mgr.RetargetPumpsFor(ctrl.transform);
                        //Debug.Log ("_mgr.RetargetPumpsFor (_cellCtrl.transform);");
                    }
                    else
                    {
                        if (!bAiding)
                        {
                            //model._GrowPumpTrigger = true;
                            model.GrowUpPump();
                            //Debug.Log ("GrowUpPump: " + model);
                        }
                        else
                        {
                            model.ShrinkPump();
                            //model._ShrinkPumpTrigger = true;
                        }
                    }
                }
            }
            else
            {
                model.ShrinkPump();
                //model._ShrinkPumpTrigger = true;
                //print ("model._ShrinkPumpTrigger = true;");
                if (bAiding)
                {
                }
            }
        }