Exemplo n.º 1
0
    //if tile is swiped over
    public int Swiped(out BasePlant plant)
    {
        int tempScore = 0;

        plant = basePlant;

        //if the plant is already active
        if (basePlant.GetActive())
        {
            //get the score from the plant
            tempScore = basePlant.GetScore();
            Debug.Log(basePlant.GetScore());

            //if the plant is type of double plant
            if (basePlant is DoubleScorePlant)
            {
                //white text
                FloatingTextManager.CreateFloatingText("+" + basePlant.GetScore().ToString(), basePlant.transform, Color.white);
            }
            else if (basePlant is NormalPlant)
            {
                //yellow text
                FloatingTextManager.CreateFloatingText("+" + basePlant.GetScore().ToString(), basePlant.transform);
            }
            else if (basePlant is DebuffPlant)
            {
                FloatingTextManager.CreateFloatingText("+" + basePlant.GetScore().ToString(), basePlant.transform, Color.blue);
                DebuffPlant debuff = basePlant as DebuffPlant;
                Destroy(lightning);
            }

            //activate the dead plant animation
            m_animator.SetTrigger("DeadPlant");

            //Set the plant state to be inactive
            basePlant.SetActive(false);

            for (int i = 0; i < emmiters.Count; i++)
            {
                emmiters [i].Play();
            }
        }
        return(tempScore);
    }