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.
45 lines
1.1 KiB
C#
45 lines
1.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
public class DrawQueue
|
|
{
|
|
List<DrawSpriteCall> spriteQueue = new List<DrawSpriteCall>();
|
|
DrawSpriteCall[] lastSpriteQueue = new DrawSpriteCall[0];
|
|
|
|
List<DrawStringCall> stringQueue = new List<DrawStringCall>();
|
|
DrawStringCall[] lastStringQueue = new DrawStringCall[0];
|
|
|
|
internal DrawSpriteCall[] LastSpriteQueue
|
|
{
|
|
get { return lastSpriteQueue; }
|
|
}
|
|
|
|
internal DrawStringCall[] LastStringQueue
|
|
{
|
|
get { return lastStringQueue; }
|
|
}
|
|
|
|
public DrawQueue ()
|
|
{
|
|
}
|
|
public void Clear()
|
|
{
|
|
lastSpriteQueue = new DrawSpriteCall[spriteQueue.Count];
|
|
spriteQueue.CopyTo(lastSpriteQueue);
|
|
spriteQueue.Clear();
|
|
|
|
lastStringQueue = new DrawStringCall[stringQueue.Count];
|
|
stringQueue.CopyTo(lastStringQueue);
|
|
stringQueue.Clear();
|
|
}
|
|
internal void EnqueueSprite(DrawSpriteCall drawSpriteCall)
|
|
{
|
|
spriteQueue.Add(drawSpriteCall);
|
|
}
|
|
|
|
internal void EnqueueString(DrawStringCall drawStringQueue)
|
|
{
|
|
stringQueue.Add(drawStringQueue);
|
|
}
|
|
}
|