Exemplo n.º 1
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;
         }
     }
 }
Exemplo n.º 2
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));
     }
 }
Exemplo n.º 3
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();
                }
            }
        }
Exemplo n.º 4
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);
            }
        }
Exemplo n.º 5
0
        void DeConfigAbsorbCtrls()
        {
            foreach (var ctrl in _AbsorbingCtrls)
            {
                MiroModelV1 model = CellObjCtrlUtils.GetMiroModelFromCell(ctrl);

                if (model == null)
                {
                    continue;
                }

                model.ReleaseAbsorbing();
            }

            _AbsorbingCtrls.Clear();
        }
Exemplo n.º 6
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);
        }
        void DeConfigAideeSubWeapon()
        {
            int         aidDir     = GetAidingRDir();
            MiroModelV1 modelAidee = GetModelAidee();

            if (aidDir >= 0 && aidDir <= 5)
            {
                /*Lyu.LineRendererPathCtrl pthCtrl =
                 *      _PipeWdStartCtrl.GetComponent<Lyu.LineRendererPathCtrl> ();
                 */
                if (modelAidee != null)
                {
                    modelAidee._WeaponSlots [aidDir]._Weapon.DettachLineRendererPathCtrl();
                }
            }
        }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
0
 static void UnSetupRing(List <CellObjCtrl> ringObjs)
 {
     foreach (CellObjCtrl ctrl in ringObjs)
     {
         for (int i = _Rings.Count - 1; i >= 0; i--)
         {
             List <CellObjCtrl> lst = _Rings [i];
             if (lst.Contains(ctrl))
             {
                 // shink this ring
                 MiroModelV1 model = ctrl._TgtObj.GetComponent <MiroModelV1> ();
                 model.ShrinkRing();
                 _Rings.RemoveAt(i);
             }
         }
     }
 }
Exemplo n.º 10
0
        void ConfigAideeSubWeapon()
        {
            int         aidDir     = GetAidingRDir();
            MiroModelV1 modelAidee = GetModelAidee();

            if (aidDir >= 0 && aidDir <= 5)
            {
                Lyu.LineRendererPathCtrl pthCtrl =
                    _PipeWdStartCtrl.GetComponent <Lyu.LineRendererPathCtrl> ();
                if (modelAidee != null)
                {
                    modelAidee._WeaponSlots [aidDir]._Weapon
                    .AttachLineRendererPathCtrl(pthCtrl);
                }
                //print ("AttachLineRendererPathCtrl");
            }
        }
Exemplo n.º 11
0
        void Update()
        {
            Transform srcTF = GetSourceTF();

            if (srcTF == null)
            {
                MiroModelV1 modelA = GetMiroModelA();
                _modelSetting = modelA.GetComponent <MiroV1ModelSetting> ();
                SetSourceTFFromENGenerator(modelA);

                Transform      tfB        = _pumpCtrl.GetAnchorTFB();
                Lyu.KeepOffset keepOffset =
                    tfB.GetComponent <Lyu.KeepOffset> ();
                Transform tfBAnchor = keepOffset._Anchor;
                SetTarget(tfBAnchor);
            }
        }
Exemplo n.º 12
0
        // 当前吸收量:当前正在吸收到敌方的攻击力的量
        // 只有当自己处于><阵型,且背对正在攻击或支援攻击的地方时,
        // 才能吸收到敌方攻击力,该数值<=吸收能力
        // 若为空格,返回-1
        public int GetAbsorbingAmtAt(Hex coord)
        {
            MiroModelV1 model = _GridCtrl.GetMiroModelAt(coord);

            if (model == null)
            {
                return(-1);
            }
            int  amt        = 0;
            bool bHoleGrown = model._BlackHole.IsGrown();

            if (bHoleGrown)
            {
                amt = model.GetAbsorbingAmt();
            }
            return(amt);
        }
Exemplo n.º 13
0
        void AddAbsorbingAttacking(MiroModelV1 modelAbsorber)
        {
            if (!_absorbers.Contains(modelAbsorber))
            {
                _absorbers.Add(modelAbsorber);
            }

            List <MiroV1BulletEmitterBase> ems = GetONNotAbsorbedEmitters();

            if (modelAbsorber._BlackHole._BlackHole == null)
            {
                print("modelAbsorber._BlackHole._BlackHole == null");
            }
            List <MiroV1AbsorbPoint> absPs =
                modelAbsorber._BlackHole._BlackHole.GetAbsorbingPos();

            LinkEmittersToAbsorbingPoss(ems, absPs);
        }
