// Updates the stat effect without messing the turn countdown thing public void updateNTCD(Unit unit, ref BattleMap map) { if(effectEvent== null) return; effectEvent(ref unit, ref map); }
// --- Constructors --- public AttackDecisionGui(GSGameplay pmGState, ref GameExt pmGame, ref BattleMap pmMap) { gstate= pmGState; game= pmGame; map= pmMap; background= new Control(game); leftPanel= new Control(game); rightPanel= new Control(game); lpName= new Label(game); lpStats= new Label[8]; for(int i= 0; i< lpStats.Length; i++) lpStats[i]= new Label(game); rpName= new Label(game); rpStats= new Label[8]; for(int i= 0; i< rpStats.Length; i++) rpStats[i]= new Label(game); accuracyLbl= new Label(game); accuracy= new Label(game); critLbl= new Label(game); crit= new Label(game); dmgLbl= new Label(game); dmg= new Label(game); commit= new Button(game); cancel= new Button(game); }
// --- Constructors --- public SkillsGui(GSGameplay pmGState, ref GameExt pmGame, ref BattleMap pmMap) { gstate= pmGState; game= pmGame; map= pmMap; tick= 0; set= new Control(game); }
// Deals a weak shock to the unit public static bool weakShock(ref Unit unit, int x, int y, Trap trap, ref BattleMap map, ref Unit parent) { if(unit== null) return false; unit.health-= 8; Console.WriteLine("Dealt 8 damage, Unit's hp: "+unit.health); return true; }
// --- Methods --- // Activates the trap on the given victim. Returns if actually activated or not public bool activate(ref Unit victim, ref BattleMap map) { if(teamID== map.getTeamID(victim.mapPos)) return false; if(trapEvent== null) return false; return trapEvent(ref victim, victim.mapPos[0], victim.mapPos[1], this, ref map, ref parent); }
// Calculates the accuracy between the two units public static float calculateAccuracy(ref Unit attacker, ref Unit defender, ref BattleMap map) { // Variables int adjacentAlliesAttacker= map.findAllies(defender.mapPos[0], defender.mapPos[1], 1, 1, map.getTeamID(attacker.mapPos)).size; int adjacentAlliesDefender= map.findAllies(attacker.mapPos[0], attacker.mapPos[1], 1, 1, map.getTeamID(defender.mapPos)).size; int distance= (defender.level-attacker.level); return MathHelper.Clamp((100f-2f*distance-4*adjacentAlliesDefender+4*adjacentAlliesAttacker)/100f, 0f, 1f); }
// Attacks the unit public virtual void ai_attackUnit(Unit unit, BattleMap map, AttackInfo info, bool isUncontrollable) { map.attackSearch(unit.mapPos[0], unit.mapPos[1], info.range[0], info.range[1]); System.Threading.Thread.Sleep(1000); map.gstate.attackDecisionGui.open(ref info); System.Threading.Thread.Sleep(2500); game.gui.close("attack_decision"); map.gstate.stage= 0; map.makeUnitAttack(map.getFullUnitID(unit.mapPos), map.getUnitX(info.defenderID), map.getUnitY(info.defenderID), ref info); }
// --- Constructors --- public EnemyUnitGui(GSGameplay pmGState, ref GameExt pmGame, ref BattleMap pmMap) { gstate= pmGState; game= pmGame; map= pmMap; set= new Control(game); skills= new Button(game); stats= new Button(game); exit= new Button(game); tick= 0; }
// Gets the target public virtual void ai_getTarget(Unit unit, BattleMap map, bool isUncontrollable, out int[] target, out int[] spotToMoveTo, out AttackInfo info) { info= new AttackInfo(); info.range= new int[] {1, 1}; map.aiSearch(unit.mapPos[0], unit.mapPos[1], unit.move, info.range[1], isUncontrollable, map.getTeamID(unit.mapPos), info); spotToMoveTo= map.findAISpot(unit.mapPos[0], unit.mapPos[1], info.range, map.aggressiveAI); target= map.tiles.items[spotToMoveTo[0], spotToMoveTo[1]].t; info= AttackInfo.createBasicAttack(map.getFullUnitID(unit.mapPos), target, ref map); }
// --- Methods --- // Updates the stat effect, and returns if the effect should be destroyed or not public bool update(Unit unit, ref BattleMap map) { if(effectEvent== null) return true; effectEvent(ref unit, ref map); turnsLeft--; return (turnsLeft== 0); }
// --- Constructors --- public PlayerUnitGui(GSGameplay pmGState, ref GameExt pmGame, ref BattleMap pmMap) { gstate= pmGState; game= pmGame; map= pmMap; set= new Control(game); move= new Button(game); skills= new Button(game); stats= new Button(game); end= new Button(game); exit= new Button(game); tick= 0; refd= false; }
// --- Constructors --- public Tile(GameExt pmGame, Vector3 pmPos, ref BattleMap pmMap) : base(pmGame, pmGame.models.get("tile"), pmPos) { texture= game.textures.get(getTextureName()); unitID= new int[] {-1, -1}; startZoneID= -1; map= pmMap; pos-= new Vector3(-Tile.size/2f, 0f, Tile.size/2f); bounds= new float[] { pmPos.X, pmPos.X+Tile.size, pmPos.Z-Tile.size, pmPos.Z }; trap= null; color= getNormalColor(); }
// --- Static Methods --- // Creates a map from a bitmap public static BattleMap createFromBitmap(string filename, ref GameExt game, GSGameplay gstate) { // Variables Sdx.Bitmap bitmap= new Sdx.Bitmap(filename); BattleMap map= new BattleMap(ref game, gstate, bitmap.Width, bitmap.Height); for(int h= 0; h< map.width; h++) { for(int k= 0; k< map.height; k++) { map.tiles.items[h, k].item= Tile.getTileFromColor(bitmap.GetPixel(h, k), h, k, ref game, map); } } return map; }
// Makes the unit attack the given unit, given that unit's coords on the map, the name of the attack, and a reference to the map public override bool attackUnit(Unit unit, bool initiatedAttack, ref Unit victim, int x, int y, ref AttackInfo info, ref BattleMap map) { switch(info.skillID) { case "basic_attack": case "precise_strike": case "serpent\'s_sting": case "vigilant_strike": case "lethal_strike": { if(victim== null) break; victim.takeDamage(ref info, ref unit, ref map); unit.mana= info.projAttackerStats[1]; if(!info.missed && unit.isAlive && !unit.isAI) unit.gainExp(ref victim, ref map); };return true; case "meditation": { unit.health= info.projAttackerStats[0]; unit.mana= info.projAttackerStats[1]; unit.attack= info.projAttackerStats[2]; unit.originalAttack= info.projAttackerStats[2]; };return true; case "hone_skill": { isSkillHoned= true; };return true; case "sun\'s_might": { if(victim== null) break; victim.takeDamage(ref info, ref unit, ref map); unit.health= Math.Max((int)(unit.health+(0.15f*info.damage)), unit.originalHealth); unit.mana= Math.Max((int)(info.projAttackerStats[1]+(0.15f*info.damage)), unit.originalMana); if(!info.missed && unit.isAlive && !unit.isAI) unit.gainExp(ref victim, ref map); };return true; } return false; }
// --- Constructors --- public UnitLevelUpGui(ref GameExt pmGame, ref BattleMap pmMap) { game= pmGame; map= pmMap; background= new Control(game); name= new Label(game); level= new Label(game); statsLbl= new Label[8]; stats= new Button[8]; for(int i= 0; i< statsLbl.Length; i++) { statsLbl[i]= new Label(game); stats[i]= new Button(game); } isOpened= false; unit= null; }
// Called when the unit has just finished with a stat effect public virtual void onDoneWithStatEffect(Profession prof, ref Unit unit, ref StatEffect statEffect, ref BattleMap map) { }
// Called when the unit has dodged an attack public virtual void onDodgedAttack(Profession prof, ref Unit unit, int amount, ref Unit instigator, ref BattleMap map) { }
// Called when the unit is about to deal damage public virtual int onDealtDamage(Profession prof, ref Unit unit, int victimHP, int amount, ref Unit victim, ref BattleMap map) { return amount; }
// Called when the unit has struck a critical public virtual int onCriticalHit(Profession prof, ref Unit unit, int victimHP, int amount, ref Unit victim, ref BattleMap map) { return 2*amount; }
// Called when the unit has ended it's attacking cycle public virtual void onAttackingDone(Profession prof, ref Unit unit, ref BattleMap map) { }
// Called when the unit has moved on the map public virtual void onUnitMove(Profession prof, ref Unit unit, ref int x, ref int y, ref BattleMap map) { }
// Called when the unit has taken damage public virtual int onTakeDamage(Profession prof, ref Unit unit, int oldHealth, int newHealth, int amount, ref Unit instigator, ref BattleMap map) { return amount; }
// Called when the unit has a new stat effect added public virtual bool onStatsEffected(Profession prof, bool isEffected, ref Unit unit, ref StatEffect statEffect, ref BattleMap map) { return isEffected; }
// Called when the unit is being to set down a trap public virtual Trap onSetTrap(Profession pref, ref Unit unit, int x, int y, ref Trap trap, ref BattleMap map) { return trap; }
// Called when the unit has set's off the trap public virtual bool onSetOffTrap(Profession prof, ref Unit unit, ref Unit parent, int x, int y, bool canSetOff, ref Trap trap, ref BattleMap map) { return canSetOff; }
// Called when the unit is reseting stats for stat effects public virtual void onResetStatAffectStats(Profession prof, ref Unit unit, ref BattleMap map) { }
// Called when the unit has been removed from the map public virtual void onRemoveFromMap(Profession prof, ref Unit unit, ref BattleMap map) { }
// Called when the unit has ended it's turn public virtual void onEndTurn(Profession prof, ref Unit unit, ref BattleMap map) { }
// Called when the unit has healed public virtual int onHeal(Profession prof, ref Unit unit, int hp, int amount, ref Unit instigator, ref BattleMap map) { return amount; }
// Called before the unit is updating the stat effects to see if it will update public virtual bool onPreUpdateStatEffect(Profession prof, ref Unit unit, bool canUpdate, ref StatEffect statEffect, ref BattleMap map) { return canUpdate; }