示例#1
0
    private void OnEnterStateDamaged()
    {
        GetComponentInChildren <ParticleSystem>().Play();
        GetComponentInChildren <MeshRenderer>().enabled = false;
        GetComponentInChildren <BoxCollider>().enabled  = false;

        m_audioSource.clip = DeadSound;
        m_audioSource.Play();

        for (int i = 0; i < PickedMushrooms.Count; ++i)
        {
            PickedMushrooms[i].transform.parent = MushroomSpawner.mushroomContainer.transform;
            Mushroom mushroom = PickedMushrooms[i].GetComponent <Mushroom>();
            mushroom.SetState(Mushroom.MushroomState.OnGround);
        }
    }
示例#2
0
    void PickUp(GameObject mushroom)
    {
        PickedMushrooms.Push(mushroom);
        mushroom.transform.rotation = Quaternion.identity;
        Mushroom mushroomScript = mushroom.GetComponent <Mushroom>();

        if (mushroomScript)
        {
            mushroomScript.SetState(Mushroom.MushroomState.Picked);
            int     headMushCount    = PickedMushrooms.Count;
            float   mushroomHeight   = headMushCount * mushroom.GetComponentInChildren <MeshRenderer>().bounds.extents.y;
            Vector3 mushroomPosition = m_mushroomPosition.transform.position;
            mushroom.transform.rotation = Quaternion.identity;
            mushroom.transform.SetParent(transform);
            mushroom.transform.position = new Vector3(mushroomPosition.x, mushroomPosition.y + mushroomHeight, mushroomPosition.z);
            m_audioSource.clip          = PickupAudio;
            m_audioSource.Play();
        }
    }
示例#3
0
    void OnEnterDamaged()
    {
        m_damageStartTime = Time.time;
        // TODO: Play Damage Anim
        int numDroppedMushrooms = (int)Mathf.Ceil(PickedMushrooms.Count / 2f);

        for (int i = 0; i < numDroppedMushrooms; i++)
        {
            if (PickedMushrooms.Count > 0)
            {
                GameObject dropMush   = PickedMushrooms.Pop();
                Mushroom   mushScript = dropMush.GetComponent <Mushroom>();
                dropMush.transform.SetParent(null, true);
                mushScript.SetState(Mushroom.MushroomState.Throw);
            }
        }
        m_audioSource.clip = DamageAudio;
        m_audioSource.Play();
    }
示例#4
0
    private void OnTriggerEnter(Collider collision)
    {
        string collisionTag = collision.gameObject.tag;

        if (State == MushroomState.Throw)
        {
            if (collisionTag == "Mushroom")
            {
                GameObject mushroom       = collision.gameObject;
                Mushroom   mushroomScript = mushroom.GetComponent <Mushroom>();
                if (mushroomScript.State == MushroomState.Idle)
                {
                    mushroomScript.SetState(MushroomState.Throw);
                }
            }
            else if (collisionTag == "Enemy")
            {
                GameObject enemy       = collision.gameObject;
                Enemy      enemyScript = enemy.GetComponent <Enemy>();
                enemyScript.ThrowMushroomCollide(this);
                IncrementHitCounter();
            }
        }
    }
示例#5
0
    private void OnExitStatePicking()
    {
        if (m_currentTargetMushroom == null)
        {
            return;
        }
        // we ate the mushroom, possibly to prematurely exit this state if the current mushroom state changes
        if (m_currentEatTime >= eatTimer)
        {
            PickedMushrooms.Add(m_currentTargetMushroom);
            Mushroom mushroom = m_currentTargetMushroom.GetComponent <Mushroom>();
            mushroom.SetState(Mushroom.MushroomState.InsideEnemy);

            int     headMushCount    = PickedMushrooms.Count;
            float   mushroomHeight   = headMushCount * m_currentTargetMushroom.GetComponentInChildren <MeshRenderer>().bounds.extents.y;
            Vector3 mushroomPosition = myMushroomPosition.transform.position;
            m_currentTargetMushroom.transform.SetParent(transform);
            m_currentTargetMushroom.transform.rotation = Quaternion.identity;
            m_currentTargetMushroom.transform.position = new Vector3(mushroomPosition.x, mushroomPosition.y + mushroomHeight, mushroomPosition.z);
        }
        m_currentTargetMushroom.GetComponent <Mushroom>().isEnemyTracking = false;
        transform.localScale = Vector3.one * 3.0f;
        m_currentEatTime     = 0.0f;
    }