Exemplo n.º 14
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);
        }
Exemplo n.º 15
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);
        }
Exemplo n.º 16
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);
            }
        }
Exemplo n.º 17
0
        override protected void _Calculate()
        {
            bool bCtrlling = CellObjCtrlUtils.IsControllingObj(_cellCtrl);

            if (!bCtrlling)
            {
                return;
            }
            MiroModelV1 modelMe =
                _cellCtrl._TgtObj.GetComponent <MiroModelV1> ();

            modelMe._bTurnMainWeaponByEN = false;

            bool bFwdEmpty   = CellObjCtrlUtils.IsNbEmpty(_cellCtrl, 0);
            bool bFwdEnemy   = CellObjCtrlUtils.IsNbEnemy(_cellCtrl, 0);
            bool bBackToBack = CellObjCtrlUtils.IsBackToBack(_cellCtrl);
            int  en          = bBackToBack ? 3 : 1;

            if (bFwdEmpty || bFwdEnemy)
            {
                SetEN(modelMe, en);
                return;
            }

            bool bFwdFriend = CellObjCtrlUtils.IsNbSameCamp(_cellCtrl, 0);

            if (bFwdFriend)
            {
                CellObjCtrl fwdCtrl          = CellObjCtrlUtils.GetNbCellObjCtrl(_cellCtrl, 0);
                bool        bFriendFaceEnemy = CellObjCtrlUtils.IsNbEnemy(fwdCtrl, 0);
                bool        bFriendFaceEmpty = CellObjCtrlUtils.IsNbEmpty(fwdCtrl, 0);
                bool        bFriendAttack    = (bFriendFaceEnemy || bFriendFaceEmpty);
                if (bFriendAttack)
                {
                    SetEN(modelMe, en);
                }
                else
                {
                    SetEN(modelMe, 0);
                }
            }
        }
Exemplo n.º 18
0
        private MiroModelV1 GetModelFromCellObj(GameObject Obj)
        {
            MiroModelV1 model = null;

            if (Obj == null)
            {
                return(model);
            }

            CellObjCtrl cctrl =
                Obj.GetComponent <CellObjCtrl> ();

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

            model = cctrl._TgtObj.GetComponent <MiroModelV1> ();
            return(model);
        }
Exemplo n.º 19
0
        private void ConfigureHole2(MiroModelV1 model, bool bFaceToFace)
        {
            if (bFaceToFace)
            {
                model._BlackHole.IsGrown();
            }
            bool IsGrown = model._BlackHole.IsGrown();

            bool bToGrow   = (!IsGrown && bFaceToFace);
            bool bToShrink = (IsGrown && !bFaceToFace);

            if (bToGrow)
            {
                model._BlackHole._GrowUpTrigger = true;
            }
            else if (bToShrink)
            {
                model._BlackHole._ShrinkTrigger = true;
            }
        }
Exemplo 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();
                }
            }
        }
Exemplo 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);
            }
        }
Exemplo 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);
            }
        }
Exemplo 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();
            }
        }
Exemplo 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);
        }
Exemplo n.º 25
0
        public bool TurnDynamicsAt(Hex coord, bool bON)
        {
            MiroModelV1 model =
                _GridCtrl.GetMiroModelAt(coord);

            if (model == null)
            {
                return(false);
            }
            else
            {
                MiroModelDynamicsCtrl dynCtrl = model.GetComponent <MiroModelDynamicsCtrl> ();
                if (dynCtrl == null)
                {
                    return(false);
                }
                else
                {
                    dynCtrl.TurnAllDynamics(bON);
                    return(true);
                }
            }
        }
Exemplo n.º 26
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);
            }
        }
Exemplo n.º 27
0
 static void SetWeaponAT(MiroModelV1 modelMe, int dir, int at)
 {
     //modelMe._WeaponSlots [dir]._ATMax = at;
     //modelMe._WeaponSlots [dir]._AT = at;
     modelMe._WeaponSlots [dir].SetATImmediate(at, at);
 }
