/*
* GameObject.cs
* Authors: Mike DeMauro, Adam Nabinger
* Copyright (c) 2007-2008 Cornell University
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
using System.Drawing;
using System.Collections.Generic;
using System;
namespace StarJackWorldEditor.Engine
{
internal enum Facing
{
Up,
Down,
Left,
Right,
}
internal class GameObject
{
internal GameObject() { }
internal GameObject(string name, bool tileMode)
{
mObjName = name;
mTileAttachment = tileMode;
}
private StarJack.ObjectTypes mType;
public StarJack.ObjectTypes Type
{
get { return mType; }
set { mType = value; }
}
private int mX;
public int X
{
get { return mX; }
set { mX = value; }
}
private int mY;
public int Y
{
get { return mY; }
set { mY = value; }
}
private bool mEnabled = true;
public bool Enabled
{
get { return mEnabled; }
set { mEnabled = value; }
}
private bool mTileAttachment = true;
public bool TileAttachment
{
get { return mTileAttachment; }
set { mTileAttachment = value; }
}
private bool mCollision;
public bool Collision
{
get { return mCollision; }
set { mCollision = value; }
}
private string mTextureGroup = string.Empty;
public string TextureGroup
{
get { return mTextureGroup; }
set { if (value != null) mTextureGroup = value; }
}
private string mActiveTextureName = string.Empty;
public string ActiveTextureName
{
get { return mActiveTextureName; }
set { if(value != null) mActiveTextureName = value; }
}
private string mInactiveTextureName = string.Empty;
public string InactiveTextureName
{
get { return mInactiveTextureName; }
set { if (value != null) mInactiveTextureName = value; }
}
private string mObjName = string.Empty;
public string ObjectName
{
get { return mObjName; }
set { if (value != null) mObjName = value; }
}
private Facing mFacing = Facing.Down;
public Facing Facing
{
get { return mFacing; }
set { mFacing = value; }
}
public override string ToString()
{
return mObjName;
}
///
/// Gets the texture bitmap for a GameObject using its TextureGroup or ActiveTextureName property.
/// If no texture exists, an exception is thrown.
///
/// The texture dictionary.
/// The bitmap image
public Image GetTexture(Dictionary textures)
{
if (mTextureGroup != null)
{
string texFacing = mTextureGroup + "\\" + mFacing;
if (textures.ContainsKey(texFacing))
return textures[texFacing];
string texActive = mTextureGroup + "\\Active";
if (textures.ContainsKey(texActive))
return textures[texActive];
}
if (mActiveTextureName != null)
{
if (textures.ContainsKey(mActiveTextureName))
return textures[mActiveTextureName];
}
throw new Exception("Texture for GameObject '" + mObjName + "' does not exist.");
}
}
}