Exemplo n.º 1
0
    private Weapon getWeapon()
    {
        Spell     weaponSpell = spellTypes.spells[(int)Random.Range(0, spellTypes.spells.Count)];
        SpellAttr limits      = weaponSpell.GetSpellAttr();

        SpellMod modifiers = new SpellMod();

        modifiers.damage = Random.Range(limits.minDamage, limits.maxDamage);
        //TODO: Change to scale
        modifiers.dot = Random.Range(0, 100) < 20;
        if (modifiers.dot)
        {
            modifiers.dotTick = Random.Range(limits.minDot, limits.maxDot);
            //TODO: Change to scale
            modifiers.dotLength = Random.Range(0, 5);
        }
        //TODO: Change to scale
        modifiers.bounce     = Random.Range(0, 100) < 20;
        modifiers.pierce     = Random.Range(0, 100) < 20;
        modifiers.track      = Random.Range(0, 100) < 20;
        modifiers.numBullets = (int)Random.Range(0, 5);

        modifiers.TTL      = Random.Range(limits.minTTL, limits.maxTTL);
        modifiers.range    = Random.Range(limits.minRange, limits.maxRange);
        modifiers.fireRate = Random.Range(limits.minFireRate, limits.maxFireRate);

        Weapon newWeapon = (Weapon)ScriptableObject.CreateInstance("Weapon");

        newWeapon.set("Test Weapon", weaponSpell, modifiers);
        return(newWeapon);
    }
Exemplo n.º 2
0
    public static EnemyStats calcStats(EnemyMaxStats max, LevelStage diff, float time)
    {
        float health = max.minHealth + (int)(time / 30) * max.healthMod;

        if (health > max.maxHealth)
        {
            health = max.maxHealth;
        }

        float speed = Random.Range(max.minSpeed, max.minSpeed + (time / 20) * max.speedMod);

        if (speed > max.maxSpeed)
        {
            speed = max.maxSpeed;
        }

        Spell attack = null;

        if (max.attacks != null && max.attacks.Count > 0)
        {
            int attackType = Random.Range(0, max.attacks.Count);
            attack = max.attacks[attackType];
        }

        SpellAttr attr      = max.attackModifiers;
        SpellMod  modifiers = new SpellMod();

        modifiers.damage = Random.Range(attr.minDamage, attr.minDamage + attr.minDamage * time / 90);
        if (modifiers.damage > attr.maxDamage)
        {
            modifiers.damage = attr.maxDamage;
        }

        modifiers.damagePercent = 1;

        int  dotChance = Random.Range(0, 101);
        bool dot       = (15 * (int)diff) >= dotChance;

        if (dot)
        {
            modifiers.dot     = true;
            modifiers.dotTick = Random.Range(attr.minDot, attr.minDot + attr.minDot * time / 180);
            if (modifiers.dotTick > attr.maxDot)
            {
                modifiers.dotTick = attr.maxDot;
            }
            modifiers.dotLength = Random.Range(attr.minFireRate, attr.maxFireRate);
        }

        modifiers.TTL      = Random.Range(attr.minTTL, attr.maxTTL);
        modifiers.fireRate = Random.Range(attr.minFireRate, attr.minFireRate + attr.minFireRate * time / 180);
        if (modifiers.fireRate > attr.maxFireRate)
        {
            modifiers.fireRate = attr.maxFireRate;
        }

        //TODO: Do range for some enemies after adding wind weapon

        return(new EnemyStats(health, attack, modifiers, max.sightRange, max.sightAngle, speed));
    }
Exemplo n.º 3
0
 public void setModifiers(SpellMod modifiers)
 {
     this.modifiers = modifiers;
     if (modifiers.bounce)
     {
         GetComponent <Collider>().isTrigger = false;
     }
     Destroy(gameObject, modifiers.TTL);
 }
Exemplo n.º 4
0
 public EnemyStats(float maxHealth, Spell attack, SpellMod mod, float sightRange, float sightAngle, float speed)
 {
     this.maxHealth  = maxHealth;
     this.attack     = attack;
     this.modifiers  = mod;
     this.sightAngle = sightAngle;
     this.sightRange = sightRange;
     this.speed      = speed;
 }
Exemplo n.º 5
0
    public override void fire(SpellMod modifiers, Transform firePoint, Camera mainCam)
    {
        GameObject temp = Instantiate(projectile) as GameObject;

        temp.transform.position = mainCam.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, mainCam.nearClipPlane));

        ISpellCollision spellScript = temp.GetComponent <ISpellCollision>();

        spellScript.setModifiers(modifiers);

        Rigidbody projectRigid = temp.GetComponent <Rigidbody>();

        projectRigid.velocity = mainCam.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0)).direction * 20;
    }
Exemplo n.º 6
0
    public override void fire(SpellMod modifiers, Vector3 firePoint, Vector3 target)
    {
        GameObject temp = Instantiate(projectile) as GameObject;

        temp.transform.position = firePoint;

        ISpellCollision spellScript = temp.GetComponent <ISpellCollision>();

        spellScript.setModifiers(modifiers);

        Rigidbody projectRigid = temp.GetComponent <Rigidbody>();

        projectRigid.velocity = (target - firePoint).normalized * 20;
    }
