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

📄 cell.h

📁 通用网络游戏开发框架
💻 H
字号:
// This file needs -*- c++ -*- mode
// ============================================================================
// Cell interface
//
// (c) 2003 Ken Reed
//
// This is free software. You can redistribute it and/or modify it under the
// terms of the GNU General Public License version 2 as published by the Free
// Software Foundation.
// ============================================================================

// If you try and put template classes into STL containers the MS compiler
// warns that there are problems using the debugger on them. Turn off this
// warning as we don't care about it.

#pragma once
#pragma warning(disable:4786)

#include "cell.h"
#include "point.h"
#include "socket.h"

#include <set>
#include <iostream>

const int cell_size         (24);
const int half_cell_size    (cell_size / 2);
const int quarter_cell_size (cell_size / 4);
const int p75_cell_size     (cell_size - quarter_cell_size);
const int all_vectors       (-1);
const int max_troops        (100);
const int max_elevation     (100);
const int growth_rate       (10);

enum {Empty, Base};

class Cell {
 public:
   Cell();

   int      get_vector();
   int      which_side(Point click);

   void     battle(double elapsed);
   void     draw(HWND window, bool hidden, int client);
   void     update(double elapsed);
   void     set_vector(Point position);
   void     toggle_vector(Point position);
   void     set_march(Point position);
   void     clear_vector(int side);
   void     reset(bool exploring);
   void     merge(const Cell & cell);
   Point    get_centre();

   bool     changed;
   bool     explored;
   bool     march;
   bool     scanned;
   bool     vector[6];

   double   elevation;
   double   march_timer;
   double   troops;
   double   strength;

   int      i;
   int      j;
   int      march_vector;
   int      player;
   int      type;

   POINT    position;
   std::set<Cell *> attackers;

private:
   void     draw_cell(HDC dc, bool hidden, int client);
   Cell     (const Cell & Cell);         // No copying allowed
};

void read_cell (Socket & socket, Cell & cell);
void send_cell (Socket & socket, Cell & cell);

std::ostream & operator<<(std::ostream & s, Cell & c);
std::istream & operator>>(std::istream & s, Cell & c);

⌨️ 快捷键说明

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