Jump to content

  • Log In with Google      Sign In   
  • Create Account

menyo

Member Since 09 May 2010
Offline Last Active Jan 22 2015 02:50 AM

Topics I've Started

first players problem with 1vs1 network game.

21 January 2015 - 08:34 AM

I created a one on one network board game. It is not completely polished bit I foreseeing a problem. When I upload it to the playstore and not get thousands of players which is likely how do people play with eachother or keep trying until there is someone?

I will create a password game mode where people can ask others to join there game but this needs the user to be active.

I could create a solo mode but this requires me to program a advance ai and even after that it won't be that challenging. So a lot of investment for little game play.

I'm wondering how this would work once I publish. The game is fun to play but waiting for hours until another player download the game and pays it is kinda boring :).

Any suggestions?

Turn based multiplayer game

19 January 2015 - 06:53 AM

Hi,

 

I'm struggling to grasp the concept of setting up a proper server/client network for a turn based board game. What I basically want is restrict certain actions for a player until it is his turn. I created a Lobby where players can create a server/game and other players can retrieve a list of servers and join them. When the server is full of players it will load a new Scene for the game. But i cannot get this turn based structure to work.

 

Here is some code for the lobby:

 

When a player starts the game the player can press the "create game" button that loads this function:

private void StartServer()
{
  Network.InitializeServer(2, 25000, false);
  MasterServer.RegisterHost(gameName, "Test game 2", "Welcome to for a row!");
  GameObject canvas = GameObject.Find("Canvas");
  canvas.SetActive(false);
}

When another player presses the "Search games" button a list of buttons appear with all the open games using MasterServer.PollHostData(). When a player selects a game it will connect and load a new scene.

private void GameButton(HostData hostData)
{
	Debug.Log(hostData.gameName);
	Network.Connect(hostData);
	Application.LoadLevel("GameScene");
}

Upon connection the player who created the server will load the new scene as well:

private void OnPlayerConnected(NetworkPlayer player)
{
	Debug.Log(player.externalIP + " Has connected!");		
	Application.LoadLevel("GameScene");
}

Now I have both players connected and in the same scene. I could create a line like:

Network.Instantiate(prefab, Vector3.zero, Quaternion.identity, 0);

And both players start spawning this prefab in the centre of the world. I could also make them move these objects individually and all i well. The problem starts when I want this turn based implementation. I need to restrict a player (server or client) from doing certain actions. They should be able to rotate the board and perhaps look into there cards or objects in there "hand". But they have to wait until it is there turn. How would I go about that?

 

Since one player is actually the server and will be running the (Network.isServer) code I am not able to sent messages to self. So how do i separate these? Is my current structure flawed and do I need to setup the server differently? What I see in certain games is that the player can just click start game a and he gets matched vs another player. Are both of these players clients? And if so, where does the server code run? Is this even possible with unity MasterServer?

 

Like I said, I am trying to grasp the concept of this kind of "match making" system but i have no clue if i am on the right track. All looks well from the lobby but when the players actually connect i have no idea how to get this turn based system going.

 

 


Adding item modifiers

09 November 2014 - 06:29 AM

I want to implement modifiers for special items. But I cannot figure out a good way to implement this. Let's say I have this item class structure:

public class Item
{
    String name;
    int strengthReq;
    int dexReq;
    int wisdomReq;
}

public class Weapon extends Item
{
    int maxDamage;
    int minDamage;
    int durability;
}

Now i want to add modifiers to this, the best way i can think of besides directly altering the item itself is a modifier class that uses a Enum to tell what has been modified. Adding a modifier object to an item and use statements every time a modifier might have been used and act accordingly. Currently my game uses a simple action system, for instance: when someone attacks source and target get passed to a static method and all the damage will be resolved according to the weapon damage/type.

public class Modifier
{
    enum ModifierType()
    {
         Strength,
         Dexterity,
         Wisdom,
         MaxDamage,
         MinDamage,
         PlayerHealth,
         lifeDrain,
         etc
    }
    ModifierType modifierType;
    int modifierValue;
}

