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); } } }
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 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); } } }
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); }