技能前摇二版

#pragma once
#include "..//Game_Module//Proxy_Factory.h"

struct IUnit{ virtual ~IUnit(){} };

class IUnitPart
{
public:
	//取得本身生物
	IUnit* get_master(){ return m_p_master; }

	//初始化
	virtual bool init( void* _p_par ) = 0;

	//反初始化
	virtual void uninit() = 0;

	//取得部件类型
	virtual long get_part_type() = 0;

	//冻结本部件
	virtual void freeze(){}

	//解冻本部件
	virtual void unfreeze(){}

protected:
	IUnitPart( IUnit* _p_master ):m_p_master(_p_master){}
	virtual ~IUnitPart(){ m_p_master = NULL; }
	friend class Role_Unit;

private:
	IUnit* m_p_master;
};

struct Unit_Part
{
	enum SIGN
	{
		SKILL_PREPARE = 1,
	};
};

#pragma once
#include "IUnit.h"


class Role_Unit: public IUnit
{
public:
	enum PART_TYPE
	{
		e_SKILL_PREPARE_UNITPART = 0,
		e_MAX = e_SKILL_PREPARE_UNITPART + 1,
	};

	Role_Unit(long _uid);
	virtual ~Role_Unit();
	IUnitPart* get_part( const PART_TYPE _part_type );

protected:
	long		m_uid;
	IUnitPart*	mp_part[e_MAX];
};

#pragma once
#include "stdafx.h"
#include "Role_Unit.h"
#include "IUnit.h"
#include "..//Unit_Part//Skill_Prepare_UnitPart.h"
#include "..//App_Module//App_Center.h"



Role_Unit::Role_Unit( long _uid ): m_uid(_uid)
{
	CString str;
	str.Format( _T("创建生物( %d )"), m_uid );
	App_Center::trace_print( Module_Name::Game_App, str.GetBuffer() );

	App_Center::get_unit_factory()->push_single(m_uid, this);
	mp_part[e_SKILL_PREPARE_UNITPART] = new Skill_Prepare_UnitPart(this);
}

Role_Unit::~Role_Unit()
{
	for(int i=0; i<e_MAX; i++)
	{
		delete mp_part[i];
		mp_part[i] = NULL;
	}
	App_Center::get_unit_factory()->pop( m_uid );


	CString str;
	str.Format( _T("删除生物( %d )"), m_uid );
	App_Center::trace_print( Module_Name::Game_App, str.GetBuffer() );
}

IUnitPart* Role_Unit::get_part( const PART_TYPE _part_type )
{
	if( _part_type >= 0 && _part_type <= e_MAX )
		return mp_part[ _part_type ];
	return NULL;
}


#pragma once

#include "..//Game_Unit//IUnit.h"
#include "..//Game_Module//Time_Axis.h"

class Skill_Prepare_UnitPart: public IUnitPart
{
public:
	//初始化
	virtual bool init( void* _p_par );

	//反初始化
	virtual void uninit();

	//取得部件类型
	virtual long get_part_type();

	//触发技能
	void action_skill();

protected:
	Skill_Prepare_UnitPart( IUnit* _p_master );
	virtual ~Skill_Prepare_UnitPart();
	friend class Role_Unit;

private:
	ITimerSink* mp_timer;
};


#include "stdafx.h"
#include "Skill_Prepare_UnitPart.h"
#include "..//App_Module//App_Center.h"
#include "..//Game_Module//Map_Par_Binder.h"

Skill_Prepare_UnitPart::Skill_Prepare_UnitPart( IUnit* _p_master ):IUnitPart(_p_master),mp_timer(NULL)
{
	CString str;
	str.Format( _T("加载部件 Skill_Prepare_UnitPart 部件标示符( %d )"), get_part_type() );
	App_Center::trace_print( Module_Name::Game_App, str.GetBuffer() );
}

Skill_Prepare_UnitPart::~Skill_Prepare_UnitPart()
{
	CString str;
	str.Format( _T("卸载部件 Skill_Prepare_UnitPart 部件标示符( %d )"), get_part_type() );
	App_Center::trace_print( Module_Name::Game_App, str.GetBuffer() );
}

