예제 #1
0
 static void ResetIdInRing(List <CellObjCtrl> ringObjs)
 {
     foreach (CellObjCtrl cctrl in ringObjs)
     {
         CCRing cring = cctrl.GetComponentInChildren <CCRing> ();
         cring.ResetIdInRing();
     }
 }
예제 #2
0
 static void AddIdInRing(List <CellObjCtrl> ringObjs)
 {
     for (int i = 0; i < ringObjs.Count; i++)
     {
         CCRing cring = ringObjs [i].GetComponentInChildren <CCRing> ();
         cring._IdInRing = i;
     }
 }
예제 #3
0
 public void TurnRing(bool bON)
 {
     if (bON)
     {
         CCRing.TurnAllON();
     }
     else
     {
         CCRing.TurnAllOFF();
     }
 }
예제 #4
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();
            }
        }
예제 #5
0
        public bool InRing(Hex coord)
        {
            List <List <Hex> > rings =
                CCRing.GetRings();

            foreach (var lstR in rings)
            {
                foreach (Hex h in lstR)
                {
                    if (h.q == coord.q &&
                        h.r == coord.r &&
                        h.s == coord.s)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
예제 #6
0
        // ------------------- 棋子阵型 -----------------------
        // 下列接口主要返回视觉上显示出来的各种特殊阵型
        public List <List <Hex> > GetRings(int campId)
        {
            List <List <Hex> > rings = CCRing.GetRings();

            return(rings);
        }
예제 #7
0
        /*
         * override protected void _Calculate()
         * {
         *      List<CellObjCtrl> ringObjs = new List<CellObjCtrl>();
         *      bool bDetected =
         *              CellObjCtrlUtils.DetectNPCCloseChainFrom (_cellCtrl, ref ringObjs);
         *
         *      bool bRing = (ringObjs.Count > 2)&&bDetected;
         *
         *      if (bRing) {
         *              //Debug.Log ("SetUpRing");
         *              SetupRing (ringObjs);
         *      } else {
         *              //Debug.Log ("UnSetUpRing");
         *              UnSetupRing (ringObjs);
         *      }
         *
         *      bool bInRing = ringObjs.Contains (_cellCtrl);
         *      if (!bInRing) {
         *              MiroModelV1 model = CellObjCtrlUtils.GetMiroModelFromCell (_cellCtrl);
         *              model.ShrinkRing ();
         *      }
         *
         * }
         */


        void SetupRing(List <CellObjCtrl> ringObjs)
        {
            bool bExist = false;

            foreach (List <CellObjCtrl> ringObjLst in _Rings)
            {
                bool bSame = IsContainSame(ringObjs, ringObjLst);
                if (bSame)
                {
                    bExist = true;
                    IsContainSame(ringObjs, ringObjLst);
                    //Debug.Log ("bSame!");
                    return;
                }
            }
            bool bIdAdded = true;

            foreach (CellObjCtrl ctrl in ringObjs)
            {
                CCRing cc = ctrl.GetComponentInChildren <CCRing> ();
                bIdAdded = bIdAdded && cc.IsIdAdded();
            }
            if (!bExist && !bIdAdded)
            {
                ReorderRing(ref ringObjs);
                AddIdInRing(ringObjs);
                // shrink smaller ring
                for (int i = _Rings.Count - 1; i >= 0; i--)
                {
                    List <CellObjCtrl> lstCtrl = _Rings [i];
                    foreach (var ctrl in lstCtrl)
                    {
                        if (ringObjs.Contains(ctrl))
                        {
                            MiroModelV1 model = ctrl._TgtObj.GetComponent <MiroModelV1> ();
                            model.ShrinkRing();
                            Debug.Log("model.ShrinkRing (): " + model.name);
                            break;
                        }
                    }
                }
                foreach (List <CellObjCtrl> lstCtrl in _Rings)
                {
                    for (int i = lstCtrl.Count - 1; i >= 0; i--)
                    {
                    }
                    foreach (var ctrl in lstCtrl)
                    {
                        if (ringObjs.Contains(ctrl))
                        {
                            MiroModelV1 model = ctrl._TgtObj.GetComponent <MiroModelV1> ();
                            model.ShrinkRing();
                            Debug.Log("model.ShrinkRing (): " + model.name);
                        }
                    }
                }
                // create new ring
                List <GameObject> rObjs = new List <GameObject> ();
                foreach (CellObjCtrl ctrl in ringObjs)
                {
                    rObjs.Add(ctrl._TgtObj);
                }
                _mgr.CreateRing(rObjs);
                Debug.Log("_mgr.CreateRing (rObjs);");
                _Rings.Add(ringObjs);
            }
            if (_IdInRing == ringObjs.Count - 1)
            {
                ResetIdInRing(ringObjs);
            }
        }