Atavism Online

In this final part of the series, we focus on building the User Interface (UI) for the Guild system in Atavism and implementing the remaining guild commands.

Prerequisites:

  • Completion of Part IV of the series.
  • Ability to edit C# scripts in Unity.
  • Basic Unity skills (creating GameObjects, modifying Inspector values, etc.).

Step 1: Designing the User Interface

Before coding or UI creation, you should have a clear design idea. The main Guild UI panel might include:

  1. Guild Name.
  2. Message of the Day (MOTD).
  3. A list of Guild Members (with details like name, rank, level).
  4. Buttons for various actions (invite members, edit ranks, etc.).
  5. A scrollbar for the member list.

Create a mockup drawing to visualize the UI layout.

Step 2: Building the Guild Window using Unity’s UI (UGUI)

  1. Creating the Panel: In Unity, create a new UI Panel under the Canvas object. Name it GuildPanel. Resize and anchor it to your preferred location, e.g., left side of the screen.
  2. Setting Up the Title Bar: Add a TitlePanel prefab to display the guild name and a close button.
  3. Message of the Day Section: Create a MotdPanel for displaying the guild’s MOTD. Include a Text object to dynamically display the message.
  4. Member List Headers: Add a HeaderPanel above the member list for headers like ‘Name’, ‘Rank’, and ‘Level’.
  5. Creating the Member List: Implement a scrollable member list using Unity’s Scroll Rect and Mask components. Include a grid layout inside the MemberList panel.
  6. Scrollbar: Add a scrollbar to the side of the MemberList to allow scrolling through the member list.
  7. Action Buttons Panel: Create a ButtonsPanel at the bottom with buttons for actions like adding members or accessing guild settings.

Step 3: Creating the GuildMemberEntry Prefab and Script

  1. GuildMemberEntry Prefab: Create a GuildMemberEntry prefab that will represent each member in the member list. It should include Text objects for the member’s name, rank, and level.
  2. GuildMemberEntry Script: Write a script (UGUIGuildMemberEntry.cs) for this prefab. The script should include public Text variables for each member attribute and a method to set these details (SetGuildMemberDetails).

Step 4: Creating the Guild Panel Script

  1. GuildPanel Script: Create a new C# script (UGUIGuildPanel.cs). This script will manage the Guild Panel’s overall functionality.
  2. Implementing UIList: Make the UGUIGuildPanel script inherit from UIList and implement required methods like NumberOfCells and UpdateCell.
  3. Additional Functions: Include functions for updating guild details, handling UI events, showing/hiding the panel, and toggling visibility.
  4. Handling Key Presses: Add a public KeyCode variable to handle toggling the guild panel visibility with a keyboard shortcut.
  5. Adding to Unity: Attach this script to the GuildPanel GameObject and set up the necessary references (e.g., title bar, MOTD text field).

Step 5: Inviting Members to the Guild

  1. Invite Request Functionality: Implement a function in UGUIGuildPanel to handle the invite member action. It should send an invite request to the server with the targeted player’s OID or name.
  2. Handling Server Invite: On the server side, update the GuildCommandHook to process invite commands. Create a method in Guild.java (inviteNewMember) to handle the invitation logic.
  3. Client-side Invite Handling: In Unity, write a message handler (HandleGuildInvite) in AtavismGuild to display a confirmation box when an invite is received.
  4. Response Handling on the Server: Implement the GuildInviteResponseHook on the server to process the player’s response to the invitation.

By following these steps, you’ll have a functional guild system in Atavism with a comprehensive UI for guild management. This system allows players to create guilds, manage members, and handle invitations seamlessly.