Пример #1
0
 void UpdateSituDict()
 {
     foreach (GameObject ctrlObj in _gridCtrl._Cells)
     {
         CellObjCtrl        ctrl    = ctrlObj.GetComponent <CellObjCtrl> ();
         MiroV1ModelSetting setting = CellObjCtrlUtils.GetModelSettingFromCtrl(ctrl);
         string             cname   = "";
         if (setting != null)
         {
             cname = setting._CampName;
         }
         _ChessBoardSitu [ctrl] = cname;
     }
 }
Пример #2
0
        public void TurnCellBlock(bool bBlock)
        {
            foreach (GameObject gb in _Cells)
            {
                CellObjCtrl   ctrl    = gb.GetComponent <CellObjCtrl> ();
                CellSelection cellSel = gb.GetComponentInChildren <CellSelection> ();
                bool          bSelect = cellSel.IsSelected();

                if (ctrl != null && bSelect)
                {
                    ctrl.SetBlock(bBlock);
                }
            }
        }
Пример #3
0
        public static bool ShouldAttacking(CellObjCtrl cctrl)
        {
            bool bFwdEnemy = IsNbEnemy(cctrl, 0);
            bool bFwdEmpty = IsNbEmpty(cctrl, 0);

            if (bFwdEnemy || bFwdEmpty)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #4
0
        public CellObjCtrl Confirm()
        {
            if (_bControlDragRotator)
            {
                TurnDragRotatorForCellObjCtrl(_cctrl, false);
            }

            _NewConfirmCtrl = _cctrl;
            _Confirm.Invoke(_NewConfirmCtrl);

            _cctrl = null;

            return(_NewConfirmCtrl);
        }
Пример #5
0
        public static bool IsNbCellControllingObj(CellObjCtrl cctrl, int NbRelativeDir)
        {
            CellObjCtrl cctrlNb =
                GetNbCellObjCtrl(cctrl, NbRelativeDir);

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

            bool bCtrlling = (cctrlNb._TgtObj != null);

            return(bCtrlling);
        }
Пример #6
0
 static void RemoveFaceToFaceRecord(CellObjCtrl ctrl)
 {
     foreach (List <CellObjCtrl> lstFF in _Holes)
     {
         foreach (CellObjCtrl thisCtrl in lstFF)
         {
             if (thisCtrl == ctrl)
             {
                 _Holes.Remove(lstFF);
                 return;
             }
         }
     }
 }
Пример #7
0
        // 棋格方向: 0~5 正常方向; -1:棋格不存在
        public int GetDirAt(Hex coord)
        {
            CellObjCtrl cctrl =
                _GridCtrl.GetCellCtrlAt(coord);

            if (cctrl != null)
            {
                return(cctrl.GetDir());
            }
            else
            {
                return(-1);
            }
        }
Пример #8
0
 public Hex GetHexOfModel(MiroModelV1 model)
 {
     if (_Model2Cell.ContainsKey(model))
     {
         CellObjCtrl ctrl = _Model2Cell [model];
         HexCoord    hc   = ctrl.GetComponent <HexCoord> ();
         Hex         h    = hc._hex;
         return(h);
     }
     else
     {
         return(new Hex(int.MaxValue, 0, 0));
     }
 }
Пример #9
0
        public List <CellObjCtrl> GetOccupiedCellObjCtrls()
        {
            List <CellObjCtrl> occupiedCtrls = new List <CellObjCtrl> ();

            foreach (GameObject gb in _Cells)
            {
                CellObjCtrl ctrl = gb.GetComponent <CellObjCtrl> ();
                if (ctrl._TgtObj != null)
                {
                    occupiedCtrls.Add(ctrl);
                }
            }
            return(occupiedCtrls);
        }
Пример #10
0
        public void ChangeCell(CellObjCtrl cctrl)
        {
            ClearNullItems();
            MiroModelV1 model = null;

            if (cctrl._TgtObj != null)
            {
                model = cctrl._TgtObj.GetComponent <MiroModelV1> ();
                if (model != null)
                {
                    ChangeItem(model, cctrl);
                    Caculate();
                }
            }
        }
Пример #11
0
        public List <CellObjCtrl> GetEmptyPlacableCellObjCtrls()
        {
            List <CellObjCtrl> epCtrls = new List <CellObjCtrl> ();

            foreach (GameObject ctrlObj in _Cells)
            {
                CellObjCtrl cctrl = ctrlObj.GetComponent <CellObjCtrl> ();
                if (cctrl._TgtObj == null && !cctrl.IsBlocked())
                {
                    epCtrls.Add(cctrl);
                }
            }

            return(epCtrls);
        }
Пример #12
0
        private bool TurnDragRotatorUI(Hex coord, bool bEnable)
        {
            CellObjCtrl cctrl = _GridCtrl.GetCellCtrlAt(coord);

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

            ChessDragRotator dragRoter =
                cctrl.GetComponentInChildren <ChessDragRotator> ();

            dragRoter.enabled = bEnable;
            return(true);
        }
Пример #13
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>());
            }
        }
