Ejemplo n.º 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;
     }
 }
Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 4
0
        public CellObjCtrl Confirm()
        {
            if (_bControlDragRotator)
            {
                TurnDragRotatorForCellObjCtrl(_cctrl, false);
            }

            _NewConfirmCtrl = _cctrl;
            _Confirm.Invoke(_NewConfirmCtrl);

            _cctrl = null;

            return(_NewConfirmCtrl);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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;
             }
         }
     }
 }
Ejemplo n.º 7
0
        // 棋格方向: 0~5 正常方向; -1:棋格不存在
        public int GetDirAt(Hex coord)
        {
            CellObjCtrl cctrl =
                _GridCtrl.GetCellCtrlAt(coord);

            if (cctrl != null)
            {
                return(cctrl.GetDir());
            }
            else
            {
                return(-1);
            }
        }
Ejemplo n.º 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));
     }
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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();
                }
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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>());
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 24
0
        public CellObjCtrl Cancel()
        {
            if (_bControlDragRotator)
            {
                TurnDragRotatorForCellObjCtrl(_cctrl, false);
            }

            _NewCancelCtrl = _cctrl;
            _Cancel.Invoke(_NewCancelCtrl);

            _mgr.DisappearMiroAtCellCtrl(_NewCancelCtrl);

            //_NewCancelCtrl.DisappearTgtObj ();

            _cctrl = null;

            return(_NewCancelCtrl);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }