Пример #1
0
    public void Initialize(Transform t)
    {
        shootingPoint                  = Utility.FindTransformFromChildren("ShootingPoint", t);
        shellPoint                     = Utility.FindTransformFromChildren("ShellPoint", t);
        lr                             = shootingPoint.GetComponentInChildren <LineRenderer>();
        gamemanager                    = GameObject.FindGameObjectWithTag("gamemanager");
        canvas                         = GameObject.FindGameObjectWithTag("Canvas");
        gunCamera                      = GameObject.FindGameObjectWithTag("GunCamera").GetComponent <Camera>();
        mainCamera                     = Camera.main;
        weaponPrefab                   = Utility.FindTransformFromChildren("Weapon Parts", t).gameObject;
        shootingLight.light            = Utility.FindTransformFromChildren("ShootingLight", t).GetComponent <Light>();
        shootingLight.shootingParticle = Utility.FindTransformFromChildren("ps-gunfire", t).GetComponent <ParticleSystem>();

        playermask  = LayerMask.GetMask("Player");
        defaultmask = LayerMask.GetMask("Default");
        gunGamera_defaultFieldOfView = gunCamera.fieldOfView;
        scope.animator   = gunCamera.GetComponent <Animator>();
        scope.scopeImage = gamemanager.GetComponent <GameManager>().scopeImage;

        gunAnimationController         = t.GetComponent <Animator>();
        gunAnimationController.enabled = false;

        audio = t.GetComponent <AudioSource>();
        weaponStats.currentRateOfFire = 0;

        //scope.animator.Play("");
        //gunAnimationController.Play("zoomOut");


        // Lataa aseen tiedot GameManagerista
        weaponStats = gamemanager.GetComponent <GameManager>().GetWeaponStats(t.name);
    }
Пример #2
0
 public DrawableWeapon()
 {
     title        = "New Weapon";
     minimumStats = new WeaponStats();
     requirements = new DrawableRequirements();
     height       = 300f + requirements.GetHeight();
 }
Пример #3
0
        string ActionListToString(List <Action> l, string nodeName)
        {
            string r = "";

            foreach (Action a in l)
            {
                r += "<" + nodeName + ">\n";
                r += "<ActionInput>" + a.input.ToString() + "</ActionInput>\n";
                r += "<ActionType>" + a.type.ToString() + "</ActionType>\n";
                r += "<targetAnim>" + a.targetAnim + "</targetAnim>\n";
                r += "<mirror>" + a.mirror + "</mirror>\n";
                r += "<canBeParried>" + a.canBeParried + "</canBeParried>\n";
                r += "<changeSpeed>" + a.changeSpeed + "</changeSpeed>\n";
                r += "<animSpeed>" + a.animSpeed.ToString() + "</animSpeed>\n";
                r += "<canParry>" + a.canParry + "</canParry>\n";
                r += "<canBackstab>" + a.canBackstab + "</canBackstab>\n";
                r += "<overrideDamageAnim>" + a.overrideDamageAnim + "</overrideDamageAnim>\n";
                r += "<damageAnim>" + a.damageAnim + "</damageAnim>\n";

                WeaponStats s = a.weaponStats;

                r += "<physical>" + s.physical + "</physical>\n";
                r += "<strike>" + s.strike + "</strike>\n";
                r += "<slash>" + s.slash + "</slash>\n";
                r += "<thrust>" + s.thrust + "</thrust>\n";
                r += "<magic>" + s.magic + "</magic>\n";
                r += "<fire>" + s.fire + "</fire>\n";
                r += "<lighting>" + s.lighting + "</lighting>\n";
                r += "<dark>" + s.dark + "</dark>\n";

                r += "</" + nodeName + ">\n";
            }
            return(r);
        }
Пример #4
0
    public void defaultGunAwake(string weaponName)
    {
        var jsonString       = File.ReadAllText("./Assets/Scripts/Weapons/weapons.json");
        var weaponsList      = JsonConvert.DeserializeObject <Weapons>(jsonString);
        var weaponJsonObject = weaponsList.GetType().GetProperty(weaponName).GetValue(weaponsList, null) as Weapon;

        baseStats        = weaponJsonObject.stats;
        title            = weaponJsonObject.title;
        description      = weaponJsonObject.description;
        unlocked         = weaponJsonObject.unlocked;
        cost             = weaponJsonObject.cost;
        xpCost           = weaponJsonObject.xpCost;
        ammoQuantity     = baseStats.ammoCapacity;
        reloadBar        = transform.GetChild(1).gameObject;
        bulletObject     = GameObject.Find("DoCBullet");
        group            = weaponJsonObject.group;
        reloadTimer      = -1;
        shooting         = -1f;
        perkList         = new List <Action <GunParent> >();
        statsBaseState   = baseStats.duplicateStats();
        currentStats     = baseStats.duplicateStats();
        gunUI            = transform.GetChild(3);
        ammoCountUI      = gunUI.GetChild(0).GetChild(1).gameObject.GetComponent <Text>();
        clipSizeUI       = gunUI.GetChild(0).GetChild(2).gameObject.GetComponent <Text>();
        gunNameUI        = gunUI.GetChild(1).GetChild(0).gameObject.GetComponent <Text>();
        ammoCountUI.text = baseStats.ammoCapacity.ToString();
        clipSizeUI.text  = baseStats.ammoCapacity.ToString();
        gunNameUI.text   = title;
        reloadMagazine();
    }
Пример #5
0
    public void ShootBullet()
    {
        WeaponStats weaponStats = GetComponent <WeaponStats>();

        if (weaponStats.ammo > 0 && Time.time >= nextTimeToFire && reloadTimer <= 0)
        {
            nextTimeToFire = Time.time + 1f / weaponStats.fireRate;
            muzzleFlash.Play();
            weaponStats.ammo--;
            if (isHit)
            {
                float distance = Vector3.Distance(hit.transform.position,
                                                  shootingPoint.transform.position);
                //if the object hit has a health component, deal damage
                if (hit.collider.GetComponent <Health>() != null)
                {
                    float damageToTake = weaponStats.damage - distance * weaponStats.damageFallOff;
                    if (damageToTake < 0)
                    {
                        damageToTake = 0;
                    }
                    hit.collider.GetComponent <Health>().TakeDamage(damageToTake);
                }

                GameObject impactGO = Instantiate(impactEffect, hit.point, Quaternion.LookRotation(hit.normal));
                Destroy(impactGO, 1f);
            }
            if (weaponStats.ammo <= 0)
            {
                Reload();
            }
        }
    }
Пример #6
0
    /* Checks the curent values of each weapon stat and upgrades any weapon that meets a
    * specific criteria:
    *
    * The sum of a weapon's levels for damage, rate of fire, and ammo consumption must
    * be greater than or equal to 7.
    * For the damage upgrade, the damage level must be greater than or equal to 4 and greater than the rate of fire level,
    * for the speed upgrade the rate of fire level must be greater than or equal to 3 and greater than or equal to the damage level,
    * for any other case, the non focus upgrade is reached after a total of 7 levels. */
    public void updateWeapons()
    {
        /* Loop through all weapons. */
        for (WEAPON_TYPE idx = WEAPON_TYPE.sword; idx <= WEAPON_TYPE.grenade; ++idx)
        {
            WeaponStats weapon = stats.weapon_by_type(idx);
            // Verify that weapon has not already been upgraded
            if (weapon.upgrade_state() == 0)
            {
                // determine each of the weapon's stat's current level
                int dmg_lvl = weapon.weapon_stat(STAT_TYPE.damage).pointer_value();
                int rof_lvl = weapon.weapon_stat(STAT_TYPE.rate_of_fire).pointer_value();
                int ac_lvl  = weapon.weapon_stat(STAT_TYPE.ammo).pointer_value();
                // the sum of all three levels must greater than 7
                if ((dmg_lvl + rof_lvl + ac_lvl) >= 7)
                {
                    if (dmg_lvl >= 4)                       // damage focus upgrade
                    {
                        weapon.setUgrade(1);
                    }
                    else if (rof_lvl >= 3 && rof_lvl >= dmg_lvl)                         // speed focus upgrade
                    {
                        weapon.setUgrade(2);
                    }
                    else                         // no focus upgrade
                    {
                        weapon.setUgrade(3);
                    }
                }
            }
        }

        wep.updateWeapon();
    }
Пример #7
0
    public List<WeaponStats> ReadWeaponStatsFromFile(string filepath)
    {
        StreamReader rd = new StreamReader(filepath);
        WeaponStats tws = new WeaponStats();
        List<WeaponStats> outputList = new List<WeaponStats>();

        while (!rd.EndOfStream)
        {
            string t = rd.ReadLine();
            if (!t.Contains("#"))
            {
                Debug.Log(t);
                string[] tt = t.Split(',');
                tws.setName(tt[0]);
                tws.setClipSize(int.Parse(tt[1]));
                tws.setMaxAmmo(int.Parse(tt[2]));
                tws.setSpreadFactor(float.Parse(tt[3]));

                Debug.Log("Added " + tws.getName() + " to weapon list");

                outputList.Add(tws);
            }
        }

        return outputList;
    }
Пример #8
0
 void DefineRangedWeapon(WeaponStats weaponData)
 {
     /*switch (weaponData.weaponRarity)
      * {
      *  case WeaponRarity.UNCOMMON:
      *      {
      *          DrawSlider("Damage", weaponData, 3f, 3.5f);
      *          break;
      *      }
      *  case WeaponRarity.RARE:
      *      {
      *          DrawSlider("Damage", weaponData, 3.5f, 4f);
      *          DrawRangedModifiers(weaponData);
      *          break;
      *      }
      *  case WeaponRarity.EPIC:
      *      {
      *          DrawSlider("Damage", weaponData, 4f, 4.5f);
      *          DrawRangedModifiers(weaponData);
      *          break;
      *      }
      *  case WeaponRarity.LEGENDARY:
      *      {
      *          DrawSlider("Damage", weaponData, 4.5f, 5f);
      *          DrawRangedModifiers(weaponData);
      *          break;
      *      }
      * }*/
 }
Пример #9
0
    protected virtual void FireProjectiles(BaseController sender,
                                           float angle, WeaponStats stats)
    {
        Vector2 hit = sender.body.ShotVector(angle);

        SpawnProjectile(sender, hit, stats, totalDamage);
    }
Пример #10
0
 void DrawRangedModifiers(WeaponStats weaponData)
 {
     /*if (weaponData.slot1)
      * {
      *  if (weaponData.weaponRarity == WeaponRarity.LEGENDARY)
      *  {
      *      EditorGUILayout.BeginHorizontal();
      *      GUILayout.Label("Legendary Melee Mod");
      *      weaponData.legendaryRangedMod = (LegendaryRangedModifier)EditorGUILayout.EnumPopup(weaponData.legendaryRangedMod);
      *      EditorGUILayout.EndHorizontal();
      *  }
      *  else
      *  {
      *      EditorGUILayout.BeginHorizontal();
      *      GUILayout.Label("Ranged Mod");
      *      weaponData.rangedMod = (RangedModifier)EditorGUILayout.EnumPopup(weaponData.rangedMod);
      *      EditorGUILayout.EndHorizontal();
      *  }
      * }
      * if (weaponData.slot2)
      * {
      *  EditorGUILayout.BeginHorizontal();
      *  GUILayout.Label("Ranged Mod");
      *  weaponData.rangedMod2 = (RangedModifier)EditorGUILayout.EnumPopup(weaponData.rangedMod2);
      *  EditorGUILayout.EndHorizontal();
      * }*/
 }
