Exemple #1
0
        static public List <MiroModelV1> GetNbEnemiesPointToThis(CellObjCtrl ctrl)
        {
            List <MiroModelV1> enemies = new List <MiroModelV1> ();

            for (int dir = 0; dir < 6; dir++)
            {
                CellObjCtrl nbCtrl = CellObjCtrlUtils.GetNbCellObjCtrl(ctrl, dir);
                if (nbCtrl == null)
                {
                    continue;
                }

                CellObjCtrl nbCtrlFwdCtrl = CellObjCtrlUtils.GetFwdCellObjCtrl(nbCtrl);
                if (nbCtrlFwdCtrl != ctrl)
                {
                    continue;
                }

                MiroModelV1 nbModel = CellObjCtrlUtils.GetMiroModelFromCell(nbCtrl);
                bool        bEnemy  = IsNbEnemy(ctrl, dir);

                if (bEnemy)
                {
                    enemies.Add(nbModel);
                }
            }
            return(enemies);
        }
Exemple #2
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);
        }
Exemple #3
0
        public static bool DetectNPCCloseChainFrom(CellObjCtrl ctrl, ref List <CellObjCtrl> ringObjs, ref List <CellObjCtrl> _chainObjs)
        {
            bool bDetected         = false;
            List <CellObjCtrl> lst = new List <CellObjCtrl> ();

            lst.Add(ctrl);
            while (CellObjCtrlUtils.IsFwdSameCamp(ctrl))
            {
                ctrl = CellObjCtrlUtils.GetFwdCellObjCtrl(ctrl);
                if (lst.Contains(ctrl))
                {
                    int startId = lst.IndexOf(ctrl);
                    int cnt     = startId;
                    //Debug.Log ("remove cnt:" + cnt);
                    _chainObjs = lst;
                    lst.RemoveRange(0, cnt);
                    bDetected = true;
                    break;
                }
                lst.Add(ctrl);
            }
            ringObjs = lst;

            return(bDetected);
        }
Exemple #4
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);
        }
Exemple #5
0
        void TryToAid()
        {
            TryAid(_cellCtrl);


            bool bFaceToFace = CellObjCtrlUtils.IsFaceToFace(_cellCtrl);

            if (bFaceToFace)
            {
                CellObjCtrl fwdCtrl = CellObjCtrlUtils.GetFwdCellObjCtrl(_cellCtrl);
                TryAid(fwdCtrl);
            }
        }
Exemple #6
0
        // absorbing configuration
        void ConfigAbsorbing()
        {
            //int bwdDir = _cellCtrl.GetBwdDir ();
            MiroModelV1 modelMe  = CellObjCtrlUtils.GetMiroModelFromCell(_cellCtrl);
            CellObjCtrl fwdCtrl  = CellObjCtrlUtils.GetFwdCellObjCtrl(_cellCtrl);
            MiroModelV1 modelFwd = CellObjCtrlUtils.GetMiroModelFromCell(fwdCtrl);

            ConfigureHole2(modelMe, true);
            ConfigureHole2(modelFwd, true);

            MiroV1PlacementMgr.ConfigAbsorbingForTF(_cellCtrl.transform);
            MiroV1PlacementMgr.ConfigAbsorbingForTF(fwdCtrl.transform);
        }
Exemple #7
0
        public bool TryMoveAlongDirAt(Hex coord, int dir = -1)
        {
            CellObjCtrl cctrl = _GridCtrl.GetCellCtrlAt(coord);

            if (cctrl == null)
            {
                return(false);
            }
            if (cctrl.IsBlocked())
            {
                return(false);
            }
            if (cctrl._TgtObj == null)
            {
                return(false);
            }

            if (dir >= 0 && dir <= 5)
            {
                cctrl.TurnToDir(dir);
            }

            CellObjCtrl fwdCCtrl = CellObjCtrlUtils.GetFwdCellObjCtrl(cctrl);

            if (fwdCCtrl == null)
            {
                return(false);
            }
            if (fwdCCtrl.IsBlocked())
            {
                return(false);
            }
            if (fwdCCtrl._TgtObj != null)
            {
                return(false);
            }

            _MiroMgr.MoveFwdInTF(cctrl.transform);

            return(false);
        }
Exemple #8
0
        void ConfigHole()
        {
            bool bFaceToFace = CellObjCtrlUtils.IsFaceToFace(_cellCtrl);

            //int bwdDir = _cellCtrl.GetBwdDir ();
            MiroModelV1 modelMe        = CellObjCtrlUtils.GetMiroModelFromCell(_cellCtrl);
            CellObjCtrl fwdCtrl        = CellObjCtrlUtils.GetFwdCellObjCtrl(_cellCtrl);
            bool        bFaceToFaceFwd = CellObjCtrlUtils.IsFaceToFace(fwdCtrl);
            MiroModelV1 modelFwd       = CellObjCtrlUtils.GetMiroModelFromCell(fwdCtrl);

            if (modelMe != null)
            {
                ConfigureHole2(modelMe, bFaceToFace);
                //RecordNewFaceToFace (_cellCtrl,fwdCtrl);
                //_HoleON.Invoke ();
            }
            if (modelFwd != null)
            {
                ConfigureHole2(modelFwd, bFaceToFaceFwd);
                //RemoveFaceToFaceRecord (_cellCtrl);
                //_HoleOFF.

                /*
                 * if (modelFwd.name == "Red0" && !bFaceToFace) {
                 *      print ("!FaceToFace");
                 *      CellObjCtrlUtils.IsFaceToFace (_cellCtrl);
                 * }*/
            }

            if (bFaceToFace)
            {
                RecordNewFaceToFace(_cellCtrl, fwdCtrl);
                CaculateAbsorbing(_cellCtrl);
                CaculateAbsorbing(fwdCtrl);
            }
            else
            {
                RemoveFaceToFaceRecord(_cellCtrl);
            }
        }
Exemple #9
0
        void ConfigHole(CellObjCtrl cellCtrl)
        {
            bool bFaceToFace = CellObjCtrlUtils.IsFaceToFace(cellCtrl);

            MiroModelV1 modelMe  = CellObjCtrlUtils.GetMiroModelFromCell(cellCtrl);
            CellObjCtrl fwdCtrl  = CellObjCtrlUtils.GetFwdCellObjCtrl(cellCtrl);
            MiroModelV1 modelFwd = CellObjCtrlUtils.GetMiroModelFromCell(fwdCtrl);

            if (modelMe != null)
            {
                ConfigureHole2(modelMe, bFaceToFace);
            }
            if (modelFwd != null)
            {
                ConfigureHole2(modelFwd, bFaceToFace);
            }

            if (!bFaceToFace)
            {
                bFaceToFace = CellObjCtrlUtils.IsFaceToFace(cellCtrl);
            }
        }
Exemple #10
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);
        }
Exemple #11
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);
        }
Exemple #12
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)
                {
                }
            }
        }