示例#1
0
    public override void OnClientConnect(NetworkConnection conn)
    {
        base.OnClientConnect(conn);
        ClientScene.AddPlayer(0);
        GameObject pref = Resources.Load("ships/dark_fighter_631") as GameObject;

        ClientScene.RegisterPrefab(pref);
        pref = Resources.Load("ships/lasergreen") as GameObject;
        ClientScene.RegisterPrefab(pref);
        pref = Resources.Load("ships/ghoul3") as GameObject;
        ClientScene.RegisterPrefab(pref);
        pref = Resources.Load("ships/redbullet") as GameObject;
        ClientScene.RegisterPrefab(pref);
        pref = Resources.Load("ships/greenbullet") as GameObject;
        ClientScene.RegisterPrefab(pref);

        pref = Resources.Load("ExplosionShim") as GameObject;
        ClientScene.RegisterPrefab(pref);
        Debug.Log("Client Connected");
        level1StartScript lsc = this.GetComponent <level1StartScript>();

        if (lsc != null)
        {
            lsc.loadLevel();
        }
    }
示例#2
0
    public void Start()
    {
        GameObject playerOverScene = GameObject.Find("PlayerOverScene");

        if (playerOverScene == null)
        {
            bool result = this.StartServer();
            Debug.Log("start server = " + result);
            if (result == true)
            {
                level1StartScript lsc = this.GetComponent <level1StartScript>();

                if (lsc != null)
                {
                    //lsc.generateLevel();
                    lsc.initLevel();
                }
            }
        }
        else
        {
            PlayerScript ps = playerOverScene.GetComponent <PlayerScript>();
            if (ps)
            {
                this.networkAddress = ps.getIpToGo();
            }

            this.StartClient();
        }
    }