Пример #11
0
 void DefineMeleeWeapon(WeaponStats weaponData)
 {
     /*switch (weaponData.weaponRarity)
      * {
      *  case WeaponRarity.UNCOMMON:
      *      {
      *          DrawSlider("Damage", weaponData, 5.5f, 6.5f);
      *          break;
      *      }
      *  case WeaponRarity.RARE:
      *      {
      *          DrawSlider("Damage", weaponData, 6f, 7f);
      *          DrawMeleeModifiers(weaponData);
      *          break;
      *      }
      *  case WeaponRarity.EPIC:
      *      {
      *          DrawSlider("Damage", weaponData, 6.5f, 7.5f);
      *          DrawMeleeModifiers(weaponData);
      *          break;
      *      }
      *  case WeaponRarity.LEGENDARY:
      *      {
      *          DrawSlider("Damage", weaponData, 7f, 8f);
      *          DrawMeleeModifiers(weaponData);
      *          break;
      *      }
      * }*/
 }
 public void OnTriggerEnter(Collider other)
 {
     //GameObject otherObj = other.gameObject;
     //Debug.Log("Triggered with: " + otherObj);
     if (BossTowerAI.BossStage >= 3)
     {
         if (other.gameObject.tag == "CurrentWeapon" || other.gameObject.tag == "CanGrab" || other.gameObject.tag == "Hammer" || other.gameObject.tag == "Sickle")
         {
             weapondmg = 0;
             WeaponStats weaponstats = null;
             if (other.gameObject.GetComponent <WeaponStats>())
             {
                 weaponstats = other.gameObject.GetComponent <WeaponStats>();
                 weapondmg   = weaponstats.WeaponStrength;
             }
             else
             {
                 if (other.gameObject.GetComponent <Rigidbody>())
                 {
                     if (!other.gameObject.GetComponent <Rigidbody>().isKinematic)
                     {
                         weapondmg = UnityEngine.Random.Range(0, 5);
                     }
                 }
             }
             DealDamage();
             //hitOnce = true;
         }
     }
 }
Пример #13
0
    void InitRandomWeapons(Weapon melee, Weapon ranged)
    {
        melee.rarity = (Items.WeaponRarity)Random.Range(1, 5);
        melee.sprite = meleeSprites[(int)melee.rarity];
        melee.stats  = WeaponStats.SetStats(melee.stats, PhotonConnection.GetInstance().randomSeed, melee.type, melee.rarity);

        ranged.rarity = (Items.WeaponRarity)Random.Range(1, 5);
        ranged.sprite = rangedSprites[(int)ranged.rarity];
        ranged.stats  = WeaponStats.SetStats(ranged.stats, PhotonConnection.GetInstance().randomSeed, ranged.type, ranged.rarity);

        if ((int)melee.rarity > 1)
        {
            WeaponStats.SetMeleeModifier(ref melee.stats, melee.stats.mod1);
            if (melee.rarity != Items.WeaponRarity.RARE)
            {
                WeaponStats.SetMeleeModifier(ref melee.stats, melee.stats.mod2);
            }
        }

        if ((int)ranged.rarity > 1)
        {
            WeaponStats.SetMeleeModifier(ref ranged.stats, ranged.stats.mod1);
            if (ranged.rarity != Items.WeaponRarity.RARE)
            {
                WeaponStats.SetMeleeModifier(ref ranged.stats, ranged.stats.mod2);
            }
        }
    }
Пример #14
0
    public virtual void TakeDamage(WeaponStats weapon)
    {
        if (_inv || health <= stats.minHealth)
        {
            return;
        }

        if (shield >= stats.minShield)
        {
            shield -= weapon.shieldDamage;
        }

        else if (armor >= stats.minArmor)
        {
            // Do some more calculations here
            armor -= weapon.hullDamage;
        }

        else if (health >= stats.minHealth)
        {
            health -= weapon.hullDamage;
        }

        OnTookDamage(weapon);

        if (health <= stats.minHealth)
        {
            OnHealthDepleted();
        }
    }
Пример #15
0
    public ClassStats(string className)
    {
        if (className == "Assault")
        {
            name = "Assault";

            vitality = 40;
            agility  = 80;
            acuracy  = 50;

            weaponStat = new WeaponStats(5, 10, 7, 20, 1f);
        }

        if (className == "Tank")
        {
            name = "Tank";

            vitality = 110;
            agility  = 8;
            acuracy  = 90;

            weaponStat = new WeaponStats(14, 4, 3, 12, 2f);
        }

        if (className == "Sniper")
        {
            name = "Sniper";

            vitality = 20;
            agility  = 70;
            acuracy  = 250;

            weaponStat = new WeaponStats(40, 0, 30, 6, 2f);
        }
    }
Пример #16
0
    protected ProjectileHandler SpawnProjectile(
        BaseController sender, Vector2 direction,
        WeaponStats stats, float damage, float statsMod = 1)
    {
        GameObject projectile = Instantiate(projectilPrefab,
                                            GameModes.GetDebrisTransform(sender.team));

        projectile.name = $"{gameObject.name}_Projectile";

        projectile.transform.position =
            (Vector2)transform.position + direction;

        ProjectileHandler handler = projectile
                                    .GetComponent <ProjectileHandler>();

        handler.onUpdate = OnProjectileUpdate;
        handler.onHit    = OnProjectileHit;

        Collider2D collider = handler.body
                              .GetComponent <Collider2D>();

        Physics2D.IgnoreCollision(collider, sender.body.Collider);

        handler.SetStats(sender, damage * statsMod,
                         (life + stats.life) / statsMod,
                         ((speed + stats.speed) / statsMod) * direction.normalized,
                         ((force + stats.force) / 4) * statsMod);

        sender.perks.Activate <IProjectileFired>(1, perk =>
                                                 perk.OnFire(handler));

        return(handler);
    }
