Esempio n. 1
0
        static private void SClearRing(List <Transform> RingObjsTFs)
        {
            List <MiroModelV1> ringObjMiros = new List <MiroModelV1> ();

            foreach (Transform tf in RingObjsTFs)
            {
                MiroModelV1 miro = tf.GetComponent <MiroModelV1> ();
                if (miro != null)
                {
                    ringObjMiros.Add(miro);
                }
            }

            for (int i = _Rings.Count - 1; i >= 0; i--)
            {
                var rc = _Rings [i];
                List <MiroModelV1> miros = new List <MiroModelV1> ();
                foreach (CellObjCtrl ctrl in rc)
                {
                    MiroModelV1 miro = CellObjCtrlUtils.GetMiroModelFromCell(ctrl);
                    if (miro != null)
                    {
                        miros.Add(miro);
                    }
                }

                bool bSame =
                    Lyu.DataStructureUtils.ContainsSame <MiroModelV1> (miros, ringObjMiros);
                if (bSame)
                {
                    _Rings.RemoveAt(i);
                    break;
                }
            }
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        // Update is called once per frame
        void Update()
        {
            MiroModelV1 model =
                CellObjCtrlUtils.GetMiroModelFromCell(_CCtrl);

            if (model == null)
            {
                _bON = false;
            }
            else
            {
                int movePwr = model.GetMovePwr();
                _bON = (movePwr > 0);
            }

            CircleCollider2D cld = GetComponent <CircleCollider2D> ();

            cld.enabled = _bON;

            if (_bONPrev != _bON)
            {
                _bONChanged.Invoke();
                _bONPrev = _bON;
            }
        }
Esempio n. 4
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. 5
0
 public void ClearMovePwr()
 {
     if (_TgtObj != null)
     {
         MiroModelV1 model =
             CellObjCtrlUtils.GetMiroModelFromCell(this);
         model.ClearMovePwr();
     }
 }
Esempio n. 6
0
 public void IncMovePwr()
 {
     if (_TgtObj != null)
     {
         MiroModelV1 model =
             CellObjCtrlUtils.GetMiroModelFromCell(this);
         model.MovePwrInc1();
         Debug.Log(model + " inc move power");
     }
 }
Esempio n. 7
0
 void ExhaustRotLeftPower()
 {
     if (_bExhaustRotPwr)
     {
         MiroModelV1 model = CellObjCtrlUtils.GetMiroModelFromCell(this);
         if (model != null)
         {
             model.AddRotLeftPwr(-1);
         }
     }
 }
Esempio n. 8
0
        void DeConfigAbsorbing()
        {
            MiroModelV1 modelMe = CellObjCtrlUtils.GetMiroModelFromCell(_cellCtrl);

            if (modelMe == null)
            {
                return;
            }

            modelMe.ReleaseAbsorbing();
        }
Esempio n. 9
0
 public void UpdateRotation()
 {
     if (_movFwdUI._bON)
     {
         MiroModelV1 model =
             CellObjCtrlUtils.GetMiroModelFromCell(_cctrl);
         if (model != null)
         {
             transform.rotation = model.transform.rotation;
         }
     }
 }
Esempio n. 10
0
 void ExhaustMovePower()
 {
     if (_bExhaustMovePwr)
     {
         MiroModelV1 model = CellObjCtrlUtils.GetMiroModelFromCell(this);
         if (model != null)
         {
             model.AddMovePwr(-1);
             print("model.AddMovePwr (-1);");
         }
     }
 }
Esempio n. 11
0
        public void ReadyToUpdate(CCRing ccr)
        {
            //print ("ReadyToUpdate!" + ccr);
            MiroModelV1 miro = CellObjCtrlUtils.GetMiroModelFromCell(ccr._cellCtrl);

            _miros.Add(miro);
            _ctrls[ccr._cellCtrl] = false;

            if (_miros.Count == _mgr._MiroObjs.Count)
            {
                PlaceRing();
            }
        }
Esempio n. 12
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);
        }
