Example #1
0
        void CaculateAbsorbing(CellObjCtrl cctrl)
        {
            CellObjCtrl backCtrl = CellObjCtrlUtils.GetNbCellObjCtrl(cctrl, 3);
            CCAbsorb    ccab     = backCtrl.GetComponentInChildren <CCAbsorb> ();

            ccab.Invoke("ConfigAbsorbing", _AbsorbingComputeDelay);
        }
Example #2
0
		override protected void _Calculate()
		{
			CellObjCtrl ctrlBwd = 
				CellObjCtrlUtils.GetNbCellObjCtrl (_cellCtrl, 3);
			if (_cellCtrl._TgtObj == null) {
				return;
			}

			bool bBackToBack = CellObjCtrlUtils.IsBackToBack (_cellCtrl);

			MiroModelV1 modelMe = 
				_cellCtrl._TgtObj.GetComponent<MiroModelV1> ();
			bool bHasFarm = modelMe.HasFarm ();
			bool bToGrow = (!bHasFarm && bBackToBack);
			bool bToShrink = (bHasFarm && !bBackToBack);
			if (bToGrow) {
				MiroModelV1 modelBwd = 
					ctrlBwd._TgtObj.GetComponent<MiroModelV1> ();
				_mgr.CreateEN2FarmFor2 (
					modelMe,_cellCtrl.transform, 
					modelBwd,ctrlBwd.transform);
				RecordNewFarm (_cellCtrl, ctrlBwd);
				//Debug.Log ("GrowFarm2 at " + _cellCtrl);
			} else if (bToShrink) {
				ShrinkFarm2 (_cellCtrl);
				//Debug.Log ("ShrinkFarm2 at " + _cellCtrl);
			}

		}
Example #3
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);
        }
Example #4
0
        public static bool IsNbAttacking(CellObjCtrl cctrl, int relativeDir)
        {
            CellObjCtrl nbCtrl = CellObjCtrlUtils.GetNbCellObjCtrl(cctrl, relativeDir);

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

            bool bNbAtt = ShouldAttacking(nbCtrl);

            return(bNbAtt);
        }
Example #5
0
        public void MoveInDir(int dir)
        {
            /*
             * if (_TgtObj == null) {
             *      return;
             * }
             *
             * HexCoord hc = GetComponent<HexCoord> ();
             * Transform tf = hc._Neighbors[dir];
             * if (tf == null) {
             *      return;
             * }
             *
             * CellObjCtrl nxtCellObjCtrl =
             *      tf.gameObject.GetComponent<CellObjCtrl> ();
             * if (nxtCellObjCtrl._TgtObj != null ||
             *      nxtCellObjCtrl._bBlocked) {
             *      return;
             * }*/

            bool bCanMove = CanMove(_Dir);

            if (!bCanMove)
            {
                return;
            }

            CellObjCtrl nxtCellObjCtrl =
                CellObjCtrlUtils.GetNbCellObjCtrl(this, 0);

            LerpMoveTo lerpMoveTo = _TgtObj.GetComponent <LerpMoveTo> ();

            if (lerpMoveTo == null)
            {
                lerpMoveTo = _TgtObj.AddComponent <LerpMoveTo> ();
            }
            lerpMoveTo.enabled = true;

            Transform tf = nxtCellObjCtrl.transform;

            lerpMoveTo._TgtTF = tf;

            nxtCellObjCtrl.SetTargetObj(_TgtObj);
            _TgtObj = null;


            nxtCellObjCtrl.SetDir(_Dir);
            nxtCellObjCtrl.PointToCurrentDir();

            InvokeTgtObjChanged();
        }
Example #6
0
        static public T GetComponentInNbCtrl <T>(CellObjCtrl ctrl, int relativeDir)
        {
            CellObjCtrl nbCtrl = CellObjCtrlUtils.GetNbCellObjCtrl(ctrl, relativeDir);

            if (nbCtrl != null)
            {
                T comp =
                    nbCtrl.gameObject.GetComponentInChildren <T> ();
                return(comp);
            }
            else
            {
                return(ctrl.gameObject.GetComponent <T>());
            }
        }
Example #7
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);
        }
Example #8
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);
                }
            }
        }
Example #9
0
        void ConfigAbsorbForCtrl2(CellObjCtrl ctrl)
        {
            for (int dir = 0; dir < 6; dir++)
            {
                CellObjCtrl nbCtrl = CellObjCtrlUtils.GetNbCellObjCtrl(ctrl, dir);

                bool bShouldBeingAbsorbed =
                    CellObjCtrlUtils.ShouldBeingAbsorbedToDir(ctrl, dir);
                if (!bShouldBeingAbsorbed)
                {
                    continue;
                }

                MiroV1PlacementMgr.ConfigAbsorbingForTF(nbCtrl.transform);
                if (!_AbsorbingCtrls.Contains(nbCtrl))
                {
                    _AbsorbingCtrls.Add(nbCtrl);
                }
            }
        }
Example #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);
        }
Example #11
0
        void ConfigAbsorbing()
        {
            //bool bFaceEnemy = CellObjCtrlUtils.IsNbEnemy (_cellCtrl,0);
            bool bShouldAttack = CellObjCtrlUtils.ShouldAttacking(_cellCtrl);

            if (!bShouldAttack)
            {
                return;
            }

            for (int dir = 1; dir < 6; dir++)
            {
                bool bNbAidingMe = CellObjCtrlUtils.IsNbAidingMe(_cellCtrl, dir);
                if (!bNbAidingMe)
                {
                    continue;
                }
                CellObjCtrl nbCtrl = CellObjCtrlUtils.GetNbCellObjCtrl(_cellCtrl, dir);
                ConfigAbsorbForCtrl2(nbCtrl);
            }

            /*
             * bool bBackToBack = CellObjCtrlUtils.IsBackToBack (_cellCtrl);
             * if (bBackToBack) {
             *      CellObjCtrl nbCtrl = CellObjCtrlUtils.GetNbCellObjCtrl (_cellCtrl, 3);
             *      _ToAbsorbCtrl = nbCtrl;
             *      //ConfigAbsorbForCtrl (nbCtrl);
             *      MiroModelV1 model = CellObjCtrlUtils.GetMiroModelFromCell(nbCtrl);
             *      _AT = model.GetAT ();
             *      _ToAbsorb = true;
             *      //print ("AT:" + _AT);
             *      //print ("ConfigAbsorbForCtrl (nbCtrl):" + nbCtrl);
             *      print("_ToAbsorb:" + nbCtrl);
             * }*/

            ConfigAbsorbForCtrl2(_cellCtrl);
        }
Example #12
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);
        }
Example #13
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)
                {
                }
            }
        }