public void RemoveUnit(UnitController unit) { List <UnitController> playerUnits; if (!unitsByPlayer.TryGetValue(unit.PlayerId, out playerUnits)) { return; } playerUnits.Remove(unit); UnitsPool.Instance.ReleaseUnit(unit); unit.Death -= RemoveUnit; unit.MovementStateChanged -= OnUnitMovementStateChanged; if (playerUnits.Count == 0) { NoMoreUnitsAtMap?.Invoke(unit.PlayerId); } }
public IEnumerator MoveUnit(UnitController unit, List <Vector3Int> path, bool costsMovement) { //TODO: hack, dead units don't play well with coroutine if (unit.HP <= 0) { yield break; } blockInputs = true; yield return(unit.Move(this, path, MovementAnimationSpeed)); if (costsMovement) { unit.CurrentMovement -= path.Count() - 1; } var destination = path.Last(); ApplyTileEffects(unit, destination); blockInputs = false; }
void Start() { // gain ownership over all child units foreach (Transform child in transform) { UnitController unit = child.GetComponent <UnitController>(); unit.Owner = index; unit.fillBackgroundColor.GetComponent <Image>().color = color; unit.fillFillColor.GetComponent <Image>().color = color; units.Add(unit); } currentUnitIndex = 0; units[0].IsActive = true; GetComponent <AudioSource>().playOnAwake = false; messageBox = FindObjectOfType <MessageBox>(); }
public void ColorAttackableCards() { Owner owner = Owner.ENEMY; int rowNum = this.battlefield.height - 1; if (this.turnState.Id() == "PlayerTurnState") { owner = Owner.PLAYER; rowNum = 0; } foreach (Transform card in this.battlefield.cards) { CardController cardController = card.GetComponent <CardController>(); UnitController unitController = card.GetComponent <UnitController>(); if (cardController.ownedBy == owner && unitController.canAttack && !unitController.isExhausted) { if (unitController.SquaresInAttackDistance().Count > 0 || unitController.square.GetComponent <SquareController>().battlefieldLocation[1] == rowNum) // Can attack the other player { cardController.ColorGreen(); } } } }
public void SetNewCard(CardController card) { this._cardController = card; this._unitController = card.GetComponent <UnitController>(); }
private void OnTurnPrepared(UnitController unitController) { _allScenarios.Clear(); }
public void ResolveCollision(UnitController defender, Collision2D collision) { if (defender == Game.Instance.CurrentUnit || !defender.IsActive || defender.Character == null) { return; } var attacker = collision.transform.GetComponent <UnitController>(); if (attacker == null || !attacker.IsActive) { return; } if (defender.PlayerId != attacker.PlayerId) { if (defender.PlayerId == Game.Instance.CurrentUnit.PlayerId) { return; } FMODUnity.RuntimeManager.PlayOneShot("event:/Punch"); attacker.HitsCount.AddValue(1); defender.CollisionReaction?.Stop(); defender.CollisionReaction = new SyncScenario(new List <ISyncScenarioItem> { new ActionScenarioItem(() => { if (DamageSystem.ApplyPassiveDamage(attacker, defender)) { defender.IsActive = false; } }), new ActionScenarioItem(() => { if (!defender.IsActive || defender.Character == null) { FMODUnity.RuntimeManager.PlayOneShot("event:/Death"); defender.Die(); } }), new ScaleTween(gameObject, Vector3.one, 1f, EaseType.Linear) { TimeManager = GameSettings.AnimaitonTimeManager }, }, (scenario, force) => { transform.localScale = Vector3.one; }) { TimeManager = GameSettings.AnimaitonTimeManager }; defender.CollisionReaction.Play(); } else { defender.CastPassiveAbility( new CastContext { Caster = defender, Target = attacker }); } }
private void Awake() { player = _player; enemy = _enemy; }
public void TeleportUnit(UnitController unit, Vector3Int destination) { unit.moveTo(this, destination); ApplyTileEffects(unit, destination); UpdateAllRangedIndicators(); }
private List <List <Vector3Int> > FindAllValidSteps(UnitController unit) { return(FindAllValidMoves(Vector3Int.FloorToInt(unit.transform.position), unit.CurrentMovement, true, (UnitController u) => u.Side != unit.Side)); }
public void DeselectUnit() { UnitClicked = null; UI.HideUnitInfo(); }
private void OnUnitDie(UnitController unit) { AllUnits.Remove(unit); CheckVictoryConditions(); }
internal void ActivateAbility(UnitController unit, Ability ability, Vector3Int target) { blockInputs = true; StartCoroutine(AbilityCoroutine(unit, ability, target)); blockInputs = false; }
public virtual bool ShouldEnd(UnitController currentUnit) { return(currentUnit == _auraHolder); }
public void SetNewUnit(UnitController unit) { this._unitController = unit; this._cardController = unit.GetComponent <CardController>(); }
public void RemoveCard() { this._unitController = null; this._cardController = null; }
private void Kill(UnitController unit) { unit.Die(); }