本文整理汇总了C#中Hex类的典型用法代码示例。如果您正苦于以下问题:C# Hex类的具体用法?C# Hex怎么用?C# Hex使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Hex类属于命名空间,在下文中一共展示了Hex类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
// Use this for initialization
void Start()
{
editorUserS.selection_menu_displayed = true;
// Hex[] keys = editorHexManagerS.hex_dict.Keys.toArray();;
Hex[] keys = new Hex[editorHexManagerS.hex_dict.Keys.Count];
editorHexManagerS.hex_dict.Keys.CopyTo(keys, 0);
int size = keys.Length;
float interval = (Mathf.PI * 2)/size;
for(int i = 0; i < size; ++i)
{
float x = Mathf.Cos(interval*i + (Mathf.PI/2))*radial_distance + transform.position.x;
float z = ((Mathf.Sin(interval*i + (Mathf.PI/2))*radial_distance)/1.16F) + transform.position.z;
GameObject new_hex = (GameObject) Instantiate(editorHexManagerS.hex_dict[keys[i]], new Vector3(x, 5 + (.01F * i) + .01F, z), Quaternion.identity);
editorHexS new_hex_script = (editorHexS) new_hex.AddComponent("editorHexS");
new_hex_script.hex_type = keys[i];
new_hex_script.menu_item = true;
new_hex_script.menu_item_num = i;
new_hex.transform.parent = transform;
}
}
示例2: AddHex
public virtual void AddHex(Hex child)
{
if (Hexes == null)
Hexes = new List<Hex>();
child.World = this;
Hexes.Add(child);
}
示例3: LocationPoint
public LocationPoint(Hex attachingHex)
{
attachedHex = new List<Hex>();
edges = new List<Edge>();
attachedHex.Add(attachingHex);
Harbor = SeaHarbor.NotHarbor;
}
示例4: CodeDevice
static void CodeDevice(string portName, string deviceName, Hex code, string[] args)
{
ErrorCode error;
int[] pins;
switch (deviceName) {
case "pic18f":
pins = GetPins(args, 2, 4);
if (pins == null)
return;
error = ProgrammerFactory.ProgramPic(portName, code, deviceName,
pins[0], pins[1], pins[2], pins[3]);
break;
case "cc25":
pins = GetPins(args, 2, 3);
if (pins == null)
return;
error = ProgrammerFactory.ProgramCC2530(portName, code, deviceName,
pins[0], pins[1], pins[2]);
break;
default:
Console.WriteLine("ERROR Device not supported.");
ShowHelp();
return;
}
if (error != ErrorCode.NoError)
Console.WriteLine("ERROR " + error.ToString());
}
示例5: SetHex
public void SetHex(GraphicCampo graphicCampo, Hex hex)
{
m_hex = hex;
m_graphicCampo = graphicCampo;
q = hex.q;
r = hex.r;
}
示例6: MoveNavy
public MoveNavy() : base() { } //JSON Constructor
public MoveNavy(Hex from, Hex to, int count)
: base()
{
this.from = from;
this.to = to;
this.count = count;
}
示例7: EqualHex
public static void EqualHex(String name, Hex a, Hex b)
{
if (!(a.q == b.q && a.s == b.s && a.r == b.r))
{
Tests.Complain(name);
}
}
示例8: CalculateHexValue
/// <summary>
/// Calculates the hex value.
/// </summary>
/// <returns>
/// The hex value.
/// </returns>
/// <param name='hex'>
/// Hex.
/// </param>
int CalculateHexValue(Hex hex)
{
if(hex.Unit != null) {
if(hex.Unit.Team == player.Team || hex.Unit.Team == 0) {
return int.MinValue;
} else {
return int.MaxValue - hex.Unit.Attack;
}
} else {
Dictionary<Flag, int> flags;
if(isAggressive) {
flags = getEnemyOrNeutralFlagValues();
} else {
flags = getFriendlyFlagValues();
}
Flag flag = null;
foreach(Flag f in flags.Keys) {
if(flag == null) flag = f;
else {
if(flags[f] > flags[flag]) {
flag = f;
}
}
}
return flags[flag] - Mathf.FloorToInt(hex.Distance(flag.Hex));
}
}
示例9: ReplaceTilePosition
public Entity ReplaceTilePosition(Hex newPosition) {
var componentPool = GetComponentPool(ComponentIds.TilePosition);
var component = (TilePositionComponent)(componentPool.Count > 0 ? componentPool.Pop() : new TilePositionComponent());
component.position = newPosition;
ReplaceComponent(ComponentIds.TilePosition, component);
return this;
}
示例10: foreach
/*public void PathFinding(Hex start) {
Queue<Hex> frontier = new Queue<Hex>();
frontier.Enqueue(start);
Dictionary<Hex, bool> visitado = new Dictionary<Hex, bool>();
foreach (Hex hex in m_hexagons) {
visitado[hex] = false;
}
visitado[start] = true;
while (frontier.Count != 0) {
Hex current = frontier.Peek();
frontier.Dequeue();
foreach (Hex hex in current.vizinhos) {
if (visitado[hex] == false) {
frontier.Enqueue(hex);
visitado[hex] = true;
Debug.Log(hex);
}
}
}
}*/
public void PathFinding(Hex start, Hex destino)
{
Queue<Hex> frontier = new Queue<Hex>();
frontier.Enqueue(start);
Dictionary<Hex, Hex> came_from = new Dictionary<Hex, Hex>();
Hex hexnulo = new Hex(100, 100);
foreach (Hex hex in m_hexagons) {
came_from[hex] = hexnulo;
}
//came_from[start] = new Hex(100, 100);
while (frontier.Count != 0) {
Hex current = frontier.Peek();
frontier.Dequeue();
foreach (Hex hex in current.vizinhos) {
if (came_from[hex] == hexnulo) {
frontier.Enqueue(hex);
came_from[hex] = current;
}
}
}
Hex atual = destino;
List<Hex> path = new List<Hex>();
path.Add(atual);
while (atual != start) {
atual = came_from[atual];
path.Add(atual);
}
path.Reverse();
foreach (Hex hex in path) {
At(hex.q, hex.r).estaVazio = false;
}
}
示例11: PlayCardOnHex
public override Unit PlayCardOnHex(Card card, Hex hex, string id)
{
CardHistory.Add(card);
GuiControl.AddCardToHistory(card);
// TODO Clean up this method to better handle multiple card types.
if(typeof(EntityCard).IsAssignableFrom(card.GetType())) {
EntityCard eCard = (EntityCard) card;
GameObject go = (GameObject) Instantiate(UnitPrefab, Vector3.zero, Quaternion.identity);
Unit unit = go.GetComponent<Unit>();
unit.Id = id;
unit.FromCard(eCard);
unit.Hex = hex;
unit.transform.position = hex.transform.position;
hex.Unit = unit;
Units.Add(unit);
unit.Team = MyTurn() ? Team.ME : Team.ENEMY;
if(MyTurn() && ThisPlayer.Hand.Count != 0) {
// TODO Find a better way to sort this
ThisPlayer.PlayCard();
}
card.OnPlay(new StateObject(Units, hex, null, MyTurn() ? ThisPlayer : EnemyPlayer, MyTurn() ? EnemyPlayer : ThisPlayer));
return unit;
} else {
if(MyTurn() && ThisPlayer.Hand.Count != 0) {
// TODO Find a better way to sort this
ThisPlayer.PlayCard();
}
card.OnPlay(new StateObject(Units, hex, null, MyTurn() ? ThisPlayer : EnemyPlayer, MyTurn() ? EnemyPlayer : ThisPlayer));
return null;
}
}
示例12: distance
public static int distance(Hex h1, Hex h2)
{
return (int)(Math.Abs(h1.axialCoordinates.X - h2.axialCoordinates.X) + Math.Abs(h1.axialCoordinates.Y - h2.axialCoordinates.Y)
+ Math.Abs(h1.axialCoordinates.X + h1.axialCoordinates.Y - h2.axialCoordinates.X - h2.axialCoordinates.Y)) / 2;
}
示例13: GetConnectedSeas
public static List<Hex> GetConnectedSeas(MapCM map, int playerID, Hex h, int moveLimit, bool is_possible_to_attack_enemy)
{
List<Hex> res = new List<Hex>();
res.Add(h);
_GetConnectedSeas(map, playerID, h, moveLimit, res, is_possible_to_attack_enemy);
return res;
}
示例14: GetDistance
public static float GetDistance(Hex a, Hex b)
{
Cube ca = a.ToCube();
Cube cb = b.ToCube();
return Cube.GetDistance(ca, cb);
}
示例15: HexVisual
public HexVisual(Point2D point, Hex hex)
: base(point)
{
_Hex = hex;
Init();
InitHex();
}