Exemplo n.º 1
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();
                    }
                }
            }
        }
    }
Exemplo n.º 2
0
    public void TouchElement(Vector3 pos)
    {
        if (m_Pause)
        {
            return;
        }
        Coord2D coord = m_BG.PosToCoord(new Vector2(pos.x, pos.y));

        m_TouchElement = m_BG.GetElementByCoord(coord);
    }
Exemplo n.º 3
0
    // Use this for initialization
    void Start()
    {
        GameObject gc = GameObject.FindGameObjectWithTag("GameController");

        m_BG = gc.GetComponent <BoxGenerator>();

        Coord2D coord = m_BG.PosToCoord(new Vector2(transform.localPosition.x, transform.localPosition.y));

        if (coord.x != -1 && coord.y != -1)
        {
            GameObject element = m_BG.GetElementByCoord(coord);
            if (element != null)
            {
                var type = element.GetComponent <BoxElementControl>().m_Type;
                m_BG.AttachRandomSpecies(element);
                var count = 1;

                //尋找同類方塊,加上物種
                for (int y = 0; y < m_BG.m_BoxNumH; y++)
                {
                    for (int x = 0; x < m_BG.m_BoxNumW; x++)
                    {
                        Coord2D    targetCoord = new Coord2D(x, y);
                        GameObject target      = m_BG.GetElementByCoord(targetCoord);
                        if (target != null)
                        {
                            BoxElementControl bec = target.GetComponent <BoxElementControl>();
                            if (bec.m_Type == type && bec.GetSpecies() == null)
                            {
                                m_BG.AttachRandomSpecies(target);
                                count++;
                                if (count >= m_Count)
                                {
                                    return;
                                }
                            }
                        }
                    }
                }
            }

            /*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) {
             *          m_BG.AttachRandomSpecies(element);
             *      }
             *  }
             * }*/
        }
    }
Exemplo n.º 4
0
    // Use this for initialization
    void Start()
    {
        GameObject gc = GameObject.FindGameObjectWithTag("GameController");

        m_BG = gc.GetComponent <BoxGenerator>();
        //寬度是偶數行時需shift,特效跟消融方塊的區域重疊位置才會一樣
        float offsetX = 0;

        if (m_Size % 2 == 0)
        {
            offsetX = 0.5f;
        }
        m_Coord            = m_BG.PosToCoord(new Vector2(transform.localPosition.x + offsetX, transform.localPosition.y));
        m_DestroyCountDown = m_DestroyTime;
    }
    // Use this for initialization
    void Start()
    {
        m_State   = BoxState.FALL;
        m_CurTime = 0;
        GameObject gc = GameObject.FindGameObjectWithTag("GameController");

        m_BG = gc.GetComponent <BoxGenerator>();

        m_SkillBt = GetSkillButton(m_Type);

        //init coordinate
        Vector2 pos   = new Vector2(transform.localPosition.x, transform.localPosition.y);
        Coord2D coord = m_BG.PosToCoord(pos);

        SetCoord(coord);

        m_InfoBar = GameObject.FindGameObjectWithTag("InfoBar").GetComponent <InfoBar>();
    }
Exemplo n.º 6
0
    // Use this for initialization
    void Start()
    {
        m_ParticleArray = new GameObject[m_ParticleNum];
        for (int i = 0; i < m_ParticleNum; i++)
        {
            m_ParticleArray[i] = (GameObject)Instantiate(m_Particle);
            m_ParticleArray[i].transform.parent        = transform;
            m_ParticleArray[i].transform.localPosition = Vector3.zero;
        }

        GameObject gc = GameObject.FindGameObjectWithTag("GameController");

        m_BG        = gc.GetComponent <BoxGenerator>();
        m_CurBounce = 0;

        Vector2 pos = new Vector2(transform.localPosition.x, transform.localPosition.y);

        m_TargetCoord = m_BG.PosToCoord(pos);
        if (m_TargetCoord.x != -1 && m_TargetCoord.y != -1)
        {
            m_Target = m_BG.GetElementByCoord(m_TargetCoord);

            if (m_Target != null)
            {
                BoxElementControl targetControl = m_Target.GetComponent <BoxElementControl>();
                m_TargetType = targetControl.m_Type;

                for (int i = 0; i < m_ParticleNum; i++)
                {
                    m_ParticleArray[i].transform.position = m_Target.transform.position + m_Offset;
                }
            }
            else
            {
                DestroyObject(gameObject);
            }
        }
    }
Exemplo n.º 7
0
    public void EndDrag()
    {
        if (m_Pause)
        {
            return;
        }
        if (m_Pattern)
        {
            Vector3 pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            pos = m_GC.transform.worldToLocalMatrix * pos;
            Coord2D coord = m_BG.PosToCoord(new Vector2(pos.x, pos.y));
            if (coord.x != -1 && coord.y != -1)
            {
                GameObject skill = (GameObject)Instantiate(m_SkillTemplate);
                skill.transform.parent        = m_BG.gameObject.transform;
                skill.transform.localPosition = new Vector3(pos.x, pos.y, -1);
                skill.transform.localScale    = Vector3.one;
                m_CurAmount = 0;
            }

            DestroyObject(m_Pattern);
            m_Pattern = null;
        }
    }