public static Vector3 getFaceOffPosition(ETeamPosition aPosition,EMonsterPos aMonster,Vector3 aOffset) { float faceOffNegator = -1.5f; switch(aPosition) { case(ETeamPosition.LeftTeam):default: switch(aMonster) { case(EMonsterPos.Top): return new Vector3(POSITION_TEAM1_1.x+aOffset.x,POSITION_TEAM1_1.y+aOffset.y,POSITION_TEAM1_1.z+faceOffNegator+aOffset.z); break; case(EMonsterPos.Front):default: return new Vector3(POSITION_TEAM1_MIDDLE.x+aOffset.x,POSITION_TEAM1_MIDDLE.y+aOffset.y,POSITION_TEAM1_MIDDLE.z+faceOffNegator+aOffset.z); break; case(EMonsterPos.Bottom): return new Vector3(POSITION_TEAM1_2.x+aOffset.x,POSITION_TEAM1_2.y+aOffset.y,POSITION_TEAM1_2.z+faceOffNegator+aOffset.z); break; } break; case(ETeamPosition.RightTeam): switch(aMonster) { case(EMonsterPos.Top): return new Vector3(POSITION_TEAM2_1.x+aOffset.x,POSITION_TEAM2_1.y+aOffset.y,POSITION_TEAM2_MIDDLE.z-faceOffNegator+aOffset.z); break; case(EMonsterPos.Front):default: return new Vector3(POSITION_TEAM2_MIDDLE.x+aOffset.x,POSITION_TEAM2_MIDDLE.y+aOffset.y,POSITION_TEAM2_MIDDLE.z-faceOffNegator+aOffset.z); break; case(EMonsterPos.Bottom): return new Vector3(POSITION_TEAM2_2.x+aOffset.x,POSITION_TEAM2_2.y+aOffset.y,POSITION_TEAM2_2.z-faceOffNegator+aOffset.z); break; } break; } }
public override void initMonster(MonsterDataMain aMonsterRef,EMonsterPos aMyPosition) { base.initMonster(aMonsterRef,aMyPosition); this._monsterRef.onStatusEffectAdded += onNewStatusEffect; this._monsterRef.onStatusEffectRemoved += onRemoveStatusEffect; this._monsterRef.onStatusEffectsHPByPercentage += onStatusEffectsHP; this._monsterRef.onStatusEffectsHPWithMove += onStatusEffectsHP; }
public MoveQueueItem(float aSpeed,MoveLibItem aMoveData,ETeamPosition aTargetTeam,EMonsterPos aTargetMonster,EMonsterPos aActionMonsterPosition) { _forcedSpeed = aSpeed; _useThisMove = aMoveData; targetTeam = aTargetTeam; targetMonster = aTargetMonster; actionPosition = aActionMonsterPosition; firstHit = true; }
public MoveQueueItem(ItemBait aBait,EMonsterCatchResult aResult) { _forcedSpeed = float.MaxValue; _useThisMove = null; targetTeam = ETeamPosition.RightTeam; targetMonster = EMonsterPos.Unset; actionPosition = EMonsterPos.Unset; baitItem = aBait; baitResult = aResult; firstHit = true; }
public MoveQueueItem(float aSpeed,SelectedMoveData aMoveData,ETeamPosition aTargetTeam,EMonsterPos aTargetMonster,BattleMonsterWithMoves aActionMonster,EMonsterPos aActionMonsterPosition) { _speed = aSpeed; _move = aMoveData; _actionMonster = aActionMonster; targetTeam = aTargetTeam; targetMonster = aTargetMonster; actionPosition = aActionMonsterPosition; // Multi hit moves timesToHit = 1; firstHit = true; }
public void applyHPBoostForMove(MoveLibItem aItem,float aSplashPercent,ETeamPosition aTeamPosition,EMonsterPos aPosition) { float boostHP = 0f; switch(aItem.powerApplicationType) { case(EPowerApplicationTypes.Normal): //TODO Do normal power formula for boosting this monsters health break; case(EPowerApplicationTypes.PowerIsPercentOfHP): boostHP = (aItem.power/100)*this.monster.MaxHP; break; } if(boostHP>0f) { this.addHP(boostHP,aTeamPosition,aPosition); doCommentaryMessage(this.name+" healed by "+aItem.Name,ECommentaryMessageType.HealMessage); } }
private void onCommentaryMessage(string aMessage,ECommentaryMessageType aMessageType,EMonsterPos aPosition,ETeamPosition aTeam) { switch(aMessageType) { case(ECommentaryMessageType.DmgInEffective): this._commentaryManager.addCommentaryInEffectiveMessage(aMessage,teamFromPosition(aTeam).monsterFromPosition(aPosition).gameObject); break; case(ECommentaryMessageType.DmgEffective): this._commentaryManager.addCommentaryEffectiveMessage(aMessage,teamFromPosition(aTeam).monsterFromPosition(aPosition).gameObject); break; case(ECommentaryMessageType.StandardMessage): this._commentaryManager.addCommentaryMessage(aMessage,aMessageType,ECommentaryMessagePosition.CenterMessage); break; case(ECommentaryMessageType.DamageMessage): this._commentaryManager.addCommentaryMessage(aMessage,aMessageType,aTeam,aPosition,teamFromPosition(aTeam).monsterFromPosition(aPosition).gameObject); break; case(ECommentaryMessageType.DmgCritical): this._commentaryManager.addCommentaryMessage(aMessage,aMessageType,aTeam,aPosition,teamFromPosition(aTeam).monsterFromPosition(aPosition).gameObject); break; } }
public void initMonster(MonsterDataMain aMonsterRef,EMonsterPos aMyPosition) { base.initMonster(aMonsterRef,aMyPosition); this.ownersName = aMonsterRef.ownersName; moveDataRef = new SelectedMoveData[aMonsterRef.selectedMoves.size]; for(int i = 0;i<aMonsterRef.selectedMoves.size;i++) { moveDataRef[i] = aMonsterRef.selectedMoves[i]; for(int j = 0;j<3;j++) { if(moveDataRef[i].moveData!=null) { GameObject g = moveDataRef[i].moveData.attackAnimationPrefab; if(g!=null) { g.SetActive(false); MoveAnimationLibItem.putBackParticles(g); } g = moveDataRef[i].moveData.attackAnimationHitPrefab; if(g!=null) { g.SetActive(false); MoveAnimationLibItem.putBackParticles(g); } } } } }
public void takeHP(float aDamage,ETeamPosition aTeamPosition,EMonsterPos aMonsterPosition,bool aCriticalApplied = false) { moveFlags = moveFlags | EMoveFlag.HealthChanging; if(aDamage>this._monsterRef.hp) { aDamage = this._monsterRef.hp; } this.hp -= aDamage; StartCoroutine(doneHPChange()); this.doCommentaryMessage(Convert.ToInt32(aDamage).ToString()+"",ECommentaryMessageType.DamageMessage); if(aCriticalApplied) { this.doCommentaryMessage("Decisive Blow on "+this.name,ECommentaryMessageType.DmgCritical); } }
public void addEnergy(float aEnergy,ETeamPosition aTeamPosition,EMonsterPos aMonsterPosition) { if(aEnergy>0f) { moveFlags = moveFlags | EMoveFlag.EnergyChanging; this.energy += aEnergy; GameObject restore = getEffect("RestoreEnergy"); if(restore!=null) restore.transform.position = this.SpawnPosition; StartCoroutine(doneEnergyChange()); this.doCommentaryMessage(aEnergy+"",ECommentaryMessageType.HealMessage); } }
public void addHP(float aHeal,ETeamPosition aTeamPosition,EMonsterPos aMonsterPosition) { if(aHeal>0f) { this.doCommentaryMessage(aHeal+"",ECommentaryMessageType.HealMessage);this.hp += aHeal; moveFlags = moveFlags | EMoveFlag.HealthChanging; StartCoroutine(doneHPChange()); GameObject restore = getEffect("RestoreHealth"); if(restore!=null) restore.transform.position = this.SpawnPosition; this.doCommentaryMessage(aHeal+"",ECommentaryMessageType.HealMessage); } }
public BetterList<BattleMonster> getTargetsForMove(EMonsterPos aPrimaryTarget,MoveLibItem aMove) { if(((aMove.splashRange&ESplashRange.AllHits)==0)&&(aMove.splashRange!=0)) { return new BetterList<BattleMonster>(); } BetterList<BattleMonster> ms = this.monstersAsBattleMonster; if(ms.size==0) { return new BetterList<BattleMonster>(); } int splashRange = (int) aMove.splashRange; BetterList<BattleMonster> r = new BetterList<BattleMonster>(); if(aMove.splashRange==ESplashRange.RandomOpponent) { int randomItem = (int) (BattleRandomizer.random*ms.size); r.Add(ms[randomItem]); return r; } int primTarget = (int) aPrimaryTarget; switch(aPrimaryTarget) { case(EMonsterPos.Front):case(EMonsterPos.Unset): { r.Add(ms[BattleConstants.FRONT_INDEX]); if(aMove.splashRange==ESplashRange.HitAll||aMove.splashRange==ESplashRange.SplashRange1) { // Middle monster has no splash range 1, only lessened damage to splashers r.Add(ms[BattleConstants.TOP_INDEX]); r.Add(ms[BattleConstants.BOTTOM_INDEX]); } } break; case(EMonsterPos.Top): { r.Add(ms[BattleConstants.TOP_INDEX]); if(aMove.splashRange==ESplashRange.HitAll||aMove.splashRange==ESplashRange.SplashRange1) { r.Add(ms[BattleConstants.FRONT_INDEX]); if(aMove.splashRange==ESplashRange.HitAll) r.Add (ms[BattleConstants.BOTTOM_INDEX]); } } break; case(EMonsterPos.Bottom): { r.Add(ms[BattleConstants.BOTTOM_INDEX]); if(aMove.splashRange==ESplashRange.HitAll||aMove.splashRange==ESplashRange.SplashRange1) { // Middle monster has no splash range 1, only lessened damage to splashers r.Add(ms[BattleConstants.FRONT_INDEX]); if(aMove.splashRange==ESplashRange.HitAll) r.Add (ms[BattleConstants.TOP_INDEX]); } } break; } // Remove those with no HP left r = cleanReturnTargets(r); if(r.size==0&&!this.teamIsDead) { // Aim downwards if we can switch(aPrimaryTarget) { case(EMonsterPos.Top): return getTargetsForMove(EMonsterPos.Bottom,aMove); case(EMonsterPos.Front): return getTargetsForMove(EMonsterPos.Top,aMove); case(EMonsterPos.Bottom): return getTargetsForMove(EMonsterPos.Front,aMove); } } return r; }
public EMonsterPos updatedTargetPosition(EMonsterPos aPosition) { BetterList<BattleMonster> ms = this.monstersAsBattleMonster; int i = 0; switch(aPosition) { case(EMonsterPos.Front):if(ms[BattleConstants.FRONT_INDEX]!=null&&ms[BattleConstants.FRONT_INDEX].monster.restingStatus==ERestingStatus.Awake) { return aPosition; } else { return updatedTargetPosition(EMonsterPos.Top); } break; case(EMonsterPos.Top):if(ms[BattleConstants.TOP_INDEX]!=null&&ms[BattleConstants.TOP_INDEX].monster.restingStatus==ERestingStatus.Awake) { return aPosition; } else { return updatedTargetPosition(EMonsterPos.Bottom); } break; case(EMonsterPos.Bottom):if(ms[BattleConstants.BOTTOM_INDEX]!=null&&ms[BattleConstants.BOTTOM_INDEX].monster.restingStatus==ERestingStatus.Awake) { return aPosition; } else { return updatedTargetPosition(EMonsterPos.Front); } break; } return aPosition; }
public BetterList<BattleMonster> getBoostTargetsForMove(EMonsterPos aPrimaryTarget,MoveLibItem aMove,BattleMonster aActioningMonster) { BetterList<BattleMonster> ms = this.monstersAsBattleMonster; BetterList<BattleMonster> r = new BetterList<BattleMonster>(); if(aMove==null) { Debug.LogError ("Move for "+aActioningMonster.name+" was "+aMove+". Monsters passive effect was: "+aActioningMonster.monster.passiveEffect.name); return r; } ESplashRange splashRange = aMove.splashRange; int boostInfo = (int) aMove.splashRange; if((splashRange&ESplashRange.AllBoosts)==0) { return new BetterList<BattleMonster>(); } if(aMove.splashRange==ESplashRange.Boost2) { for(int i = 0;i<ms.size;i++) { if(ms[i]!=aActioningMonster) { r.Add(ms[i]); } } r = cleanReturnTargets(r); return r; } switch(aPrimaryTarget) { case(EMonsterPos.Front): { r.Add(ms[BattleConstants.FRONT_INDEX]); if(aMove.splashRange==ESplashRange.BoostAll/*||aMove.splashRange==ESplashRange.Boost1*/) { // Middle monster has no splash range 1, only lessened damage to splashers r.Add(ms[BattleConstants.TOP_INDEX]); r.Add(ms[BattleConstants.BOTTOM_INDEX]); } } break; case(EMonsterPos.Top): { r.Add(ms[BattleConstants.TOP_INDEX]); if(aMove.splashRange==ESplashRange.BoostAll/*||aMove.splashRange==ESplashRange.Boost1*/) { r.Add(ms[BattleConstants.FRONT_INDEX]); if(aMove.splashRange==ESplashRange.BoostAll) r.Add (ms[BattleConstants.BOTTOM_INDEX]); } } break; case(EMonsterPos.Bottom): { r.Add(ms[BattleConstants.BOTTOM_INDEX]); if(aMove.splashRange==ESplashRange.BoostAll/*||aMove.splashRange==ESplashRange.Boost1*/) { // Middle monster has no splash range 1, only lessened damage to splashers r.Add(ms[BattleConstants.FRONT_INDEX]); if(aMove.splashRange==ESplashRange.BoostAll) r.Add (ms[BattleConstants.TOP_INDEX]); } } break; } r = cleanReturnTargets(r); if(r.size==0&&!this.teamIsDead) { // Aim downwards if we can switch(aPrimaryTarget) { case(EMonsterPos.Top): return getBoostTargetsForMove(EMonsterPos.Front,aMove,aActioningMonster); case(EMonsterPos.Front): return getBoostTargetsForMove(EMonsterPos.Bottom,aMove,aActioningMonster); case(EMonsterPos.Bottom): return getBoostTargetsForMove(EMonsterPos.Top,aMove,aActioningMonster); } } return r; }
public void addCommentaryMessage(string aMessage,ECommentaryMessageType aType,ETeamPosition aTeamPosition,EMonsterPos aMonsterPosition,GameObject aMonster) { BattleMonster bm = aMonster.GetComponent<BattleMonster>(); HUDText h = bm.healthBar.GetComponentInChildren<HUDText>(); if(h!=null) h.Add(aMessage,Color.blue,1f); else Debug.Log (aMonster); /* GameObject prefab; if(aType!=ECommentaryMessageType.DmgCritical) { prefab = NGUITools.AddChild(this.gameObject.transform.parent.gameObject,commentaryDamageMessage); } else { prefab = NGUITools.AddChild(this.gameObject.transform.parent.gameObject,this.commentaryDecisiveBlow); } UILabel label = prefab.GetComponent<UILabel>(); label.text = aMessage; // UIFollowTarget followTarget = prefab.GetComponent("UIFollowTarget") as UIFollowTarget; //UIFollowTarget followTarget = (UIFollowTarget) prefab.AddComponent<UIFollowTarget>(); /*followTarget.initTarget(aMonster.gameObject.transform);; if(aType==ECommentaryMessageType.DmgCritical) { followTarget.heightToAddPerFrame = 0f; followTarget.heightOffset = 30; } else { followTarget.heightToAddPerFrame = 2f; followTarget.heightOffset = 10; } prefab.transform.localScale = new Vector3(1f,1f,1f); TweenAlpha.Begin(prefab,damageFadeSpeed,0.0f); //TweenPosition.Begin(prefab,damageMoveSpeed,new Vector3(prefab.transform.position.x,prefab.transform.position.y+yDistance,prefab.transform.position.z)); Destroy(prefab,damageFadeSpeed);*/ }
// From passive effect public void applyHPEffectToTeam(PassiveEffect aEffect,BattleMonster aMonster,EMonsterPos aPositions) { if(containsMonster(aMonster)) { Debug.Log("NO HP Effect to apply"); } else { ESplashRange splash = aEffect.moveRef.splashRange; float splashPrecent = aEffect.moveRef.splashPercent; EMonsterPos target = EMonsterPos.Unset; BetterList<BattleMonster> targets = getTargetsForMove(target,aEffect.moveRef); for(byte c = 0;c<targets.size;c++) { if(c == 0) { applyHPEffectToMonster(aMonster,aEffect.moveRef,1.0f,targets[c],null,aPositions); } else { applyHPEffectToMonster(aMonster,aEffect.moveRef,splashPrecent,targets[c],null,aPositions); } } } }
public virtual void initMonster(MonsterDataMain aMonsterRef,EMonsterPos aMyPosition) { _monsterRef = aMonsterRef; if(aMonsterRef==null) { Debug.LogError("Trying to init monster to null monster"); } _myPosition = aMyPosition; createHealthBar(); }
public float applyPassiveEffectToMonsters(EWhenToApply aWhen,PassiveEffect aEffect,BattleMonster aPassiveEffectOwner,EMonsterPos aEffectOwnerPosition,MoveQueueItem aMoveQueueItem) { float delayAmount = 0f; if(aEffect.applyAt==aWhen) { if(this.containsMonster(aPassiveEffectOwner)) { // Check Splash on this passive effect BetterList<BattleMonster> monsters = new BetterList<BattleMonster>(); if(aMoveQueueItem!=null) monsters = this.getBoostTargetsForMove(positionForMonster(aPassiveEffectOwner),aEffect.moveRef,(BattleMonster) aMoveQueueItem.actioningMonster); else monsters = this.getBoostTargetsForMove(positionForMonster(aPassiveEffectOwner),aEffect.moveRef,aPassiveEffectOwner); if(aEffect.moveRef==null) { Debug.LogError("Passive effect for: "+aPassiveEffectOwner.name+" is "+aEffect.moveRef+" passive effect is: "+aPassiveEffectOwner.monster.passiveEffect.name); return 0f; } if(aEffect.moveRef.elementType!=ElementalLibrary.REF.getElement("Normal")) { // This passive effect can only be applied to monsters of type: aEffect.moveRef.elementType for(int i = 0;i<monsters.size;i++) { if(monsters[i].monster.elementType!=aEffect.moveRef.elementType) { monsters.RemoveAt(i); i--; } } for(int i = 0;i<monsters.size;i++) { monsters[i].applyStatEffectsFromMove(aEffect.moveRef,null,aEffect); delayAmount += monsters[i].applyStatusEffectsForMove(aEffect.moveRef,1,aEffect); this.applyHPBoostsToTeam(aEffect,aPassiveEffectOwner,aMoveQueueItem,this._position); if(aEffect.moveRef.decisiveBlowsImmunity>0f) { monsters[i].criticalHitImmune = true; } if(aEffect.moveRef.oneHitKillInvulnerable>0f) { monsters[i].oneHitKOImmune = true; } } } } else { BetterList<BattleMonster> monsters = this.getTargetsForMove(EMonsterPos.Unset,aEffect.moveRef); for(int i = 0;i<monsters.size;i++) { monsters[i].applyStatEffectsFromMove(aEffect.moveRef,null,aEffect); delayAmount += monsters[i].applyStatusEffectsForMove(aEffect.moveRef,1,aEffect); applyHPEffectToTeam(aEffect,aPassiveEffectOwner,aEffectOwnerPosition); } } } return delayAmount; }
public MoveQueueItem(ITMItem aItem,BattleMonsterWithMoves aActionMonster) { this._actionMonster = aActionMonster; _forcedSpeed = float.MaxValue; _useThisMove = null; targetTeam = ETeamPosition.RightTeam; targetMonster = EMonsterPos.Unset; actionPosition = EMonsterPos.Unset; usedItem = aItem; firstHit = true; }
private void initBattleMonsterGameObject(GameObject aMonster,MonsterDataMain aMonsterData,int aLayerOffset,EMonsterPos aPosition) { BattleMonster monster = aMonster.GetComponent("BattleMonster") as BattleMonster; if(monster==null) { aMonster.AddComponent<BattleMonster>(); BattleConstants.positionMonster(aMonster,this._position,positionForMonster(aMonster),GameObject.Find("BattleSetup").transform.position); monster = aMonster.GetComponent("BattleMonster") as BattleMonster; } monster.initMonster(aMonsterData,aPosition); monster.onFaintComplete += onFaintComplete; monster.onFainting += onFainting; monster.onIdle += onMonsterIdle; monster.onCommentaryMessage += onMonsterCommentary; monster.transform.parent = this.gameObject.transform; if(monster.monster==null) { Debug.LogError("Monster is null"); } }
public BattleMonster monsterFromPosition(EMonsterPos aPosition) { BetterList<BattleMonster> ms = this.monstersAsBattleMonster; if(aPosition==EMonsterPos.Top&&ms[BattleConstants.TOP_INDEX]!=null) { return ms[BattleConstants.TOP_INDEX]; } if(aPosition==EMonsterPos.Front&&ms[BattleConstants.FRONT_INDEX]!=null) { return ms[BattleConstants.FRONT_INDEX]; } if(aPosition==EMonsterPos.Bottom&&ms[BattleConstants.BOTTOM_INDEX]!=null) { return ms[BattleConstants.BOTTOM_INDEX]; } for(int i =0;i<ms.size;i++) { if(ms[i]!=null) { return ms[i]; } } return null; }
public void setFutureMove(byte aMoveIndex,ETeamPosition aTargetTeam,EMonsterPos aTargetMonster,bool aAutomatic) { SelectedMoveData moveData = null; if(aMoveIndex<moves.size) moveData = moves[aMoveIndex]; else { moveData = new SelectedMoveData(); } if(_futureMoveInfo!=null) { _futureMoveInfo.cleanUp(); _futureMoveInfo =null; } _futureMoveInfo = new MoveQueueItem(this.speed,moveData,aTargetTeam,aTargetMonster,this,this.myPosition); if(onMoveSet!=null) { onMoveSet(this as BattleMonster,this._futureMoveInfo.moveData,aAutomatic); } }
private void applyHPEffectToMonster(BattleMonsterWithMoves aAttacker,MoveLibItem aMove,float aSplashPercent,BattleMonsterWithMoves aDefending,CommentaryManager aCommentaryManager,EMonsterPos aAttackersPosition) { //Damage = ((((2 * Level / 5 + 2) * AttackStat * AttackPower / DefenseStat) / 50) + 2) * STAB * Weakness/Resistance * RandomNumber / 100 BattleBase.DebugText("BattleTeamWithMoves->applyHPEffectToMonster"); PassiveEffect attackersEffect = getAttackHPHitPassiveEffect((BattleMonster) aAttacker,(BattleMonster) aDefending,aMove); PassiveEffect defendersEffect = getDefenderHPHitPassiveEffect((BattleMonster) aAttacker,(BattleMonster) aDefending,aMove); if(CommentaryManager.REF!=null) { CommentaryManager.REF.passiveEffect = attackersEffect; CommentaryManager.REF.battleMonster = (BattleMonster) aAttacker; } if((int) aMove.powerOnlyIfTheseStatusEffects>0&&((aDefending.statusEffects&aMove.powerOnlyIfTheseStatusEffects)==EStatusEffects.None)) { return; } float attackStatPower = aAttacker.rangeAttack; float defenseStat = aDefending.rangeDefense; if(aMove.rangeStatus == ERangedStatus.Melee) { attackStatPower = aAttacker.meleeAttack; defenseStat = aDefending.meleeDefense; } bool criticalHitRandom = BattleRandomizer.random < (aMove.criticalHitChance*aAttacker.criticalHitChanceMultiplier); float dmg = 0; float selfHitPercent = aMove.selfInflictPercent; bool criticalApplied = false; if(criticalHitRandom) { if(aDefending.criticalHitImmune) { BattleBase.DebugText("Critical hit immune"); } else { attackStatPower *= 2; criticalApplied = true; BattleBase.DebugText("Critical hit being applied"); } } else { BattleBase.DebugText("No critical hit"); } switch(aMove.powerApplicationType) { case(EPowerApplicationTypes.Normal): float attackPower = aMove.getPower(aAttacker.unlockLevelForMove(aMove));; float stab = 1.0f; if(aMove.elementType==aAttacker.monster.elementType) { stab = 1.15f; } else if(aMove.elementType==aAttacker.monster.secondaryType) { stab = 1.075f; } int random = (int) (BattleRandomizer.random*15)+85; if(attackStatPower == 0) { } if(attackersEffect!=null) { if(!attackersEffect.applyToSelf) { // My attackers effect does something to the opponent. attackStatPower = attackStatPower * attackersEffect.getEffectOnAttackPower(aMove.rangeStatus,aMove.elementType); selfHitPercent += attackersEffect.moveRef.selfInflictPercent; } } BattleBase.DebugText("Defending Monster is: "+aDefending.name+" - Level: "+aDefending.monster.level); float weaknessStrength = aDefending.getWeaknessStrengthToElement(aMove.elementType); if(weaknessStrength>1f) this.onMonsterCommentary((BattleMonster) aDefending,"Effective vs. "+aDefending.monster.name,ECommentaryMessageType.DmgEffective); else if(weaknessStrength<1f) { this.onMonsterCommentary((BattleMonster) aDefending,"Ineffective vs. "+aDefending.monster.name,ECommentaryMessageType.DmgInEffective); } BattleBase.DebugText("Random in use is: "+random+" - Move element is: "+aMove.elementType.Name+", Move Range: "+aMove.rangeStatus+",Range Defense: "+aDefending.meleeDefense+" - Melee Defense: "+aDefending.rangeDefense); if(attackPower>0) dmg = ((((2 * aAttacker.monster.level / 5 + 2) * attackStatPower * attackPower / defenseStat) / 50) + 2) * stab * aDefending.getWeaknessStrengthToElement(aMove.elementType) * random / 100; dmg = (float) Math.Ceiling(dmg*2); BattleBase.DebugText("((((2 * "+aAttacker.monster.level+" / 5 + 2) * "+attackStatPower+" * "+attackPower+" / "+defenseStat+") / 50) + 2) * "+stab+" * "+aDefending.getWeaknessStrengthToElement(aMove.elementType)+" * "+random+" / 100"); BattleBase.DebugText("Dmg to apply is: "+dmg); break; case(EPowerApplicationTypes.PowerIsPercentOfHP): dmg = (aMove.power/100)*aDefending.monster.MaxHP; break; } if(defendersEffect!=null) { if(defendersEffect.applyToSelf) { } else { this.applyStatusEffectToMonster(aDefending,defendersEffect.moveRef,1.0f,aAttacker); } } if(aDefending.oneHitKOImmune&&aDefending.hp==aDefending.monster.MaxHP&&dmg>=aDefending.monster.MaxHP) { dmg = aDefending.monster.MaxHP-1f; } EMonsterPos defendingPosition = monsterPositionByMonster(aDefending as BattleMonster); if(dmg>0) { dmg = dmg*aSplashPercent; if(dmg>aDefending.hp) { dmg = aDefending.hp; } BattleBase.DebugText("HP before is: "+aDefending.hp); aDefending.takeHP(dmg,this._position,defendingPosition,criticalApplied); BattleBase.DebugText("HP after is: "+aDefending.hp); } if(selfHitPercent>0f&&aSplashPercent==1f) { float selfDamage = dmg * selfHitPercent; BattleBase.DebugText("Self hit damage is "+selfDamage); aAttacker.takeHP((int) selfDamage,otherPosition(),aAttackersPosition); } else { float selfHeal = dmg * selfHitPercent*-1;; if(selfHeal>0f) aAttacker.addHP(selfHeal,otherPosition(),aAttackersPosition); } }
public void setFutureMove(MoveLibItem aMoveData,ETeamPosition aTargetTeam,EMonsterPos aTargetMonster,bool aAutomatic) { for(byte i = 0;i<moves.size;i++) { if(moves[i]!=null&&moves[i].moveData!=null&&moves[i].moveData.Name==aMoveData.Name) { setFutureMove (i,aTargetTeam,aTargetMonster,aAutomatic); return; } } }
public static void positionMonster(GameObject aMonsterObject,ETeamPosition aTeam,EMonsterPos aMonsterPosition,Vector3 aOffset) { Vector3 useVec = POSITION_TEAM1_MIDDLE; Quaternion useQ = new Quaternion(0,0,0,0); int layer = 8; switch(aTeam) { case(ETeamPosition.RightTeam): { switch(aMonsterPosition) { case(EMonsterPos.Top): useVec = POSITION_TEAM2_1;useQ = Quaternion.Euler(0,12,0);break; case(EMonsterPos.Front): useVec = POSITION_TEAM2_MIDDLE;useQ = Quaternion.Euler(0,0,0);break; case(EMonsterPos.Bottom): useVec = POSITION_TEAM2_2;useQ = Quaternion.Euler(0,-10,0);break; } } break; case(ETeamPosition.LeftTeam): { switch(aMonsterPosition) { case(EMonsterPos.Top): useVec = POSITION_TEAM1_1;useQ = Quaternion.Euler(0,170,0);;break; case(EMonsterPos.Front): useVec = POSITION_TEAM1_MIDDLE;useQ = Quaternion.Euler(0,180,0);break; case(EMonsterPos.Bottom): useVec = POSITION_TEAM1_2;useQ =useQ = Quaternion.Euler(0,-170,0);break; } } break; case(ETeamPosition.MonsterPreview): { useVec = POSITION_PREVIEW;useQ = Quaternion.Euler(0,0,0);break; } case(ETeamPosition.MonsterPreviewRight): { useVec = POSITION_PREVIEW_RIGHT;useQ = Quaternion.Euler(0,180,0);break; } } if(aMonsterObject!=null) { BattleMonster monster = aMonsterObject.GetComponent("BattleMonster") as BattleMonster; monster.initTargetDefaults (aTeam, aMonsterPosition); Vector3 tempvect = new Vector3(useVec.x+aOffset.x, useVec.y+aOffset.y, useVec.z+aOffset.z); aMonsterObject.transform.position = tempvect; aMonsterObject.transform.rotation =useQ; aMonsterObject.transform.localScale = MONSTER_SCALE; aMonsterObject.layer = layer; Renderer[] allRenderers = aMonsterObject.GetComponentsInChildren<Renderer>(); byte offset = 0; string monsterLayer = "MonsterLayer1"; switch(aMonsterPosition) { case(EMonsterPos.Top): break; case(EMonsterPos.Front): offset = 50; monsterLayer = "MonsterLayer2"; break; case(EMonsterPos.Bottom): offset = 100; monsterLayer = "MonsterLayer3"; break; } if(allRenderers.Length==1) { Debug.Log("1"); } for(int i = 0;i<allRenderers.Length;i++) { allRenderers[i].sortingLayerName = monsterLayer; // SortingOrderUpdate sortOrder = allRenderers[i].GetComponent<SortingOrderUpdate>(); // sortOrder.sortOffset = offset; allRenderers[i].sortingOrder += offset; if(allRenderers[i].gameObject.name.ToLower().Contains("shadow")) { allRenderers[i].sortingLayerName = "BackgroundLayer"; allRenderers[i].sortingOrder = 2; } } } }
public void initTargetDefaults(ETeamPosition aMyTeam,EMonsterPos aMyPosition) { switch (aMyTeam) { default:_targetTeam = ETeamPosition.LeftTeam;break; case(ETeamPosition.LeftTeam):_targetTeam = ETeamPosition.RightTeam;break; } this._targetMonster = aMyPosition; }
private void initBattleMonsterGameObject(GameObject aMonster,MonsterDataMain aMonsterData,int aLayerOffset,EMonsterPos aPosition) { BattleMonster monster = aMonster.GetComponent("BattleMonster") as BattleMonster; if(monster==null) { aMonster.AddComponent<BattleMonster>(); BattleConstants.positionMonster(aMonster,ETeamPosition.MonsterPreview,EMonsterPos.Front,Vector3.forward); monster = aMonster.GetComponent("BattleMonster") as BattleMonster; } monster.initMonster(aMonsterData,aPosition); monster.sortingLayer = "MonsterLayer3"; previewMonster = monster; if(monster.monster==null) { Debug.LogError("Monster is null"); } }