コード例 #1
0
ファイル: Pattern.cs プロジェクト: JDreamHeart/KMAHJR
    // Start is called before the first frame update
    void Start()
    {
        m_audioSource    = this.GetComponent <AudioSource>();
        m_patternName    = this.transform.Find("PatternName");
        m_patternTips    = this.transform.Find("PatternTips");
        m_leftLightning  = this.transform.Find("LeftLightning").GetComponent <LightningChain>();
        m_rightLightning = this.transform.Find("RightLightning").GetComponent <LightningChain>();
        // 暂时隐藏提示
        // m_patternTips.gameObject.SetActive(false);
        // 获取闪电位置
        Vector3 pos      = Camera.main.WorldToScreenPoint(m_patternName.position);
        Vector3 startPos = Camera.main.ScreenToWorldPoint(new Vector3(0, pos.y, pos.z));
        Vector3 endPos   = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, pos.y, pos.z));
        float   width    = m_patternName.GetComponent <RectTransform>().rect.width;
        Vector3 leftPos  = Camera.main.ScreenToWorldPoint(new Vector3(pos.x - width / 2, pos.y, pos.z));
        Vector3 rightPos = Camera.main.ScreenToWorldPoint(new Vector3(pos.x + width / 2, pos.y, pos.z));

        // 更新闪电链位置
        m_leftLightning.UpdatePosList(startPos, leftPos);
        m_rightLightning.UpdatePosList(rightPos, endPos);
    }
コード例 #2
0
ファイル: BoardSpawn.cs プロジェクト: JDreamHeart/KMAHJR
    void createLightningList(List <Vector3[]> posList)
    {
        // 更新闪电链对象
        List <LightningChain> lcList = new List <LightningChain>();

        foreach (Vector3[] pos in posList)
        {
            LightningChain lc = getLightningChain();
            lc.UpdatePosList(pos[0], pos[1]);
            lcList.Insert(0, lc);
        }
        // 隐藏已有对象
        foreach (LightningChain lc in m_lightningList)
        {
            lc.gameObject.SetActive(false);
        }
        // 更新m_lightningList
        foreach (LightningChain lc in lcList)
        {
            m_lightningList.Insert(0, lc);
        }
    }