コード例 #1
0
ファイル: Digging.cs プロジェクト: flofe104/SpackJerrow
 private void Update()
 {
     if (!onCooldown && GameManager.AllowPlayerActions && Input.GetButtonDown("PrimaryAction"))
     {
         //Physics.CheckSphere
         RaycastHit hit;
         Vector3    firePosition;
         if (fireRayFromParent)
         {
             firePosition = transform.parent.position;
         }
         else
         {
             firePosition = transform.position;
         }
         ///spherecast?
         if (Physics.Raycast(firePosition, Vector3.up * -1, out hit, 0.75f))
         {
             Island island = hit.transform.GetComponent <Island>();
             if (island != null)
             {
                 Vector3 playerLookDirection = transform.up * -1;
                 // Vector3 playerLookDirection = transform.parent.right;
                 playerLookDirection.y = 0;
                 playerLookDirection.Normalize();
                 island.Dig(transform.position, digSize, 0.5f, 2, 2.5f, 3f, playerLookDirection);
                 PlayRandomClip(sourceDiggingSounds, succesDigSounds);
                 StartDigAnim();
             }
             else
             {
                 StartWrongTerrainDigAnim();
                 PlayRandomClip(sourceDiggingSounds, wrongSurfaceDiggingSound);
             }
         }
         else
         {
             StartDigAnim();
             //PlayRandomClip(sourceDiggingSounds, succesDigSounds);
         }
         onCooldown = true;
         StartCoroutine(DelayNextUse());
     }
 }