⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cbzhenfa.cpp

📁 网页游戏赤壁
💻 CPP
字号:
/////////////
//	CBZhenFa.cpp	:	v0010
//	Written by		:	Liu Gang
//	Compiler		:	Microsoft Visual C++ 4.2
//	Copyright (C)	:	1996 WayAhead Corporation
//	v0010			:	Apr.16.1997
/////////////
// implementation file
// 阵法

#include "stdafx.h"
#include "Assert.h"
#include "CBGame.h"		// struct UNIT_STRUCT
#include "CBMap.h"
#include "CBCtrl.h"		// enum CTRL_ZHENXING
#include "CBEyes.h"		// EYE_
#include "CBZhenFa.h"

/////////////
// local functions
// 简单设置所有阵法
void ZHEN_SetAll( struct UNIT_STRUCT *pUnit, int nID );

// 一字长蛇阵
void ZHEN_Set1( struct UNIT_STRUCT *pUnit );

// 二龙出水阵
void ZHEN_Set2( struct UNIT_STRUCT *pUnit );

// 三才天地阵
void ZHEN_Set3( struct UNIT_STRUCT *pUnit );

// 四象奇门阵
void ZHEN_Set4( struct UNIT_STRUCT *pUnit );

// 五行梅花阵
void ZHEN_Set5( struct UNIT_STRUCT *pUnit );

// 六合连环阵
void ZHEN_Set6( struct UNIT_STRUCT *pUnit );

// 七星北斗阵
void ZHEN_Set7( struct UNIT_STRUCT *pUnit );

// 八门金锁阵
void ZHEN_Set8( struct UNIT_STRUCT *pUnit );

// 九宫八卦阵
void ZHEN_Set9( struct UNIT_STRUCT *pUnit );

// 十面埋伏阵
void ZHEN_Set10( struct UNIT_STRUCT *pUnit );
/////////////

/////////////
// 改变阵法
// pUnit	:	被改变的部队,必须是将领ID
// nID		:	阵法ID
void ZHEN_Change( struct UNIT_STRUCT *pUnit, int nID )
{
	Assert( EYE_IfUnitIsGen( pUnit ) );
	Assert( !EYE_IfUnitIsWorkerGen( pUnit ) );

	ZHEN_SetAll( pUnit, nID-1 );
/*
	switch( nID )	
	{
	case	YIZI:	// 一字长蛇阵
		ZHEN_Set1( pUnit );
		break;
	case	ERLONG:	// 二龙出水阵
		ZHEN_Set2( pUnit );
		break;
	case	SANCAI:	// 三才天地阵
		ZHEN_Set3( pUnit );
		break;
	case	SIXIANG:// 四象奇门阵
		ZHEN_Set4( pUnit );
		break;
	case	WUXING:	// 五行梅花阵
		ZHEN_Set5( pUnit );
		break;
	case	LIUHE:	// 六合连环阵
		ZHEN_Set6( pUnit );
		break;
	case	QIXING:	// 七星北斗阵
		ZHEN_Set7( pUnit );
		break;
	case	BAMEN:	// 八门金锁阵
		ZHEN_Set8( pUnit );
		break;
	case	JIUGONG:// 九宫八卦阵
		ZHEN_Set9( pUnit );
		break;
	case	SHIMIAN:// 十面埋伏阵
		ZHEN_Set10( pUnit );
		break;
	}
*/
}
/////////////

/////////////
// local functions