Exemplo n.º 28
0
        void ConfigAttack()
        {
            bool bCtrlling = CellObjCtrlUtils.IsControllingObj(_cellCtrl);

            if (!bCtrlling)
            {
                return;
            }
            MiroModelV1 modelMe = _cellCtrl._TgtObj.GetComponent <MiroModelV1> ();

            modelMe.ResetEmitterTrigger();
            // to avoid petrification 防止固化
            //modelMe._bTurnMainWeaponByEN = false;

            /*
             * int mhp = modelMe.GetMaxHP ();
             * bool bAlive = true;
             * if (mhp > 0) {
             *      int atkrCnt = modelMe.GetAttackersCount ();
             *      bAlive = (atkrCnt < mhp);
             * }*/

            bool bAlive = modelMe.IsAlive();

            bool bFwdEmpty        = CellObjCtrlUtils.IsNbEmpty(_cellCtrl, 0);
            bool bFwdEnemy        = CellObjCtrlUtils.IsNbEnemy(_cellCtrl, 0);
            bool bShouldAttacking = (bFwdEmpty || bFwdEnemy) && bAlive;

            if (bShouldAttacking)
            {
                //Debug.Log (_cellCtrl + " should attacking!");
            }
            bool bAttacking = modelMe.IsAttacking();

            if (bAttacking)
            {
                //Debug.Log (_cellCtrl + " is attacking!");
            }
            // main weapon
            bool StartAttacking = (bShouldAttacking && !bAttacking);
            bool StopAttacking  = (bAttacking && !bShouldAttacking);
            bool IsAttacking    = bAttacking && bShouldAttacking;
            int  atMain         = bShouldAttacking ? modelMe._ENGenerator._EN : 0;

            if (StartAttacking)
            {
                //Debug.Log ("StartAttacking at=" + atMain + " of " +  _cellCtrl._TgtObj);
                modelMe._WeaponSlots [0].ActivateImmediate();
                SetWeaponAT(modelMe, 0, atMain);
            }
            else
            if (StopAttacking)
            {
                //Debug.Log ("StopAttacking: at=" + atMain+ " of " +  _cellCtrl._TgtObj);
                SetWeaponAT(modelMe, 0, atMain);
                modelMe._WeaponSlots [0].Shrink();;
            }
            else
            if (IsAttacking)
            {
                //Debug.Log ("IsAttacking: at=" + atMain+ " of " +  _cellCtrl._TgtObj);
                SetWeaponAT(modelMe, 0, atMain);
            }
            else
            {
                //print ("Not Attack! " + " ShouldAtt" +  bShouldAttacking + " Atting" + bAttacking + " " + _cellCtrl._TgtObj);
                //print ("Dir:" + _cellCtrl._Dir);

                /*
                 * if (_cellCtrl._Dir == 5) {
                 * bFwdEmpty = CellObjCtrlUtils.IsNbEmpty (_cellCtrl,0);
                 * bFwdEnemy = CellObjCtrlUtils.IsNbEnemy (_cellCtrl,0);
                 * }*/}
            // sub weapons
            for (int dir = 1; dir < 6; dir++)
            {
                bool bAssistingAT = CellObjCtrlUtils.IsNbAssistingAT(_cellCtrl, dir);
                //bool bNbAlive = CellObjCtrlUtils.IsNb
                bAssistingAT = bAssistingAT && bAlive;
                MiroModelV1 nbModel = CellObjCtrlUtils.GetNbModel(_cellCtrl, dir);
                int         en      = 0;
                if (nbModel != null)
                {
                    en = nbModel._ENGenerator._EN;                     // Change to Support;
                }
                if (bAssistingAT)
                {
                    modelMe._WeaponSlots [dir].ActivateImmediate();
                    SetWeaponAT(modelMe, dir, en);
                }
                else
                {
                    modelMe._WeaponSlots [dir].Shrink();
                    SetWeaponAT(modelMe, dir, 0);
                }
            }
        }
Exemplo n.º 29
0
		void ShrinkFarm2 (CellObjCtrl ctrl)
		{
			MiroModelV1 model = CellObjCtrlUtils.GetMiroModelFromCell (ctrl);
			model.ShrinkFarm2 ();
			RemoveFarmRecord (_cellCtrl);
		}
Exemplo n.º 30
0
        // 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);
        }