Exemplo n.º 1
0
    public override void AddWeapon(string _weaponID, WeaponTemplate _weaponPrefab)
    {
        if (this.currWeapon.GetID() == _weaponID)
        {
            this.currWeapon.AddBullet(_weaponPrefab.GetMagazineSize());
        }
        else
        {
            WeaponTemplate controller = null;

            if (this.defaultWeapon.GetID() != _weaponID)
            {
                GameObject instance = ObjectManager.instance.Instantiate(_weaponID, transform.position, Quaternion.identity);

                controller = instance.GetComponent <WeaponTemplate>();
            }
            else
            {
                controller = this.defaultWeapon;
                controller.gameObject.SetActive(true);
            }

            if (controller != null)
            {
                this.SetWeapon(controller);
            }
        }
    }
Exemplo n.º 2
0
    public void equipWeapon(WeaponTemplate wep)
    {
        weaponData        = wep;
        gunModel          = weaponData.BlendFile;
        ejectionPort      = gunModel.transform.Find("EjectionPort");
        ejectionDirection = gunModel.transform.Find("EjectionDirection");
        MagazineTypes     = weaponData.magazineTypes;
        rateOfFire        = weaponData.weaponRateOfFire;
        // wepDamageRange = wep.weaponDamageRange;
        weaponRange = weaponData.weaponRange;

        gameObject.GetComponent <MeshFilter>().mesh   = weaponData.weaponModel;
        gameObject.GetComponent <Renderer>().material = weaponData.weaponMaterial;

        GameObject barrel = new GameObject();

        barrel.AddComponent <MeshFilter>();
        barrel.GetComponent <MeshFilter>().mesh = weaponData.barrelModel;
        barrel.transform.position = transform.TransformPoint(gunModel.transform.Find("Barrel").position);

        Debug.Log(weaponData.Name + " equipped.");

        /*foreach(AudioSource s in wep.weaponShootSounds)
         * {
         *  shootSounds.Add(s);
         * }
         * foreach (AudioSource s in wep.weaponImpactSounds)
         * {
         *  impactSounds.Add(s);
         * }*/
    }
Exemplo n.º 3
0
        public bool CanUseWeapon(Cell cell, WeaponTemplate weapon)
        {
            if (!IsFighterTurn())
            {
                return(false);
            }

            if (HasState((int)SpellStatesEnum.AFFAIBLI_42))
            {
                return(false);
            }

            var point = new MapPoint(cell);

            if ((weapon.CastInDiagonal && (point.EuclideanDistanceTo(Position.Point) > weapon.WeaponRange || point.EuclideanDistanceTo(Position.Point) < weapon.MinRange)) ||
                (!weapon.CastInDiagonal && point.ManhattanDistanceTo(Position.Point) > weapon.WeaponRange || point.ManhattanDistanceTo(Position.Point) < weapon.MinRange))
            {
                return(false);
            }

            if (m_weaponUses >= weapon.MaxCastPerTurn)
            {
                return(false);
            }

            return(AP >= weapon.ApCost && Fight.CanBeSeen(cell, Position.Cell));
        }
Exemplo n.º 4
0
    private void OnWeaponPickup(WeaponClassname weaponClassname)
    {
        if (weaponSlots[(int)weaponClassname])
        {
            Console.DebugLog("Weapon already picked up.");
            return;
        }

        if (weaponList.Any(i => i.WeaponType == weaponClassname))
        {
            Console.DebugLog("Pickup " + weaponClassname.ToString() + "!");

            WeaponTemplate wt = weaponList.First(i => i.WeaponType == weaponClassname);

            Weapon w = Instantiate(wt.WeaponModel, playerCamera);
            w.WeaponTemplate = wt;

            float scale = Globals.scale.Value;
            w.transform.localPosition -= new Vector3(-weaponXOffset, 12.3f * scale, 0);

            weaponSlots[(int)weaponClassname] = w;

            SetWeaponSlot((int)weaponClassname);
        }
        else
        {
            Console.DebugLog("Weapon " + weaponClassname.ToString() + " not found!");
        }
    }
Exemplo n.º 5
0
    public static WeaponModel create(WeaponType type)
    {
        WeaponModel instance = new WeaponModel();

        instance._template   = WeaponTemplate.Find(type);
        instance._durability = instance._template.DurabilityMax();
        return(instance);
    }
Exemplo n.º 6
0
 public WoundResolution(BattleSoldier inflicter, WeaponTemplate weapon, BattleSoldier sufferer, float damage, HitLocation hitLocation)
 {
     Inflicter   = inflicter;
     Weapon      = weapon;
     Suffererer  = sufferer;
     Damage      = damage;
     HitLocation = hitLocation;
 }