void ZHEN_SetAll( struct UNIT_STRUCT *pUnit, int nType )
{
	// 阵型位置相对坐标
	POINT ptPOS[CTRL_ZHENXING_MAX][GENERAL_TROOP_MAX]=
	{
		//1
		{{0,-4},{-1,-2},{1,-2},{-2,-2},{2,-2},
		{-3,-2},{3,-2},{-4,-2},{4,-2},{-5,-2},
		{5,-2},{-6,-2},{6,-2},{-7,-2},{7,-2}},

		//2
		{{0,-6},{-1,4},{1,4},{-2,2},{2,2},
		{-2,0},{2,0,},{-3,-2},{3,-2},{-3,-4},
		{3,-4},{-4,-6},{4,-6},{-4,-8},{4,-8}},

		//3
		{{0,-6},{-3,2},{3,2},{-2,-6},{-4,0},
		{4,0},{2,-6},{-2,4},{2,4},{-4,-6},
		{-5,-2},{5,-2},{4,-6},{-1,6},{1,6}},

		//4
		{{2,0},{0,4},{2,4},{0,-4},{2,-4},
		{-2,0},{-2,-4},{-2,4},{-2,-8},{0,-8},
		{2,-8},{4,0},{4,-4},{4,4},{4,-8}},

		//5
		{{0,-8,},{-4,-2},{4,-2},{-3,6},{3,6},
		{-1,-4},{-3,2},{3,2},{-2,4},{2,4},
		{1,-4},{-2,-2},{2,-2},{-1,6},{1,6}},

		//6
		{{0,-6},{-2,-2},{2,-2},{-2,2},{2,2},
		{0,6},{-3,-2},{3,-2},{-3,2},{3,2},
		{0,8},{0,-2},{-1,0},{1,0},{0,2}},
		
		//7
		{{0,-4},{-1,-2},{-3,2},{-2,-4},{-3,-2},
		{1,-4},{2,-6},{0,4},{1,2},{3,-2},
		{2,4},{3,2},{-1,4},{-2,6},{0,-10}},

		//8
		{{0,-8},{-1,-6},{1,-6},{-2,-4},{2,-4},
		{-1,-2},{1,-2},{0,-12},{-4,-4},{4,-4},
		{0,4},{-2,-8},{2,-8},{-2,0},{2,0}},

		//9
		{{2,0},{0,4},{2,4},{-1,-2},{3,-2},
		{-1,6},{3,6},{-2,0},{0,8},{4,4},
		{2,-4},{-3,2},{1,10},{5,2},{1,-6}},

		//10
		{{0,-10},{-1,-8},{1,-8},{0,4},{-2,-8},
		{2,-8},{-1,4},{1,4},{-3,-6},{3,-6},
		{-4,-6},{4,-6},{-2,4},{2,4},{0,-4}},
	};

	int i;	// 计数器
	WORD arTroop[GENERAL_TROOP_MAX];	// 存放本部队的士兵ID
	int nTrp;							// 本部队士兵的个数
	struct UNIT_STRUCT *parUnit[GENERAL_TROOP_MAX];	// // 存放本部队的士兵指针

	// 得到本部队的所有士兵
	nTrp = GENERAL_TROOP_MAX;
	EYE_GetUnitInGroup( 1, pUnit->nID, arTroop, &nTrp );
	Assert( nTrp >= 0 );
	for( i=0; i<nTrp; i++ )
	{
		Assert( arTroop[i] != MAP_DATA_NONE );
		parUnit[i] = MAP_GetUnit( arTroop[i] );
		Assert( parUnit[i] );
		Assert( !EYE_IfUnitIsDead( parUnit[i] ) );
		//parUnit[i]->nZhenFa = nType;	// 设置阵型类型
	}

	// 设置每个士兵在阵型中的位置
	for( i=0; i<nTrp; i++ )
	{
		parUnit[i]->ptZhenFa.x = ptPOS[nType][i].x,
		parUnit[i]->ptZhenFa.y = ptPOS[nType][i].y;
	}

	// 保存本将领的阵型
//	pUnit->nZhenFa = nType;
}

// 一字长蛇阵
void ZHEN_Set1( struct UNIT_STRUCT *pUnit )
{
	// 阵型位置相对坐标
	POINT ptPOS[GENERAL_TROOP_MAX]=
	{{0,-2},{-1,-2},{1,-2},{-2,-2},{2,-2},
	{-3,-2},{3,-2},{-4,-2},{4,-2},{-5,-2},
	{5,-2},{-6,-2},{6,-2},{-7,-2},{7,-2}};

	int i;	// 计数器
	WORD arTroop[GENERAL_TROOP_MAX];	// 存放本部队的士兵ID
	int nTrp;							// 本部队士兵的个数
	struct UNIT_STRUCT *parUnit[GENERAL_TROOP_MAX];	// // 存放本部队的士兵指针

	// 得到本部队的所有士兵
	nTrp = GENERAL_TROOP_MAX;
	EYE_GetUnitInGroup( 1, pUnit->nID, arTroop, &nTrp );
	Assert( nTrp >= 0 );
	for( i=0; i<nTrp; i++ )
	{
		Assert( arTroop[i] != MAP_DATA_NONE );
		parUnit[i] = MAP_GetUnit( arTroop[i] );
//		parUnit[i]->nZhenFa = YIZI;	// 设置阵型类型
		Assert( parUnit[i] );
		Assert( !EYE_IfUnitIsDead( parUnit[i] ) );
	}

	// 设置每个士兵在阵型中的位置
	for( i=0; i<nTrp; i++ )
	{
		parUnit[i]->ptZhenFa.x = ptPOS[i].x,
		parUnit[i]->ptZhenFa.y = ptPOS[i].y;
	}

	// 保存本将领的阵型
//	pUnit->nZhenFa = YIZI;
}

// 二龙出水阵
void ZHEN_Set2( struct UNIT_STRUCT *pUnit )
{
}

// 三才天地阵
void ZHEN_Set3( struct UNIT_STRUCT *pUnit )
{
}

// 四象奇门阵
void ZHEN_Set4( struct UNIT_STRUCT *pUnit )
{
}

// 五行梅花阵
void ZHEN_Set5( struct UNIT_STRUCT *pUnit )
{
}

// 六合连环阵
void ZHEN_Set6( struct UNIT_STRUCT *pUnit )
{
}

// 七星北斗阵
void ZHEN_Set7( struct UNIT_STRUCT *pUnit )
{
}

// 八门金锁阵
void ZHEN_Set8( struct UNIT_STRUCT *pUnit )
{
}

// 九宫八卦阵
void ZHEN_Set9( struct UNIT_STRUCT *pUnit )
{
}

// 十面埋伏阵
void ZHEN_Set10( struct UNIT_STRUCT *pUnit )
{
}
/////////////

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -