Exemple #1
0
        public static bool IsNbEnemy(CellObjCtrl ctrl, int relativeDir)
        {
            bool bEnemy = false;

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

            MiroModelV1 modelThis = GetMiroModelFromCell(ctrl);
            MiroModelV1 modelNb   = GetNbModel(ctrl, relativeDir);

            if (modelNb == null || modelThis == null)
            {
                return(false);
            }

            MiroV1ModelSetting settingThis =
                modelThis.gameObject.GetComponent <MiroV1ModelSetting> ();
            MiroV1ModelSetting settingNb =
                modelNb.gameObject.GetComponent <MiroV1ModelSetting> ();

            bEnemy = !settingNb.IsSameCamp(settingThis);
            return(bEnemy);
        }
Exemple #2
0
        void SetLRColor()
        {
            MiroV1ModelSetting modelSetting = GetComponentInParent <MiroV1ModelSetting> ();

            _LineRenderer.startColor = modelSetting._colorSetting._ENMax;
            _LineRenderer.endColor   = modelSetting._colorSetting._ENMax;
        }
Exemple #3
0
        // 将当前正在操作的棋子取消
        public bool CancelOperatingChess(
            out Hex coord,
            out int dir,
            out int campId)
        {
            CellObjCtrl newestCtrl = _StdChessSpawer.GetSpawningCellObjCtrl();

            if (newestCtrl == null)
            {
                coord  = new Hex();
                dir    = -1;
                campId = -1;
                return(false);
            }

            coord = newestCtrl.GetComponent <HexCoord> ()._hex;
            dir   = newestCtrl.GetDir();
            MiroV1ModelSetting msetting = CellObjCtrlUtils.GetModelSettingFromCtrl(newestCtrl);

            campId = _MiroMgr.GetIdOfMiroModelSetting(msetting);


            _StdChessSpawer.Cancel();
            //_GridCtrl.ConfirmOccupiedCells ();
            //DisableAllChessOperation ();
            _GridCtrl.TurnDragRotatersOnEmptyPlacableCells(true);
            return(true);
        }
Exemple #4
0
 public void GetModelSetting()
 {
     if (_modelSetting == null)
     {
         _modelSetting = GetComponentInParent <MiroV1ModelSetting> ();
     }
 }
Exemple #5
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);
        }
 void SetLineRenderersColor()
 {
     if (_LineRendererBG != null)
     {
         MiroV1ModelSetting modelSet = _model.GetComponent <MiroV1ModelSetting> ();
         Color cr = modelSet._colorSetting._ENBG;
         LineRendererSetting.SetColor(_LineRendererBG, cr);
     }
 }
Exemple #7
0
        public static MiroV1ModelSetting GetModelSettingFromCtrl(CellObjCtrl cctrl)
        {
            if (cctrl == null || cctrl._TgtObj == null)
            {
                return(null);
            }
            MiroV1ModelSetting setting = cctrl._TgtObj.GetComponent <MiroV1ModelSetting> ();

            return(setting);
        }
        void SetLineRenderersColor()
        {
            MiroV1ModelSetting modelSet = _model.GetComponent <MiroV1ModelSetting> ();
            Color cr = modelSet._colorSetting._ENMax;

            foreach (LineRenderer lr in _StrokeLineRenderers)
            {
                LineRendererSetting.SetColor(lr, cr);
            }
        }
 public void SetModelSetting(MiroV1ModelSetting modelSetting)
 {
     _modelSetting = modelSetting;
     foreach (GameObject gb in _Plants)
     {
         MiroV1BulletEmitterBase em =
             gb.GetComponentInChildren <MiroV1BulletEmitterBase> ();
         em._modelSetting = modelSetting;
     }
 }
Exemple #10
0
        void OperateBwdAnteller(
            HexCoord hc,
            MiroV1ModelSetting mSetThis,
            MiroModelV1 model)
        {
            int  DirBwd = _cellCtrl.GetBwdDir();
            bool bBwd   = CheckValidInDir(mSetThis, hc, DirBwd);

            ChangeAnteller(bBwd, model._Antellers [1]);
        }
 void UpdateYinYangColor()
 {
     if (_modelSetting == null)
     {
         _modelSetting = GetComponentInParent <MiroV1ModelSetting> ();
     }
     if (_modelSetting != null)
     {
         Lyu.LineRendererSetting.SetColor(
             _LRLight, _modelSetting._colorSetting._ENMax);
     }
 }