Пример #17
0
    void CreateSpaceTrash()
    {
        for (int i = 0; i < 6; i++)
        {
            Vector3 posShift = Vector3.zero;

            posShift.x = Random.Range(2f, 5f);
            posShift.y = Random.Range(2f, 5f);

            Vector3 launchPosition = transform.position + posShift;

            GameObject         particlePrefab   = Storage.Instance.GetSpaceTrashPrefab();
            GameObject         particleObject   = Instantiate(particlePrefab, launchPosition, Quaternion.identity);
            SpaceTrashBehavior newTrashParticle = particleObject.GetComponent <SpaceTrashBehavior>();
            newTrashParticle.OwnerID = -1;

            WeaponStats stats = Storage.Instance.GetWeaponData(4);
            //same direction where mouse pointed

            //random direaction
            Vector3 launchDirection = new Vector3(Random.Range(-1f, 1f), Random.Range(-1f, 1f), 0f);

            newTrashParticle.Initialize(stats, launchDirection);

            //add to storage
            Storage.Instance.AddToPool(particleObject);
        }
    }
Пример #18
0
        string ActionListToString(List <Action> l, string nodeName)
        {
            string xml = null;

            for (int j = 0; j < l.Count; j++)
            {
                xml += "<" + nodeName + ">" + "\n";
                xml += "<ActionInput>" + l[j].input.ToString() + "</ActionInput>" + "\n";
                xml += "<ActionType>" + l[j].type.ToString() + "</ActionType>" + "\n";
                xml += "<targetAnim>" + l[j].targetAnim + "</targetAnim>" + "\n";
                xml += "<mirror>" + l[j].mirror + "</mirror>" + "\n";
                xml += "<canBeParried>" + l[j].canBeParried + "</canBeParried>" + "\n";
                xml += "<changeSpeed>" + l[j].changeSpeed + "</changeSpeed>" + "\n";
                xml += "<animSpeed>" + l[j].animSpeed.ToString() + "</animSpeed>" + "\n";
                xml += "<canParry>" + l[j].canParry + "</canParry>" + "\n";
                xml += "<canBackstab>" + l[j].canBackstab + "</canBackstab>" + "\n";
                xml += "<overrideDamageAnim>" + l[j].overrideDamageAnim + "</overrideDamageAnim>" + "\n";
                xml += "<damageAnim>" + l[j].damageAnim + "</damageAnim>" + "\n";

                WeaponStats s = l [j].weaponStats;
                xml += "<physical>" + s.physical + "</physical>" + "\n";
                xml += "<strike>" + s.strike + "</strike>" + "\n";
                xml += "<slash>" + s.slash + "</slash>" + "\n";
                xml += "<thrust>" + s.thrust + "</thrust>" + "\n";
                xml += "<magic>" + s.magic + "</magic>" + "\n";
                xml += "<fire>" + s.fire + "</fire>" + "\n";
                xml += "<lighting>" + s.lighting + "</lighting>" + "\n";
                xml += "<dark>" + s.dark + "</dark>" + "\n";

                xml += "</" + nodeName + ">" + "\n";
            }

            return(xml);
        }
Пример #19
0
    public List<WeaponStats> ReadWeaponStatsFromFile(TextAsset weaponAssets)
    {
        List<WeaponStats> outputList = new List<WeaponStats>();
        if (weaponAssets != null)
        {
            Debug.Log(weaponAssets.text);
            using (StreamReader sr = new StreamReader(new MemoryStream(weaponAssets.bytes)))
            {
                while (!sr.EndOfStream)
                {
                    string t = sr.ReadLine();
                    Debug.Log("Line contents: " + t);
                    if (!t.Contains("#"))
                    {
                        WeaponStats tws = new WeaponStats();
                        Debug.Log(t);
                        string[] tt = t.Split(',');
                        tws.setName(tt[0]);
                        tws.setClipSize(int.Parse(tt[1]));
                        tws.setMaxAmmo(int.Parse(tt[2]));
                        tws.setSpreadFactor(float.Parse(tt[3]));

                        Debug.Log("Added " + tws.getName() + " to weapon list");

                        outputList.Add(tws);
                    }
                }
            }
        }
        return outputList;
    }
Пример #20
0
    private bool ValidWeapon(GameObject obj)
    {
        Inventory inventory = obj.GetComponent <Inventory>();

        if (inventory == null)
        {
            return(false);
        }

        GameObject weapon = inventory.equippedWeapon;

        if (weapon == null)
        {
            return(false);
        }

        WeaponStats weaponStats = weapon.GetComponent <WeaponStats> ();

        if (weaponStats == null)
        {
            return(false);
        }

        return(true);
    }
Пример #21
0
    public override void OnInspectorGUI()
    {
        WeaponStats copy = EditorGUILayout.ObjectField("Copy Values", null, typeof(WeaponStats), false) as WeaponStats;

        if (copy != null)
        {
            Undo.RegisterCompleteObjectUndo(target, "Copy WeaponStats");
            WeaponStats target1 = target as WeaponStats;
            target1.attackRadius            = copy.attackRadius;
            target1.attackSpeed             = copy.attackSpeed;
            target1.attackLatency           = copy.attackLatency;
            target1.chargeInTime            = copy.chargeInTime;
            target1.chargeOutTime           = copy.chargeOutTime;
            target1.stabDistance            = copy.stabDistance;
            target1.stabSpeed               = copy.stabSpeed;
            target1.knockbackForce          = copy.knockbackForce;
            target1.knockbackTime           = copy.knockbackTime;
            target1.damage                  = copy.damage;
            target1.hitsPerSwing            = copy.hitsPerSwing;
            target1.swingInterruptionLayers = copy.swingInterruptionLayers;
            target1.sprite                  = copy.sprite;
        }

        DrawDefaultInspector();
    }
