コード例 #1
0
ファイル: Shoot.cs プロジェクト: Soined/Physik
    private void HandleShot(bool isFreeze)
    {
        if (isOnCD || Time.timeScale == 0)
        {
            return;
        }

        gunAnimator.SetTrigger("shootTrigger");
        SoundManager.Instance.PlayNewSound(AudioType.gunShot);

        //We shoot a Ray through the middle of our screen and see what we find
        if (Physics.Raycast(Camera.main.ViewportPointToRay(new Vector3(.5f, .5f, 0)), out RaycastHit hit))
        {
            //Debug.Log($"found: {hit.collider.name}");

            if (hit.collider.GetComponentInParent <GravityPhysics>() != null)
            {
                ActivateLightning(hit.point);
                GravityPhysics other = hit.collider.GetComponentInParent <GravityPhysics>();
                if (isFreeze)
                {
                    HandleFreezeOnOther(other);
                }
                else
                {
                    HandleFlipOnOther(other);
                }
            }
        }
        isOnCD = true;
    }
コード例 #2
0
ファイル: FPController.cs プロジェクト: Soined/Physik
 // Start is called before the first frame update
 void Start()
 {
     gravity          = GetComponent <GravityPhysics>();
     Cursor.lockState = CursorLockMode.Locked;
     Cursor.visible   = false;
     startPosition    = transform.position;
     startRotation    = transform.rotation;
 }
コード例 #3
0
ファイル: Shoot.cs プロジェクト: Soined/Physik
 private void HandleFreezeOnOther(GravityPhysics other)
 {
     if (other.IsEnabled())
     {
         other.DisableGravity();
     }
     else
     {
         other.EnableGravity();
     }
 }
コード例 #4
0
ファイル: Shoot.cs プロジェクト: Soined/Physik
 private void HandleFlipOnOther(GravityPhysics other)
 {
     other.FlipGravity();
 }