示例#1
0
文件: Main.cs 项目: ouroborose/LD40
    public void HandleScratch(Vector3 pos)
    {
        int hitCount = Physics2D.OverlapPointNonAlloc(pos, s_collider2Ds);

        if (hitCount > 0)
        {
            m_hand.DoScratchFeedback();
        }

        if (m_currentGameState != GameState.Game)
        {
            return;
        }

        int  rashHits = 0;
        bool itchHit  = false;

        for (int i = 0; i < hitCount; ++i)
        {
            Collider2D collider = s_collider2Ds[i];
            Rash       rash     = collider.GetComponentInParent <Rash>();
            if (rash != null)
            {
                rashHits++;
                Scratch(rash);
                if (m_itchPoints.Contains(rash))
                {
                    itchHit         = true;
                    m_targetSanity += MAX_SANITY * m_itchSanityRecovery;
                    if (m_targetSanity > MAX_SANITY)
                    {
                        m_targetSanity = MAX_SANITY;
                    }

                    // give sanity
                    rash.ReduceItch();
                    // give itch relief feedback
                    m_uiManager.DoItchFeedback();

                    if (rash.m_itchAmount <= 0)
                    {
                        m_itchPoints.Remove(rash);

                        // pick new itch point
                        AddItch(m_rashes[Random.Range(0, m_rashes.Count)]);
                    }
                }
                else
                {
                    // give itch point hint
                    GiveHint(pos);
                }
            }
        }



        if (rashHits <= 0 && hitCount > 0)
        {
            // spawn new rash here
            SpawnRash(pos);
        }

        if (itchHit)
        {
            m_cameraManager.Shake(1.0f);
        }
        else if (rashHits >= 2)
        {
            m_cameraManager.Shake(0.5f);
        }
        else if (rashHits >= 1)
        {
            m_cameraManager.Shake(0.25f);
        }
        else
        {
            m_cameraManager.Shake(0.15f);
        }

        if (!itchHit)
        {
            m_targetSanity -= m_itchMissSanityPenalty;
        }
    }