Пример #14
0
        public List <Hex> GetAllPlacableHexes()
        {
            List <Hex> lstHexes = new List <Hex> ();

            foreach (KeyValuePair <Hex, GameObject> item in _HexToCells)
            {
                CellObjCtrl ctrl =
                    item.Value.GetComponent <CellObjCtrl> ();
                bool bBlocked = ctrl.IsBlocked();
                if (!bBlocked)
                {
                    lstHexes.Add(item.Key);
                }
            }
            return(lstHexes);
        }
Пример #15
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);
        }
Пример #16
0
        public void PlaceChesses(
            List <ChessInfo> chesses)
        {
            foreach (ChessInfo chInfo in chesses)
            {
                CellObjCtrl cctrl = _GridCtrl.GetCellCtrlAt(chInfo.pos);
                if (cctrl == null)
                {
                    continue;
                }

                cctrl.SetDir(chInfo.dir);
                _MiroMgr.SetMiroPrefabID(chInfo.campId);
                _MiroMgr.SpawnAtCellCtrl(cctrl);
            }
        }
Пример #17
0
        public List <Hex> GetAllPlacableEmptyHexes()
        {
            List <Hex> placableHexes = GetAllPlacableHexes();
            List <Hex> emptyHexes    = new List <Hex> ();

            foreach (Hex h in placableHexes)
            {
                CellObjCtrl ctrl =
                    _HexToCells [h].GetComponent <CellObjCtrl> ();
                if (ctrl._TgtObj == null)
                {
                    emptyHexes.Add(h);
                }
            }
            return(emptyHexes);
        }
Пример #18
0
        public static bool IsNbEmpty(CellObjCtrl cctrl, int relativeDir)
        {
            CellObjCtrl fwdCtrl =
                GetNbCellObjCtrl(cctrl, relativeDir);
            bool bEmpty = false;

            if (fwdCtrl == null)
            {
                bEmpty = true;
            }
            else
            {
                bEmpty = (fwdCtrl._TgtObj == null);
            }
            return(bEmpty);
        }
Пример #19
0
        static void ConfigAbsorbingSrcFor(CellObjCtrl cCtrl)
        {
            int dirFwd = cCtrl.GetDir();
            int dirBwd = (int)Mathf.Repeat((float)(cCtrl.GetDir() + 3), (float)6);

            if (cCtrl._TgtObj == null)
            {
                return;
            }
            MiroModelV1 model = cCtrl._TgtObj.GetComponent <MiroModelV1> ();
            HexCoord    hc    = cCtrl.GetComponent <HexCoord> ();
            Transform   tfFwd = hc._Neighbors [dirFwd];
            Transform   tfBwd = hc._Neighbors [dirBwd];

            model.SetFwdAbsorbingSrcTF(tfFwd);
            model.SetBwdAbsorbingSrcTF(tfBwd);
        }
Пример #20
0
        public List <Hex> GetAllOccupiedHexes()
        {
            List <Hex> allHexes      = GetAllHexes();
            List <Hex> occupiedHexes = new List <Hex> ();

            foreach (Hex h in allHexes)
            {
                CellObjCtrl ctrl =
                    _HexToCells [h].GetComponent <CellObjCtrl> ();
                if (ctrl._TgtObj != null)
                {
                    occupiedHexes.Add(h);
                }
            }

            return(occupiedHexes);
        }
