Ejemplo n.º 1
0
    public void SetProjectile(GameObject projectile)
    {
        ProjectileBase pb = projectile.GetComponent <ProjectileBase>();

        pb.SetDirection(projectileDirection);
        pb.SetSpeed(projectileSpeed);
    }
Ejemplo n.º 2
0
    protected void Shoot()
    {
        foreach (Transform fp in fps)
        {
            for (int i = 0; i < bullets.Count; i++)
            {
                if (!bullets[i].activeInHierarchy)
                {
                    Transform      t = bullets[i].transform;
                    ProjectileBase p = bullets[i].GetComponent <ProjectileBase>();
                    //t.position = new Vector3(fp.position.x,possibleTargets[0].transform.position.y,fp.position.z);
                    t.position = new Vector3(fp.position.x, fp.position.y, fp.position.z);
                    t.rotation = fp.rotation;
                    bullets[i].SetActive(true);
                    //p.SetTarget(possibleTargets[0].transform);
                    Vector3 dir = fp.GetChild(0).transform.position - t.position;
                    dir.y = 0;
                    p.SetDirection(dir);

                    UpdateBulletStatus(p);

                    if (p.durability < projectileDurability)
                    {
                        p.durability += projectileDurability;
                    }

                    //Debug.Log(p.GetDirection());
                    break;
                }
            }
        }
        rotationPart.Rotate(new Vector3(0, 30, 0));
        if (GetComponentInParent <AudioSource>())
        {
            GetComponentInParent <AudioSource>().Play();
        }
        //List<GameObject> backup = new List<GameObject>(possibleTargets);
        //foreach (GameObject item in backup)
        //{
        //    if (!item.gameObject.activeSelf)
        //        possibleTargets.Remove(item);
        //}
    }
Ejemplo n.º 3
0
    protected virtual void CreateProjectile()
    {
        //Create basic projectile
        GameObject newBullet;

        if (projectileData.hitscan)
        {
            newBullet = Instantiate(hitscanProjectilePrefab, projectileStartPos.position, Quaternion.identity);
        }
        else
        {
            newBullet = Instantiate(physicalProjectilePrefab, projectileStartPos.position, Quaternion.identity);
        }
        ProjectileBase projectile = newBullet.GetComponent <ProjectileBase>();

        //Set general properties
        projectile.SetDirection(TrigUtilities.DegreesToVector(owner.GetPlayerMovement().GetPlayerAngle() + Random.Range(-accuracyDegreeOffsetRange, accuracyDegreeOffsetRange)));
        projectile.SetDamage(projectileData.damage);
        projectile.SetDamageForce(projectileData.damageForce);
        projectile.SetOwner(owner);
        projectile.SetCanHitOwner(projectileData.canHitOwner);
        projectile.SetColor(owner.GetColor().GetModifiedBrightness(3f));
        projectile.SetBounces(projectileData.bounces);
        projectile.SetCauseExplosion(projectileData.causeExplosion);
        projectile.SetExplosionRadius(projectileData.explosionRadius);
        projectile.SetExplodeEveryBounce(projectileData.explodeEveryBounce);

        //Set properties depending on if it's hitscan or physical
        if (projectileData.hitscan)
        {
            SetHitscanProperties(newBullet);
        }
        else
        {
            SetPhysicalProperties(newBullet);
        }
    }