public void Damage() { int damage = player1.Attack(enemy1); Assert.AreEqual(20, damage); Assert.AreEqual(30, enemy1.GetHP()); damage = enemy1.Attack(player1); Assert.AreEqual(10, damage); Assert.AreEqual(90, player1.GetHP()); }
static public float GetHpPercent(uint objId) { BaseScene scn = SceneManager.Instance.GetCurScene(); if (scn == null) { return(0.0f); } ObjectBase obj = scn.FindObject(objId); if (obj == null) { return(0.0f); } BattleUnit npc = (BattleUnit)obj; return((float)npc.GetHP() / npc.GetMaxHP()); }
void onPlayerFightPropChange(EventBase e) { if (!mEnable) { return; } PropertyEvent evt = (PropertyEvent)e; BattleUnit unit = PlayerController.Instance.GetControlObj() as BattleUnit; if (unit.GetMaxHP() <= 0) { mSprite.alpha = 0.0f; } else { mHpScale = (float)unit.GetHP() / (float)unit.GetMaxHP(); if (mHpScale <= mOpenScalse) { float alpha = (mOpenScalse - mHpScale) / mOpenScalse + mBeginAlpha; if (!mBeginFlicker) { mSprite.alpha = mCurAlpha = mBeginAlpha; mBeginFlicker = true; } //mLastAlpha = 1.0f; } else { mSprite.alpha = 0.0f; mBeginFlicker = false; } } }
protected override void OnStateChangeToClosing() { base.OnStateChangeToClosing(); mBattleUIModule.ShowTimer(false); RemoveAllActionFlag(); mParam.guid = mModule.GetGhostGuid(); if (mParam.guid == null) { SceneManager.Instance.RequestEnterLastCity(); return; } if (mResult < 0) { BattleUnit unit = PlayerController.Instance.GetControlObj() as BattleUnit; if (unit == null) { SceneManager.Instance.RequestEnterLastCity(); return; } float mMainRate = (float)unit.GetHP() / (float)unit.GetMaxHP(); float mGhostRate = (float)mGhost.GetHP() / (float)mGhost.GetMaxHP(); if (mMainRate > mGhostRate) { mResult = 1; } else { mResult = 0; } } if (mResult == 0) { mModule.Win = false; if (mGhost != null && !mGhost.IsDead()) { mGhost.GetStateController().DoAction(mAnimParam); } } else if (mResult == 1) { mModule.Win = true; mResult = 1; Player player = PlayerController.Instance.GetControlObj() as Player; if (player != null && !player.IsDead()) { player.GetStateController().DoAction(mAnimParam); } } mParam.result = mResult; Net.Instance.DoAction((int)Message.MESSAGE_ID.ID_MSG_ARENA_END, mParam, false); WindowManager.Instance.OpenUI("pvpbalance", 0); }