//初始化
bool Skill_Prepare_UnitPart::init( void* _p_par )
{
	App_Center::trace_print( Module_Name::Game_Server, _T("开启技能前摇") );
	App_Center::trace_print( Module_Name::Game_Client, _T("播放技能前摇动画(一次性播放)") );
	uninit();
	mp_timer = new_memfn_time_tgr_impl(App_Center::get_time_axis(), this, &Skill_Prepare_UnitPart::action_skill, 2000, 10000);
	return true;
}

//反初始化
void Skill_Prepare_UnitPart::uninit()
{
	if( NULL != mp_timer)
	{
		delete mp_timer;
		mp_timer = NULL;
		App_Center::trace_print( Module_Name::Game_Server, _T("结束技能前摇") );
	}
}

//触发技能
void Skill_Prepare_UnitPart::action_skill()
{
	uninit();
	App_Center::trace_print( Module_Name::Game_Server, _T("触发技能") );
	App_Center::trace_print( Module_Name::Game_Client, _T("播放技能动画(一次性播放)") );
}

//取得部件类型
long Skill_Prepare_UnitPart::get_part_type()
{
	return Unit_Part::SKILL_PREPARE;
}

#pragma once
#include "..//Game_Module//Evt_Server.h"

using namespace Evt_Server_Space;

struct SKILL_ID
{
	enum SKILL 
	{
		SKL_PLAN		=	1,	//施法前摇
		SKL_BREAK		=	2,	//施法打断
		LXTX			=	3,	//流星突现
		MFX				=	4,	//魔法箭
	};
};


//执行基类
class SKL_Base_Act: public IAction_Event_Listener<>
{
public:
	SKL_Base_Act(long _skill_evt);
	virtual ~SKL_Base_Act();
private:
	long m_skill_evt;
};

#include "stdafx.h"
#include "SKL_define.h"
#include "..//App_Module//App_Center.h"

SKL_Base_Act::SKL_Base_Act(long _skill_evt):m_skill_evt(_skill_evt)
{
	App_Center::get_skill_server()->add_listener(m_skill_evt, this);
	App_Center::get_delete_proxy()->push_single( this );
}

SKL_Base_Act::~SKL_Base_Act()
{
	App_Center::get_delete_proxy()->pop( this );
	App_Center::get_skill_server()->remove_listener(m_skill_evt, this);
}

#pragma once
#include "SKL_define.h"




//施法准备
struct PLAN_SKL: public SKL_Base_Act
{
	PLAN_SKL();
	virtual void on_action(Msg *_p_msg);
};


//打断施法前摇
struct BREAK_SKL: public SKL_Base_Act
{
	BREAK_SKL();
	virtual void on_action(Msg *_p_msg);
};




#include "stdafx.h"
#include "SKL_Prepare.h"
#include "SKL_define.h"
#include "..//Game_Module//Map_Par_Binder.h"
#include "..//App_Module//App_Center.h"
#include "..//Game_Unit//Role_Unit.h"







//施法准备
PLAN_SKL::PLAN_SKL():SKL_Base_Act(SKILL_ID::SKL_PLAN)
{

}
void PLAN_SKL::on_action(Msg *_p_msg)
{
	App_Center::trace_print( Module_Name::Game_App, _T("进入施法前摇") );
	//投手, 前摇时间, 技能(技能ID, 投手, 投递目标, 投递地点)
	//Bind_Par< TYPELIST_2(long, TCHAR*) >* p_buf = NULL;
	//_p_msg->get_sub_buf(p_buf);
	Role_Unit* p = (Role_Unit*)App_Center::get_unit_factory()->get_unit( 1 );
	RETURN_IF_NULL( p );
	p->get_part( Role_Unit::e_SKILL_PREPARE_UNITPART )->init(NULL);
}



//打断施法前摇
BREAK_SKL::BREAK_SKL():SKL_Base_Act(SKILL_ID::SKL_BREAK){}
void BREAK_SKL::on_action(Msg *_p_msg)
{
	App_Center::trace_print( Module_Name::Game_App, _T("打断施法前摇") );
	Role_Unit* p = (Role_Unit*)App_Center::get_unit_factory()->get_unit( 1 );
	RETURN_IF_NULL( p );
	p->get_part( Role_Unit::e_SKILL_PREPARE_UNITPART )->uninit();
}





  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值