Example #1
0
        public static Ammo getAmmoFromAmmoData(AmmoData data, Dictionary <long, AbilityData> abilityDataDictionary, Dictionary <long, EffectData> effectDataDictionary)
        {
            Item i = getItemFromItemData(data, abilityDataDictionary, effectDataDictionary);
            Ammo a = new Ammo()
            {
                activeEffects  = i.activeEffects,
                ammoType       = data.ammoType,
                bonusDamage    = data.bonusDamage,
                ID             = i.ID,
                name           = i.name,
                passiveEffects = i.passiveEffects,
                sheetname      = i.sheetname,
                spriteindex    = i.spriteindex,
                type           = i.type,
                price          = data.price
            };


            return(a);
        }
Example #2
0
 public void EquipAmmo(Ammo a)
 {
     if (inventory.Contains(a))
     {
         this.Ammo = ItemHelper.getItemSet(inventory, a);
     }
 }
Example #3
0
        private static bool Hit(GameCharacter attacker, GameCharacter defender, BattleGame game, Ammo ammo)
        {
            int bonusDamage = 0;
            if(ammo != null)
            {
                bonusDamage = ammo.bonusDamage;

                if (ammo.activeEffects != null)
                {
                    foreach (var ae in ammo.activeEffects)
                    {
                        defender.AddActiveEffect(AbilityHelper.cloneActiveEffect(ae), game);
                    }
                }
            }

            int dmg = game.r.Next(attacker.weapon.minDamage, attacker.weapon.maxDamage) + bonusDamage;

            defender.Damage(dmg, game);

            game.battleLog.AddEntry(string.Format("{0} hit {1} for {2} damage.", attacker.name, defender.name, dmg));
            game.gameControllerScript.StartTempTextOnChar(defender, dmg, true);
            game.gameControllerScript.StartTempSpriteOnChar(defender, "DamageEffects", 1);

            if(attacker.weapon.activeEffects != null)
            {
                foreach(var ae in attacker.weapon.activeEffects)
                {
                    defender.AddActiveEffect(AbilityHelper.cloneActiveEffect(ae), game);
                }
            }

            return true;
        }
Example #4
0
 //Creates an ItemSet to assign to Ammo
 public void EquipAmmo(Ammo a)
 {
     this.Ammo = ItemHelper.getItemSet(inventory, a);
 }
Example #5
0
        private static bool Hit(GameCharacter attacker, GameCharacter defender, BattleGame game, Ammo ammo)
        {
            int bonusDamage = 0;

            if (ammo != null)
            {
                bonusDamage = ammo.bonusDamage;

                if (ammo.activeEffects != null)
                {
                    foreach (var ae in ammo.activeEffects)
                    {
                        defender.AddActiveEffect(AbilityHelper.cloneActiveEffect(ae), game);
                    }
                }
            }

            int dmg = game.r.Next(attacker.weapon.minDamage, attacker.weapon.maxDamage) + bonusDamage;

            defender.Damage(dmg, game);

            game.battleLog.AddEntry(string.Format("{0} hit {1} for {2} damage.", attacker.name, defender.name, dmg));
            game.gameControllerScript.StartTempTextOnChar(defender, dmg, true);
            game.gameControllerScript.StartTempSpriteOnChar(defender, "DamageEffects", 1);

            if (attacker.weapon.activeEffects != null)
            {
                foreach (var ae in attacker.weapon.activeEffects)
                {
                    defender.AddActiveEffect(AbilityHelper.cloneActiveEffect(ae), game);
                }
            }

            return(true);
        }
Example #6
0
        public static bool RangedAttack(GameCharacter attacker, GameCharacter defender, Tile targetTile, BattleGame game)
        {
            bool retval = false;

            //check for ranged weapon
            if (attacker.weapon is RangedWeapon)
            {
                RangedWeapon w = (RangedWeapon)attacker.weapon;
                Ammo         a = (Ammo)ItemHelper.getFirstItemWithID(attacker.inventory, attacker.Ammo.itemID);

                //check we have ammo
                if (attacker.Ammo != null && attacker.Ammo.count > 0 && a.ammoType == w.ammoType)
                {
                    List <Tile> tileLOSList = game.board.getBoardLOS(game.ActiveTile, targetTile);


                    //check LOS
                    //check range
                    if (tileLOSList[tileLOSList.Count - 1] == targetTile)
                    {
                        if (tileLOSList.Count <= w.range)
                        {
                            if (attacker.SpendAP(attacker.weapon.actionPoints))
                            {
                                var attackerPos = new UnityEngine.Vector3(attacker.x, -attacker.y);
                                var targetPos   = new UnityEngine.Vector3(defender.x, -defender.y);
                                game.gameControllerScript.StartTempSpriteProjectile(attackerPos, targetPos, GameConstants.rangedAttackSpritesheet, GameConstants.rangedAttackSpriteindex);


                                //check for hit
                                if (game.r.Next(20) + attacker.attack > defender.ac)
                                {
                                    retval = Hit(attacker, defender, game, a);

                                    //remove ammo
                                    attacker.inventory.Remove(a);
                                    attacker.Ammo = ItemHelper.getItemSet(attacker.inventory, a);

                                    retval = true;
                                }
                                else
                                {
                                    game.battleLog.AddEntry(string.Format("{0} missed {1}.", attacker.name, defender.name));
                                }
                            }
                        }
                        else
                        {
                            game.battleLog.AddEntry(string.Format("{0} is out of range.", defender.name));
                        }
                    }
                    else
                    {
                        game.battleLog.AddEntry(string.Format("Unable to hit {0}", defender.name));
                    }
                }
                else
                {
                    game.battleLog.AddEntry(string.Format("{0} requires {1} ammo equipped", w.name, w.ammoType));
                }
            }
            else
            {
                game.battleLog.AddEntry(string.Format("Equip a ranged weapon for ranged attack"));
            }

            return(retval);
        }
Example #7
0
        public static Ammo getAmmoFromAmmoData(AmmoData data, Dictionary<long, AbilityData> abilityDataDictionary, Dictionary<long, EffectData> effectDataDictionary)
        {
            Item i = getItemFromItemData(data, abilityDataDictionary, effectDataDictionary);
            Ammo a = new Ammo()
            {
                activeEffects = i.activeEffects,
                ammoType = data.ammoType,
                bonusDamage = data.bonusDamage,
                ID = i.ID,
                name = i.name,
                passiveEffects = i.passiveEffects,
                sheetname = i.sheetname,
                spriteindex = i.spriteindex,
                type = i.type,
                price = data.price
            };
            

            return a;
        }