示例#1
0
    public void Change(Protomsg.BulletDatas data)
    {
        // 更新位置
        if (m_Mode != null)
        {
            //Vector3 add = new Vector3(data.X, 0, data.Y);
            m_Position += new Vector3(data.X, data.Z, data.Y);
            m_StartPos += new Vector3(data.StartX, data.StartZ, data.StartY);
            m_EndPos   += new Vector3(data.EndX, data.EndZ, data.EndY);
            m_State    += data.State;

            //var pos = GetPosition();
            //m_Position.y += (float)addy;
            //更新位置

            if (m_State == 3)
            {
                //Quaternion rotation = Quaternion.FromToRotation(m_StartPos, m_EndPos);
                m_Mode.GetComponent <ProjectileScript>().ShowEndParticle(m_EndPos - m_StartPos);
                //Debug.Log("22start:" + m_StartPos + "pos:" + m_Position + "end:" + m_EndPos);
            }

            m_Mode.transform.LookAt(m_Position);
            //Debug.Log("111 rotation:" + m_Mode.transform.localRotation);
            m_Mode.transform.position = m_Position;

            m_Mode.GetComponent <ProjectileScript>().ChangePos(m_StartPos, m_Position);



            //Debug.Log("2222bullet pos:" + m_Mode.transform.position+"  end pos:"+ m_EndPos+"   state:"+m_State);
        }
    }
示例#2
0
    public BulletEntity(Protomsg.BulletDatas data, GameScene scene)
    {
        //Debug.Log("----------------11time:" + Tool.GetTime());

        //数据赋值
        m_Scene    = scene;
        m_ID       = data.ID;
        m_Position = new Vector3(data.X, data.Z, data.Y);
        m_StartPos = new Vector3(data.StartX, data.StartZ, data.StartY);
        m_EndPos   = new Vector3(data.EndX, data.EndZ, data.EndY);
        m_State    = data.State;

        m_ModeType = BulletEntityManager.Instance.GetBulletModePath(data.ModeType);
        //Debug.Log("ddd------------------------22time:" + Tool.GetTime());
        //数据处理
        m_Mode = (GameObject)(GameObject.Instantiate(Resources.Load(m_ModeType)));
        m_Mode.transform.parent   = m_Scene.transform.parent;
        m_Mode.transform.position = m_Position;
        m_Mode.transform.LookAt(m_EndPos);
        //Debug.Log("aaa------------------------22time:" + Tool.GetTime());
        if (m_State == 1)
        {
            m_Mode.GetComponent <ProjectileScript>().ShowStartParticle(m_StartPos, m_EndPos);
            //Debug.Log("bbb------------------------22time:" + Tool.GetTime());
            //Debug.Log("11start:" + m_StartPos+ "pos:" + m_Position + "end:" + m_EndPos);
        }
        else if (m_State == 3)
        {
            //Quaternion rotation = Quaternion.FromToRotation(m_StartPos, m_EndPos);
            m_Mode.GetComponent <ProjectileScript>().ShowEndParticle(m_EndPos - m_StartPos);
        }
        //Debug.Log("------------------------22time:" + Tool.GetTime());

        //Debug.Log("1111bullet pos:" + m_Mode.transform.position + "  end pos:" + m_EndPos + "   state:" + m_State);
    }
    //更改显示位置
    public void ChangeShowPos(Protomsg.BulletDatas data, float scale)
    {
        BulletEntity unity = m_BulletEntitys[data.ID];

        if (unity != null)
        {
            unity.ChangeShowPos(scale, new Vector3(data.X, data.Y, data.Z));
        }
    }
    //更改单位数据
    public void ChangeBulletEntity(Protomsg.BulletDatas data)
    {
        BulletEntity unity = m_BulletEntitys[data.ID];

        if (unity != null)
        {
            unity.Change(data);
        }
    }
    //创建新单位
    public void CreateBulletEntity(GameScene gs, Protomsg.BulletDatas data)
    {
        BulletEntity hero = new BulletEntity(data, gs);

        m_BulletEntitys[data.ID] = hero;
    }