コード例 #1
0
    private void OnMouseOver()
    {
        if (EventSystem.current.IsPointerOverGameObject() || !canBeBuild)
        {
            return;
        }

        if (GameManager.Instance.toolToBuild != null && currentObject == null)
        {
            spr.color = targetColor;

            // build
            if (Input.GetMouseButtonDown(0))
            {
                if (ShopSystem.CanBuild())
                {
                    PlaceTool();
                }
                else
                {
                    shake.CameraShake();
                    // Show not enought money UI
                    shake.ShowNotEnoughMoney();
                    // sound
                    AudioManager.Play(Sound.MoneyNotEnoughSound);
                }
            }
            else
            {
                return;
            }
        }
        return;
    }
コード例 #2
0
ファイル: PlayerCollision.cs プロジェクト: mjhansen3/Escape
    // Ths function runs when the player hits an obstacle
    // Information about the collision is collected and called "collisionInfo"
    void OnCollisionEnter(Collision collisionInfo)
    {
        // Check if object collided with has a tag called "Obstacle"
        if (collisionInfo.collider.tag == "Obstacle")
        {
            movement.enabled = false; // Player stops moving
            FindObjectOfType <GameManager>().EndGame();
            shake.CameraShake();
            FindObjectOfType <AudioManager>().PlaySound("DeathSound");

            //Destroy(gameObject);
        }
    }
コード例 #3
0
    public void OnHit(InputValue value)
    {
        if (gameStart == false)
        {
            return;
        }
        if (m_move == locks[0])
        {
            lockHit -= skill;

            Debug.Log("click!");
            if (lockHit <= 0)
            {
                shaker.CameraShake();
                Debug.Log("clank!!");
                locks.Remove(locks[0]);
                lockHit = lockDur;
            }
        }
    }
コード例 #4
0
ファイル: Health.cs プロジェクト: PeanutButte7/Backpacked
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.CompareTag("PlayerBullet"))
        {
            health--;

            if (health > 0)
            {
                FindObjectOfType <AudioManager>().Play("EnemyHit");
                _material.color = flashColor;
                Invoke(nameof(ResetMaterial), 0.15f);
            }
            else
            {
                _material.color = flashColor;
                _shake.CameraShake();
                FindObjectOfType <AudioManager>().Play("EnemyDeath");

                GameObject effect = Instantiate(deathEffect, transform.position, Quaternion.identity);
                Destroy(effect, 2f);
                Destroy(gameObject, 0.2f);
            }
        }
    }
コード例 #5
0
    // Camera:

    public void shakeCamera()
    {
        StartCoroutine(shakeScript.CameraShake());
    }