Ejemplo n.º 1
0
 void Awake()
 {
     player             = GameObject.FindWithTag("Player");
     playerMovement     = player.GetComponent <PlayerMovement>();
     playerBark         = player.GetComponent <GrenadeBehaviour>();
     playerBark.enabled = false;
 }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        float delta = (transform.position - lastPosition).magnitude / Time.deltaTime;

        fieldStrengthPercentage = Mathf.SmoothDamp(fieldStrengthPercentage, (delta - velocityMin) / (velocityMax - velocityMin), ref fieldStrengthVel, fieldSpeed);

        fieldStrength = Mathf.Lerp(fieldStrengthMin, fieldStrengthMax, fieldStrengthPercentage);

        Collider[] insiders = Physics.OverlapSphere(transform.position, 5);
        foreach (Collider insider in insiders)
        {
            // Controller (player/entity) stuff
            //Controller slowable = insider.gameObject.GetComponent<Controller>();

            //if (slowable != null)
            //{
            //    if (slowable.Faction != parent.Faction)
            //    {
            //        slowable.Timestep = fieldStrength;
            //    }
            //}
            //else
            //{
            // Grenade stuff
            GrenadeBehaviour grenade = insider.gameObject.GetComponent <GrenadeBehaviour>();
            if (grenade != null)
            {
                if (grenade.parent.Faction != parent.Faction)
                {
                    grenade.SetTimestep(fieldStrength);
                }
            }
            else
            {
                // Projectile stuff
                ProjectileBehaviour projectile = insider.gameObject.GetComponent <ProjectileBehaviour>();
                if (projectile != null)
                {
                    if (projectile.parent.Faction != parent.Faction)
                    {
                        projectile.SetTimestep(fieldStrength);
                    }
                }
            }
            //}
        }

        lastPosition = transform.position;

        distort.material.shader = Shader.Find("FX/Glass/Stained BumpDistort");
        distort.material.SetFloat("_BumpAmt", Mathf.Lerp(fieldDistortMax, fieldDistortMin, fieldStrengthPercentage));
    }
Ejemplo n.º 3
0
    void OnTriggerStay(Collider other)
    {
        ProjectileBehaviour projectile = other.GetComponent <ProjectileBehaviour>();

        if (projectile != null)
        {
            if (projectile.parent.Faction != parent.Faction)
            {
                projectile.SetTimestep(fieldStrength);
            }
        }
        else
        {
            GrenadeBehaviour grenade = other.GetComponent <GrenadeBehaviour>();
            if (grenade != null)
            {
                if (grenade.parent.Faction != parent.Faction)
                {
                    grenade.SetTimestep(fieldStrength);
                }
            }
        }
    }
Ejemplo n.º 4
0
 void Start()
 {
     grenadeScript = GetComponent <GrenadeBehaviour>();
     barkCooldown  = grenadeScript.grenadeMaxCD;
 }