Пример #22
0
    private void CmdSwapWeapon(GunType _gunType)
    {
        switch (_gunType)
        {
        case GunType.PRIMARY:
            if (currWeaponStats.gunType == GunType.PRIMARY)
            {
                return;
            }

            currWeaponStats = primaryGun;
            break;

        case GunType.SECONDARY:
            if (currWeaponStats.gunType == GunType.SECONDARY)
            {
                return;
            }

            currWeaponStats = secondaryGun;
            break;

        default:
            break;
        }
    }
Пример #23
0
    public void OnTriggerEnter(Collider other)
    {
        //GameObject otherObj = other.gameObject;
        //Debug.Log("Triggered with: " + otherObj);


        if (other.gameObject.tag == "CurrentWeapon" || other.gameObject.tag == "CanGrab" || other.gameObject.tag == "Hammer" || other.gameObject.tag == "Sickle")
        {
            weapondmg = 0;
            WeaponStats weaponstats = null;
            if (other.gameObject.GetComponent <WeaponStats>())
            {
                weaponstats = other.gameObject.GetComponent <WeaponStats>();
                weapondmg   = weaponstats.WeaponStrength;
            }
            else
            {
                if (other.gameObject.GetComponent <Rigidbody>())
                {
                    if (!other.gameObject.GetComponent <Rigidbody>().isKinematic)
                    {
                        weapondmg = Random.Range(0, 5);
                    }
                }
            }
            Debug.Log("Arm Hit");
            ArmDamage();
            StartCoroutine(WaitQuick());
            //hitOnce = true;
        }
    }
Пример #24
0
    /// <summary>
    /// Filters thru what item the player is holding
    /// <para>what player's current combo status is</para>
    /// <para>and casts the correct attack based on that</para>
    /// </summary>
    private void GetAbility()
    {
        Item item = playerHand.GetComponent <Item>();

        if (item.itemType == Item.ItemType.weapon)
        {                                                                      // is Weapon ?
            WeaponStats weaponStats = playerHand.GetComponent <WeaponStats>(); // Use to adjust Ability's attributes
            if (item.itemName.Contains("Sword"))
            {                                                                  // is Sword ?
                switch (stats.currentCombo)
                {                                                              // Current Combo ?
                case 0: AbilitySelector("Entry-Attack"); break;

                case 1: AbilitySelector("First-MainAttack"); break;

                case 2: AbilitySelector("Second-MainAttack"); break;
                }
            }
            if (item.itemName.Contains("Bow"))
            { // is Bow?
              // Insert Bow Mechanics
            }
        }

        if (item.itemType != Item.ItemType.weapon) // is non-Weapon ?
        {
            AbilitySelector("NonWeaponAttack");
        }

        // Read from Combo manager
        // Filter thru the abilities available for the currently holding item
    }
Пример #25
0
    public void AddWeapon(WeaponStats _WeaponToAdd)
    {
        bool DontAdd = false;

        foreach (Slots_Info WS in HoldersWeapon)
        {
            if (_WeaponToAdd.Weapon_Name == WS.SlotWeapon.Weapon_Name)
            {
                DontAdd = true;
            }
        }

        if (DontAdd == false)
        {
            int i = 0;
            foreach (Slots_Info WS in HoldersWeapon)
            {
                if (WS.SlotWeapon.Damage == 0)
                {
                    //WS.SlotWeapon = _WeaponToAdd;
                    WS.SlotWeapon   = AddInfo(_WeaponToAdd, WS.SlotWeapon);
                    Slots[i].sprite = _WeaponToAdd.Icon;
                    break;
                }
                i++;
            }
            UpdateAmmotxt();
        }
    }
Пример #26
0
    private IEnumerator Createhoe()
    {
        if (!weaponismade)
        {
            if (CaveMound)
            {
                direction = gameObject.transform.right;
                distance  = 2;
            }
            if (!CaveMound)
            {
                direction = gameObject.transform.up;
                distance  = 1;
            }
            GameObject hoeclone = Instantiate(hoe, transform.position + direction * distance, hoe.transform.rotation) as GameObject;
            hoeclone.transform.parent = null;
            weaponstats = hoeclone.GetComponent <WeaponStats>();
            weaponstats.WeaponStrength = Random.Range(10, 20) * levelmultiplier;
            rend = hoeclone.GetComponentsInChildren <Renderer>();

            if (CaveMound)
            {
                Vector3 fixPos = new Vector3(1, -2, 1);
                hoeclone.transform.localPosition = hoeclone.transform.position + fixPos;
            }
            weaponismade = true;
            Destroy(gameObject, 1);

            StopCoroutine(Createhoe());
            yield return(null);
        }
        weaponismade = true;
        yield return(null);
    }
