public PathCell(Cell cell, CellPartEnum prevDirection, CellPartEnum nextDirection) { _cell = cell; _prevDirection = prevDirection; _nextDirection = nextDirection; _isAvoidObstracle = false; }
public AnimationSequence AddDefend(CellPartEnum attackDirection) { Heroes.Core.Battle.Characters.Armies.Army currentArmy = (Heroes.Core.Battle.Characters.Armies.Army)this._character; // get opposite direction Animation animation = null; HorizontalDirectionEnum facing = HorizontalDirectionEnum.None; switch (attackDirection) { case CellPartEnum.CenterRight: case CellPartEnum.LowerRight: case CellPartEnum.UpperRight: animation = currentArmy._animations._defendLeft; facing = HorizontalDirectionEnum.Left; break; case CellPartEnum.CenterLeft: case CellPartEnum.LowerLeft: case CellPartEnum.UpperLeft: animation = currentArmy._animations._defendRight; facing = HorizontalDirectionEnum.Right; break; } AnimationSequence animationSeq = new AnimationSequence(animation, AnimationPurposeEnum.Defend, facing); animationSeq._waitToTrigger = true; animationSeq._destPoint = currentArmy._cell.GetStandingPoint(); this._animationSeqs.Add(animationSeq); return animationSeq; }
public static Action CreateAttackAction(StandardCharacter character, CellPartEnum attackDirection, ArrayList path, ArrayList targets) { Action action = new Action(ActionTypeEnum.Attack); SubAction subAction = new SubAction(); action._subActions.Add(subAction); subAction._character = character; subAction._path = path; if (path != null && path.Count > 0) { subAction.AddStartMoving(); subAction.AddMoving(); subAction.AddStopMoving(); } // target getting hit or death ArrayList defendTriggers = new ArrayList(); ArrayList hitTriggers = new ArrayList(); foreach (Heroes.Core.Battle.Characters.Armies.Army target in targets) { SubAction subAction2 = new SubAction(); action._subActions.Add(subAction2); subAction2._character = target; AnimationSequence animationSeq = null; if (target._isDead) animationSeq = subAction2.AddDeath(attackDirection); else if (target._isDefend) animationSeq = subAction2.AddDefend(attackDirection); else animationSeq = subAction2.AddGettingHit(attackDirection); subAction2._currentAnimationSeq = animationSeq; if (target._isDefend) defendTriggers.Add(animationSeq); else hitTriggers.Add(animationSeq); } subAction.AddStartAttack(attackDirection, defendTriggers); subAction.AddStopAttack(attackDirection, hitTriggers); subAction._currentAnimationSeq = (AnimationSequence)subAction._animationSeqs[0]; return action; }
public static Action CreateShootAction(StandardCharacter character, CellPartEnum attackDirection, ArrayList targets, Cell targetCell) { Action action = new Action(ActionTypeEnum.RangeAttack); SubAction subAction = new SubAction(); action._subActions.Add(subAction); subAction._character = character; // add getting hit or death ArrayList defendTriggers = new ArrayList(); ArrayList hitTriggers = new ArrayList(); foreach (Heroes.Core.Battle.Characters.Armies.Army target in targets) { SubAction subAction2 = new SubAction(); action._subActions.Add(subAction2); subAction2._character = target; AnimationSequence animationSeq = null; if (target._isDead) animationSeq = subAction2.AddDeath(attackDirection); else if (target._isDefend) animationSeq = subAction2.AddDefend(attackDirection); else animationSeq = subAction2.AddGettingHit(attackDirection); subAction2._currentAnimationSeq = animationSeq; if (target._isDefend) defendTriggers.Add(animationSeq); else hitTriggers.Add(animationSeq); } subAction.AddStartShoot(attackDirection, defendTriggers); subAction.AddStopShoot(attackDirection, hitTriggers); subAction._currentAnimationSeq = (AnimationSequence)subAction._animationSeqs[0]; return action; }
private void CreateAttackActions(CellPartEnum attackDirection, StandardCharacter attacker, StandardCharacter defender, ArrayList path, bool hasRetaliate) { // attack { ArrayList targets = new ArrayList(); targets.Add(defender); Action action = Action.CreateAttackAction(attacker, attackDirection, path, targets); _actions.Add(action); } // retaliate if (hasRetaliate) { CellPartEnum oppAttackDirection = BattleTerrain.GetOppositeDirection(attackDirection); ArrayList targets = new ArrayList(); targets.Add(attacker); Action action = Action.CreateAttackAction(defender, oppAttackDirection, null, targets); _actions.Add(action); } // attack more than once { ArrayList targets = new ArrayList(); targets.Add(defender); for (int i = 1; i < attacker._noOfAttack; i++) { Action action = Action.CreateAttackAction(attacker, attackDirection, null, targets); _actions.Add(action); } } }
private void SetRangeAttackNAnimate(StandardCharacter attacker, StandardCharacter defender, CellPartEnum attackDirection, Cell targetCell) { // reset defend and wait Heroes.Core.Battle.Characters.Armies.Army army = (Heroes.Core.Battle.Characters.Armies.Army)attacker; army._isWait = false; army._isDefend = false; // attack SetAttackDamage(attacker, defender, true); attacker._shotRemain -= 1; // attack Action { ArrayList targets = new ArrayList(); targets.Add(defender); Action action = Action.CreateShootAction(attacker, attackDirection, targets, targetCell); _actions.Add(action); } if (!defender._isDead) { // retaliate //if (defender._canRangeRetaliate && defender._retaliateRemain > 0 && defender._shotRemain > 0) //{ // SetAttackDamage(defender, attacker, true); // defender._retaliateRemain -= 1; // // retaliate action // { // CellPartEnum oppAttackDirection = BattleTerrain.GetOppositeDirection(attackDirection); // ArrayList targets = new ArrayList(); // targets.Add(attacker); // Action action = Action.CreateShootAction(defender, oppAttackDirection, targets, attacker._cell); // _actions.Add(action); // } //} // attack more { ArrayList targets = new ArrayList(); targets.Add(defender); for (int i = 1; i < attacker._noOfAttack; i++) { SetAttackDamage(attacker, defender, true); attacker._shotRemain -= 1; // attack more action { Action action = Action.CreateShootAction(attacker, attackDirection, targets, targetCell); _actions.Add(action); } } } } }
private void SetAttackNAnimate(StandardCharacter attacker, StandardCharacter defender, CellPartEnum attackDirection, ArrayList path) { // reset defend and wait Heroes.Core.Battle.Characters.Armies.Army army = (Heroes.Core.Battle.Characters.Armies.Army)attacker; army._isWait = false; army._isDefend = false; // attack SetAttackDamage(attacker, defender, false); // attack Action { ArrayList targets = new ArrayList(); targets.Add(defender); Action action = Action.CreateAttackAction(attacker, attackDirection, path, targets); _actions.Add(action); } if (!defender._isDead) { // retaliate if (defender._retaliateRemain > 0) { SetAttackDamage(defender, attacker, false); defender._retaliateRemain -= 1; // retaliate action { CellPartEnum oppAttackDirection = BattleTerrain.GetOppositeDirection(attackDirection); ArrayList targets = new ArrayList(); targets.Add(attacker); Action action = Action.CreateAttackAction(defender, oppAttackDirection, null, targets); _actions.Add(action); } } // attack more { ArrayList targets = new ArrayList(); targets.Add(defender); for (int i = 1; i < attacker._noOfAttack; i++) { SetAttackDamage(attacker, defender, false); // attack more action { Action action = Action.CreateAttackAction(attacker, attackDirection, null, targets); _actions.Add(action); } } } } }
public static CellPartEnum GetOppositeDirection(CellPartEnum direction) { switch (direction) { case CellPartEnum.CenterLeft: return CellPartEnum.CenterRight; case CellPartEnum.CenterRight: return CellPartEnum.CenterLeft; case CellPartEnum.LowerRight: return CellPartEnum.UpperLeft; case CellPartEnum.LowerLeft: return CellPartEnum.UpperRight; case CellPartEnum.UpperRight: return CellPartEnum.LowerLeft; case CellPartEnum.UpperLeft: return CellPartEnum.LowerRight; default: return CellPartEnum.Center; } }
public void AddStopShoot(CellPartEnum attackDirection, ArrayList triggerSeqs) { Heroes.Core.Battle.Characters.Armies.Army currentArmy = (Heroes.Core.Battle.Characters.Armies.Army)this._character; Animation animation = null; HorizontalDirectionEnum facing = HorizontalDirectionEnum.None; switch (attackDirection) { case CellPartEnum.CenterRight: case CellPartEnum.LowerRight: case CellPartEnum.UpperRight: animation = currentArmy._animations._shootStraightRightEnd; facing = HorizontalDirectionEnum.Right; break; case CellPartEnum.CenterLeft: case CellPartEnum.LowerLeft: case CellPartEnum.UpperLeft: animation = currentArmy._animations._shootStraightLeftEnd; facing = HorizontalDirectionEnum.Left; break; } AnimationSequence animationSeq = new AnimationSequence(animation, AnimationPurposeEnum.AttackEnd, facing); animationSeq._waitToTrigger = false; animationSeq._destPoint = currentArmy._cell.GetStandingPoint(); animationSeq._triggerWhenBegin = true; animationSeq._triggerAnimationSeqs = triggerSeqs; this._animationSeqs.Add(animationSeq); }
public AnimationSequence AddSpellHit(PointF destPoint, CellPartEnum attackDirection) { Heroes.Core.Battle.Characters.Spells.Spell currentSpell = (Heroes.Core.Battle.Characters.Spells.Spell)this._character; Animation animation = null; animation = currentSpell._animations._hitRight; HorizontalDirectionEnum facing = HorizontalDirectionEnum.Right; switch (attackDirection) { case CellPartEnum.CenterRight: case CellPartEnum.LowerRight: case CellPartEnum.UpperRight: animation = currentSpell._animations._hitRight; facing = HorizontalDirectionEnum.Right; break; case CellPartEnum.CenterLeft: case CellPartEnum.LowerLeft: case CellPartEnum.UpperLeft: animation = currentSpell._animations._hitLeft; facing = HorizontalDirectionEnum.Left; break; } AnimationSequence animationSeq = new AnimationSequence(animation, AnimationPurposeEnum.Moving, facing); animationSeq._waitToTrigger = true; animationSeq._destPoint = destPoint; this._animationSeqs.Add(animationSeq); return animationSeq; }
private bool FindPath_Sub(Cell cell, Cell cellDest, ArrayList path, CellPartEnum direction, ArrayList deadPath, bool ignoreDestCharacter, bool ignoreObstacle, bool useStraightAngle) { Debug.WriteLine(string.Format("Find cell at {0}", direction)); Cell cellNext = null; if (direction == CellPartEnum.Center) cellNext = null; else cellNext = cell._adjacentCells[direction]; if (cellNext == null) { // no more cell found Debug.WriteLine(string.Format("No cell")); // get new direction CellPartEnum direction2 = FindDirection(cell.GetCenterPoint(), cellDest.GetCenterPoint()); if (direction == direction2) { switch (direction2) { case CellPartEnum.LowerRight: direction2 = CellPartEnum.LowerLeft; break; case CellPartEnum.LowerLeft: direction2 = CellPartEnum.LowerRight; break; case CellPartEnum.UpperLeft: direction2 = CellPartEnum.UpperRight; break; case CellPartEnum.UpperRight: direction2 = CellPartEnum.UpperLeft; break; } } direction = direction2; //Debug.WriteLine(string.Format("Find cell on {0}", direction)); return FindPath_Sub(cell, cellDest, path, direction, deadPath, ignoreDestCharacter, ignoreObstacle, useStraightAngle); } if (!cellNext.HasPassability() || deadPath.Contains(cellNext)) { // has character or dead cell //Debug.WriteLine(string.Format("Obstacle found")); if (ignoreDestCharacter) { if (cellNext.Equals(cellDest)) { path.Add(cellNext); // end return true; } } if (ignoreObstacle) { return FindPath_Good(cellNext, cellDest, direction, path, deadPath, ignoreDestCharacter, ignoreObstacle, useStraightAngle); } else { // change direction Cell cellNextTest = GetPathNextCell(cell, cellDest, direction, deadPath); if (cellNextTest != null) { // if go backward, remove unwanted (dead) cell if (path.Contains(cellNextTest)) { int index = path.IndexOf(cellNextTest); while (path.Count - 1 > index) { Cell deadCell = (Cell)path[path.Count - 1]; deadPath.Add(deadCell); path.RemoveAt(path.Count - 1); } } //Debug.WriteLine(string.Format("ChangeDir, {0},{1},{2}", direction, cellNextTest._row, cellNextTest._col)); cellNext = cellNextTest; path.Add(cellNext); // continue to find next cell cell = cellNext; } else { // cannot move // end Debug.WriteLine(string.Format("No more move")); return false; } return FindPath_Sub(cell, cellDest, path, direction, deadPath, ignoreDestCharacter, ignoreObstacle, useStraightAngle); } } return FindPath_Good(cellNext, cellDest, direction, path, deadPath, ignoreDestCharacter, ignoreObstacle, useStraightAngle); }
private bool FindPath_Good(Cell cellNext, Cell cellDest, CellPartEnum direction, ArrayList path, ArrayList deadPath, bool ignoreDestCharacter, bool ignoreObstacle, bool useStraightAngle) { //Debug.WriteLine(string.Format("Accept cell {0},{1}", cellNext._row, cellNext._col)); path.Add(cellNext); if (cellNext.Equals(cellDest)) { // end //Debug.WriteLine("Reach Destination"); return true; } if (useStraightAngle) direction = CellPartEnum.Center; else { // change direction if has whole/direct angle double degree = FindDegree(cellNext.GetCenterPoint(), cellDest.GetCenterPoint()); if (Math.Abs(degree) <= 0.05) direction = CellPartEnum.CenterRight; else if (Math.Abs(degree - DIGONAL_ANGLE) <= 0.05) direction = CellPartEnum.LowerRight; else if (Math.Abs(degree - (180 - DIGONAL_ANGLE)) <= 0.05) direction = CellPartEnum.LowerLeft; else if (Math.Abs(degree - 180) <= 0.05) direction = CellPartEnum.CenterLeft; else if (Math.Abs(degree - (180 + DIGONAL_ANGLE)) <= 0.05) direction = CellPartEnum.UpperLeft; else if (Math.Abs(degree - (360 - DIGONAL_ANGLE)) <= 0.05) direction = CellPartEnum.UpperRight; } return FindPath_Sub(cellNext, cellDest, path, direction, deadPath, ignoreDestCharacter, ignoreObstacle, useStraightAngle); }
private bool FindPathAdj(Cell cellSrc, Cell cellDest, CellPartEnum startingDirection, bool ignoreDestCharacter, bool ignoreObstacle, bool useStraightAngle, out List<ArrayList> shortestPathAvoids, out bool hasObstacle) { shortestPathAvoids = new List<ArrayList>(); hasObstacle = false; // source is destination if (cellSrc.Equals(cellDest)) return true; // destination cannot has character or obstacle if (!cellDest.HasPassability()) { if (!ignoreDestCharacter && !ignoreObstacle) return false; } // find direct path (shortest path) ArrayList directPath = new ArrayList(); if (!FindPath(cellSrc, cellDest, directPath, startingDirection, true, true, true, useStraightAngle)) return false; // find all adjacent cells for obstacle ArrayList adjCells = new ArrayList(); ArrayList obsCells = new ArrayList(); GetAdjCells(directPath, cellDest, ignoreDestCharacter, adjCells, obsCells); // if no obstacles if (obsCells.Count < 1) { hasObstacle = false; shortestPathAvoids.Add(directPath); return true; } else { hasObstacle = true; } // find new path List<ArrayList> pathAvoids = null; FindPathAvoid(directPath, adjCells, obsCells, cellDest, out pathAvoids); if (pathAvoids.Count < 1) return false; // get shortest avoid path (might be many) FindShortestPathAvoid(pathAvoids, out shortestPathAvoids); if (shortestPathAvoids.Count < 1) return false; return true; }
private bool FindPathAdj(Cell cellSrc, Cell cellDest, CellPartEnum staringDirection, bool ignoreDestCharacter, bool ignoreObstacle, bool useStraightAngle, out ArrayList path) { path = null; bool hasObstacle = false; List<ArrayList> shortestPathAvoids = null; if (!FindPathAdj(cellSrc, cellDest, staringDirection, ignoreDestCharacter, ignoreObstacle, useStraightAngle, out shortestPathAvoids, out hasObstacle)) return false; if (!hasObstacle) { if (shortestPathAvoids.Count > 0) { path = shortestPathAvoids[0]; // remove srcCell if (path.Count > 0) path.RemoveAt(0); } return true; } // find shortest path from srcCell to pathAvoid foreach (ArrayList shortestPathAvoid in shortestPathAvoids) { if (shortestPathAvoid.Count < 1) continue; int index = 0; while (index < shortestPathAvoid.Count) { Cell cell = (Cell)shortestPathAvoid[index]; List<ArrayList> shortestPathAvoids2 = new List<ArrayList>(); bool hasObstacle2 = false; if (!FindPathAdj(cellSrc, cell, staringDirection, false, false, true, out shortestPathAvoids2, out hasObstacle2)) { break; } else { foreach (ArrayList shortestPathAvoid2 in shortestPathAvoids2) { if (shortestPathAvoid2.Count - 1 < index) { // shorter found Debug.WriteLine("Shorter found."); // remove previous while (!shortestPathAvoid[0].Equals(cell)) { shortestPathAvoid.RemoveAt(0); } // add cell foreach (Cell cell2 in shortestPathAvoid2) { shortestPathAvoid.Insert(0, cell2); } } } } index += 1; } } List<ArrayList> shortestPathAvoids3 = null; FindShortestPathAvoid(shortestPathAvoids, out shortestPathAvoids3); path = shortestPathAvoids3[0]; // remove srcCell if (path.Count > 0) path.RemoveAt(0); return true; }
public Cell GetNextCell(Cell cell, CellPartEnum direction) { if (cell == null) return null; switch (direction) { case CellPartEnum.UpperLeft: { return GetCell(cell._row - 1, cell._rect.Left); } case CellPartEnum.UpperRight: { return GetCell(cell._row - 1, cell._rect.Right); } case CellPartEnum.CenterLeft: { if (cell._col - 1 < 0) return null; else { return _cells[cell._row, cell._col - 1]; } } case CellPartEnum.CenterRight: { if (cell._col + 1 >= _colCount) return null; else { return _cells[cell._row, cell._col + 1]; } } case CellPartEnum.LowerRight: { return GetCell(cell._row + 1, cell._rect.Right); } case CellPartEnum.LowerLeft: { return GetCell(cell._row + 1, cell._rect.Left); } default: return null; } }
public bool FindPath(Cell cellSrc, Cell cellDest, ArrayList path, CellPartEnum startingDirection, bool ignoreDestCharacter, bool ignoreObstacle, bool includeSrcCell, bool useStraightAngle) { if (includeSrcCell) path.Add(cellSrc); if (cellSrc.Equals(cellDest)) { // end return true; } //CellPartEnum direction = FindDirection(cellSrc.GetCenterPoint(), cellDest.GetCenterPoint()); CellPartEnum direction = startingDirection; Debug.WriteLine("--------------------------------------"); Debug.WriteLine(string.Format("Start to find at {0}", direction)); // detect unless cell ArrayList deadPath = new ArrayList(); return FindPath_Sub(cellSrc, cellDest, path, direction, deadPath, ignoreDestCharacter, ignoreObstacle, useStraightAngle); }
private void SetAttack(Heroes.Core.Hero attackHero, Heroes.Core.Battle.Armies.Army attacker, Heroes.Core.Hero defendHero, Heroes.Core.Battle.Armies.Army defender, CellPartEnum attackDirection, ArrayList path) { // reset defend and wait Heroes.Core.Battle.Armies.Army army = (Heroes.Core.Battle.Armies.Army)attacker; army._isWait = false; army._isDefend = false; // attack SetAttackDamage(this._battleTerrain, attackHero, attacker, defendHero, defender, false); if (!defender._isDead) { // retaliate if (defender._retaliateRemain > 0) { SetAttackDamage(this._battleTerrain, defendHero, defender, attackHero, attacker, false); defender._retaliateRemain -= 1; } // attack more { ArrayList targets = new ArrayList(); targets.Add(defender); for (int i = 1; i < attacker._noOfAttack; i++) { SetAttackDamage(this._battleTerrain, attackHero, attacker, defendHero, defender, false); } } } }
public static Action CreateCastSpellAction(Heroes.Core.Battle.Characters.Hero hero, Heroes.Core.Battle.Characters.Spells.Spell spell, CellPartEnum attackDirection, ArrayList targets, Cell targetCell) { Action action = new Action(ActionTypeEnum.Spell); SubAction subAction = new SubAction(); action._subActions.Add(subAction); subAction._character = hero; // hero casting animation AnimationSequence startCastSpellSeq = subAction.AddStartCasting(attackDirection); AnimationSequence stopCastSpellSeq = subAction.AddStopCasting(attackDirection); stopCastSpellSeq._waitToTrigger = true; // add casting AnimationSequence spellSeq = null; AnimationSequence spellHitSeq = null; AnimationSequence hitSeq = null; foreach (Heroes.Core.Battle.Characters.ICharacter target in targets) { // spell animate { SubAction subAction2 = new SubAction(); action._subActions.Add(subAction2); subAction2._character = spell; PointF destPoint = spell._destCell.GetStandingPoint(); if (spell._isMissile) { // move missile PointF srcPoint = hero._castingPointRight; spell._currentAnimationPt = srcPoint; destPoint.Y -= hero._castingHeight; Character.CalculateFlySpeed(srcPoint, destPoint, spell._defaultMoveSpeed, out spell._moveSpeedX, out spell._moveSpeedY); spellSeq = subAction2.AddMissileSpell(destPoint, attackDirection, AnimationPurposeEnum.Moving); subAction2._currentAnimationSeq = spellSeq; } else { spell._currentAnimationPt = destPoint; spellSeq = subAction2.AddOnArmySpell(destPoint, attackDirection, AnimationPurposeEnum.CastSpell); subAction2._currentAnimationSeq = spellSeq; } // hit if (spell._isHit) { spellHitSeq = subAction2.AddSpellHit(destPoint, attackDirection); subAction2._currentAnimationSeq = spellSeq; } } // target if (spell._isDamage) { Heroes.Core.Battle.Characters.Armies.Army army = (Heroes.Core.Battle.Characters.Armies.Army)target; SubAction subAction2 = new SubAction(); action._subActions.Add(subAction2); subAction2._character = target; if (army._isDead) hitSeq = subAction2.AddDeath(attackDirection); else if (army._isDefend) hitSeq = subAction2.AddDefend(attackDirection); else hitSeq = subAction2.AddGettingHit(attackDirection); hitSeq._waitToTrigger = true; subAction2._currentAnimationSeq = hitSeq; } } startCastSpellSeq._waitToTrigger = false; startCastSpellSeq._triggerWhenEnd = true; startCastSpellSeq._triggerAnimationSeqs.Add(spellSeq); spellSeq._waitToTrigger = true; spellSeq._triggerWhenEnd = true; if (spell._isHit) { spellHitSeq._waitToTrigger = true; spellSeq._triggerAnimationSeqs.Add(spellHitSeq); } if (spell._isDamage) { hitSeq._waitToTrigger = true; spellSeq._triggerAnimationSeqs.Add(hitSeq); } stopCastSpellSeq._waitToTrigger = true; spellSeq._triggerAnimationSeqs.Add(stopCastSpellSeq); subAction._currentAnimationSeq = (AnimationSequence)subAction._animationSeqs[0]; return action; }
private ArrayList GetPathFavourDirections(double degree, CellPartEnum direction) { ArrayList directions = new ArrayList(); switch (direction) { case CellPartEnum.CenterRight: if (degree <= 180) { directions.Add(CellPartEnum.LowerRight); directions.Add(CellPartEnum.LowerLeft); directions.Add(CellPartEnum.UpperRight); directions.Add(CellPartEnum.UpperLeft); directions.Add(CellPartEnum.CenterLeft); } else { directions.Add(CellPartEnum.UpperRight); directions.Add(CellPartEnum.UpperLeft); directions.Add(CellPartEnum.LowerRight); directions.Add(CellPartEnum.LowerLeft); directions.Add(CellPartEnum.CenterLeft); } break; case CellPartEnum.CenterLeft: if (degree <= 180) { directions.Add(CellPartEnum.LowerLeft); directions.Add(CellPartEnum.LowerRight); directions.Add(CellPartEnum.UpperLeft); directions.Add(CellPartEnum.UpperRight); directions.Add(CellPartEnum.CenterRight); } else { directions.Add(CellPartEnum.UpperLeft); directions.Add(CellPartEnum.UpperRight); directions.Add(CellPartEnum.LowerLeft); directions.Add(CellPartEnum.LowerRight); directions.Add(CellPartEnum.CenterRight); } break; case CellPartEnum.UpperLeft: if (degree <= 180 + DIGONAL_ANGLE) { // preferred directions.Add(CellPartEnum.CenterLeft); directions.Add(CellPartEnum.LowerLeft); // alternative directions.Add(CellPartEnum.UpperRight); directions.Add(CellPartEnum.CenterRight); // reverse directions.Add(CellPartEnum.LowerRight); } else { directions.Add(CellPartEnum.UpperRight); directions.Add(CellPartEnum.CenterRight); directions.Add(CellPartEnum.CenterLeft); directions.Add(CellPartEnum.LowerLeft); directions.Add(CellPartEnum.LowerRight); } break; case CellPartEnum.UpperRight: if (degree <= 360 - DIGONAL_ANGLE) { // preferred directions.Add(CellPartEnum.UpperLeft); directions.Add(CellPartEnum.CenterLeft); // alternative directions.Add(CellPartEnum.CenterRight); directions.Add(CellPartEnum.LowerRight); // reverse directions.Add(CellPartEnum.LowerLeft); } else { directions.Add(CellPartEnum.CenterRight); directions.Add(CellPartEnum.LowerRight); directions.Add(CellPartEnum.UpperLeft); directions.Add(CellPartEnum.CenterLeft); directions.Add(CellPartEnum.LowerLeft); } break; case CellPartEnum.LowerLeft: if (degree <= 180 - DIGONAL_ANGLE) { // preferred directions.Add(CellPartEnum.LowerRight); directions.Add(CellPartEnum.CenterRight); // alternative directions.Add(CellPartEnum.CenterLeft); directions.Add(CellPartEnum.UpperLeft); // reverse directions.Add(CellPartEnum.UpperRight); } else { // preferred directions.Add(CellPartEnum.CenterLeft); directions.Add(CellPartEnum.UpperLeft); // alternative directions.Add(CellPartEnum.LowerRight); directions.Add(CellPartEnum.CenterRight); // reverse directions.Add(CellPartEnum.UpperRight); } break; case CellPartEnum.LowerRight: if (degree <= DIGONAL_ANGLE) { // preferred directions.Add(CellPartEnum.CenterRight); directions.Add(CellPartEnum.UpperRight); // alternative directions.Add(CellPartEnum.LowerLeft); directions.Add(CellPartEnum.CenterLeft); // reverse directions.Add(CellPartEnum.UpperLeft); } else { // preferred directions.Add(CellPartEnum.LowerLeft); directions.Add(CellPartEnum.CenterLeft); // alternative directions.Add(CellPartEnum.CenterRight); directions.Add(CellPartEnum.UpperRight); // reverse directions.Add(CellPartEnum.UpperLeft); } break; } return directions; }
public AnimationSequence AddStopCasting(CellPartEnum attackDirection) { Heroes.Core.Battle.Characters.Hero currentHero = (Heroes.Core.Battle.Characters.Hero)this._character; Animation animation = null; HorizontalDirectionEnum facing = HorizontalDirectionEnum.Right; switch (attackDirection) { case CellPartEnum.CenterRight: case CellPartEnum.LowerRight: case CellPartEnum.UpperRight: if (currentHero._sex == SexEnum.Female) animation = currentHero._animations._stopCastSpellRightFemale; else animation = currentHero._animations._stopCastSpellRightMale; facing = HorizontalDirectionEnum.Right; break; case CellPartEnum.CenterLeft: case CellPartEnum.LowerLeft: case CellPartEnum.UpperLeft: if (currentHero._sex == SexEnum.Female) animation = currentHero._animations._stopCastSpellLeftFemale; else animation = currentHero._animations._stopCastSpellLeftMale; facing = HorizontalDirectionEnum.Left; break; } AnimationSequence animationSeq = new AnimationSequence(animation, AnimationPurposeEnum.CastSpell, facing); animationSeq._waitToTrigger = true; this._animationSeqs.Add(animationSeq); return animationSeq; }
public Action CreateAttackAction(ArrayList path, CellPartEnum attackDirection, StandardCharacter target) { Action action = new Action(ActionTypeEnum.Attack); action._targetCharacter = target; SetMovingAction(action, path); // attack switch (attackDirection) { case CellPartEnum.CenterRight: { // attack begin AnimationSequence seq = new AnimationSequence(_animations._attackStraightRightBegin, AnimationPurposeEnum.AttackBegin, HorizontalDirectionEnum.Right); action._animationSeqs.Add(seq); // attack end seq = new AnimationSequence(_animations._attackStraightRightEnd, AnimationPurposeEnum.AttackEnd, HorizontalDirectionEnum.Right); action._animationSeqs.Add(seq); } break; case CellPartEnum.CenterLeft: { // attack begin AnimationSequence seq = new AnimationSequence(_animations._attackStraightLeftBegin, AnimationPurposeEnum.AttackBegin, HorizontalDirectionEnum.Left); action._animationSeqs.Add(seq); // attack end seq = new AnimationSequence(_animations._attackStraightLeftEnd, AnimationPurposeEnum.AttackEnd, HorizontalDirectionEnum.Left); action._animationSeqs.Add(seq); } break; case CellPartEnum.LowerRight: { // attack begin AnimationSequence seq = new AnimationSequence(_animations._attackStraightRightBegin, AnimationPurposeEnum.AttackBegin, HorizontalDirectionEnum.Right); action._animationSeqs.Add(seq); // attack end seq = new AnimationSequence(_animations._attackStraightRightEnd, AnimationPurposeEnum.AttackEnd, HorizontalDirectionEnum.Right); action._animationSeqs.Add(seq); } break; case CellPartEnum.LowerLeft: { // attack begin AnimationSequence seq = new AnimationSequence(_animations._attackStraightLeftBegin, AnimationPurposeEnum.AttackBegin, HorizontalDirectionEnum.Left); action._animationSeqs.Add(seq); // attack end seq = new AnimationSequence(_animations._attackStraightLeftEnd, AnimationPurposeEnum.AttackEnd, HorizontalDirectionEnum.Left); action._animationSeqs.Add(seq); } break; case CellPartEnum.UpperRight: { // attack begin AnimationSequence seq = new AnimationSequence(_animations._attackStraightRightBegin, AnimationPurposeEnum.AttackBegin, HorizontalDirectionEnum.Right); action._animationSeqs.Add(seq); // attack end seq = new AnimationSequence(_animations._attackStraightRightEnd, AnimationPurposeEnum.AttackEnd, HorizontalDirectionEnum.Right); action._animationSeqs.Add(seq); } break; case CellPartEnum.UpperLeft: { // attack begin AnimationSequence seq = new AnimationSequence(_animations._attackStraightLeftBegin, AnimationPurposeEnum.AttackBegin, HorizontalDirectionEnum.Left); action._animationSeqs.Add(seq); // attack end seq = new AnimationSequence(_animations._attackStraightLeftEnd, AnimationPurposeEnum.AttackEnd, HorizontalDirectionEnum.Left); action._animationSeqs.Add(seq); } break; } action._currentAnimationSeq = (AnimationSequence)action._animationSeqs[0]; return action; }
private CellPartEnum GetClockwiseDirection(CellPartEnum direction) { switch (direction) { case CellPartEnum.CenterRight: return CellPartEnum.LowerRight; case CellPartEnum.LowerRight: return CellPartEnum.LowerLeft; case CellPartEnum.LowerLeft: return CellPartEnum.CenterLeft; case CellPartEnum.CenterLeft: return CellPartEnum.UpperLeft; case CellPartEnum.UpperLeft: return CellPartEnum.UpperRight; case CellPartEnum.UpperRight: return CellPartEnum.CenterRight; default: return CellPartEnum.Center; } }
private Cell GetPathNextCell(Cell cell, Cell cellDest, CellPartEnum direction, ArrayList deadPath) { double degree = FindDegree(cell.GetCenterPoint(), cellDest.GetCenterPoint()); switch (direction) { case CellPartEnum.CenterRight: { // get preferred directions ArrayList directions = GetPathFavourDirections(degree, direction); foreach (CellPartEnum direction2 in directions) { Cell cellNextTest = GetNextCell(cell, direction2); if (cellNextTest != null && cellNextTest.HasPassability() && !deadPath.Contains(cellNextTest)) { //Debug.WriteLine(string.Format("Change direction to {0},{1},{2}", direction2, cellNextTest._row, cellNextTest._col)); return cellNextTest; } } } break; case CellPartEnum.CenterLeft: { // get preferred directions ArrayList directions = GetPathFavourDirections(degree, direction); foreach (CellPartEnum direction2 in directions) { Cell cellNextTest = GetNextCell(cell, direction2); if (cellNextTest != null && cellNextTest.HasPassability() && !deadPath.Contains(cellNextTest)) { //Debug.WriteLine(string.Format("Change direction to {0},{1},{2}", direction2, cellNextTest._row, cellNextTest._col)); return cellNextTest; } } } break; case CellPartEnum.LowerRight: { // get preferred directions ArrayList directions = GetPathFavourDirections(degree, direction); foreach (CellPartEnum direction2 in directions) { Cell cellNextTest = GetNextCell(cell, direction2); if (cellNextTest != null && cellNextTest.HasPassability() && !deadPath.Contains(cellNextTest)) { //Debug.WriteLine(string.Format("Change direction to {0},{1},{2}", direction2, cellNextTest._row, cellNextTest._col)); return cellNextTest; } } } break; case CellPartEnum.LowerLeft: { // get preferred directions ArrayList directions = GetPathFavourDirections(degree, direction); foreach (CellPartEnum direction2 in directions) { Cell cellNextTest = GetNextCell(cell, direction2); if (cellNextTest != null && cellNextTest.HasPassability() && !deadPath.Contains(cellNextTest)) { //Debug.WriteLine(string.Format("Change direction to {0},{1},{2}", direction2, cellNextTest._row, cellNextTest._col)); return cellNextTest; } } } break; case CellPartEnum.UpperLeft: { // get preferred directions ArrayList directions = GetPathFavourDirections(degree, direction); foreach (CellPartEnum direction2 in directions) { Cell cellNextTest = GetNextCell(cell, direction2); if (cellNextTest != null && cellNextTest.HasPassability() && !deadPath.Contains(cellNextTest)) return cellNextTest; } } break; case CellPartEnum.UpperRight: { // get preferred directions ArrayList directions = GetPathFavourDirections(degree, direction); foreach (CellPartEnum direction2 in directions) { Cell cellNextTest = cell._adjacentCells[direction2]; if (cellNextTest != null && cellNextTest.HasPassability() && !deadPath.Contains(cellNextTest)) { //Debug.WriteLine(string.Format("Change direction to {0},{1},{2}", direction2, cellNextTest._row, cellNextTest._col)); return cellNextTest; } } } break; } Debug.WriteLine("Change direction but no cell found."); return null; }