Beispiel #1
0
        // Gets all the passives available to the profession
        public override List<PassiveInfo> getAvailablePassives(Unit unit)
        {
            // Variables
            List<PassiveInfo>	info=	new List<PassiveInfo>();

            return info;
        }
Beispiel #2
0
        // 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);
        }
Beispiel #3
0
 // 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;
 }
Beispiel #4
0
        internal static int ntid = 0; // New Trap ID

        #endregion Fields

        #region Constructors

        // --- Constructors ---
        public Trap(ActivateTrapEvent pmTrapEvent, int pmTeamID, string pmName, ref Unit pmParent)
        {
            trapEvent=	pmTrapEvent;
            teamID=	pmTeamID;
            trapID=	Trap.getNextTrapID();
            parent=	pmParent;
            name=	pmName;
        }
Beispiel #5
0
 // Calculates the critical chance between the two units
 public static float calculateCriticalChance(ref Unit attacker, ref Unit defender)
 {
     return MathHelper.Clamp(
         (((float)(attacker.speed)/2f+((attacker.health< 0.25f*attacker.originalHealth) ? 16f : 1f)-(float)(defender.speed)/4f)-16f)/100f,
         0f,
         1f
     );
 }
Beispiel #6
0
        // Creates a new default trap of the given id
        public static Trap createDefault(string id, int teamID, ref Unit parent)
        {
            switch(id.ToLower())
            {
                case "weak_shock":	return new Trap(weakShock, teamID, id, ref parent);
            }

            return new Trap(weakShock, teamID, id, ref parent);
        }
Beispiel #7
0
        // --- 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);
        }
Beispiel #8
0
        // 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);
        }
Beispiel #9
0
 // 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);
 }
Beispiel #10
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);
        }
Beispiel #11
0
        // --- 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);
        }
Beispiel #12
0
        // Gets all the skills available to the profession
        public override List<SkillInfo> getAvailableSkills(Unit unit)
        {
            // Variables
            List<SkillInfo>	info=	new List<SkillInfo>();

            info.add(new SkillInfo(
                "Basic Attack",
                "basic_attack",
                "Deals physical attack",
                0
            ));

            return info;
        }
Beispiel #13
0
        // 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;
        }
Beispiel #14
0
        // Opens up the gui
        public void open(ref Unit pmUnit)
        {
            unit=	pmUnit;

            // Unit's name
            name.text=	unit.name;

            // Unit's level
            level.text=	"Lv. "+unit.level;
            level.bounds.X=	game.Window.ClientBounds.Width-24-(int)(level.font.MeasureString(level.text).X);

            // HP
            statsLbl[0].text=	"HP:    "+spaceOutEvenly(unit.health)+"  +"+unit.getStatDifference("hp");
            stats[0].isEnabled=	(unit.statVariance.hp< 12);

            // Mana
            statsLbl[1].text=	"Mana:  "+spaceOutEvenly(unit.mana)+"  +"+unit.getStatDifference("mana");
            stats[1].isEnabled=	(unit.statVariance.mana< 12);

            // Attack
            statsLbl[2].text=	"Atk:   "+spaceOutEvenly(unit.attack)+"  +"+unit.getStatDifference("atk");
            stats[2].isEnabled=	(unit.statVariance.atk< 12);

            // Defense
            statsLbl[3].text=	"Def:   "+spaceOutEvenly(unit.defense)+"  +"+unit.getStatDifference("def");
            stats[3].isEnabled=	(unit.statVariance.def< 12);

            // Magic
            statsLbl[4].text=	"Mag:   "+spaceOutEvenly(unit.magic)+"  +"+unit.getStatDifference("mag");
            stats[4].isEnabled=	(unit.statVariance.mag< 12);

            // Resistance
            statsLbl[5].text=	"Res:   "+spaceOutEvenly(unit.resistance)+"  +"+unit.getStatDifference("res");
            stats[5].isEnabled=	(unit.statVariance.res< 12);

            // Speed
            statsLbl[6].text=	"Spd:   "+spaceOutEvenly(unit.speed)+"  +"+unit.getStatDifference("spd");
            stats[6].isEnabled=	(unit.statVariance.spd< 12);

            // Movement
            statsLbl[7].text=	"Move:  "+spaceOutEvenly(unit.move);
            stats[7].isEnabled=	(unit.statVariance.move< 6);

            game.gui.open("unit_level_up");
        }
Beispiel #15
0
        // --- Static Methods ---
        // Calculates the damage between the two units. The percentages must be in between [0f, 1f]
        public static int calculateDamage(ref Unit attacker, ref Unit defender, float atkPerc, float magPerc, float defPerc, float resPerc)
        {
            // Variables
            float	diff=	(attacker.level-defender.level)+1f;
            float	damage=	4f;
            float	datk=	0f;
            float	dmag=	0f;

            if(diff> 0f)
            {
                if(atkPerc> 0f)
                    datk=	Math.Max((attacker.attack*atkPerc)-(defender.defense*defPerc), 0f);
                if(magPerc> 0f)
                    dmag=	Math.Max((attacker.magic*magPerc)-(defender.resistance*resPerc), 0f);
                damage=	(attacker.level+datk+dmag+8f*diff)/4f+4f;
            }

            return (int)(Math.Round(damage));
        }
Beispiel #16
0
        // --- 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;
        }
Beispiel #17
0
 // 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)
 {
 }
Beispiel #18
0
 // 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)
 {
 }
Beispiel #19
0
 // 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;
 }
Beispiel #20
0
 // 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;
 }
Beispiel #21
0
 // Called when the unit has ended it's attacking cycle
 public virtual void onAttackingDone(Profession prof, ref Unit unit, ref BattleMap map)
 {
 }
Beispiel #22
0
 // 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)
 {
 }
Beispiel #23
0
 // 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;
 }
Beispiel #24
0
 // 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;
 }
Beispiel #25
0
 // 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;
 }
Beispiel #26
0
 // Called when the unit is reseting stats for stat effects
 public virtual void onResetStatAffectStats(Profession prof, ref Unit unit, ref BattleMap map)
 {
 }
Beispiel #27
0
 // Called when the unit has been removed from the map
 public virtual void onRemoveFromMap(Profession prof, ref Unit unit, ref BattleMap map)
 {
 }
Beispiel #28
0
 // Called when the unit has ended it's turn
 public virtual void onEndTurn(Profession prof, ref Unit unit, ref BattleMap map)
 {
 }
Beispiel #29
0
 // 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;
 }
Beispiel #30
0
 // 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;
 }