Exemplo n.º 7
0
    public void OnDrop(PointerEventData eventData)
    {
        player = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerScript>();
        WeaponTemplate weaponTemplate = eventData.pointerDrag.gameObject.GetComponentInChildren <WeaponSingle>().getWeapon();

        player.setWeaponTo(weaponTemplate);
        weapTemp = weaponTemplate;

        SaveLoad.saveWeaponConjunto1(weapTemp);
    }
Exemplo n.º 8
0
    public override void Picked(CharacterTemplate _char)
    {
        WeaponTemplate weapon = _char.GetWeapon();

        if (weapon != null)
        {
            weapon.AddBullet(this.bulletAmount);

            base.Picked(_char);
        }
    }
Exemplo n.º 9
0
    public virtual void OnParticleCollision(GameObject _other)
    {
        WeaponTemplate weapon = _other.GetComponentInParent <WeaponTemplate>();

        if (weapon)
        {
            this.playerScore.value += this.ScoreOnHit;
            this.OnScoreChange.Raise();

            this.ApplyDamage(weapon.GetDamage());
        }
    }
Exemplo n.º 10
0
            private static void LoadLandEquipment(GameSave __result)
            {
                bool   flag  = true;
                string path  = "Mods/EquipmentMod/Rifles.txt";
                bool   flag2 = !File.Exists(path);

                if (flag2)
                {
                    File.CreateText(path).Close();
                    flag = false;
                }
                bool flag3 = !flag;

                if (flag3)
                {
                    List <WeaponTemplate> rifles = __result.campaign.campaignController.campSettings.shopSettings.riflePool.rifles;
                    bool flag4 = rifles == null;
                    if (!flag4)
                    {
                        List <WeaponHotpatch> list = new List <WeaponHotpatch>();
                        foreach (WeaponTemplate current in rifles)
                        {
                            list.Add(new WeaponHotpatch(current));
                        }
                        File.WriteAllText(path, JsonConvert.SerializeObject(list, Formatting.Indented, new JsonSerializerSettings
                        {
                            ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
                            MaxDepth = new int?(2)
                        }));
                    }
                }
                else
                {
                    List <WeaponHotpatch> list2   = JsonConvert.DeserializeObject <List <WeaponHotpatch> >(File.ReadAllText(path));
                    List <WeaponTemplate> rifles2 = __result.campaign.campaignController.campSettings.shopSettings.riflePool.rifles;
                    using (List <WeaponHotpatch> .Enumerator enumerator2 = list2.GetEnumerator())
                    {
                        while (enumerator2.MoveNext())
                        {
                            WeaponHotpatch updatedItem = enumerator2.Current;
                            try
                            {
                                WeaponTemplate weaponTemplate = rifles2.Find((WeaponTemplate x) => x.textName.ToString() == updatedItem.ID);
                                updatedItem.Update(ref weaponTemplate);
                                weaponTemplate.OnAfterDeserialize();
                            }
                            catch (Exception)
                            {
                            }
                        }
                    }
                }
            }
Exemplo n.º 11
0
    public void setWeaponTemplate(WeaponTemplate weaponTemplate)
    {
        weaponTemp = weaponTemplate;
        //item.itemPrefab.sprite;

        // Sprite myFruit = Resources.Load("fruits_1", typeof(Sprite)) as Sprite;
        if (weaponTemp.weaponMaestro != null)
        {
            sprite = UtilsItems.getSpriteWeapon(weaponTemp.weaponMaestro.sprite);
            GetComponent <Image>().sprite = sprite;
        }
    }
        public FightSpellCastCriticalEnum RollCriticalDice(WeaponTemplate weapon)
        {
            AsyncRandom asyncRandom = new AsyncRandom();

            FightSpellCastCriticalEnum result = FightSpellCastCriticalEnum.NORMAL;

            if (weapon.CriticalHitProbability != 0u && asyncRandom.Next(100) < this.CalculateCriticRate((uint)weapon.CriticalHitProbability))
            {
                result = FightSpellCastCriticalEnum.CRITICAL_HIT;
            }

            return(result);
        }
