// private void OnCrzay(EventBase e) // { // MaoStageCrazyEvent ev = e as MaoStageCrazyEvent; // if (ev == null) // return; // // Crzay(ev.Crazy); // // if(ev.Crazy) // { // mCrazyBeginAni.SetActive(true); // mCrazyEndAni.SetActive(false); // mCrazyBeginAni.GetComponent<UIPlayTween>().Play(true); // } // else // { // mCrazyBeginAni.SetActive(false); // mCrazyEndAni.SetActive(true); // mCrazyEndAni.GetComponent<UIPlayTween>().Play(true); // } // } // // private void Crzay(bool crazy) // { // if(crazy) // { // mAngerEffect.SetActive(true); // mFace.gameObject.SetActive(false); // mFaceCrazy.gameObject.SetActive(true); // } // else // { // mAngerEffect.SetActive(false); // mFace.gameObject.SetActive(true); // mFaceCrazy.gameObject.SetActive(false); // } // } private void OnUpdateTargetPos(EventBase e) { MaoStageUpdateTargetPosEvent ev = e as MaoStageUpdateTargetPosEvent; if (ev == null) { return; } if (WindowManager.current2DCamera == null) { return; } if (CameraController.Instance == null) { return; } mTarget.SetActive(true); Vector3 pos = CameraController.Instance.WorldToScreenPoint(ev.CatPos); pos.z = 0.0f; pos = WindowManager.current2DCamera.ScreenToWorldPoint(pos); Vector3 dir = pos; dir.Normalize(); if (dir.magnitude < 0.000001f) { return; } mTargetCatArrow.transform.localRotation = Quaternion.FromToRotation(new Vector3(0.0f, 1.0f, 0.0f), dir); }
public override void OnBeHit(uint whoId, float value) { base.OnBeHit(whoId, value); if (!mIsFighting) { return; } if (mState != BATTLE_STATE.STATE_1) { return; } SetAngerValue(mAngerValue + value * mDamageToAnger); mMoneyValue += value * mDamageToMoney; while (mMoneyValue > MAX_MONEY_VALUE) { mMoneyValue -= MAX_MONEY_VALUE; CreateGold(); } MaoStageUpdateTargetPosEvent e = new MaoStageUpdateTargetPosEvent(); e.CatPos = mOwner.GetPosition(); EventSystem.Instance.PushEvent(e); mStateTime += 32; switch (mState) { case BATTLE_STATE.STATE_1: { if (mAngerValue >= MAX_ANGER_VALUE) { ChangeState(BATTLE_STATE.STATE_2); } else { if (IsTimerTrigger(1, mTimerStandIntervalMin, mTimerStandIntervalMax)) { if (BeginCommand(1000)) { AddCommand(new AIGoalStand(this, mStandTimeMin, mStandTimeMax)); } ResetTimer(1); } if (IsTimerTrigger(0, mTimerUseSkillIntervalMin, mTimerUseSkillIntervalMax)) { if (BeginCommand(9000)) { if (mSkillList1.Count > 0) { int index = BaseAI.Random(0, mSkillList1.Count); int skillid = mSkillList1[index]; AddCommand(new AIGoalUseSkillToTarget(this, GetID(), skillid)); } ResetTimer(0); } } } } break; case BATTLE_STATE.STATE_2: { if (BeginCommand(10000)) { OnCrazy(true); AddCommand(new AIGoalAddBuff(this, GetEnemyPlayerId(), mBuffIdToPlayer)); // 把角色变身,不能攻击 AddCommand(new AIGoalAddBuff(this, GetID(), mBuffIdToBoss)); AddCommand(new AIGoalUseSkillToTarget(this, GetID(), mSkillId)); // 给自己添加狂暴效果 ChangeState(BATTLE_STATE.STATE_3); } } break; case BATTLE_STATE.STATE_3: { if (EmptyCommand()) { CreateJieYao(); ChangeState(BATTLE_STATE.STATE_4); } } break; case BATTLE_STATE.STATE_4: { if (mStateTime > mFrenzyMaxTime || mFindJieYao) { ChangeState(BATTLE_STATE.STATE_5); } else { float v = MAX_ANGER_VALUE / mFrenzyMaxTime * 32; if (mAngerValue > v) { SetAngerValue(mAngerValue - v); } else { SetAngerValue(0); } if (BeginCommand(100)) { // 进行战斗 if (mSkillList2.Count > 0) { int index = BaseAI.Random(0, mSkillList2.Count); int skillid = mSkillList2[index]; uint mainTargetId = GetCurrentTargetId(); AddCommand(new AIGoalApproachTarget(this, mainTargetId, BaseAI.GetSkillMaxRangle(skillid) * 0.95f)); AddCommand(new AIGoalUseSkillToTarget(this, mainTargetId, skillid)); } } } } break; case BATTLE_STATE.STATE_5: { mFindJieYao = false; if (BeginCommand(10000)) { AddCommand(new AIGoalRemoveBuff(this, GetID(), mBuffIdToBoss)); // 移除狂暴效果 AddCommand(new AIGoalRemoveBuff(this, GetEnemyPlayerId(), mBuffIdToPlayer)); // 把角色变为正常 ChangeState(BATTLE_STATE.STATE_6); } } break; case BATTLE_STATE.STATE_6: { if (EmptyCommand()) { OnCrazy(false); SetAngerValue(0); ChangeState(BATTLE_STATE.STATE_1); } } break; default: break; } if (TimerLeftMillisecond(0) > 1000 && TimerLeftMillisecond(1) > 1000) { if (BeginCommand(200)) { AddCommand(new AIGoalRun(this, CaleMovePosition())); } } }