Exemplo n.º 7
0
    public void passWeapon(Weapon current, Weapon info)
    {
        string   weaponInfo = "";
        SpellMod spellInfo  = info.modifiers;

        weaponInfo += info.spellPrefab.spellName + "\n";

        float  damageDiff    = spellInfo.damage - current.modifiers.damage;
        string damageDiffStr = " (" + (damageDiff < 0 ? "-" : "+") + damageDiff + ")";

        weaponInfo += "Damage: " + spellInfo.damage + damageDiffStr + "\n";

        if (spellInfo.dot)
        {
            weaponInfo += "Applies DoT for " + spellInfo.dotTick + "/s for " + spellInfo.dotLength + "\n";
        }

        switch (info.spellPrefab.spellAttributes.spellType)
        {
        case 0:
            weaponInfo += "Fire Rate: " + spellInfo.fireRate + " shots/second" + "\n";
            weaponInfo += "Travel Time: " + spellInfo.TTL + "\n";
            break;

        case 1:
            weaponInfo += "Hit Rate: " + spellInfo.fireRate + " ticks/second" + "\n";
            weaponInfo += "Charge: " + spellInfo.TTL + "\n";
            weaponInfo += "Max Range Time: " + 1 / spellInfo.range + "s\n";
            break;

        case 2:
            weaponInfo += "Max Charge Time: " + spellInfo.fireRate + "s\n";
            weaponInfo += "Travel Time: " + spellInfo.TTL + "\n";
            break;

        case 3:
            weaponInfo += "Fire Rate: " + spellInfo.fireRate + " shots/second" + "\n";
            break;
        }

        if (spellInfo.pierce)
        {
            weaponInfo += "(+Piercing) ";
        }
        if (spellInfo.bounce)
        {
            weaponInfo += "(+Bouncing Bullets) ";
        }
        weaponInfoText.text = weaponInfo;
    }
Exemplo n.º 8
0
    public override void fire(SpellMod modifiers, Transform firePoint, Camera mainCam)
    {
        GameObject temp = Instantiate(projectile, mainCam.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, mainCam.nearClipPlane)) - mainCam.transform.forward.normalized * 10, firePoint.rotation);

        RaycastHit[] hits;

        ISpellCollision spellCollision = temp.GetComponent <ISpellCollision>();

        temp.GetComponent <Rigidbody>().velocity = mainCam.transform.forward.normalized * 500;
        hits = Physics.SphereCastAll(mainCam.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, mainCam.nearClipPlane)), 0.5f, mainCam.transform.forward);
        Debug.DrawRay(mainCam.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, mainCam.nearClipPlane)), mainCam.transform.forward);
        if (hits.Length > 0)
        {
            hits = raycastSort(hits, firePoint.position);
            foreach (RaycastHit hit in hits)
            {
                if (hit.collider.tag == "Enemy")
                {
                    HealthControl collidedHealth = hit.collider.GetComponent <HealthControl>();
                    collidedHealth.takeDamage(modifiers.damage * modifiers.damagePercent);

                    if (modifiers.dot)
                    {
                        collidedHealth.applyDot(modifiers.dotTick, modifiers.dotLength);
                    }
                }
                else if (hit.collider.tag == "EnemyAttack")
                {
                    Destroy(hit.collider.gameObject);
                }
                else if (hit.collider.gameObject.layer == 0)
                {
                    //modifiers.range = (hit.point - temp.transform.position).magnitude / 250;
                    return;
                }
            }
            spellCollision.setModifiers(modifiers);
        }
    }
Exemplo n.º 9
0
 public override void fire(SpellMod modifiers, Transform firePoint, Camera mainCam)
 {
     if (!switchedOn)
     {
         switchedOn             = true;
         beam                   = Instantiate(projectile, firePoint.position, firePoint.rotation);
         beam.transform.forward = mainCam.transform.forward;
         beam.transform.parent  = firePoint;
         beam.GetComponent <ISpellCollision>().setModifiers(modifiers);
         beam.GetComponent <ParticleSystem>().Play();
     }
     else
     {
         switchedOn = false;
         if (beam == null)
         {
             return;
         }
         beam.GetComponent <ParticleSystem>().Stop();
         Destroy(beam);
         return;
     }
     //Destroy(beam, modifiers.TTL);
 }
Exemplo n.º 10
0
 public abstract void fire(SpellMod modifiers, Transform firePoint, Camera mainCam);
Exemplo n.º 11
0
 public override void fire(SpellMod modifiers, Transform firePoint, Camera mainCam)
 {
     return;
 }
Exemplo n.º 12
0
 public override void fire(SpellMod modifiers, Vector3 firePoint, Vector3 target)
 {
     return;
 }
Exemplo n.º 13
0
    // void Update() {
    //     timer += Time.deltaTime;
    //     Debug.Log(timer);
    //     if(timer >= modifiers.range) {
    //         GetComponent<Rigidbody>().velocity = Vector3.zero;
    //     }
    // }

    public void setModifiers(SpellMod modifiers)
    {
        this.modifiers = modifiers;
        Destroy(gameObject, modifiers.TTL);
    }
Exemplo n.º 14
0
 public override void fire(SpellMod modifiers, Vector3 firePoint, Vector3 target)
 {
     //Implement for tracking?
     return;
 }
Exemplo n.º 15
0
 public void setModifiers(SpellMod modifiers)
 {
     this.modifiers = modifiers;
     damageCooldown = 1 / modifiers.fireRate;
 }
Exemplo n.º 16
0
 public void set(string name, Spell spell, SpellMod mod)
 {
     this.weaponName  = name;
     this.spellPrefab = spell;
     this.modifiers   = mod;
 }
Exemplo n.º 17
0
 public abstract void fire(SpellMod modifiers, Vector3 firePoint, Vector3 target);