Esempio n. 13
0
 // Update is called once per frame
 void Update()
 {
     if (_ToAbsorb)
     {
         MiroModelV1 model = CellObjCtrlUtils.GetMiroModelFromCell(_ToAbsorbCtrl);
         int         at    = model.GetAT();
         //print ("at:" + at);
         if (at != _AT)
         {
             ConfigBackToBackNb();
             _ToAbsorb = false;
         }
     }
 }
Esempio n. 14
0
 public int GetMovePwr()
 {
     if (_TgtObj != null)
     {
         MiroModelV1 model =
             CellObjCtrlUtils.GetMiroModelFromCell(this);
         int movePwr = model.GetMovePwr();
         return(movePwr);
     }
     else
     {
         return(-1);
     }
 }
Esempio n. 15
0
        public void BeHurt()
        {
            MiroModelV1 miro = CellObjCtrlUtils.GetMiroModelFromCell(_cellCtrl);

            List <MiroModelV1> enemies =
                CellObjCtrlUtils.GetNbEnemiesPointToThis(_cellCtrl);

            foreach (var en in enemies)
            {
                //en.CeaseAttacking ();
                en.SetAttackTarget(miro);
                en.UpdateAttackTarget();
                //print (en + " SetAttackTarget as:" + miro);
            }
        }
Esempio n. 16
0
        void DeConfigAbsorbCtrls()
        {
            foreach (var ctrl in _AbsorbingCtrls)
            {
                MiroModelV1 model = CellObjCtrlUtils.GetMiroModelFromCell(ctrl);

                if (model == null)
                {
                    continue;
                }

                model.ReleaseAbsorbing();
            }

            _AbsorbingCtrls.Clear();
        }
Esempio n. 17
0
        public bool SetDispHPAt(Hex coord, int dispHP)
        {
            CellObjCtrl cctrl =
                _GridCtrl.GetCellCtrlAt(coord);

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

            MiroModelV1 model =
                CellObjCtrlUtils.GetMiroModelFromCell(cctrl);

            model.SetDispHP(dispHP);
            return(true);
        }
Esempio n. 18
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. 19
0
        public void MoveFwd(bool bUseMovePwr = false)
        {
            bool bMove = true;

            if (bUseMovePwr)
            {
                MiroModelV1 model = CellObjCtrlUtils.GetMiroModelFromCell(this);
                if (model != null)
                {
                    int movePwr = model.GetMovePwr();
                    bMove = (movePwr > 0);
                }
            }
            if (bMove && CanMove(_Dir))
            {
                ExhaustMovePower();
                MoveInDir(_Dir);
            }
        }
Esempio n. 20
0
        public void DoHurt()
        {
            bool bFwdEnemy = CellObjCtrlUtils.IsNbEnemy(_cellCtrl, 0);

            if (bFwdEnemy)
            {
                CCHurt fwdCCHurt =
                    CellObjCtrlUtils.GetComponentInNbCtrl <CCHurt> (_cellCtrl, 0);

                fwdCCHurt.BeHurt();
                //print (_cellCtrl._TgtObj + " do hurt on:" + fwdCCHurt._cellCtrl._TgtObj);
            }
            else
            {
                MiroModelV1 modelMe = CellObjCtrlUtils.GetMiroModelFromCell(_cellCtrl);
                if (modelMe != null)
                {
                    modelMe.CeaseAttacking();
                }
            }
        }
Esempio n. 21
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);
            }
        }
Esempio n. 22
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);
            }
        }
Esempio n. 23
0
        public void RotateClockwise(bool bUseRotPwr = false)
        {
            _Dir++;
            _Dir = (int)Mathf.Repeat(_Dir, 6);

            bool bChangeDir = true;

            if (bUseRotPwr)
            {
                MiroModelV1 model = CellObjCtrlUtils.GetMiroModelFromCell(this);
                if (model != null)
                {
                    int rotRPwr = model.GetRotRightPwr();
                    bChangeDir = (rotRPwr > 0);
                }
            }
            if (bChangeDir)
            {
                ChangeDir();
                ExhaustRotRightPower();
            }
        }
