Search Unity

Clash of clans style of multiplayer.

Discussion in 'Multiplayer' started by Valon, Feb 17, 2015.

  1. Valon

    Valon

    Joined:
    Jan 15, 2014
    Posts:
    30
    Hi,

    I know there is already a couple of thread about it but I can't figure it out because I am a very big noob at network coding but I would like to learn and the clash of clans model is very interesting to me.

    Basically for those who don't know, in clash of clans you play on your own (I don't care much for general chat and joining a clan right now) with your base like a singleplayer game which means you can't wander around you just have the map with your base and that's it. But then you can attack another player base if the player owning it is disconnected.

    When you attack all of his base will be here with the defenses and stuff but not his army. Then you can drop your troops where you want and the goal is to destroy as much of his base as possible.

    So it's basically never 1v1, the guy you attack has no control about it, his base is just as he left it, the only one with control is the player on the offense.

    I would really like to know some tips on how to start doing that, like how can I save a full base and show it to the other player? Right now I'd like to do it maybe for only a two players game.

    I really have no clue about it. Also is it possible using Unity Free and free assets?

    Thank you very much.
     
  2. jpthek9

    jpthek9

    Joined:
    Nov 28, 2013
    Posts:
    944
    The models seem easy enough to make and the AI won't be too hard. The main thing is you need a deterministic simulation for replays (if you place the same units at the same places at the same times, you'll get the same results). For multiplayer, it's not real-time. You just need to download the map from a server (where you store everyone's information). Grid building is pretty straightforward. There're a bunch of tutorials on it.

    Your hardest tasks are probably 1. Making simulations deterministic and 2. Setting up the servers efficiently to send the appropriate information. Note: #1 is harder than it sounds. Actually, it won't be too big of a deal because the replays will be short so there's less time to get out of sync. Still, it'd be awkward to have the TH destroyed on 1 phone but not the other.
     
    Last edited: Feb 17, 2015
  3. Valon

    Valon

    Joined:
    Jan 15, 2014
    Posts:
    30
    Thank you for your answer.

    I'll start to look into that!
     
  4. zedzag

    zedzag

    Joined:
    Mar 16, 2015
    Posts:
    4
    i have the same exact question as the OP. i thought one thing i needed to do was to determine what was placed on what tile and then store that in a database on a server. Then when the player attacks the defending player the game code would get that data from the database and show it the attacker (thereby replicating how the defenders map looks). In my case I need the attacker to be able to individually select the defenders items within the base (for example selecting the Town Hall in CoC and specific actions would be available).

    Is this a good solution? And if so, if i have a website already, is all I need to do is to create a database in MySQL and store the data there for querying?

    Sorry to add to this question but I think the answer will be helpful to the OP as well.
     
  5. Glader

    Glader

    Joined:
    Aug 19, 2013
    Posts:
    456
    Supposing you were able to pull of deterministic simulations you don't have to uses tiles. In CoC when a player requests to drop a unit onto the terrain of an enemy base you can associate that with both a discrete time and position. For each of these requests, and others, you can build a log of what happened. If your simulation works based on these inputs it can potentially be replayed by these inputs as well.

    It may be difficult to get something like that to work 100% so you could save events that occur on the serverside, such as a building was destroyed or sustained damage, as well. In this way you can maybe decouple replaying troop action simulations and the result. I would think in most cases nobody would notice as they've nothing to compare it to.

    You can certainly save a base in a DB and look it up upon loading. Best way to do so would be to maybe save information about the base every attack. Bases can change post-attack so you don't want to just load the current one. I guess you could just save a history of them. I'm not a DB guy, someone else might have a better idea about that.