Exemplo n.º 13
0
    WeaponInfo getItemforRecipe(ContentType.contentItem ingredient, int ingredientCount)
    {
        //2 metals = dagger
        //3 metals = sword
        //4 metals = greatsword

        gameControl = GameObject.Find("GameControl");

        int damageMultiplier = 1;

        if (ingredient == ContentType.contentItem.copper_ingot || ingredient == ContentType.contentItem.iron_ingot)
        {
            if (ingredient == ContentType.contentItem.copper_ingot)
            {
                damageMultiplier = 1;
            }

            if (ingredient == ContentType.contentItem.iron_ingot)
            {
                damageMultiplier = 2;
            }

            WeaponInfo.weaponTypes newWeaponType = WeaponInfo.weaponTypes.none;
            switch (ingredientCount)
            {
            case 2:
                newWeaponType = WeaponInfo.weaponTypes.Dagger;
                break;

            case 3:
                newWeaponType = WeaponInfo.weaponTypes.LongSword;
                break;

            case 4:
                newWeaponType = WeaponInfo.weaponTypes.GreatSword;
                break;
            }

            WeaponTemplate template = gameControl.GetComponent <CraftingManager> ().getTemplateforType(newWeaponType);

            return(new WeaponInfo(template, damageMultiplier));
        }
        return(null);
        //2 berries = weak hp potion
        //3 berries = med hp potion
        //4 berries = strong hp potion

        //2 wood = short bow
        //3 wood = recurve box
        //4 wood = longbox
    }
Exemplo n.º 14
0
        private int GetHandsForWeapon(WeaponTemplate template)
        {
            switch (template.Location)
            {
            case EquipLocation.OneHand:
                return(1);

            case EquipLocation.TwoHand:
                return(2);

            default:
                return(0);
            }
        }
        public bool CanUseWeapon(Cell cell, WeaponTemplate weapon)
        {
            bool result;

            if (!base.IsFighterTurn())
            {
                result = false;
            }
            else
            {
                MapPoint mapPoint = new MapPoint(cell);
                result = ((ulong)mapPoint.DistanceToCell(this.Position.Point) <= (ulong)((long)weapon.WeaponRange) && (ulong)mapPoint.DistanceToCell(this.Position.Point) >= (ulong)((long)weapon.MinRange) && base.AP >= weapon.ApCost && base.Fight.CanBeSeen(cell, this.Position.Cell, false));
            }
            return(result);
        }
        private int GoldCost(GradeTemplate gradeTemplate, Item item, int ItemType)
        {
            int cost = 0;

            uint slotTypeId = 0;

            switch (ItemType)
            {
            case 1:
                WeaponTemplate weaponTemplate = (WeaponTemplate)item.Template;
                _log.Info(weaponTemplate.HoldableTemplate.SlotTypeId);
                slotTypeId = weaponTemplate.HoldableTemplate.SlotTypeId;
                break;

            case 2:
                ArmorTemplate armorTemplate = (ArmorTemplate)item.Template;
                _log.Info(armorTemplate.SlotTemplate.SlotTypeId);
                slotTypeId = armorTemplate.SlotTemplate.SlotTypeId;
                break;

            case 24:
                AccessoryTemplate accessoryTemplate = (AccessoryTemplate)item.Template;
                _log.Info(accessoryTemplate.SlotTemplate.SlotTypeId);
                slotTypeId = accessoryTemplate.SlotTemplate.SlotTypeId;
                break;
            }

            if (slotTypeId == 0)
            {
                return(-1);
            }
            EquipSlotEnchantingCost enchantingCost = ItemManager.Instance.GetEquipSlotEnchantingCost(slotTypeId);

            int item_grade = gradeTemplate.EnchantCost;
            int item_level = item.Template.Level;
            int equip_slot_enchant_cost = enchantingCost.Cost;

            Dictionary <string, double> parameters = new Dictionary <string, double>();

            parameters.Add("item_grade", item_grade);
            parameters.Add("item_level", item_level);
            parameters.Add("equip_slot_enchant_cost", equip_slot_enchant_cost);
            Formula formula = FormulaManager.Instance.GetFormula(22);

            cost = (int)formula.Evaluate(parameters);

            return(cost);
        }
Exemplo n.º 17
0
        void OnWeaponUsed(FightActor fighter, WeaponTemplate weapon, Cell cell, FightSpellCastCriticalEnum critical, bool silentCast)
        {
            if (critical == FightSpellCastCriticalEnum.CRITICAL_FAIL)
            {
                return;
            }

            if (m_weaponsUsed.Contains(fighter))
            {
                UpdateStatus(ChallengeStatusEnum.FAILED);
            }
            else
            {
                m_weaponsUsed.Add(fighter);
            }
        }
