C# XNA Enter Houses - c#

I'm making a role playing game in C# using XNA. I already have a map and some stuff, but that's not interesting at the moment. My question is: How can I give the player the possibility to enter houses or rooms?
To create the worlds, I've used standard int-arrays where each number represents a different type of tile. That works all fine, but the house isn't enterable but a solid textured block of something.
BTW I've used a Vector3 to determine in which world the player's currently located and which one the program must load next.
Any suggestions how I can make the houses enterable?

One easy way to make houses enterable is to create a trigger object at the door of the house.
This object can be a simple Rect along with an id.
While the player moves around your map check for a collision between the player and the trigger.
When the player enters this trigger you can change the displayed map with a new one (the interior of the house) and move the player where the door should lead.

If you're using C# to make a game, you might want to consider switching to MonoGame (which is practically XNA's successor since XNA is dead) or Unity.
As mentioned previously, your best option in XNA is to create a Rectangle which will trigger on collision and change the game world.

Related

How to validate chess moves with a server? Winboard and Unity 2020.3

I'm looking for advice on how to implement online chess move validation using a winboard chess engine. I am creating a mobile battle chess game in Unity 2020.3. Right now I have the possible moves for each player, castle rights, check status, etc being generated by an open source C# chess engine. I chose this engine because it's written in C# and the code could be directly included in my Unity Project. I successfully wrote my own code that connects this chess engine to a 3D battle chess game.
How the game works (video preview):
A piece is selected by the player clicking it with their mouse or
tapping the screen.
The possible moves for the current board are calculated by the chess engine.
I use the possible move indexes to show possible move highlights.
When a player makes one of these possible moves, the move is applied on the chess engine.
It becomes the other player's turn.
I have some custom code to run player animations, based on the kind of move (ex. an attack animation runs when a piece is captured). I also show have screens that show when it's time for a promotion, a player is in check, or the game is over.
I'd like to somehow make the process of calculating possible moves and applying moves to be done on a server. My goal is to protect from players sending illegal moves to the board and breaking the game.
How would you recommend I approach this problem? This is the last thing I need to turn this game into an enjoyable online experience. I just lack the crucial skill of understanding how to make this game online.
On the server, you'll have a separate version of the chess game running.
A player(/client) will send a move to the server (so a unique piece ID, and the target square the player wants to move).
On the server-side, you'll need to check to see if that move is indeed possible. This could be by getting all possible moves from that piece, and checking to see if the intendedChessPosition can be found in the list of possibleChessPositions that was calculated on server-side. Only then, will you actually move the piece server-side.
All players/clients will communicate using the server as the middleman and authority.
The exact implementation could change depending on the API of the chess engine you're using, but that's the basic idea.

Run two animations on object in Unity simultaneously

I'm still pretty fresh to the Unity 3D world. I'm trying to get an animation on two children of an object (a door that has the exterior facing outward and a door facing inward). Maybe I'm approaching this the wrong way? See below:
Is there a way in which by pressing one key,i can get both "open" animations for both the inward and outward facing doors to play at the same time? Note: I originally created this FBX in Blender.

Making a tile map

I am creating a tower defense game, i need help with a method or program to make it a tile map so then i can slowly input enemies on a road have turrets that shoot at them etc, i have already tried:
Inputting a picture one by one which i failed on.
Also i tried using the program called tiled but i failed on understand how that makes it tile map so i am pretty lost on the definition on tile map now.
Could someone make some suggestions, links, explanations would be very helpful?
You can load maps generated by 'Tiled' using 'TiledSharp'.
You'll have to figure another way for getting the enemies to move on the map, getting the towers to shoot them, etc. Try this for a start:
Algorithms for realtime strategy wargame AI
You can also try to use Unity3D that might already have something ready for use (unless, of course, the reason is for you to learn the algorithms rather than making the game).
If you need more help please specify exactly what it is you're looking for, i.e. displaying the map, moving the forces, shooting at the forces, UI, etc.

Trying to write generic code for a board game

I'm actually working on a board game using unity. It's a board game where players have to connect two opposites borders by claiming empty hexagonal cases. Borders are assigned to players at the beginning.
I chose to represent my empty cases with gems, white when unclaimed, and red or blue for players. So I made a single prefab for all gems.
To check connections between gems themselves and with borders, I assigned to them slightly bigger box colliders so they are colliding (trigger) with other objects, so I can detect if a claimed gem is connected (directly or not) to a border. I wrote this code generically as gems are one single prefab, naively thinking that every entity would run its own version of the script.. But that's not the case.
So I'm looking for an alternative way to detect connections with borders, but still generically, as the size of the board is variable.
Thanks in advance !
Your problem is closely related on how you break your game in game objects and components on Unity3D.
First of all, use scripts to define components. For example your gems could have a script that contains data related to its state (your white, red and blue gems meaning empty, playerA and playerB).
You will probably need a game object (normally called a GameManager) to handle all behavior related to game rules like which player is playing, if a player can pick a specific gem and if a player won the game. Depending on the game complexity is a good idea to also have a game object with a component (script) to keep your board state, instead of simply getting it from the gems objects Transform component.
After you have structured your game you do not need colliders to detect connections. Every time you have to check for connections, just iterate over your gems or use your board state object.
Edit:
References to help you develop your game:
How do I represent a hextile/hex grid in memory?
Creating a holder for game level for simple board tile based game.
creating 2d table\chess board\2d array

Goblin XNA -- Creating a labyrinth style game

Anyone know how to use Goblin XNA to implement ball control in the same way as one might find in the board game labyrinth?
There don't appear to be any tutorials or information at all regarding how to do this, despite there being a demo video displaying just such a thing.
I've setup the environment and gravity and added the ground and a sphere. I use WorldTransformation.Decompose to extract the current orientation of the board. I know the next step will be either ApplyLinearVelocity or AddForce to the sphere based on the current board orientation, but I don't know how to constantly apply these methods to the ball so that the ball is moving in response to the movement of the ball. Adding code to the Draw or Update methods only executes the code a single time. Anyone familiar with Goblin XNA at all and able to help?
As far as I can see in Goblin XNA the Update and Draw methods are called the same way as standard XNA games. Can you give more specific information? source code perhaps?

Categories