Exemple #1
0
 private void Player_ModRayStateChange(ModRayStates oldState, ModRayStates state)
 {
     if (state == ModRayStates.Offline)
     {
         StartCoroutine(DefocusVision());
     }
     else if (oldState == ModRayStates.Offline)
     {
         StartCoroutine(FocusVision());
     }
 }
Exemple #2
0
    void DeactivateModRay()
    {
        lRend.SetPosition(1, Vector3.zero);
        modRayTime = 0;

        if (modRayHitting != ModRayStates.Offline && OnModRayStateChage != null)
        {
            OnModRayStateChage(modRayHitting, ModRayStates.Offline);
        }
        modRayHitting = ModRayStates.Offline;

        modRayEdge.Stop();
        modRayHitInit = -modRayHitActivationTime;
    }
Exemple #3
0
    void ElongateModificationRay()
    {
        //Make camera ray;
        Ray camRay = Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2f, Screen.height / 2f));


        if (Physics.Raycast(camRay, out modRayCamHit, modRayMaxLength, modLayers, QueryTriggerInteraction.Ignore))
        {
            modRayTime += modRaySpeed * Time.deltaTime;
            hitPoint    = modRayCamHit.point;
            Vector3 modRayTarget = modRaySource.InverseTransformPoint(hitPoint);
            float   hitDistance  = modRayTarget.magnitude;

            modRayTime = Mathf.Clamp(modRayTime, 0, hitDistance);

            ModRayStates oldHitState = modRayHitting;
            modRayHitting = modRayTime < 0.999f * hitDistance ? ModRayStates.Elongating : ModRayStates.PowerUp;
            if ((oldHitState == ModRayStates.Offline || oldHitState == ModRayStates.Elongating) && modRayHitting == ModRayStates.PowerUp)
            {
                if (!modRayEdge.isPlaying)
                {
                    modRayEdge.Play();
                }
                modRayEdge.Emit(Random.Range(50, 200));
                modRayHitInit = Time.timeSinceLevelLoad;
            }
            else if (Time.timeSinceLevelLoad - modRayHitInit > modRayHitActivationTime && modRayHitting == ModRayStates.PowerUp)
            {
                modRayHitting = ModRayStates.Fire;
                modRayEdge.Emit(Random.Range(100, 400));
            }

            if (oldHitState != modRayHitting && OnModRayStateChage != null)
            {
                OnModRayStateChage(oldHitState, modRayHitting);
            }

            lRend.SetPosition(1, modRayTarget.normalized * modRayTime);

            modRayEdge.transform.position = modRaySource.TransformPoint(modRayTarget.normalized * modRayTime * 0.93f);

            if (modRayHitting == ModRayStates.Elongating)
            {
                modRayEdge.transform.LookAt(head);
            }
            else
            {
                modRayEdge.transform.rotation = Quaternion.LookRotation(modRayCamHit.normal, Vector3.up);
            }
        }
        else
        {
            if (modRayHitting != ModRayStates.Offline && OnModRayStateChage != null)
            {
                OnModRayStateChage(modRayHitting, ModRayStates.Offline);
            }
            modRayHitting = ModRayStates.Offline;
        }

        if (modRayHitting == ModRayStates.Fire)
        {
            ActivateModificationRay();
        }
        else if (modRayHitting == ModRayStates.Offline)
        {
            DeactivateModRay();
        }
    }