Exemplo n.º 18
0
 // Use this for initialization
 void Start()
 {
     //TODO: clean up all these private & public things I no longer need
     selectedWeapon        = (GameObject)Instantiate(weapon, this.gameObject.transform);
     weaponScript          = selectedWeapon.GetComponent <WeaponTemplate>();
     weaponScript.player   = this;
     weaponScript.playerRB = GetComponent <Rigidbody>();
     characterController   = GetComponent <CharacterController> ();
     gunTransform          = selectedWeapon.transform;
     spawnPoint            = this.transform.position;
     HP.value          = maxHP.value;
     kills.value       = 0;
     playerID          = getPlayerID(this.gameObject);
     frameMovement     = Vector3.zero;
     lastFrameMovement = Vector3.zero;
 }
Exemplo n.º 19
0
        void OnWeaponUsed(FightActor fighter, WeaponTemplate weapon, Cell cell, FightSpellCastCriticalEnum critical, bool silentCast)
        {
            if (critical == FightSpellCastCriticalEnum.CRITICAL_FAIL)
            {
                return;
            }

            if (m_weaponsUsed.Any(x => x.First == fighter && x.Second == Fight.TimeLine.RoundNumber))
            {
                UpdateStatus(ChallengeStatusEnum.FAILED);
            }
            else
            {
                m_weaponsUsed.Add(new Pair <FightActor, int>(fighter, Fight.TimeLine.RoundNumber));
            }
        }
Exemplo n.º 20
0
    private static bool TryGetWeaponModel(string classname, out Weapon weapon)
    {
        if (!PlayerInventory.Instance)
        {
            weapon = null;
            return false;
        }

        WeaponTemplate t = PlayerInventory.Instance.weaponList.FirstOrDefault(i => i.WeaponType.ToString() == classname);
        if (t)
        {
            weapon = t.WeaponModel;
            return true;
        }
        weapon = null;
        return false;
    }
Exemplo n.º 21
0
    static WeaponTemplate()
    {
        WeaponTemplate shortSword = new WeaponTemplate();

        shortSword.type          = WeaponType.ShortSword;
        shortSword.clazz         = WeaponClass.Sword;
        shortSword.subClazz      = WeaponSubClass.Standard;
        shortSword.rangeMin      = 1;
        shortSword.rangeMax      = 1;
        shortSword.powerMin      = 3;
        shortSword.powerMax      = 5;
        shortSword.damageType    = DamageType.SLASH;
        shortSword.weight        = 6;
        shortSword.accuracy      = 80;
        shortSword.dropRate      = 0.2f;
        shortSword.durabilityMax = 40;
        weaponTemplates.Add(WeaponType.ShortSword, shortSword);
    }
Exemplo n.º 22
0
 public void Update(ref WeaponTemplate template)
 {
     template.adaptationCoeff     = this.adaptationCoeff;
     template.altitude            = this.altitude;
     template.ammoCost            = this.ammoCost;
     template.ammunition          = this.ammunition;
     template.baseReload          = this.baseReload;
     template.cannonRequiredStaff = this.cannonRequiredStaff;
     template.collateralRadius    = this.collateralRadius;
     template.damage             = this.damage;
     template.effectiveRange     = this.effectiveRange;
     template.effectiveRangeHint = this.effectiveRangeHint;
     template.meleeDamage        = this.meleeDamage;
     template.price             = this.price;
     template.randHi            = this.randHi;
     template.randLow           = this.randLow;
     template.damageDegradation = this.damageDegradation;
     template.ballistics        = this.ballistics;
 }
Exemplo n.º 23
0
        public int AddWeapon(WeaponTemplate weapon)
        {
            if (this.weapons.Length == 0)
            {
                throw new InvalidOperationException("No weapon slots on this boat.");
            }
            var slot = 0;

            while (slot < this.weapons.Length)
            {
                if (this.weapons[slot] == null)
                {
                    this.SetWeapon(slot, new Weapon(this.Context, this, weapon));
                    return(slot);
                }
                slot++;
            }
            throw new InvalidOperationException("No available weapon slots on this boat.");
        }
Exemplo n.º 24
0
    public override void SetWeapon(WeaponTemplate _weapon)
    {
        if (this.currWeapon != _weapon)
        {
            if (this.currWeapon == this.defaultWeapon)
            {
                this.currWeapon.gameObject.SetActive(false);
            }
            else
            {
                ObjectManager.instance.Destroy(this.currWeapon.gameObject);
            }
        }

        this.currWeapon = _weapon;
        this.currWeapon.transform.parent = transform;

        this.currWeapon.Init();


        this.playerMaterial.SetColor("_ArmColor", this.currWeapon.GetColor());
    }
