static private void SClearRing(List <Transform> RingObjsTFs) { List <MiroModelV1> ringObjMiros = new List <MiroModelV1> (); foreach (Transform tf in RingObjsTFs) { MiroModelV1 miro = tf.GetComponent <MiroModelV1> (); if (miro != null) { ringObjMiros.Add(miro); } } for (int i = _Rings.Count - 1; i >= 0; i--) { var rc = _Rings [i]; List <MiroModelV1> miros = new List <MiroModelV1> (); foreach (CellObjCtrl ctrl in rc) { MiroModelV1 miro = CellObjCtrlUtils.GetMiroModelFromCell(ctrl); if (miro != null) { miros.Add(miro); } } bool bSame = Lyu.DataStructureUtils.ContainsSame <MiroModelV1> (miros, ringObjMiros); if (bSame) { _Rings.RemoveAt(i); break; } } }
static public List <MiroModelV1> GetNbEnemiesPointToThis(CellObjCtrl ctrl) { List <MiroModelV1> enemies = new List <MiroModelV1> (); for (int dir = 0; dir < 6; dir++) { CellObjCtrl nbCtrl = CellObjCtrlUtils.GetNbCellObjCtrl(ctrl, dir); if (nbCtrl == null) { continue; } CellObjCtrl nbCtrlFwdCtrl = CellObjCtrlUtils.GetFwdCellObjCtrl(nbCtrl); if (nbCtrlFwdCtrl != ctrl) { continue; } MiroModelV1 nbModel = CellObjCtrlUtils.GetMiroModelFromCell(nbCtrl); bool bEnemy = IsNbEnemy(ctrl, dir); if (bEnemy) { enemies.Add(nbModel); } } return(enemies); }
// Update is called once per frame void Update() { MiroModelV1 model = CellObjCtrlUtils.GetMiroModelFromCell(_CCtrl); if (model == null) { _bON = false; } else { int movePwr = model.GetMovePwr(); _bON = (movePwr > 0); } CircleCollider2D cld = GetComponent <CircleCollider2D> (); cld.enabled = _bON; if (_bONPrev != _bON) { _bONChanged.Invoke(); _bONPrev = _bON; } }
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); }
public void ClearMovePwr() { if (_TgtObj != null) { MiroModelV1 model = CellObjCtrlUtils.GetMiroModelFromCell(this); model.ClearMovePwr(); } }
public void IncMovePwr() { if (_TgtObj != null) { MiroModelV1 model = CellObjCtrlUtils.GetMiroModelFromCell(this); model.MovePwrInc1(); Debug.Log(model + " inc move power"); } }
void ExhaustRotLeftPower() { if (_bExhaustRotPwr) { MiroModelV1 model = CellObjCtrlUtils.GetMiroModelFromCell(this); if (model != null) { model.AddRotLeftPwr(-1); } } }
void DeConfigAbsorbing() { MiroModelV1 modelMe = CellObjCtrlUtils.GetMiroModelFromCell(_cellCtrl); if (modelMe == null) { return; } modelMe.ReleaseAbsorbing(); }
public void UpdateRotation() { if (_movFwdUI._bON) { MiroModelV1 model = CellObjCtrlUtils.GetMiroModelFromCell(_cctrl); if (model != null) { transform.rotation = model.transform.rotation; } } }
void ExhaustMovePower() { if (_bExhaustMovePwr) { MiroModelV1 model = CellObjCtrlUtils.GetMiroModelFromCell(this); if (model != null) { model.AddMovePwr(-1); print("model.AddMovePwr (-1);"); } } }
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(); } }
// absorbing configuration void ConfigAbsorbing() { //int bwdDir = _cellCtrl.GetBwdDir (); MiroModelV1 modelMe = CellObjCtrlUtils.GetMiroModelFromCell(_cellCtrl); CellObjCtrl fwdCtrl = CellObjCtrlUtils.GetFwdCellObjCtrl(_cellCtrl); MiroModelV1 modelFwd = CellObjCtrlUtils.GetMiroModelFromCell(fwdCtrl); ConfigureHole2(modelMe, true); ConfigureHole2(modelFwd, true); MiroV1PlacementMgr.ConfigAbsorbingForTF(_cellCtrl.transform); MiroV1PlacementMgr.ConfigAbsorbingForTF(fwdCtrl.transform); }
// 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; } } }
public int GetMovePwr() { if (_TgtObj != null) { MiroModelV1 model = CellObjCtrlUtils.GetMiroModelFromCell(this); int movePwr = model.GetMovePwr(); return(movePwr); } else { return(-1); } }
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); } }
void DeConfigAbsorbCtrls() { foreach (var ctrl in _AbsorbingCtrls) { MiroModelV1 model = CellObjCtrlUtils.GetMiroModelFromCell(ctrl); if (model == null) { continue; } model.ReleaseAbsorbing(); } _AbsorbingCtrls.Clear(); }
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); }
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); }
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); } }
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(); } } }
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); } }
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); } }
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(); } }
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); }
// 支援攻击力: 若棋子正在支援友军攻击, // 则本数值==增强友军攻击力的加成数值==眼睛中彩色点数量-被敌方吸收掉的攻击 // 若为空格,返回-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); } }
void ShrinkFarm2 (CellObjCtrl ctrl) { MiroModelV1 model = CellObjCtrlUtils.GetMiroModelFromCell (ctrl); model.ShrinkFarm2 (); RemoveFarmRecord (_cellCtrl); }
public void PlaceRing() { //print ("PlaceRing!"); foreach (var item in _ctrls) { _ctrlLst.Add(item.Key); } List <List <CellObjCtrl> > currentRings = new List <List <CellObjCtrl> > (); DetectRingCtrlsLst(ref currentRings); // detect obsolete rings List <List <CellObjCtrl> > obsoleteRings = new List <List <CellObjCtrl> > (); for (int i = _Rings.Count - 1; i >= 0; i--) { var ringObjs = _Rings [i]; bool bExist = false; for (int j = currentRings.Count - 1; j >= 0; j--) { var newRingObjs = currentRings [j]; bExist = Lyu.DataStructureUtils.ContainsSame <CellObjCtrl> (ringObjs, newRingObjs); if (bExist) { break; } } if (!bExist) { obsoleteRings.Add(ringObjs); _Rings.RemoveAt(i); } } // detect new rings List <List <CellObjCtrl> > newCreateRings = new List <List <CellObjCtrl> > (); for (int i = currentRings.Count - 1; i >= 0; i--) { var ringObjs = currentRings [i]; bool bExist = false; for (int j = _Rings.Count - 1; j >= 0; j--) { var existRObjs = _Rings [j]; bExist = Lyu.DataStructureUtils.ContainsSame <CellObjCtrl> (ringObjs, existRObjs); if (bExist) { break; } } if (!bExist) { newCreateRings.Add(ringObjs); _Rings.Add(ringObjs); } } //delete obsolete rings foreach (var lstCtrl in obsoleteRings) { //print ("Delete Ring:" + lstCtrl); MiroModelV1 miro = CellObjCtrlUtils.GetMiroModelFromCell(lstCtrl [0]); miro.ShrinkRing(); } // create new ring foreach (var lstCtrl in newCreateRings) { //print ("new Ring:" + lstCtrl); List <GameObject> rObjs = new List <GameObject> (); foreach (CellObjCtrl ctrl in lstCtrl) { rObjs.Add(ctrl._TgtObj); } _mgr.CreateRing(rObjs); } //_Rings = currentRings; ClearContainers(); }
public static bool ShouldBeingAbsorbedToDir(CellObjCtrl cctrl, int relativeDir) { if (cctrl == null) { return(false); } bool bAttacking = CellObjCtrlUtils.ShouldAttacking(cctrl); bool bAssisting = CellObjCtrlUtils.ShouldAssistingAttacking(cctrl); if (!(bAttacking || bAssisting)) { return(false); } CellObjCtrl nbCtrl = CellObjCtrlUtils.GetNbCellObjCtrl(cctrl, relativeDir); if (nbCtrl == null) { return(false); } bool bIsEnemy = CellObjCtrlUtils.IsNbEnemy(cctrl, relativeDir); if (!bIsEnemy) { return(false); } CellObjCtrl nbBwdCtrl = CellObjCtrlUtils.GetNbCellObjCtrl(nbCtrl, 3); if (nbBwdCtrl == null) { return(false); } bool bNbBackToMe = (nbBwdCtrl == cctrl); if (!bNbBackToMe) { return(false); } MiroModelV1 nbModel = CellObjCtrlUtils.GetMiroModelFromCell(nbCtrl); bool bNbAlive = nbModel.IsAlive(); if (!bNbAlive) { return(false); } bool bNbFaceToFace = CellObjCtrlUtils.IsFaceToFace(nbCtrl); if (!bNbFaceToFace) { return(false); } CellObjCtrl nbFwdCtrl = CellObjCtrlUtils.GetFwdCellObjCtrl(nbCtrl); MiroModelV1 nbFwdModel = CellObjCtrlUtils.GetMiroModelFromCell(nbFwdCtrl); if (!nbFwdModel.IsAlive()) { return(false); } return(true); }
public MiroModelV1 GetMiroModelAt(Hex hex) { CellObjCtrl cctrl = GetCellCtrlAt(hex); return(CellObjCtrlUtils.GetMiroModelFromCell(cctrl)); }