|
//*******************************************************************
/*
Solution: NerdkillPocket
Project: NerdkillPocket
File: REvent.cs
Copyright 2003, 2004, Raphael MOLL.
This file is part of NerdkillPocket.
NerdkillPocket 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.
NerdkillPocket 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 NerdkillPocket; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//*******************************************************************
using System;
using System.Drawing;
//******************************
namespace Alfray.Nerdkill.Engine
{
//-------------------------------------------
//----------- Public Types ------------------
//-------------------------------------------
//*********************************
/// <summary>
/// Summary description for REvent.
/// </summary>
//*********************************
public sealed class REvent
{
//-------------------------------------------
//----------- Public Types ------------------
//-------------------------------------------
//*****************
public enum EventId
{
// event_id | argument
// -------------------------
MouseClick, // position + screen_id
MouseUp, // position + screen_id
MouseMoved, // position + screen_id
MouseIn, // none
MouseOut, // none
KeyPress, // key
Scroll, // position (interpreted as direction)
ChangeWeapon, // code
FireWeapon, // position
FullScreen, // none
Pause, // none
EndPause, // none
Restart, // none
SoundOn, // none
SoundOff, // none
Quit // none
}
//-------------------------------------------
//----------- Public Constants --------------
//-------------------------------------------
//-------------------------------------------
//----------- Public Properties -------------
//-------------------------------------------
//***************
public EventId Id
{
get
{
return mEventId;
}
}
//*******************
public Point Position
{
get
{
return mEventPos;
}
}
//***************
public string Key
{
get
{
return mEventKey;
}
}
//*****************************
public RConstants.SpriteId Code
{
get
{
return mEventCode;
}
}
//*******************************
public RConstants.ScreenId Screen
{
get
{
return mScreenId;
}
}
//-------------------------------------------
//----------- Public Methods ----------------
//-------------------------------------------
//*****************************
public REvent(EventId event_id)
{
// some events require extra data and must be constructed
// using a constructor that takes extra information
System.Diagnostics.Debug.Assert(event_id != EventId.MouseClick
&& event_id != EventId.MouseUp
&& event_id != EventId.MouseMoved
&& event_id != EventId.KeyPress
&& event_id != EventId.ChangeWeapon
&& event_id != EventId.FireWeapon
&& event_id != EventId.Scroll);
mEventId = event_id;
}
//***********************
public REvent(string key)
{
mEventId = EventId.KeyPress;
mEventKey = key;
}
//*******************************************************
public REvent(EventId event_id, RConstants.SpriteId code)
{
System.Diagnostics.Debug.Assert(event_id == EventId.ChangeWeapon);
mEventId = event_id;
mEventCode = code;
}
//***************************************************
public REvent(EventId event_id, Point event_position)
{
System.Diagnostics.Debug.Assert(
event_id == EventId.FireWeapon
|| event_id == EventId.Scroll);
mEventId = event_id;
mEventPos = event_position;
}
//******************************************
public REvent(EventId event_id,
Point event_position,
RConstants.ScreenId screen_id)
{
System.Diagnostics.Debug.Assert(event_id == EventId.MouseClick
|| event_id == EventId.MouseUp
|| event_id == EventId.MouseMoved);
mEventId = event_id;
mScreenId = screen_id;
mEventPos = event_position;
}
//-------------------------------------------
//----------- Private Methods ---------------
//-------------------------------------------
//-------------------------------------------
//----------- Private Attributes ------------
//-------------------------------------------
EventId mEventId;
Point mEventPos;
string mEventKey;
RConstants.SpriteId mEventCode;
RConstants.ScreenId mScreenId;
} // class REvent
} // namespace Alfray.Nerdkill.Gameplay
//---------------------------------------------------------------
//
// $Log: REvent.cs,v $
// Revision 1.3 2004/05/27 17:25:06 ralf
// Scroll event for directional keys
//
// Revision 1.2 2004/05/26 08:49:18 ralf
// Polishing.
//
// Revision 1.1.1.1 2004/05/24 14:21:57 ralf
// Stable port to PockerPC/.Net Compact Framework.
// Uses .Net/GDI+ for graghic. Uses WinCE's SoundPlay for sound.
//
//---------------------------------------------------------------
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Raphael is a senior software engineer with a background in electronics engineering.
He enjoys programming in C++ since 1994.
He developed professional software for the BeOS and now focuses on Windows, MacOS and Linux software development.
He uses C++, C#, Java,VB.Net, PHP, Bash and Perl on a regular basis. He is familiar with C, Objective-C, VB6, Python, ML, Haskell, Lisp, Scheme, some obsolete languages (Basic and Pascal) and x86/Motorola assembly languages.
Raphael is a big fan of the .Net platform.
A number of open source personal projects can be found on his web site.