Пример #27
0
    public void fire(WeaponStats wp, Vector2 targetPoint)
    {
        GetComponent <Attackable>().TakeDamage(wp.RecoilDamage);
        for (int i = 0; i < Weapon.shots; i++)
        {
            //float angle = Mathf.Atan2(targetPoint.y - transform.position.y, targetPoint.x - transform.position.x) * Mathf.Rad2Deg - 90f;
            //float angle = (transform.rotation.eulerAngles.z + 90) * Mathf.Deg2Rad;
            //GameObject bullet = GameObject.Instantiate(Weapon.bullet, transform.position + new Vector3(Offset.x * Mathf.Cos(angle), Offset.y * Mathf.Sin(angle), +.5f), Quaternion.identity);

            //Debug.Log("from: " + transform.position + " to: " + targetPoint + " ang: " + angle);
            ////bullet.GetComponent<Projectile>().SetAngle(angle + Random.Range(-Weapon.spread, Weapon.spread));
            //bullet.GetComponent<Projectile>().
            //bullet.GetComponent<Projectile>().SetWeapon(Weapon);
            //GetComponent<FactionHolder>().SetFaction(bullet);
            //Destroy(bullet, Weapon.duration);

            Vector3 rawTargetPoint = targetPoint;
            rawTargetPoint = rawTargetPoint + new Vector3(Offset.x, Offset.y, 0f);
            float angle  = Mathf.Atan2(rawTargetPoint.y, rawTargetPoint.x);
            float spread = Weapon.spread * Mathf.Deg2Rad;
            float rand   = Random.Range(-spread, spread);

            angle      += rand;
            targetPoint = new Vector3(Mathf.Cos(angle), Mathf.Sin(angle), 0);
            //Debug.Log(rand + " : " + Mathf.Cos(angle) + " : " + Mathf.Sin(angle));
            CreateProjectile(wp.bullet, Vector2.zero, targetPoint, wp);
        }
        if (Weapon.attackSound != null && Weapon.attackSound.Count > 0 && AudioManager != null)
        {
            AudioManager.playSound(Weapon.attackSound[Random.Range(0, Weapon.attackSound.Count)]);
        }
        coolDown = Weapon.firerate / 1000;
    }
Пример #28
0
 void Start()
 {
     stats           = PlayerStats.instance;
     stats.curHealth = stats.maxHealth;
     if (statusIndicator == null)
     {
         Debug.LogError(this);
     }
     else
     {
         statusIndicator.SetHealth(stats.curHealth, stats.maxHealth);
     }
     GameMaster.gm.onTogglePauseGame += OnPauseGameToggle;
     soundManager = SoundManager.instance;
     if (soundManager == null)
     {
         Debug.LogError("No SoundManager found");
     }
     weaponstats = WeaponStats.instance;
     if (weaponstats == null)
     {
         Debug.LogError("No WeaponStats found");
     }
     pistol         = GameObject.Find("Arm").transform.GetChild(0).GetComponent <Weapon>();
     pistol.damage  = weaponstats.pistolDMG;
     rifle          = GameObject.Find("Arm").transform.GetChild(1).GetComponent <Weapon>();
     rifle.damage   = weaponstats.rifleDMG;
     rifle.fireRate = weaponstats.rifleFR;
     InvokeRepeating("RegenHealth", 1f, 0.5f);
 }
Пример #29
0
    void PlayerHurt(GameObject enemyWeap)
    {
        if (invulnerable || !isAlive)
        {
            return;
        }
        stunned = true;
        StartCoroutine(HurtCooldown());
        currentHealth -= enemyWeap.GetComponent <WeaponStats>().damage;
        healthBar.transform.localScale = new Vector3(originalHealthLength * (currentHealth / maxHealth), healthBar.transform.localScale.y, healthBar.transform.localScale.z);
        if (currentHealth <= 0)
        {
            // Player dies, restart level/scene
            StartCoroutine(HandleDeath());
            return;
        }
        else
        {
            AudioSource.PlayClipAtPoint(playerHurt, Camera.main.transform.position + Vector3.forward);
            WeaponStats ws = enemyWeap.GetComponent <WeaponStats>();
            Vector2     kb = new Vector2(ws.knockback.x * enemyWeap.transform.right.x, ws.knockback.y);
            controller.PlayerKnockback(kb);

            // TODO: PlayerHurt audio
        }
        // Check if dead
    }
Пример #30
0
    /// <summary>
    /// Attempts to purchase a weapon and displays dialog based on the result
    /// of the attempt.
    /// </summary>
    /// <param name="slot"></param>
    public void purchaseWeapon(int slot)
    {
        ShopInventorySlot shopSlot  = inventorySlots[slot];
        GameObject        selection = inventory[slot];
        WeaponStats       stats     = selection.GetComponentInChildren <WeaponStats>(true);

        if (stats.price > StateManager.cashOnHand)
        {
            audioS.PlayOneShot(failureSound, Settings.volume);
            dialogText.text = getRandomDialog(brokeDialogs);
            return;
        }

        if (playerShoot.guns.Count >= MAX_GUNS)
        {
            audioS.PlayOneShot(failureSound, Settings.volume);
            dialogText.text = getRandomDialog(fullInventoryDialogs);
            return;
        }

        // can purchase
        playerInventory.addWeapon(selection);
        shopSlot.purchased = true;

        // only remove cash if everything above that succeeded and the player received the gun
        StateManager.cashOnHand -= stats.price;
        shopSlot.buttonObject.GetComponent <Button>().interactable = false;
        shopSlot.infoBlock.SetActive(false);
        shopSlot.soldout.SetActive(true);
        shopSlot.pricetag.text = "-";
        audioS.PlayOneShot(paymentSound, Settings.volume);
        dialogText.text = getRandomDialog(purchaseDialogs);
    }
Пример #31
0
    public void Initialize(WeaponStats stats, Vector3 initDirection)
    {
        rocketLaunchTime = Time.time;
        currentStats     = stats;

        rocketAccelerationForce = stats.InitialSpeed;
        maxForce = rocketAccelerationForce;
        Mass     = stats.Mass;

        Debug.Log("launched weapon:" + stats.Type);


        //get vector to Sun
        Vector3 sunPosition = SunBehavior.Instance.transform.position;

        Vector3 gravityDirection = sunPosition - transform.position;

        //  currentDirection = Vector3.Cross(gravityDirection, Vector3.forward * -1f) * rocketAccelerationForce;
        currentDirection = initDirection * rocketAccelerationForce;

        //detect orbital force direction
        //if sun on left or right side
        if (AngleDir(initDirection, gravityDirection, -Vector3.forward) > 0)
        {
            upVector = -Vector3.forward;
            //  Debug.Log("Up Vector");
        }
        else
        {
            upVector = Vector3.forward;
            // Debug.Log("Down Vector");
        }

        isInitialized = true;
    }
