public void RevertAnimation(IUnitController unitController = null) { if (activeAnimation != null) { selectionManager.StopCoroutine(activeAnimation); //Don't animate any further selectionManager.AnimationComplete(activeAnimation); activeAnimation = null; } if (deathAnimation != null) { selectionManager.StopCoroutine(deathAnimation); deathAnimation = null; } outcomeQueue.Clear(); if (unitController != null) { unitController.SpriteManager.VisiblePosition = unitController.Position; unitController.SpriteManager.VisualMovesRemaining = unitController.MovesRemaining; unitController.SpriteManager.RevertUnitVisuals(); unitController.SpriteManager.CurrentHealthDisplay = unitController.HP; if (unitController.Position == null) { unitController.SpriteManager.ShowExtraInfo(UnitSpriteManager.UnitInfoDisplaySource.Death, false); unitController.SpriteManager.DisableUnit(); } } }
void Awake() { pCtrl = GetComponent <IUnitController> (); anim = GetComponentInChildren <Animator> (); //rBody = GetComponent<Rigidbody2D>(); pc = GetComponent <PhysicsComponent> (); if (pc == null) { pc = gameObject.AddComponent <PhysicsComponent>(); } image = GetComponentInChildren <SpriteRenderer> (); buffManager = GetComponent <EnemyBuffComponent> (); if (buffManager == null) { buffManager = gameObject.AddComponent <EnemyBuffComponent>(); } effectManager = GetComponent <BuffEffectComponent> (); if (effectManager == null) { effectManager = gameObject.AddComponent <BuffEffectComponent>(); } }
public void SelectUnit(IUnitController unitController) { if (unitController.PlayerOwner == gameManager.ActivePlayer && _unitSelected != unitController) { UnitSelected = unitController; } }
public void TravelToHex(HexEntry hex) { if (_unitSelected != null) { if (hex.Occupant == null && selectionReachableHexes.Contains(hex)) { List <Outcome> outcomes = outcomeCache[hex]; outcomeExecutor.ExecuteMoves(outcomes, _unitSelected); // Immediately update all internal values to reflect the outcomes of the move boardStateHistory.Add(CreateBoardState(outcomes)); outcomeAnimator.Interpret(outcomes); // Launch coroutine to animate move outcomes sequentially if (_unitSelected.HP <= 0) { UnitSelected = null; } else { UnitSelected = _unitSelected; } } else { UnitSelected = null; } } else { Debug.Log("No unit selected"); } }
private static int movePointExpense(List<Outcome> outcomes, IUnitController unitController) { int sum = 0; foreach (Outcome outcome in outcomes) { sum += UnitBaseStats.TerrainCost(unitController.UnitType, outcome.position.Terrain); } return sum; }
public void UpdateUnitList() { _unitsByPlayer = new Dictionary <int, List <IUnitController> >(); unitsByUniqueID = new List <IUnitController>(); foreach (int player in gameManager.playerDirectory.Keys) { _unitsByPlayer[player] = new List <IUnitController>(); } foreach (HexEntry hex in scenarioLoader.HexGrid.Values) { if (hex.Occupant != null) { _unitsByPlayer[hex.Occupant.PlayerOwner].Add(hex.Occupant); unitsByUniqueID.Add(hex.Occupant); } } /* * foreach (IUnitController unit in unitsByUniqueID) { * if (unit.PlayerOwner == gameManager.ActivePlayer) { * unit.SpriteManager.MovePointDisplay(true); * } * else { * unit.SpriteManager.MovePointDisplay(false); * } * }*/ _unitSelected = null; boardStateHistory = new List <BoardState>(); boardStateHistory.Add(CreateBoardState(new List <Outcome>())); storedEnemyPremoveState = boardStateHistory[0]; storedEnemyMoves = new List <Outcome>(); }
public EmptyWeapon(IUnitController unitController, GameManager gameManager, ScenarioLoader scenarioLoader, SelectionManager selectionManager) { this.unitController = unitController; this.gameManager = gameManager; this.scenarioLoader = scenarioLoader; this.selectionManager = selectionManager; }
public DefaultMover(IUnitController unitController, GameManager gameManager, SelectionManager selectionManager, ScenarioLoader scenarioLoader) { this.gameManager = gameManager; this.unitController = unitController; this.selectionManager = selectionManager; this.scenarioLoader = scenarioLoader; }
public GameUnit(GameObject go) { this.unit = go.GetComponent <Unit>(); this.healthBar = Instantiate <GameObject>(healthbarPrefab).GetComponent <HealthBar3D>(); this.healthBar.unit = this.unit; this.controller = null; }
public List <Outcome> SimulatePush(IUnitController target, Vector2 pushDirection, int pushAmount) { List <Outcome> outcomes = new List <Outcome>(); //outcomes.Add(new Outcome(target, target.SimPosition)); // Add current hex for interpreter convenience if (pushAmount > 0) { for (int i = 1; i <= pushAmount; i++) { if (!scenarioLoader.HexGrid.ContainsKey(pushDirection + target.SimPosition.BoardPos)) { break; } HexEntry nextHex = scenarioLoader.HexGrid[pushDirection + target.SimPosition.BoardPos]; if (nextHex.SimOccupant != null) { break; } if (UnitBaseStats.TerrainCost(target.UnitType, nextHex.Terrain) == 0) { break; } target.SimPosition = nextHex; List <AttackResult> combat = target.Weapon.CombatResults(target.SimRecentPath); outcomes.Add(new Outcome(target, nextHex, false, combat)); } } return(outcomes); }
public void UnitMouseEnter(IUnitController unitController) { hoveredUnit = unitController; if (inputEnabled.unitHover) { unitController.SpriteManager.ShowExtraInfo(UnitSpriteManager.UnitInfoDisplaySource.Cursor, true); } }
public void UnitMouseExit(IUnitController unitController) { if (hoveredUnit == unitController) { hoveredUnit = null; } unitController.SpriteManager.FullBackground(); unitController.SpriteManager.ShowExtraInfo(UnitSpriteManager.UnitInfoDisplaySource.Cursor, false); }
public UnitState(IUnitController unitController, HexEntry pos, List <HexEntry> recentPath, int movesRemaining, int zoCMovesRemaining, int hp, int shots) { this._unitController = unitController; this.pos = pos; this.recentPath = recentPath; this.movesRemaining = movesRemaining; this.zoCMovesRemaining = zoCMovesRemaining; this.hp = hp; this.shots = shots; }
private List <Outcome> OutcomesFromVectors(List <Vector2> vectorList, IUnitController unit) { List <Outcome> outcomeList = new List <Outcome>(); foreach (Vector2 boardPos in vectorList) { outcomeList.Add(new Outcome(unit, scenarioLoader.HexGrid[boardPos], true)); } return(outcomeList); }
public void ShowEnemyReachableHexes(IUnitController unit) { if (unit.PlayerOwner != gameManager.ActivePlayer) { foreach (HexEntry hex in unit.Mover.CalculatePaths()) { enemyReachableHexes.Add(hex); hex.EnemyHighlighted = true; } } }
public override int CheckSupport(IUnitController target) { if (unitController.SimPosition.Neighbors.Values.Contains(target.SimPosition)) { return(unitController.DamageOutput); } else { return(0); } }
public void ClearRangeIndicator(IUnitController unit) { if (rangeIndicatorSegments.ContainsKey(unit)) { foreach (GameObject segment in rangeIndicatorSegments[unit]) { Destroy(segment); } rangeIndicatorSegments[unit].Clear(); } }
public override int CheckSupport(IUnitController target) { if (HexVectorUtil.AxialDistance(unitController.SimPosition.BoardPos, target.SimPosition.BoardPos) <= 3 && target != unitController) { return(unitController.DamageOutput); } else { return(0); } }
public AttackResult(IUnitController target, IUnitController source, int healthRemaining, HexEntry sourceHex, HexEntry targetHex, AttackType attackType, List <Outcome> pushMoves = null) { this.target = target; this.source = source; this.healthRemaining = healthRemaining; this.sourceHex = sourceHex; this.targetHex = targetHex; this.attackType = attackType; this.pushMoves = pushMoves; }
public Outcome(SelectionManager selectionManager, ScenarioLoader scenarioLoader, SZOutcome toCopy) { activeUnit = selectionManager.GetUnitByID(toCopy.activeUnit); position = scenarioLoader.GetHexByID(toCopy.position); spendingMoves = toCopy.spendingMoves; combat = new List <AttackResult>(); foreach (SZAttackResult attackResult in toCopy.combat) { combat.Add(new AttackResult(selectionManager, scenarioLoader, attackResult)); } }
// True if unit has enough Zone of Control moves to follow this path--false otherwise. private static bool RespectsZoneOfControl(List <HexEntry> path, IUnitController controller) { for (var i = 0; i < path.Count - 1; i++) { // Not correct for ZoCRemaining values not equal to 0 or 1 if (IsEnemyNeighbor(path[i], controller.PlayerOwner) && path.Count > i + 1 + controller.ZoCRemaining) { return(false); } } return(true); }
public Outcome(IUnitController activeUnit, HexEntry position, bool spendingMoves, List <AttackResult> combat = null) { this.activeUnit = activeUnit; this.position = position; this.spendingMoves = spendingMoves; if (combat == null) { this.combat = new List <AttackResult>(); } else { this.combat = combat; } }
private void AddUnit(IUnitController unitController) { switch (unitController.UnitSide) { case UnitSide.SideA: GuildAList.Add(unitController); break; case UnitSide.SideB: GuildBList.Add(unitController); break; } _unitHitHandler.AddToMap(unitController); }
public void AddExp(int e, IUnitController controller) { exp += e; if (exp < exp_need) { return; } ++level; exp -= exp_need; exp_need += 100; controller.Notify($"{Name} gained {level} level."); Game.instance.LevelUp(this); ApplyRaceBonus(controller); if (controlled) { gained_level = true; } else { switch (clas.GetAttribute()) { case Stats.Attribute.Strength: ++str; if (controller.CombatDetails) { controller.Notify($"{Name} increased strength."); } break; case Stats.Attribute.Dexterity: ++dex; if (controller.CombatDetails) { controller.Notify($"{Name} increased dexterity."); } break; case Stats.Attribute.Endurance: ++end; if (controller.CombatDetails) { controller.Notify($"{Name} increased endurance."); } break; } RecalculateHp(); } }
// Update the actual game state after a commitment to a certain move public void ExecuteMoves(List <Outcome> outcomes, IUnitController unitSpendingMoves = null) { foreach (Outcome outcome in outcomes) { if (outcome.activeUnit == unitSpendingMoves) { //Deduct zone of control and movement costs before moving onto a hex outcome.activeUnit.MovesRemaining -= UnitBaseStats.TerrainCost(outcome.activeUnit.UnitType, outcome.position.Terrain); if (DefaultPathGenerator.IsEnemyNeighbor(outcome.activeUnit.Position, outcome.activeUnit.PlayerOwner)) { outcome.activeUnit.ZoCRemaining -= 1; if (outcome.activeUnit.ZoCRemaining < 0) { throw new System.Exception("This should not have happened"); } else if (outcome.activeUnit.ZoCRemaining == 0) { outcome.activeUnit.MovesRemaining = 0; } } } // Move to the next hex, tell it we're occupying it, and add hex to our recent path outcome.activeUnit.Position = outcome.position; foreach (AttackResult attackResult in outcome.combat) { //Debug.Log("Execute attack on enemy at " + outcome.activeUnit.CurrentHex); attackResult.source.ExecuteAttack(); attackResult.target.HP = attackResult.healthRemaining; if (attackResult.healthRemaining <= 0) { attackResult.target.Position = null; selectionManager.UnitsByPlayer[attackResult.target.PlayerOwner].Remove(attackResult.target); } if (attackResult.pushMoves != null) { ExecuteMoves(attackResult.pushMoves); // When executing forced movement, don't deduct ZoC or move points } } if (outcome.activeUnit.Position != null && outcome.activeUnit.Position.Terrain == Terrain.Pit) { outcome.activeUnit.Position = null; selectionManager.UnitsByPlayer[outcome.activeUnit.PlayerOwner].Remove(outcome.activeUnit); } } }
// gets called by other units public override int CheckRetal(List <HexEntry> enemyRecentPath, IUnitController enemy) { List <IUnitController> affectedCombats = CheckHit(enemyRecentPath) .Where(x => x == unitController) .ToList(); if (affectedCombats.Count > 0 && enemy != unitController && enemy.SimHealth() > 0 && enemy.SimPosition.Terrain != Terrain.Pit) // && enemy.PlayerOwner != unitController.PlayerOwner) { -- Flail hits allies { return(unitController.DamageOutput); } else { return(0); } }
public override void OnPlayerUpdated() { _uiManager = canvas._player.uiManager; unitController = canvas._player.UnitController; //Debug.Log("Player Updated"); //update images of skills, and the state a skill is in lightAttack.SetImage(GetSpriteFromBoundAction(BindableActions.LightAttack)); heavyAttack.SetImage(GetSpriteFromBoundAction(BindableActions.HeavyAttack)); //select.SetImage(canvas._player.XXXX.Select.actionIcon); //maneuver.SetImage(canvas._player.XXXX.Select.actionIcon); skillOne.SetImage(GetSpriteFromBoundAction(BindableActions.SkillOne)); skillTwo.SetImage(GetSpriteFromBoundAction(BindableActions.SkillTwo)); skillThree.SetImage(GetSpriteFromBoundAction(BindableActions.SkillThree)); skillFour.SetImage(GetSpriteFromBoundAction(BindableActions.SkillFour)); }
private void MarkEdge(IUnitController unit, HexEntry hex, Bearing b) { Vector2 cornerSpot = new Vector2(); Vector2 rotationVec = new Vector2(); switch (b) { case Bearing.E: cornerSpot = FindCorner(hex, -30); rotationVec = Vector2.down; break; case Bearing.NNE: cornerSpot = FindCorner(hex, -90); rotationVec = new Vector2(1.732f, -1); break; case Bearing.NNW: cornerSpot = FindCorner(hex, -150); rotationVec = new Vector2(1.732f, 1); break; case Bearing.W: cornerSpot = FindCorner(hex, -210); rotationVec = Vector2.up; break; case Bearing.SSW: cornerSpot = FindCorner(hex, -270); rotationVec = new Vector2(-1.732f, 1); break; case Bearing.SSE: cornerSpot = FindCorner(hex, -330); rotationVec = new Vector2(-1.732f, -1); break; } GameObject segment = Instantiate(rangeIndicator, new Vector3(cornerSpot.x, cornerSpot.y, 3), Quaternion.FromToRotation(Vector2.right, rotationVec)); segment.transform.SetParent(rangeIndicatorContainer.transform); segment.GetComponent <SpriteRenderer>().color = Config.Palette.PlayerColor(unit.PlayerOwner); rangeIndicatorSegments[unit].Add(segment); }
void OnCollisionEnter(Collision col) { if (col.transform.tag == "terrain") { Debug.Log("hit ground"); Destroy(gameObject); } else { IUnitController controller = col.gameObject.GetComponent <IUnitController>(); Debug.Log("hit other, controller: " + controller); if (controller != null) { controller.getVehicle().DoDamage(source.damageMax, source.type); } Destroy(gameObject, 0.5f); } }
public override int CheckRetal(List <HexEntry> recentPath, IUnitController enemy) { if (recentPath.Count < 2 || enemy.PlayerOwner == unitController.PlayerOwner) { return(0); } HexEntry current = recentPath[recentPath.Count - 1]; HexEntry last = recentPath[recentPath.Count - 2]; if (HexVectorUtil.AxialDistance(current.BoardPos, unitController.SimPosition.BoardPos) == 3) { if (HexVectorUtil.AxialDistance(last.BoardPos, unitController.SimPosition.BoardPos) > 3) { return(unitController.DamageOutput); } } return(0); }