// Update is called once per frame
 void Update()
 {
     if (m_Pause)
     {
         return;
     }
     m_CurTime += Time.deltaTime;
     if (m_CurTime >= m_LifeTime)
     {
         DestroyObject(gameObject);
     }
     else
     {
         m_DestroyCountDown -= Time.deltaTime;
         if (m_DestroyCountDown <= 0)
         {
             int halfSize = m_Size >> 1;
             for (int x = m_Coord.x - halfSize; x < m_Coord.x - halfSize + m_Size; x++)
             {
                 GameObject obj = m_BG.GetElementByCoord(new Coord2D(x, m_Coord.y));
                 if (obj != null)
                 {
                     BoxElementControl control = obj.GetComponent <BoxElementControl>();
                     control.DestroyElement();
                 }
             }
             m_DestroyCountDown = m_DestroyTime;
         }
     }
 }
示例#2
0
    // Use this for initialization
    void Start()
    {
        GameObject gc = GameObject.FindGameObjectWithTag("GameController");

        m_BG = gc.GetComponent <BoxGenerator>();

        //寬度是偶數行時需shift,特效跟消融方塊的區域重疊位置才會一樣
        float offsetX = 0, offsetY = 0;

        if (m_Size % 2 == 0)
        {
            offsetX = 0.5f;
            offsetY = 0.5f;
        }
        Coord2D coord = m_BG.PosToCoord(new Vector2(transform.localPosition.x + offsetX, transform.localPosition.y + offsetY));

        if (coord.x != -1 && coord.y != -1)
        {
            int halfSize = m_Size >> 1;
            for (int x = coord.x - halfSize; x < coord.x - halfSize + m_Size; x++)
            {
                for (int y = coord.y - halfSize; y < coord.y - halfSize + m_Size; y++)
                {
                    Coord2D    targetCoord = new Coord2D(x, y);
                    GameObject element     = m_BG.GetElementByCoord(targetCoord);
                    if (element != null)
                    {
                        BoxElementControl control = element.GetComponent <BoxElementControl>();
                        control.DestroyElement();
                    }
                }
            }
        }
    }
示例#3
0
    // Update is called once per frame
    void Update()
    {
        if (m_Pause)
        {
            return;
        }

        if (m_Target == null)
        {
            if (!FindNextTarget())
            {
                DestroyObject(gameObject);
            }
        }
        else if (Vector3.Distance(m_ParticleArray[0].transform.position, m_Target.transform.position + m_Offset) < 0.5f)
        {
            BoxElementControl control = m_Target.GetComponent <BoxElementControl>();
            control.DestroyElement();
            if (!FindNextTarget())
            {
                DestroyObject(gameObject);
            }
        }
        else
        {
            TraceTarget();
        }
    }
示例#4
0
    public void EliminateRow(int row)
    {
        int w = m_BG.GetCoordW();

        for (int x = 0; x < w; x++)
        {
            GameObject obj = m_BG.GetElementByCoord(new Coord2D(x, row));
            if (!obj)
            {
                continue;
            }
            BoxElementControl control = obj.GetComponent <BoxElementControl>();
            control.DestroyElement();
        }
    }