Exemple #12
0
        // 获得棋格坐标处的阵营id: -1~3
        // -1: 无棋子
        // 0~3: 四个阵营的编号
        public int GetCampIdAt(Hex coord)
        {
            MiroV1ModelSetting miroSetting =
                _GridCtrl.GetMiroModelSettingAt(coord);

            if (miroSetting == null)
            {
                return(-1);
            }
            int id = _MiroMgr.GetIdOfMiroModelSetting(miroSetting);

            return(id);
        }
Exemple #13
0
        public MiroV1ModelSetting GetMiroModelSettingAt(Hex hex)
        {
            GameObject cellObj = GetCellObjAt(hex);

            if (cellObj == null)
            {
                return(null);
            }
            CellObjCtrl        cctrl   = cellObj.GetComponent <CellObjCtrl> ();
            MiroV1ModelSetting setting = CellObjCtrlUtils.GetModelSettingFromCtrl(cctrl);

            return(setting);
        }
 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;
     }
 }
 void UpdateENColor()
 {
     if (_modelSetting == null)
     {
         _modelSetting = _Fix0.connectedBody.GetComponentInParent <MiroV1ModelSetting> ();
     }
     if (_modelSetting != null)
     {
         foreach (GameObject p in _Plants)
         {
             SpriteRenderer sr = p.GetComponentInChildren <SpriteRenderer> ();
             sr.color = _modelSetting._colorSetting._ENEmpty;
             TrailRenderer tr = p.GetComponentInChildren <TrailRenderer> ();
             Lyu.TrailRendererCtrl.SetColor(tr, _modelSetting._colorSetting._ENEmpty);
         }
     }
 }
Exemple #16
0
        override protected void _Calculate()
        {
            bool bCtrlling = CellObjCtrlUtils.IsControllingObj(_cellCtrl);

            if (!bCtrlling)
            {
                return;
            }
            HexCoord hc = _cellCtrl.GetComponent <HexCoord> ();

            MiroV1ModelSetting mSetThis =
                _cellCtrl._TgtObj.GetComponent <MiroV1ModelSetting> ();
            MiroModelV1 model = mSetThis.GetComponent <MiroModelV1> ();

            OperateFwdAnteller(hc, mSetThis, model);
            OperateBwdAnteller(hc, mSetThis, model);

            MiroV1PlacementMgr.ConfigAbsorbingSrcForTF(_cellCtrl.transform);
        }
        private void SetHighlightColorAsChoosen()
        {
            MiroV1ModelSetting modelSetting = CellObjCtrlUtils.GetModelSettingFromCtrl(_CCtrl);

            if (modelSetting == null)
            {
                return;
            }
            if (_ColorMode == "Boom")
            {
                _HighlightColor   = modelSetting._colorSetting._ENMax;
                _HighlightColor.a = _AlphaBoom;
            }
            else if (_ColorMode == "UpDown")
            {
                _HighlightColor   = modelSetting._colorSetting._ENEmpty;
                _HighlightColor.a = _AlphaUpDown;
            }
        }
        // Update is called once per frame
        void Update()
        {
            bool bEnable  = (_Placer.enabled == true);
            bool bPress   = (_Placer.IsPressed());
            bool bControl = (_CCtrl._TgtObj != null);

            if (!_bEnable && bEnable)
            {
                _Anim.SetTrigger("Enable");
                alpha = 0.0f;
            }
            else if (!_bPressed && bPress)
            {
                _Anim.SetTrigger("StartPlacing");
                alpha = _AlphaPlacing;
            }
            else if (_bPressed && !bPress)
            {
                _Anim.SetTrigger("StopPlacing");
                alpha = _AlphaPlaced;
            }
            else if (bControl && !_bControl)
            {
                _Anim.SetTrigger("Ready");
                alpha = _AlphaReady;
            }

            Color crNow = _SRRing.color;

            if (bControl)
            {
                MiroV1ModelSetting setting =
                    _CCtrl._TgtObj.GetComponent <MiroV1ModelSetting> ();
                crNow = setting._colorSetting._ENBG;
            }
            crNow.a       = alpha;
            _SRRing.color = crNow;
            //Debug.Log ("Alpha:" + alpha);

            _bPressed = bPress;
            _bEnable  = bEnable;
            _bControl = bControl;
        }
