From f81e80230f64b9679915fd7298522aea0eb91468 Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 16 Jan 2001 19:35:34 +0000 Subject: [PATCH] --- source/enemy/npc.cpp | 175 +++++++++++++++++++++++++++++++++++++++++++ source/enemy/npc.h | 90 ++++++++++++++++++++++ 2 files changed, 265 insertions(+) create mode 100644 source/enemy/npc.cpp create mode 100644 source/enemy/npc.h diff --git a/source/enemy/npc.cpp b/source/enemy/npc.cpp new file mode 100644 index 000000000..a904ae330 --- /dev/null +++ b/source/enemy/npc.cpp @@ -0,0 +1,175 @@ +#include "enemy\npc.h" + +#ifndef __LEVEL_LEVEL_H__ +#include "level\level.h" +#endif + +#ifndef __FILE_EQUATES_H__ +#include +#endif + +#ifndef __SPR_UIGFX_H__ +#include +#endif + +#ifndef __GAME_GAME_H__ +#include "game\game.h" +#endif + +#ifndef __PLAYER_PLAYER_H__ +#include "player\player.h" +#endif + + +CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] = +{ + { + NPC_INIT_DEFAULT, + NPC_SENSOR_NONE, + NPC_MOVEMENT_VERTICAL, + NPC_MOVEMENT_MODIFIER_NONE, + }, +}; + + +void CNpc::init() +{ + m_type = NPC_TEST_TYPE; + + switch ( m_data[this->m_type].initFunc ) + { + case NPC_INIT_DEFAULT: + m_controlFunc = NPC_CONTROL_MOVEMENT; + + break; + + default: + m_controlFunc = NPC_CONTROL_MOVEMENT; + + break; + } +} + + +void CNpc::shutdown() +{ +} + + +void CNpc::think(int _frames) +{ + m_controlFunc = NPC_CONTROL_MOVEMENT; + + switch ( this->m_controlFunc ) + { + case NPC_CONTROL_MOVEMENT: + if ( !processSensor() ) + { + processMovement(); + } + + break; + + case NPC_CONTROL_SHOT: + processShot(); + + break; + + case NPC_CONTROL_CLOSE: + processClose(); + + break; + + case NPC_CONTROL_COLLISION: + processCollision(); + + break; + } + + processTimer(); +} + + +bool CNpc::processSensor() +{ + switch( m_data[this->m_type].sensorFunc ) + { + case NPC_SENSOR_NONE: + return( false ); + + case NPC_SENSOR_USER_CLOSE: + /*if ( user is close ) + { + this->controlFunc = NPC_CONTROL_CLOSE; + processClose(); + + return( true ); + } + else*/ + { + return( false ); + } + } + + return( false ); +} + +void CNpc::processMovement() +{ + switch( m_data[this->m_type].movementFunc ) + { + case NPC_MOVEMENT_STATIC: + switch( m_data[this->m_type].movementModifierFunc ) + { + case NPC_MOVEMENT_MODIFIER_NONE: + break; + + case NPC_MOVEMENT_MODIFIER_BOB: + //staticBob(); + + break; + } + + break; + + case NPC_MOVEMENT_FIXED_PATH: + + break; + + case NPC_MOVEMENT_USER_SEEK: + CPlayer *player; + + player = GameScene.getPlayer(); + + break; + + case NPC_MOVEMENT_VERTICAL: + Pos.vy--; + + break; + + default: + + break; + } +} + +void CNpc::processShot() +{ +} + +void CNpc::processClose() +{ +} + +void CNpc::processCollision() +{ +} + +void CNpc::processTimer() +{ +} + +void CNpc::render() +{ +} diff --git a/source/enemy/npc.h b/source/enemy/npc.h new file mode 100644 index 000000000..4b7d1097b --- /dev/null +++ b/source/enemy/npc.h @@ -0,0 +1,90 @@ + +#ifndef __NPC_H__ +#define __NPC_H__ + +//#include +#include "Game/Thing.h" +#include "Gfx/Skel.h" + + +/*****************************************************************************/ + +class CNpc : public CThing +{ +public: + void init(); + void shutdown(); + void think(int _frames); + virtual void render(); + + +protected: + // NPC data structure definitions // + + enum NPC_UNIT_TYPE + { + NPC_TEST_TYPE = 0, + NPC_UNIT_TYPE_MAX, + }; + + enum NPC_INIT_FUNC + { + NPC_INIT_DEFAULT = 0, + NPC_INIT_SNAKE = 1, + NPC_INIT_ACID, + }; + + enum NPC_CONTROL_FUNC + { + NPC_CONTROL_MOVEMENT, + NPC_CONTROL_SHOT, + NPC_CONTROL_CLOSE, + NPC_CONTROL_COLLISION, + }; + + enum NPC_SENSOR_FUNC + { + NPC_SENSOR_NONE = 0, + NPC_SENSOR_USER_CLOSE = 1, + }; + + enum NPC_MOVEMENT_FUNC + { + NPC_MOVEMENT_STATIC = 0, + NPC_MOVEMENT_FIXED_PATH = 1, + NPC_MOVEMENT_USER_SEEK, + NPC_MOVEMENT_VERTICAL, + }; + + enum NPC_MOVEMENT_MODIFIER_FUNC + { + NPC_MOVEMENT_MODIFIER_NONE = 0, + NPC_MOVEMENT_MODIFIER_BOB = 1, + }; + + + typedef struct NPC_DATA_TYPE + { + NPC_INIT_FUNC initFunc; + NPC_SENSOR_FUNC sensorFunc; + NPC_MOVEMENT_FUNC movementFunc; + NPC_MOVEMENT_MODIFIER_FUNC movementModifierFunc; + } + NPC_DATA; + + NPC_UNIT_TYPE m_type; + NPC_CONTROL_FUNC m_controlFunc; + + bool processSensor(); + void processMovement(); + void processShot(); + void processClose(); + void processCollision(); + void processTimer(); + + static NPC_DATA m_data[NPC_UNIT_TYPE_MAX]; +}; + + +/*****************************************************************************/ +#endif