Esempio n. 24
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. 25
0
        // 支援攻击力: 若棋子正在支援友军攻击,
        // 则本数值==增强友军攻击力的加成数值==眼睛中彩色点数量-被敌方吸收掉的攻击
        // 若为空格,返回-1
        public int GetAssistingATAt(Hex coord)
        {
            CellObjCtrl cctrl = _GridCtrl.GetCellCtrlAt(coord);

            if (cctrl == null)
            {
                return(-1);
            }

            bool bAssisting =
                CellObjCtrlUtils.ShouldAssistingAttacking(cctrl);

            if (bAssisting)
            {
                MiroModelV1 model       = CellObjCtrlUtils.GetMiroModelFromCell(cctrl);
                int         assistingAT = model.GetAssistingAT();
                return(assistingAT);
            }
            else
            {
                return(0);
            }
        }
Esempio n. 26
0
		void ShrinkFarm2 (CellObjCtrl ctrl)
		{
			MiroModelV1 model = CellObjCtrlUtils.GetMiroModelFromCell (ctrl);
			model.ShrinkFarm2 ();
			RemoveFarmRecord (_cellCtrl);
		}
Esempio n. 27
0
        public void PlaceRing()
        {
            //print ("PlaceRing!");

            foreach (var item in _ctrls)
            {
                _ctrlLst.Add(item.Key);
            }

            List <List <CellObjCtrl> > currentRings = new List <List <CellObjCtrl> > ();

            DetectRingCtrlsLst(ref currentRings);

            // detect obsolete rings
            List <List <CellObjCtrl> > obsoleteRings = new List <List <CellObjCtrl> > ();

            for (int i = _Rings.Count - 1; i >= 0; i--)
            {
                var  ringObjs = _Rings [i];
                bool bExist   = false;
                for (int j = currentRings.Count - 1; j >= 0; j--)
                {
                    var newRingObjs = currentRings [j];
                    bExist =
                        Lyu.DataStructureUtils.ContainsSame <CellObjCtrl> (ringObjs, newRingObjs);
                    if (bExist)
                    {
                        break;
                    }
                }

                if (!bExist)
                {
                    obsoleteRings.Add(ringObjs);
                    _Rings.RemoveAt(i);
                }
            }

            // detect new rings
            List <List <CellObjCtrl> > newCreateRings = new List <List <CellObjCtrl> > ();

            for (int i = currentRings.Count - 1; i >= 0; i--)
            {
                var  ringObjs = currentRings [i];
                bool bExist   = false;
                for (int j = _Rings.Count - 1; j >= 0; j--)
                {
                    var existRObjs = _Rings [j];
                    bExist =
                        Lyu.DataStructureUtils.ContainsSame <CellObjCtrl> (ringObjs, existRObjs);
                    if (bExist)
                    {
                        break;
                    }
                }

                if (!bExist)
                {
                    newCreateRings.Add(ringObjs);
                    _Rings.Add(ringObjs);
                }
            }

            //delete obsolete rings
            foreach (var lstCtrl in obsoleteRings)
            {
                //print ("Delete Ring:" + lstCtrl);
                MiroModelV1 miro = CellObjCtrlUtils.GetMiroModelFromCell(lstCtrl [0]);
                miro.ShrinkRing();
            }

            // create new ring
            foreach (var lstCtrl in newCreateRings)
            {
                //print ("new Ring:" + lstCtrl);
                List <GameObject> rObjs = new List <GameObject> ();
                foreach (CellObjCtrl ctrl in lstCtrl)
                {
                    rObjs.Add(ctrl._TgtObj);
                }
                _mgr.CreateRing(rObjs);
            }

            //_Rings = currentRings;

            ClearContainers();
        }
Esempio n. 28
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);
        }
Esempio n. 29
0
        public MiroModelV1 GetMiroModelAt(Hex hex)
        {
            CellObjCtrl cctrl = GetCellCtrlAt(hex);

            return(CellObjCtrlUtils.GetMiroModelFromCell(cctrl));
        }