Looking for pointers to make my item system more dynamic and fun with modifiers.


Action system with XML

31 October 2014 - 01:46 PM

Hi,

 

I want all my different character actions to be read in by XML so i can easily balance things out and modify all those actions. I would like some feedback on what I have started. I will have some basic actions like attack, move, cast, etc but most of the skills will be a combination of those (like "Dash" and "Wound" in the example below).

 

Q: I would also like to incorporate some kind of formula. Like a cooldown is based on (X * weapon weight) or damage is based on (skill level * weapon damage) but i am not sure how to implement this.

 

<?xml version="1.0" encoding="UTF-8"?>
<actions>
    <ability>
        <name>Attack</name>
        <info>A regular melee attack with your main weapon.</info>
        <coodown>10</coodown>
        <action>
            <type>damage</type>
            <sort>mainWeapon</sort>
        </action>
    </ability>
    <ability>
        <name>Dash</name>
        <info>Dash forward to a target to hit him with greater impact.</info>
        <coodown>20</coodown>
        <action>
            <type>move</type>
            <location>target</location>
        </action>
        <action>
            <type>damage</type>
            <sort>mainWeapon</sort>
        </action>
    </ability>
    <ability>
        <name>Wound</name>
        <info>Inflicts a wound to your target.</info>
        <action>
            <type>damage</type>
            <sort>mainWeapon</sort>
        </action>
        <action>
            <type>dot</type>
            <element>physical</element>
        </action>
    </ability>
</actions>

I basically check for the type value and read XML accordingly. Q: Later i want to expand on this and i'm wondering if it is ok to to have different elements/nodes below these same types? Can i filter those out with something like:

if (action.GetChildByName("childThatMayOrMayNotExist"))
{
     //Do something if it exists!
}

For those formula's i can think of something hacky like below. But i am really looking for something more flexibel and of course compatible with LibGDX/Android if you recommend a library.

<first>weaponDamage</first>
<operator>*</operator>
<second>skillLevel</second>

Like i said, i would love to have some feedback from people with more experience.

 

Thank you,

 

Do i really need to deep copy this?

27 October 2014 - 03:42 PM

Hey,

 

I come from a C# and i'm trying to get my Astar implementation working on java for Android. Since Java is pass by value I need to make a copy of this Array[][] each time I request a path. This feels awkward for me and perhaps unnecessary.

 

So what i actually do in my Astar method, instead of iterating over a closed and open list many time, or putting new nodes into it in a ordered fashion I am creating a 2D map resembling my map in nodes. These nodes hold a open and closed boolean so all i need to do is check directly on this map if this tile belongs to the open/closed list, see move cost and if it is walkable. Instead of searching for it in a potential huge open list each time. I create this map when a new map is loaded, so with C# this actually got created only once.

 

Anyway, I did the same in Java but when I passed this NodeMap as a parameter it actually alters the base object instead of making a copy to work on. Now my (crude?) solution was to implement a constructor for my Node class so i can deep copy the complete NodeArray[][].

public Node(Node copy)
        {
            this.G = copy.G;
            this.H = copy.H;
            this.position = copy.position;
            this.parent = copy.parent;
            this.closed = copy.closed;
            this.open = copy.open;
            this.walkable = copy.walkable;
        }

And here i copy it, every time i need a path, i pass the actual Array[][] that needs to stay unaltered as nodeMapRef.

Node[][] nodeMap = new Node[nodeMapRef.length][nodeMapRef[0].length];
        for (int y = 0; y < nodeMapRef[0].length;y++)
        {
            for (int x = 0; x < nodeMapRef.length;x++)
            {
                nodeMap[x][y] = new Node(nodeMapRef[x][y]);
            }
       }

It really loses it's charm this way but i cannot think of a good way to handle this. And i can imagine if my map size grows and need much more paths this might slow things down significantly.


PARTNERS