Beispiel #1
0
        public static RangedWeapon getRangedWeaponFromRangedWeaponData(RangedWeaponData data, Dictionary <long, AbilityData> abilityDataDictionary, Dictionary <long, EffectData> effectDataDictionary)
        {
            Weapon       w  = getWeaponFromWeaponData(data, abilityDataDictionary, effectDataDictionary);
            RangedWeapon rw = new RangedWeapon()
            {
                ID             = w.ID,
                name           = w.name,
                actionPoints   = w.actionPoints,
                activeEffects  = w.activeEffects,
                maxDamage      = w.maxDamage,
                minDamage      = w.minDamage,
                passiveEffects = w.passiveEffects,
                sheetname      = w.sheetname,
                spriteindex    = w.spriteindex,
                type           = w.type,
                weaponType     = w.weaponType,

                range    = data.range,
                ammoType = data.ammoType,
                price    = data.price
            };

            return(rw);
        }
Beispiel #2
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);
        }
Beispiel #3
0
        public static RangedWeapon getRangedWeaponFromRangedWeaponData(RangedWeaponData data, Dictionary<long, AbilityData> abilityDataDictionary, Dictionary<long, EffectData> effectDataDictionary)
        {
            Weapon w = getWeaponFromWeaponData(data, abilityDataDictionary, effectDataDictionary);
            RangedWeapon rw = new RangedWeapon()
            {
                ID = w.ID,
                name = w.name,
                actionPoints = w.actionPoints,
                activeEffects = w.activeEffects,
                maxDamage = w.maxDamage,
                minDamage = w.minDamage,
                passiveEffects = w.passiveEffects,
                sheetname = w.sheetname,
                spriteindex = w.spriteindex,
                type = w.type,
                weaponType = w.weaponType,

                range = data.range,
                ammoType = data.ammoType,
                price = data.price
            };

            return rw;
        }