示例#1
0
    private void CheckFlowerRadius()
    {
        Collider2D[] cols = Physics2D.OverlapCircleAll(transform.position, m_flowerRadius, m_playerMask);
        foreach (Collider2D col in cols)
        {
            if (m_currentPlayerTransform != null)
            {
                if (col.gameObject.transform.parent != m_currentPlayerTransform)
                {
                    if (m_canSwap)
                    {
                        m_currentPlayerTransform = col.gameObject.transform.parent;

                        transform.parent        = m_currentPlayerTransform;
                        transform.localPosition = Vector3.zero;
                        m_playerRespawn         = m_currentPlayerTransform.GetComponent <PlayerRespawn>();
                        ObjectStatus(true);
                        m_flowerSwapped.Invoke();
                        StartCoroutine(CanPickUp());
                    }
                }
            }
            else
            {
                m_currentPlayerTransform = col.gameObject.transform.parent;

                transform.parent        = m_currentPlayerTransform;
                transform.localPosition = Vector3.zero;
                m_playerRespawn         = m_currentPlayerTransform.GetComponent <PlayerRespawn>();
                ObjectStatus(true);
                StartCoroutine(CanPickUp());
                m_flowerPickedUp.Invoke();
                m_flowerManager.FlowerPickedUp();
            }
        }


        if (Physics2D.OverlapCircle(transform.position, m_flowerRadius, m_safeZone) != null)
        {
            m_currentPlayerTransform = null;
            m_scoreManager.ChangeScore(m_flowerAwardScore);
            ResetFlower();
            m_flowerReturned.Invoke();
            m_spookyManager.ChangeSpookyTime(false);
            gameObject.SetActive(false);
        }
    }
    void FlowerDropped()
    {
        FlowerSpawner.isPlayerCarryingFlower  = false;
        FlowerSpawner.isPlayer2CarryingFlower = false;
        FlowerSpawner.isFlowersInScene        = false;


        // find all flowers in scene
        FlowerPrefabsInScene = GameObject.FindGameObjectsWithTag("Flower");
        // destroy them
        for (int i = 0; i < FlowerPrefabsInScene.Length; i++)
        {
            Destroy(FlowerPrefabsInScene[i]);
        }


        // get reference to spooky timer
        m_spookyTime.ChangeSpookyTime(false);
    }