Exemplo n.º 1
0
    protected void Update()
    {
        UpdatePlayerControls();

        switch (m_currentGameState)
        {
        case GameState.Game:
            UpdateRash();
            UpdateSanity();

            UpdateProgress();
            break;

        case GameState.Lose:
            // show lose screen
            //SceneManager.LoadScene(0);
            m_cameraManager.Shake(3);
            break;

        case GameState.Win:
            if (m_rashes.Count > 0)
            {
                Rash rash = m_rashes[Random.Range(0, m_rashes.Count)];
                m_rashes.Remove(rash);
                Destroy(rash.gameObject);
            }
            break;
        }

        if (m_currentGameState != GameState.Title)
        {
            m_cameraManager.UpdateCamera();
        }
    }
Exemplo n.º 2
0
    public void GiveHint(Vector3 pos)
    {
        Rash closestItch = FindClosestItch(pos);

        if (closestItch != null)
        {
            // give hint
            Vector3 delta = closestItch.transform.position - pos;
            if (Mathf.Abs(delta.x) > Mathf.Abs(delta.y))
            {
                if (delta.x < 0)
                {
                    m_uiManager.GiveHint(UIManager.FeedBackType.LEFT);
                }
                else
                {
                    m_uiManager.GiveHint(UIManager.FeedBackType.RIGHT);
                }
            }
            else
            {
                if (delta.y < 0)
                {
                    m_uiManager.GiveHint(UIManager.FeedBackType.DOWN);
                }
                else
                {
                    m_uiManager.GiveHint(UIManager.FeedBackType.UP);
                }
            }
        }
    }
Exemplo n.º 3
0
    public void SpawnRash(Vector3 pos)
    {
        GameObject rashObj = Instantiate(m_rashPrefabs[Random.Range(0, m_rashPrefabs.Length)], transform);

        rashObj.transform.position = pos;
        rashObj.transform.Rotate(Vector3.forward, Random.value * 360.0f);
        Rash newRash = rashObj.GetComponent <Rash>();

        m_rashes.Add(newRash);
    }
Exemplo n.º 4
0
    public void Scratch(Rash rash)
    {
        if (rash.m_scratchedThisFrame)
        {
            return;
        }

        rash.m_scratchedThisFrame = true;
        rash.Scratch();
        m_scratchedThisFrame.Add(rash);
        m_rashIntensity += m_scratchRashIntensityValue;
    }
Exemplo n.º 5
0
    public Rash FindClosestItch(Vector3 pos)
    {
        Rash  closestItch = null;
        float closestDist = float.MaxValue;

        for (int i = 0; i < m_itchPoints.Count; ++i)
        {
            Rash  rash = m_itchPoints[i];
            float dist = Vector3.SqrMagnitude(rash.transform.position - pos);
            if (dist < closestDist)
            {
                closestItch = rash;
                closestDist = dist;
            }
        }

        return(closestItch);
    }
Exemplo n.º 6
0
    public void TryToSpreadRash(Rash source, float minRadius, float maxRadius)
    {
        Vector2 center   = source.transform.position;
        int     attempts = 0;

        while (attempts < 2)
        {
            if (Random.value > 0.5f)
            {
                return; // random chance each attempt to early out
            }

            Vector2 spawnPos = center + Random.insideUnitCircle.normalized * Random.Range(minRadius, maxRadius);
            int     hits     = Physics2D.OverlapPointNonAlloc(spawnPos, s_collider2Ds);
            if (hits > 0)
            {
                int rashHits = 0;
                for (int i = 0; i < hits; ++i)
                {
                    Collider2D collider = s_collider2Ds[i];
                    Rash       rash     = collider.GetComponentInParent <Rash>();
                    if (rash != null)
                    {
                        rashHits++;
                        Scratch(rash);
                    }
                }

                if (rashHits <= 0)
                {
                    // hit skin so spawn a new rash
                    SpawnRash(spawnPos);
                    m_rashIntensity += m_spreadRashIntensityValue;
                }
                return;
            }

            attempts++;
        }
    }
Exemplo n.º 7
0
 public void AddItch(Rash rash)
 {
     rash.RandomizeItchAmount();
     m_itchPoints.Add(rash);
     m_rashIntensity += m_itchRashIntensityValue;
 }
Exemplo n.º 8
0
    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;
        }
    }