﻿using UnityEngine;
using System.Collections;

public class Torchlight : interactor {


    public string m_state="dead";
    public Light m_light;
    public float m_lightOnDuration=1.0f;

    float m_maxIntensity;
    float m_lightOnTime =0.0f; 

    public GameObject m_fireEff;

    //辅助施法对象
    public Fighter m_spellHelper;
    public SkillBase m_spell;
    public override void DoClick(moveControler mc)
    {
        if (m_state == "dead")
        {
            m_state = "light on";
            if(m_fireEff!=null)
            {
                Debug.Log("active fire");
                m_fireEff.gameObject.SetActive(true);
                m_light.gameObject.SetActive(true);
                m_maxIntensity = m_light.intensity;
                m_light.intensity = 0;
            }
            return;
        }else if(m_state=="light on")//亮度逐渐增大
        {
            
        }
        else if(m_state=="light")
        {
            //释放净化
            m_spellHelper.CommandSpell(m_spell);

        }
        else if (m_state == "shockwave")
        {
            
        }
    }
	// Use this for initialization
	void Start () {

	}
	
	// Update is called once per frame
	void Update () {
        if (m_state == "dead")
        {
            return;
        }
        else if (m_state == "light on")//亮度逐渐增大
        {
            m_lightOnTime+=Time.deltaTime;
            float f1 = Mathf.Lerp(0,m_maxIntensity,m_lightOnTime/m_lightOnDuration);
            m_light.intensity = f1;

            if (m_lightOnTime > m_lightOnDuration)
            {
                m_state = "light";
            }
        }
        else if (m_state == "light")
        {

        }
        else if (m_state == "shockwave")
        {

        }
	}
}