Пример #32
0
	public ClassStats (string className) {
	
		if (className == "Assault") {
			name = "Assault";
			
			vitality = 40;
			agility = 80;
			acuracy = 50;
			
			weaponStat = new WeaponStats(5, 10, 7, 20, 1f);
		}
		
		if (className == "Tank") {
			name = "Tank";
			
			vitality = 110;
			agility = 8;
			acuracy = 90;
			
			weaponStat = new WeaponStats(14, 4, 3, 12, 2f);
		}
		
		if (className == "Sniper") {
			name = "Sniper";
			
			vitality = 20;
			agility = 70;
			acuracy = 250;
			
			weaponStat = new WeaponStats(40, 0, 30, 6, 2f);
		}
	}
Пример #33
0
    // Start is called before the first frame update
    void Start()
    {
        //using constuctor to initialize calss object
        blasters = new WeaponStats("Blasters", 0.25f, 50);
        rockets  = new WeaponStats("Rockets", 5f, 1);

        print(blasters.name);
        print(blasters.fireRate);
        print(blasters.ammoCount);

        /*
         * If we do not use constructor this is how we intilize class object
         * and after we assign each vraible one by one
         * This is bad practice, time consuming and not clean
         */
        /*
         * blasters = new WeaponStats();
         * blasters.name = "Blasters";
         * blasters.fireRate = 0.25f;
         * blasters.ammoCount = 50;
         *
         * rockets = new WeaponStats();
         * rockets.name = "Roket";
         * rockets.fireRate = 5.0f;
         * rockets.ammoCount = 1;
         */
    }
Пример #34
0
    public void changeWeapon(int type)
    {
        wepStats = WeaponHandler.GetWeaponStats(activeChar, type);
        wepType = type;

        if (Network.isClient)
            networkView.RPC("changeWeaponRPC", RPCMode.Server, type);
    }
 public WeaponStats(WeaponStats stats)
 {
     m_Damage = stats.m_Damage;
     m_Knockback = stats.m_Knockback;
     m_AttackType = stats.m_AttackType;
     m_Weight = stats.m_Weight;
     m_MountPoints = stats.m_MountPoints;
 }
Пример #36
0
 /// <summary>
 /// Combines the parsed stats with this stats. Nothing returned, but the parsed stats are edited.
 /// </summary>
 /// <param name="other">Other stats.</param>
 public void CombineWith(WeaponStats other)
 {
     other.damage *= damage;
     other.spread *= spread;
     other.speed *= speed;
     other.weight += weight;
     other.recoil *= recoil;
     other.firerate /= firerate;
     other.bulletAmount *= bulletAmount;
 }
Пример #37
0
 public WeaponStats Clone()
 {
     WeaponStats s = new WeaponStats();
     s.damage = damage;
     s.spread = spread;
     s.speed = speed;
     s.weight = weight;
     s.recoil = recoil;
     s.firerate = firerate;
     s.bulletAmount = bulletAmount;
     return s;
 }
Пример #38
0
	public Player_Stats() {
		int[] val_temp = new int[11];
		Stat_Cost[] cost_temp = new Stat_Cost[10];
		// initialize health values
		for (int idx = 0; idx < val_temp.Length; ++idx) {
			val_temp[idx] = (int)(1.5f * idx * idx) + 8 * idx + 5;
		}
		// initialize stat costs
		for (int idx = 0; idx < cost_temp.Length; ++idx) {
			cost_temp[idx] = new Stat_Cost(0, (int)(0.35f * idx * idx) + 9 * idx + 6);

		}

		MAX_HEALTH = new Stat(STAT_TYPE.health, val_temp, cost_temp);
		health = (int)MAX_HEALTH.current();
		HP_raised = true;

		val_temp = new int[11];
		cost_temp = new Stat_Cost[10];
		// initialize shield values
		for (int idx = 0; idx < val_temp.Length; ++idx) {
			val_temp[idx] = (int)(0.55f * idx * idx) + 5 * idx + 3;
		}

		// initialize stat costs
		for (int idx = 0; idx < cost_temp.Length; ++idx) {
			cost_temp[idx] = new Stat_Cost((int)(0.19f * idx * idx) + 2 * idx + 3, 0);
		}

		MAX_SHIELD = new Stat(STAT_TYPE.shield, val_temp, cost_temp);
		shield = (int)MAX_SHIELD.current();
		Shield_raised = true;

		WEAPONS = new WeaponStats[4];
		WEAPONS[0] = new WeaponStats(0);
		WEAPONS[1] = new WeaponStats(1);
		WEAPONS[2] = new WeaponStats(2);
		WEAPONS[3] = new WeaponStats(3);
		held_weapon = WEAPON_TYPE.sword;

		scrap = 0; //2573
		energyCores = 0; //1197

		MEDPACKS = new Stat(STAT_TYPE.other, new int[] { 0, 1, 2, 3 },
											 new Stat_Cost[] { new Stat_Cost(1, 5), new Stat_Cost(3, 18), new Stat_Cost(5, 43) } );

	}
