mirror of
https://github.com/Memorix101/UnityXNA/
synced 2024-12-30 15:25:35 +01:00
The XNA 4.0 PlatformerGame sample is successfully running inside Unity3D 3.5. Implemented a basic game loop, game timing, content loading for Texture2D, SoundEffect and Song. Emulated SpriteBatch drawing for sprites and strings (note SpriteFont is not yet supported to all strings are rendered using the default GUI label font). Songs can be played using an AudioSource attached to the XNATest game object which acts as an emulator for MediaPlayer. Playing a SoundEffect creates a game object with an AudioSource attached which is automatically deleted when the sound finishes. Implemented keyboard input with a limited set of XNA Keys mapping to Unity3D KeyCodes.
63 lines
1.8 KiB
C#
63 lines
1.8 KiB
C#
#region File Description
|
|
//-----------------------------------------------------------------------------
|
|
// Tile.cs
|
|
//
|
|
// Microsoft XNA Community Game Platform
|
|
// Copyright (C) Microsoft Corporation. All rights reserved.
|
|
//-----------------------------------------------------------------------------
|
|
#endregion
|
|
|
|
using System;
|
|
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
|
|
namespace Platformer
|
|
{
|
|
/// <summary>
|
|
/// Controls the collision detection and response behavior of a tile.
|
|
/// </summary>
|
|
enum TileCollision
|
|
{
|
|
/// <summary>
|
|
/// A passable tile is one which does not hinder player motion at all.
|
|
/// </summary>
|
|
Passable = 0,
|
|
|
|
/// <summary>
|
|
/// An impassable tile is one which does not allow the player to move through
|
|
/// it at all. It is completely solid.
|
|
/// </summary>
|
|
Impassable = 1,
|
|
|
|
/// <summary>
|
|
/// A platform tile is one which behaves like a passable tile except when the
|
|
/// player is above it. A player can jump up through a platform as well as move
|
|
/// past it to the left and right, but can not fall down through the top of it.
|
|
/// </summary>
|
|
Platform = 2,
|
|
}
|
|
|
|
/// <summary>
|
|
/// Stores the appearance and collision behavior of a tile.
|
|
/// </summary>
|
|
struct Tile
|
|
{
|
|
public Texture2D Texture;
|
|
public TileCollision Collision;
|
|
|
|
public const int Width = 40;
|
|
public const int Height = 32;
|
|
|
|
public static readonly Vector2 Size = new Vector2(Width, Height);
|
|
|
|
/// <summary>
|
|
/// Constructs a new tile.
|
|
/// </summary>
|
|
public Tile(Texture2D texture, TileCollision collision)
|
|
{
|
|
Texture = texture;
|
|
Collision = collision;
|
|
}
|
|
}
|
|
}
|