예제 #1
0
        public void Initialize()
        {
            _closedRacesList.Clear();

            foreach (var raceData in RaceDatabase.All())
            {
                var race = RaceFactory.Create(raceData.Value);
                Register(race);
            }
        }
    void OnGUI_DisplayPlayer(NetworkPlayer player)
    {
        GUILayout.BeginHorizontal("box", GUILayout.Height(50));

        GUILayout.Label(NameDatabase.getName(player.guid), GUILayout.Width(200));
        if (Network.isServer && player != Network.player)
        {
            if (GUILayout.Button("Kick"))
            {
                Network.CloseConnection(player, true);
            }
        }
        GUILayout.FlexibleSpace();

        if (player == Network.player)
        {
            GUILayout.Label(new GUIContent("", "Click to pick a Race!"), "", GUILayout.Width(125));
            if (GUI.tooltip != "")
            {
                GUI.Label(new Rect(Input.mousePosition.x - 50, Screen.height - Input.mousePosition.y - 50, 200, 30), "Click to pick a Race!");
            }

            Rect popupRect = GUILayoutUtility.GetLastRect();

            if (player == Network.player)
            {
                if (Popup.List(popupRect, ref raceListShow, ref raceListEntry, new GUIContent(RaceDatabase.getRace(Network.player)), raceList, "button", "box", raceListStyle))
                {
                    if (Network.isServer)
                    {
                        requestRace(Network.player, raceListKey[raceListEntry]);
                    }
                    else
                    {
                        networkView.RPC("requestRace", RPCMode.Server, Network.player, raceListKey[raceListEntry]);
                    }
                }
            }
        }
        else
        {
            GUILayout.Label(RaceDatabase.getRace(player));
        }

        GUILayout.FlexibleSpace();

        GUILayout.Label("Ping: " + Network.GetAveragePing(player), GUILayout.Width(150));

        GUILayout.EndHorizontal();
    }
예제 #3
0
 public static IRace Create(RaceName type)
 {
     return(new GeneralRace(RaceDatabase.Find(type)));
 }
 void setRace(NetworkPlayer player, string race)
 {
     RaceDatabase.setRace(player, race);
 }
    void OnGUI_Connected()
    {
        //Screen area
        GUILayout.BeginArea(new Rect(50, 50, Screen.width - 100, Screen.height - 100));

        //Begin top section
        GUILayout.BeginVertical();
        if (Network.isServer)
        {
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.BeginVertical("window");
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label("Hosting Information");
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            if (Network.HavePublicAddress())
            {
                NetworkPlayer thisPlayer = Network.player;

                GUILayout.Label("Public IP Address:");
                GUILayout.Label(Network.player.ipAddress + ":" + Network.player.port);
                //GUI.Label(new Rect(20, 70, 100, 30), Network.proxyIP + ":" + Network.proxyPort);
                GUILayout.FlexibleSpace();
                GUILayout.Label("GUID:");
                GUILayout.Label(Network.player.guid);
            }
            else
            {
                GUILayout.Label("NAT Facilitator IP:");
                GUILayout.Label(Network.natFacilitatorIP + ":" + Network.natFacilitatorPort);
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }

        GUILayout.FlexibleSpace();

        //Vertically middle section begin

        GUILayout.BeginVertical("window");
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.Label("Game Lobby");
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();

        OnGUI_DisplayPlayers();

        GUILayout.BeginHorizontal();
        if (Network.isServer)
        {
            if (GUILayout.Button("Start", GUILayout.Width(100), GUILayout.Height(50)))
            {
                MasterServer.UnregisterHost();
                networkView.RPC("launchGameScene", RPCMode.AllBuffered);
            }
        }
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Disconnect", GUILayout.Height(50)))
        {
            Network.Disconnect();
            connected = false;
        }
        GUILayout.EndHorizontal();
        GUILayout.EndVertical();
        GUILayout.FlexibleSpace();

        GUILayout.BeginVertical("window");

        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        string race = RaceDatabase.getRace(Network.player);

        GUILayout.Label(race);
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();


        string description = "";

        if (race == "Undead")
        {
            description = "The great bogs of the South claim hundreds of lives a year, but not every death is of natural causes.  This boneyard presents the perfect location for aspiring Necromancers to practice their craft.  The Necromancer towers are cheap and weak, but their attacks are fast.  The trapped souls also share their Suffering with their target, applying a small damage over time effect on their attacks that deals more damage the lower life their target is.";
        }
        else if (race == "Arcane")
        {
            description = "The humans of the Plains are avid practitioners of magic.  Indeed, this edge is the only way they have maintained a civilized life for as long as they have.  Vast walls were erected in haste after the latest Undead Incursion.  Speed took priority over power in this matter, but the humans discovered a new field of magic in the process.  Only the most basic Arcane tower is capable of attacking enemies.  The higher level towers instead buff these nearby towers with special attributes such as increased attacking speed, higher damage, or area of effect splash.";
        }

        GUILayout.TextArea(description, GUILayout.Height(100), GUILayout.ExpandWidth(false));
        GUILayout.EndVertical();


        GUILayout.FlexibleSpace();
        GUILayout.EndVertical();
        GUILayout.EndArea();
    }
 void OnPlayerConnected(NetworkPlayer player)
 {
     requestRace(player, raceListKey[0]);
     networkView.RPC("setRace", player, Network.player, RaceDatabase.getRace(Network.player));
 }