Exemplo n.º 25
0
        public PhbWeapon(string weaponKey)
        {
            weaponTemplate = ItemData.RetrieveWeaponTemplate(weaponKey);

            WeaponName            = weaponTemplate.weaponName;
            Proficiency           = weaponTemplate.Proficiency;
            WeaponUse             = weaponTemplate.WeaponUse;
            WeaponCategory        = weaponTemplate.WeaponCategory;
            WeaponSubCategory     = weaponTemplate.WeaponSubCategory;
            WeaponSize            = weaponTemplate.WeaponSize;
            WeaponCost            = weaponTemplate.WeaponCost;
            Damage                = weaponTemplate.Damage;
            ThreatRangeLowerBound = weaponTemplate.threatRangeLowerBound;
            CriticalDamage        = weaponTemplate.CriticalDamage;
            RangeIncrement        = weaponTemplate.RangeIncrement;
            DamageType            = weaponTemplate.DamageType;
            Weight                = weaponTemplate.Weight;
            Hardness              = weaponTemplate.Hardness;
            HitPoints             = weaponTemplate.HitPoints;
            SpecialInfo           = weaponTemplate.specialInfo;
            IsBow = weaponTemplate.IsBow;
        }
Exemplo n.º 26
0
 public WeaponHotpatch(WeaponTemplate template)
 {
     this.ID = template.textName.ToString();
     this.adaptationCoeff     = template.adaptationCoeff;
     this.altitude            = template.altitude;
     this.ammoCost            = template.ammoCost;
     this.ammunition          = template.ammunition;
     this.baseReload          = template.baseReload;
     this.cannonRequiredStaff = template.cannonRequiredStaff;
     this.collateralRadius    = template.collateralRadius;
     this.damage             = template.damage;
     this.effectiveRange     = template.effectiveRange;
     this.effectiveRangeHint = template.effectiveRangeHint;
     this.meleeDamage        = template.meleeDamage;
     this.price             = template.price;
     this.randHi            = template.randHi;
     this.randLow           = template.randLow;
     this.textDescription   = template.textDescription.ToString();
     this.textName          = template.textName.ToString();
     this.textShootType     = template.textShootType.ToString();
     this.damageDegradation = template.damageDegradation;
     this.ballistics        = template.ballistics;
 }
Exemplo n.º 27
0
    public string[] soundEffectOptions; //All possible sound effect names that can be selected

    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        WeaponTemplate targetTemplate = (WeaponTemplate)target;

        //Draw the default ScriptableObject GUI first
        base.OnInspectorGUI();

        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Sound Effect Properties", EditorStyles.boldLabel);

        SoundEffect[] availableSounds = GameObject.Find("_Audio Manager").GetComponent <SoundEffectPlayer>().GetSoundEffects();
        soundEffectOptions = new string[availableSounds.Length];
        for (int i = 0; i < availableSounds.Length; i++)
        {
            soundEffectOptions[i] = availableSounds[i].name;
        }

        //Set the sound array indexes to the index of the chosen sound (prevents them from resetting)
        if (!string.IsNullOrEmpty(targetTemplate.m_attackSound))
        {
            attackSoundIndex = Array.IndexOf(soundEffectOptions, targetTemplate.m_attackSound);
        }

        //Attack Sound
        GUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Attack sound: ", EditorStyles.label, GUILayout.MaxWidth(100f));
        attackSoundIndex = EditorGUILayout.Popup(attackSoundIndex, soundEffectOptions);
        targetTemplate.m_attackSoundVolume = EditorGUILayout.FloatField(targetTemplate.m_attackSoundVolume);
        GUILayout.EndHorizontal();
        targetTemplate.m_attackSound = soundEffectOptions[attackSoundIndex];

        //Apply any properties that have been changed
        EditorUtility.SetDirty(target);
        serializedObject.ApplyModifiedProperties();
    }
Exemplo n.º 28
0
 public void setWeaponTo(WeaponTemplate weap)
 {
     weaponTemplate    = weap;
     weaponRightSprite = UtilsItems.getSpriteWeapon(weap.weaponMaestro.sprite);
     rightHandGO.GetComponent <SpriteRenderer>().sprite = weaponRightSprite;
 }
Exemplo n.º 29
0
 public static void SendGameActionFightCloseCombatMessage(IPacketReceiver client, FightActor source, FightActor target, Cell cell, FightSpellCastCriticalEnum castCritical, bool silentCast, WeaponTemplate weapon)
 {
     SendGameActionFightCloseCombatMessage(client, source, target, cell, castCritical, silentCast, (short)weapon.Id);
 }
Exemplo n.º 30
0
 void OnWeaponUsed(FightActor caster, WeaponTemplate weapon, Cell target, FightSpellCastCriticalEnum critical, bool silentCast)
 => UpdateStatus(ChallengeStatusEnum.FAILED);