Пример #21
0
        // Update is called once per frame
        void Update()
        {
            CellObjCtrl ctrlA =
                _TwoObj._A.GetComponent <CellObjCtrl> ();
            CellObjCtrl ctrlB =
                _TwoObj._B.GetComponent <CellObjCtrl> ();
            bool bBlockA = ctrlA.IsBlocked();
            bool bBlockB = ctrlB.IsBlocked();
            bool bBlock  = bBlockA || bBlockB;

            LineRenderer lr      = GetComponent <LineRenderer> ();
            Color        startCr = GetColorWithBlockState(bBlock);
            Color        endCr   = GetColorWithBlockState(bBlock);

            lr.startColor = startCr;
            lr.endColor   = endCr;
        }
Пример #22
0
        public bool TryMoveFromA2B(Hex A, Hex B, int dirB = -1)
        {
            CellObjCtrl ctrlA = _GridCtrl.GetCellCtrlAt(A);
            CellObjCtrl ctrlB = _GridCtrl.GetCellCtrlAt(B);

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

            bool bTeleported = ctrlA.TeleportTo(ctrlB, dirB);

            return(bTeleported);
        }
Пример #23
0
        public bool IsBlockedAtHex(Hex h)
        {
            if (!_HexToCells.ContainsKey(h))
            {
                return(true);
            }
            var cellObj = _HexToCells[h];

            if (cellObj == null)
            {
                return(true);
            }

            CellObjCtrl cctrl   = cellObj.GetComponent <CellObjCtrl> ();
            bool        blocked = cctrl.IsBlocked();

            return(blocked);
        }
Пример #24
0
        public CellObjCtrl Cancel()
        {
            if (_bControlDragRotator)
            {
                TurnDragRotatorForCellObjCtrl(_cctrl, false);
            }

            _NewCancelCtrl = _cctrl;
            _Cancel.Invoke(_NewCancelCtrl);

            _mgr.DisappearMiroAtCellCtrl(_NewCancelCtrl);

            //_NewCancelCtrl.DisappearTgtObj ();

            _cctrl = null;

            return(_NewCancelCtrl);
        }
Пример #25
0
        public static bool ShouldAssistingAttacking(CellObjCtrl cctrl)
        {
            bool bShouldAT = ShouldAttacking(cctrl);

            if (bShouldAT)
            {
                return(false);
            }
            bool bFwdSameCamp = IsNbSameCamp(cctrl, 0);

            if (!bFwdSameCamp)
            {
                return(false);
            }
            CellObjCtrl FwdCtrl       = GetNbCellObjCtrl(cctrl, 0);
            bool        bFwdAttacking = ShouldAttacking(FwdCtrl);

            return(bFwdAttacking);
        }
Пример #26
0
        static void RecordNewFaceToFace(
            CellObjCtrl ctrlA, CellObjCtrl ctrlB)
        {
            foreach (List <CellObjCtrl> lstCtrl in _Holes)
            {
                foreach (CellObjCtrl ctrl in lstCtrl)
                {
                    if (ctrl == ctrlA || ctrl == ctrlB)
                    {
                        return;
                    }
                }
            }
            List <CellObjCtrl> ff = new List <CellObjCtrl> ();

            ff.Add(ctrlA);
            ff.Add(ctrlB);
            _Holes.Add(ff);
        }
Пример #27
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);
        }
Пример #28
0
        public static bool IsControllingSameCampS(CellObjCtrl cctrl0, CellObjCtrl cctrl1)
        {
            if (cctrl0 == null || cctrl0._TgtObj == null)
            {
                return(false);
            }
            MiroV1ModelSetting setting0 = cctrl0._TgtObj.GetComponent <MiroV1ModelSetting> ();


            if (cctrl1 == null || cctrl1._TgtObj == null)
            {
                return(false);
            }
            MiroV1ModelSetting setting1 = cctrl1._TgtObj.GetComponent <MiroV1ModelSetting> ();

            bool bSame = setting0.IsSameCamp(setting1);

            return(bSame);
        }
Пример #29
0
        public bool IsEmptyAtHex(Hex h)
        {
            if (!_HexToCells.ContainsKey(h))
            {
                return(false);
            }

            var cellObj = _HexToCells[h];

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

            CellObjCtrl cctrl  = cellObj.GetComponent <CellObjCtrl> ();
            bool        bEmpty = (cctrl._TgtObj == null);

            return(bEmpty);
        }
Пример #30
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);
        }