Exemple #19
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);
        }
Exemple #20
0
        private bool CheckValidInDir(MiroV1ModelSetting mSetThis, HexCoord hc, int dir)
        {
            bool bValid = true;

            if (hc._Neighbors [dir] != null)
            {
                CellObjCtrl fwdCtrl =
                    hc._Neighbors [dir].GetComponent <CellObjCtrl> ();
                if (fwdCtrl._TgtObj != null)
                {
                    MiroV1ModelSetting mSetFwd =
                        fwdCtrl._TgtObj.GetComponent <MiroV1ModelSetting> ();
                    if (mSetFwd != null && !mSetFwd.IsSameCamp(mSetThis))
                    {
                        bValid = false;
                    }
                }
            }
            return(bValid);
        }
Exemple #21
0
        public bool IsSameCamp(MiroV1ModelSetting other)
        {
            bool bSame = false;

            if (other == null)
            {
                bSame = false;
            }
            else
            {
                bSame = (_CampName == other._CampName);
            }

            /*
             * if (bSame) {
             *      //Debug.Log ("What Same!");
             *      bSame = bSame;
             * }*/
            //Debug.Log ("bSame:" + bSame);
            return(bSame);
        }
Exemple #22
0
        public static bool IsNbSameCamp(CellObjCtrl cctrl, int relativeDir)
        {
            bool bSame = false;

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

            CellObjCtrl nbCtrl = GetNbCellObjCtrl(cctrl, relativeDir);

            if (nbCtrl._TgtObj != null)
            {
                MiroV1ModelSetting settingNb =
                    nbCtrl._TgtObj.GetComponent <MiroV1ModelSetting> ();
                bSame = settingNb.IsSameCamp(setting0);
            }

            return(bSame);
        }
        void UpdateCampChessCountDict()
        {
            List <string> cnames = _mgr.GetMiroPrefabsCampNames();

            foreach (string cname in cnames)
            {
                _CampChessCount [cname] = 0;
            }

            /*
             * int prefCnt = _mgr._MiroPrefabs.Count;
             * for (int i = 0; i < prefCnt; i++) {
             *      MiroV1ModelSetting setting = _mgr._MiroPrefabs [i].GetComponent<MiroV1ModelSetting> ();
             *      if (_CampChessCount.ContainsKey (setting._CampName)) {
             *              _CampChessCount [setting._CampName] = 0;
             *      }
             * }*/

            foreach (GameObject ctrlObj in _gridCtrl._Cells)
            {
                CellObjCtrl        ctrl    = ctrlObj.GetComponent <CellObjCtrl> ();
                MiroV1ModelSetting setting = CellObjCtrlUtils.GetModelSettingFromCtrl(ctrl);
                if (setting != null)
                {
                    string cname = setting._CampName;
                    if (!_CampChessCount.ContainsKey(cname))
                    {
                        _CampChessCount [cname] = 0;
                    }
                    else
                    {
                        _CampChessCount [cname]++;
                    }
                }
            }
        }
        // Update is called once per frame
        void Update()
        {
            bool bA2B, bB2A;

            // get comps
            CellObjCtrl ctrlA =
                _TwoLink._A.GetComponent <CellObjCtrl> ();
            MiroModelV1 modelA =
                GetModelFromCellObj(_TwoLink._A);
            MiroV1ModelSetting modelSettingA = null;

            if (modelA != null)
            {
                modelSettingA =
                    modelA.GetComponent <MiroV1ModelSetting> ();
            }

            MiroModelV1 modelB =
                GetModelFromCellObj(_TwoLink._B);
            CellObjCtrl ctrlB =
                _TwoLink._B.GetComponent <CellObjCtrl> ();
            MiroV1ModelSetting modelSettingB = null;

            if (modelB != null)
            {
                modelSettingB =
                    modelB.GetComponent <MiroV1ModelSetting> ();
            }

            // check direction
            bA2B = IsXPointToY(ctrlA, ctrlB);
            bB2A = IsXPointToY(ctrlB, ctrlA);
            bool bBias = bA2B && bB2A;

            // compute at
            float dt  = Time.deltaTime;
            int   ata = 0;

            if (modelA != null)
            {
                ata = bA2B ? modelA.GetAT() : 0;
            }
            _ATAF = Mathf.Lerp(_ATAF, ata, dt * _LerpSpd);
            int atb = 0;

            if (modelB != null)
            {
                atb = bB2A? modelB.GetAT():0;
            }
            float lerpT = dt * _LerpSpd;

            _ATBF = Mathf.Lerp(_ATBF, atb, lerpT);

            // get Width
            float wdA = _WdOnAT.Evaluate(_ATAF) * _WdMult;
            float wdB = _WdOnAT.Evaluate(_ATBF) * _WdMult;

            if (!bA2B)
            {
                wdA = 0.0f;
            }
            if (!bB2A)
            {
                wdB = 0.0f;
            }
            _WdA = Mathf.Lerp(_WdA, wdA, lerpT);
            _WdB = Mathf.Lerp(_WdB, wdB, lerpT);

            // config LR
            Transform tfa, tfb;

            tfa = _TwoLink._A.transform;
            tfb = _TwoLink._B.transform;

            ConfigLR(_LRAB, tfa, tfb, modelSettingA, _ATAF, _WdA, bBias);
            ConfigLR(_LRBA, tfa, tfb, modelSettingB, _ATBF, -_WdB, bBias);
        }
        private void ConfigLR(
            LineRenderer lr,
            Transform akrA,
            Transform akrB,
            MiroV1ModelSetting modelASetting,
            float at,
            float wd,
            bool bBias)
        {
            float wwd = wd;

            // set line width
            if (modelASetting == null)
            {
                wd = 0.0f;
            }
            wd = Mathf.Abs(wd);
            lr.widthMultiplier = wd;
            if (wd == 0.0f)
            {
                return;
            }

            // set line path
            int     ptCnt = lr.positionCount;
            float   step  = 1.0f / (float)(ptCnt - 1);
            Vector3 Bias  = Vector2.zero;

            if (bBias)
            {
                Vector3 posA = akrA.position;
                Vector3 posB = akrB.position;
                Vector3 AB   = posB - posA;
                Vector3 AB01 = AB.normalized;
                float   deg  = 90.0f;
                if (wwd < 0)
                {
                    deg = -90.0f;
                }
                Bias = Quaternion.AngleAxis(deg, Vector3.forward) *
                       AB01 * (wd * _BiasAmt01);
            }

            float TNow = _NoiseSpd * Time.realtimeSinceStartup;

            for (int i = 0; i < ptCnt; i++)
            {
                float   t    = i * step;
                Vector3 posA = akrA.position;
                Vector3 posB = akrB.position;
                Vector3 p    = Vector3.Lerp(posA, posB, t) + Bias + _ZBias * Vector3.forward;

                if (i > 0)
                {
                    Vector3 posPrev      = lr.GetPosition(i - 1);
                    Vector3 prevToThis01 = (p - posPrev).normalized;
                    Vector3 NDir         = Quaternion.AngleAxis(90.0f, Vector3.forward) * prevToThis01;
                    Vector3 NoiseBias    = _NoiseAmt * NDir *
                                           (Mathf.PerlinNoise(p.x + TNow, p.y - TNow) - 0.5f);
                    p += NoiseBias;
                    p += _ZBiasOnWD * wd * Vector3.forward;
                }

                lr.SetPosition(i, p);
            }

            // set line color
            lr.startColor = modelASetting._colorSetting._ENBG;
            lr.endColor   = modelASetting._colorSetting._ENBG;
        }