public WSUnitDescriptor(SZWSUnitDescriptor toCopy) { position = new Vector2(toCopy.positionX, toCopy.positionY); unitType = toCopy.unitType; weaponType = toCopy.weaponType; player = toCopy.player; }
public WSUnitDescriptor(Vector2 position, UnitBaseType unitType, WeaponType weaponType, int player) { this.position = position; this.unitType = unitType; this.weaponType = weaponType; this.player = player; }
public void MenuOptionClicked(UnitOrWeapon optionType, UnitBaseType unitType, WeaponType weapon) { MenuOptionEndHover(); if (optionType == UnitOrWeapon.Unit) { _units[activePlayer][SelectedUnitIter].UnitType = unitType; SelectedUnitIter++; } if (optionType == UnitOrWeapon.Weapon) { _units[activePlayer][SelectedUnitIter].WeaponType = weapon; bool foundEmpty = false; /* * for (int i = 0; i < _units[turn].Count; i++) { * if (_units[turn][i].WeaponType == WeaponType.None) { * SelectedUnitIter = i; * foundEmpty = true; * break; * } * }*/ if (!foundEmpty) { SelectedUnitIter++; } } }
public SZWSUnitDescriptor(WSUnitDescriptor toCopy) { positionX = toCopy.position.x; positionY = toCopy.position.y; unitType = toCopy.unitType; weaponType = toCopy.weaponType; player = toCopy.player; }
public void MenuOptionHover(UnitOrWeapon optiontype, UnitBaseType unitType, WeaponType weaponType) { hoverStartTime = Time.time; amHovering = true; hoveredOptionType = optiontype; hoveredBaseType = unitType; hoveredWeaponType = weaponType; }
public void UnitGhostReleased(WSUnitManager unit) { if (_hoveredUnit == null) { unit.EnableUnitVisual(); } else { UnitBaseType tempUnit = unit.UnitType; WeaponType tempWeapon = unit.WeaponType; unit.UnitType = _hoveredUnit.UnitType; unit.WeaponType = _hoveredUnit.WeaponType; _hoveredUnit.UnitType = tempUnit; _hoveredUnit.WeaponType = tempWeapon; unit.EnableUnitVisual(); } }
public void OptionGhostReleased(UnitOrWeapon optionType, UnitBaseType unitType, WeaponType weapon) { if (_hoveredUnit != null) { if (_units[activePlayer][SelectedUnitIter] == _hoveredUnit) { SelectedUnitIter++; } if (optionType == UnitOrWeapon.Unit) { _hoveredUnit.UnitType = unitType; } else if (optionType == UnitOrWeapon.Weapon) { _hoveredUnit.WeaponType = weapon; } } }
private static bool MeetsTerrainCostRequirement(List <HexEntry> path, IUnitController controller, int movesRemaining) { int sum = 0; UnitBaseType unitType = controller.UnitType; // Note: skip the origin of the path foreach (HexEntry hex in path.Skip(1)) { if (UnitBaseStats.TerrainCost(unitType, hex.Terrain) <= 0) { return(false); } if (hex.Occupant != null) { return(false); } sum += UnitBaseStats.TerrainCost(unitType, hex.Terrain); } return(sum <= movesRemaining); }
public static int TerrainCost(UnitBaseType unitType, Terrain terrain) { return(Stats[(int)unitType, (int)terrain + (int)StatOrder.Normal]); }
public static int Damage(UnitBaseType unitType, WeaponType weapon) { return(Stats[(int)unitType, (int)weapon - 1 + (int)StatOrder.Spear]); }
public static int HP(UnitBaseType unitType) { return(Stats[(int)unitType, (int)StatOrder.HP]); }
public static int MoveSpeed(UnitBaseType unitType) { return(Stats[(int)unitType, (int)StatOrder.MoveSpeed]); }
//</Stats> public DefaultUnitController(UnitBaseType unitType, WeaponType weaponType, int playerOwner) { this._unitType = unitType; this._weaponType = weaponType; this._playerOwner = playerOwner; }
public IUnitController Create(int playerOwner, UnitBaseType type, WeaponType weapon, HexEntry startPosition) { if (gameManager == null) { gameManager = GetComponent <GameManager>(); scenarioLoader = GetComponent <ScenarioLoader>(); selectionManager = GetComponent <SelectionManager>(); uiHandler = GetComponent <UIHandler>(); } GameObject unit = Instantiate(unitPrefab, Vector3.zero, Quaternion.identity); IUnitController unitController = new DefaultUnitController(type, weapon, playerOwner); UnitSpriteManager unitSpriteManager = unit.GetComponent <UnitSpriteManager>(); unitSpriteManager.UnitController = unitController; IMover mover = new DefaultMover(unitController, gameManager, selectionManager, scenarioLoader); OutcomeAnimator outcomeAnimator = new OutcomeAnimator(selectionManager, uiHandler); unitController.Initialize(mover, outcomeAnimator, unitSpriteManager, startPosition); switch (weapon) { case WeaponType.None: unitController.Weapon = new EmptyWeapon(unitController, gameManager, scenarioLoader, selectionManager); break; case WeaponType.Spear: unitController.Weapon = new Spear(unitController, gameManager, scenarioLoader, selectionManager); break; case WeaponType.Sword: unitController.Weapon = new Sword(unitController, gameManager, scenarioLoader, selectionManager); break; case WeaponType.Axe: unitController.Weapon = new Axe(unitController, gameManager, scenarioLoader, selectionManager); break; case WeaponType.Quarterstaff: unitController.Weapon = new Quarterstaff(unitController, gameManager, scenarioLoader, selectionManager); break; case WeaponType.Flail: unitController.Weapon = new Flail(unitController, gameManager, scenarioLoader, selectionManager); break; case WeaponType.Dagger: unitController.Weapon = new Dagger(unitController, gameManager, scenarioLoader, selectionManager); break; case WeaponType.Longbow: unitController.Weapon = new Longbow(unitController, gameManager, scenarioLoader, selectionManager); break; case WeaponType.Crossbow: unitController.Weapon = new Crossbow(unitController, gameManager, scenarioLoader, selectionManager); break; case WeaponType.Shield: unitController.Weapon = new Shield(unitController, gameManager, scenarioLoader, selectionManager); break; } return(unitController); }
// Lower is better private int HexSpacingWeight(UnitBaseType unitType, WeaponType weaponType, HexEntry hex) { int result = 0; // Per-weapon spacing weights if (weaponType == WeaponType.Spear) { if (hex.AIDistanceToEnemy == 1) { result = +2; } if (hex.AIDistanceToEnemy == UnitBaseStats.MoveSpeed(unitType) + 1) { result = -2; } } if (weaponType == WeaponType.Sword) { if (hex.AIDistanceToEnemy == 1) { result = -1; } if (hex.AIDistanceToEnemy == 2) { result = +1; } if (hex.AIDistanceToEnemy == UnitBaseStats.MoveSpeed(unitType) + 1) { result = +2; } } if (weaponType == WeaponType.Flail) { result = -1 * hex.aiAdjacentEnemies; } if (weaponType == WeaponType.Longbow) { if (hex.AIDistanceToEnemy == 2) { result = -4; } if (hex.AIDistanceToEnemy == 3) { result = -8; } } if (weaponType == WeaponType.Dagger) { result = -2 * hex.aiAdjacentEnemies; } if (weaponType == WeaponType.Shield) { if (hex.AIDistanceToEnemy == 1) { result = +3; } } //Generally encourage movement toward the enemy if out of range if (hex.AIDistanceToEnemy > UnitBaseStats.MoveSpeed(unitType) + 1) { result += hex.AIDistanceToEnemy - UnitBaseStats.MoveSpeed(unitType) - 1; } return(result); }