Пример #39
0
    // Switch the current weapon
    public void SwitchWeapon(Weapons weapon)
    {
        switch (weapon) {
            case Weapons.laserGun:
                stats = new LaserGun();
                ammo.text = "∞";
                break;
            case Weapons.alienWeapon:
                stats = new AlienWeapon();
                break;
            case Weapons.gravityGun:
                stats = new GravityGun();
                break;
            case Weapons.dummyGun:
                stats = new DummyGun();
                break;
        }

        int index = 0;
        foreach (Transform child in transform) {
            child.gameObject.SetActive(false);
            if (index == (int)weapon)
                child.gameObject.SetActive(true);
            index++;
        }

        currentWeapon = weapon;
        // change weapon in HUD and play sound
        index = 0;
        foreach (GameObject image in weaponImages)
        {
            image.SetActive(false);
            if (index == (int)weapon)
                image.SetActive (true);
            index++;
        }
        weaponText.text = stats.name;
        if (weapon != Weapons.laserGun)
        {
            ammo.text = stats.ammo.ToString();
        }
        StartCoroutine(PlayWeaponAudio());
    }
Пример #40
0
    public void CombineData()
    {
        string newName = "";
        if (body.barrel)
            newName += body.barrel.nameMod;
        if (body.optic)
            newName += " " + body.optic.nameMod;
        if (body.stock)
            newName += " " + body.stock.nameMod;
        newName += " " + body.nameMod;
        if (body.underBarrel)
            newName += " with " + body.underBarrel.nameMod;

        weaponName = newName;
        WeaponStats stats = body.stats.Clone ();

        for (int i = 0; i < weaponParts.Count; i++) {
            weaponParts[i].stats.CombineWith (stats);
        }

        combinedStats = stats;
    }
    void setStringData(WeaponStats stats)
    {
        for(int i = 0; i < m_Stats.Length; i++)
        {
            m_Stats[i] = m_StatsBaseString[i];
        }

        m_Stats[(int)Stats.Damage]          += stats.m_Damage.ToString();
        m_Stats[(int)Stats.Knockback]       += stats.m_Knockback.ToString();
        m_Stats[(int)Stats.AttackType]      += stats.m_AttackType.ToString();
        m_Stats[(int)Stats.Weight]     		+= stats.m_Weight.ToString();
        m_Stats[(int)Stats.MountPoints]     += stats.m_MountPoints.Count.ToString();
    }
Пример #42
0
    void FillWeapons()
    {
        int count = 1;


        foreach (GameObject heroObject in heroObjects)
        {
            ILevelObject<PlayerStats> ho = heroObject.GetComponent<ILevelObject<PlayerStats>>();
            if (ho != null)
            {

                GameObject go = heroPrefabs[count-1];
                ws = heroObject.GetComponent<HeroLevelObject>().weapons[0];
                go.GetComponent<PlayerWeaponManager>().characterGo = heroObject;
                count++;
            }
        }
    }
    public void SetTotalStatsAfterCrafting()
    {
        m_TotalStats = GetStats ();

        m_MiscEffects.Clear ();

        /*foreach(MiscEffects effect in GetComponentsInChildren<MiscEffects>())
        {
            m_MiscEffects.Add (effect);
        }*/

        CreateEffects ();
    }
    WeaponStats GetStats()
    {
        WeaponStats stats = new WeaponStats (m_Stats);

        foreach(Transform attachment in m_Stats.m_MountPoints)
        {
            if(attachment.childCount > 0)
            {
                WeaponStats attachmentStats = attachment.GetChild (0).GetComponent<BaseAttachment>().GetStats ();

                stats.m_Damage += attachmentStats.m_Damage;
                stats.m_Knockback += attachmentStats.m_Knockback;
                stats.m_AttackType += attachmentStats.m_AttackType;
                stats.m_Weight += attachmentStats.m_Weight;
            }
        }
        return stats;
    }
Пример #45
0
 private void GenerateJSON()
 {
     WeaponStats abc = new WeaponStats();
     Debug.Log(abc.SaveToString());
 }
Пример #46
0
 public void PlayerHit(Transform player, Transform other)
 {
     if(other.gameObject.tag == "Weapon")
     {
         if(player != other.parent)
         {
             Weapon = other.gameObject.GetComponent<WeaponStats>();
             Racer = player.gameObject.GetComponent<RacerHealth>();
             switch(weapon.theName.ToString())
             {
             case "Flamethrower":
                 Damage = FlameThrowerDamage;
                 Racer.CurrentHealth -= Damage;
                 break;
             case "FlakCannon":
                 Damage = FlakCannonDamage;
                 Racer.CurrentHealth -= Damage;
                 break;
             case "Hellfire":
                 Damage = HellfireDamage;
                 Racer.CurrentHealth -= Damage;
                 break;
             case "Roll":
                 Damage = RollDamage;
                 Racer.CurrentHealth -= Damage;
                 break;
             case "LaserBeam":
                 Damage = LaserBeamDamage;
                 Racer.CurrentHealth -= Damage;
                 break;
             case "EMP":
                 Damage = EmpDamage;
                 Racer.CurrentHealth -= Damage;
                 break;
             case "SonicScream":
                 Damage = SonicScreamDamage;
                 Racer.CurrentHealth -= Damage;
                 break;
             case "EggDrop":
                 Damage = EggDropDamage;
                 Racer.CurrentHealth -= Damage;
                 break;
             case "EggMine":
                 Damage = EggMineDamage;
                 Racer.CurrentHealth -= Damage;
                 break;
             case "TeleportSlam":
                 Damage = TeleportSlamDamage;
                 Racer.CurrentHealth -= Damage;
                 break;
             case "AcidSpit":
                 Damage = AcidSpitDamage;
                 Racer.CurrentHealth -= Damage;
                 break;
             case "Smite":
                 Damage = SmiteDamage;
                 Racer.CurrentHealth -= Damage;
                 break;
             case "Orbs":
                 Damage = OrbsDamage;
                 Racer.CurrentHealth -= Damage;
                 break;
             default:
                 break;
             }
         }
     }
 }