コード例 #1
0
    public void CreateProjectile(Vector3 position, Quaternion rotation, double createTime, int projectileId)
    {
        m_LastShootTime = Time.realtimeSinceStartup;

        //Every player receives this so we create the prefabs locally instead of calling PhotonNetwork.Instantiate
        //By having its start position, start rotation and time when it was created, we can calculate where the laser is at all times
        //Check out Part 1 Lesson 3 http://youtu.be/ozBmZ9FoN_o for more detailed explanations
        GameObject newProjectileObject = (GameObject)Instantiate(Resources.Load <GameObject>("Laser1"), new Vector3(0, -100, 0), rotation);

        newProjectileObject.name = "ZZZ_" + newProjectileObject.name;

        ProjectileBase newProjectile = newProjectileObject.GetComponent <ProjectileBase>();

        newProjectile.SetCreationTime(createTime);
        newProjectile.SetStartPosition(position);
        newProjectile.SetProjectileId(projectileId);

        newProjectile.Owner = Ship;

        m_Projectiles.Add(newProjectile);
    }