public AnimationSequence AddDeath(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._deathLeft; facing = HorizontalDirectionEnum.Left; break; case CellPartEnum.CenterLeft: case CellPartEnum.LowerLeft: case CellPartEnum.UpperLeft: animation = currentArmy._animations._deathRight; facing = HorizontalDirectionEnum.Right; break; } AnimationSequence animationSeq = new AnimationSequence(animation, AnimationPurposeEnum.GettingHit, facing); animationSeq._waitToTrigger = true; animationSeq._destPoint = currentArmy._cell.GetStandingPoint(); this._animationSeqs.Add(animationSeq); return animationSeq; }
public ArrayList _path; // moving path #endregion Fields #region Constructors public SubAction() { _character = null; _animationSeqs = new ArrayList(); _currentAnimationSeq = null; _path = null; _isEnd = false; }
public StandardCharacter _targetCharacter; // attack target #endregion Fields #region Constructors public Action(ActionTypeEnum actionType) { _actionType = actionType; _animationSeqs = new ArrayList(); _currentAnimationSeq = null; _path = null; _isEnd = false; _targetCharacter = null; _subActions = new ArrayList(); }
public Hero() { _animations = new HeroAnimations(); _standingPointRight = new PointF(27f, 127f); _standingPointLeft = new PointF(800f - 27f, 127f); _castingHeight = 64f; _castingPointRight = new PointF(27f + 54f, // plus 54f to make it cast in front of hero 127f - _castingHeight); _castingPointLeft = new PointF(800f - 27f - 54f, 127f - _castingHeight); _imgSize = new Size(150, 175); _rightPt = new Point(43, 146 - 127); _leftPt = new Point(48, 146 - 127); _rect = new Rectangle(0, 16, 54, 111); _currentSpell = null; _canCastSpell = true; _currentAnimationSeq = null; }
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; }
public void AddMoving() { Heroes.Core.Battle.Characters.Armies.Army currentArmy = (Heroes.Core.Battle.Characters.Armies.Army)this._character; // moving seqs Cell prevCell = currentArmy._cell; HorizontalDirectionEnum facing = this._character.CurrentFacingDirection; Heroes.Core.Battle.Characters.Armies.Army army = (Heroes.Core.Battle.Characters.Armies.Army)this._character; if (army._moveType == MoveTypeEnum.Ground) { foreach (Cell cell in this._path) { // get direction Point prevPoint = prevCell.GetCenterPoint(); Point point = cell.GetCenterPoint(); CellPartEnum direction = BattleTerrain.FindDirection(prevPoint, point); Animation animation = null; facing = HorizontalDirectionEnum.None; switch (direction) { case CellPartEnum.CenterRight: case CellPartEnum.UpperRight: case CellPartEnum.LowerRight: animation = army._animations._movingRight; facing = HorizontalDirectionEnum.Right; break; default: animation = army._animations._movingLeft; facing = HorizontalDirectionEnum.Left; break; } AnimationSequence seq = new AnimationSequence(animation, AnimationPurposeEnum.Moving, facing); seq._waitToTrigger = false; seq._destPoint = cell.GetStandingPoint(); this._animationSeqs.Add(seq); prevCell = cell; } } else { // flying, telepote Point prevPoint = prevCell.GetCenterPoint(); Cell cell = (Cell)this._path[this._path.Count - 1]; Point point = cell.GetCenterPoint(); CellPartEnum direction = BattleTerrain.FindDirection(prevPoint, point); Animation animation = null; facing = HorizontalDirectionEnum.None; switch (direction) { case CellPartEnum.CenterRight: case CellPartEnum.UpperRight: case CellPartEnum.LowerRight: animation = army._animations._movingRight; facing = HorizontalDirectionEnum.Right; break; default: animation = army._animations._movingLeft; facing = HorizontalDirectionEnum.Left; break; } AnimationSequence seq = new AnimationSequence(animation, AnimationPurposeEnum.Moving, facing); seq._waitToTrigger = false; seq._destPoint = cell.GetStandingPoint(); this._animationSeqs.Add(seq); // calculate move speed, because move straight line Character.CalculateFlySpeed(prevPoint, point, currentArmy._moveSpeed, out currentArmy._moveSpeedX, out currentArmy._moveSpeedY); } }
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; }
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 Action CreateStandingAction(Hero character, HorizontalDirectionEnum facing) { Action action = new Action(ActionTypeEnum.Standing); Animation animation = null; if (facing == HorizontalDirectionEnum.Right) { if (this._sex == SexEnum.Male) animation = this._animations._standingRightMale; else animation = this._animations._standingRightFemale; } else { if (this._sex == SexEnum.Male) animation = this._animations._standingLeftMale; else animation = this._animations._standingLeftFemale; } AnimationSequence seq = new AnimationSequence(animation, AnimationPurposeEnum.StandingStill, facing); action._animationSeqs.Add(seq); action._currentAnimationSeq = seq; return action; }
public StandardCharacter() { _moveSpeed = 5; _moveSpeedX = _moveSpeed; // animation move speed _moveSpeedY = _moveSpeed; // animation move speed\ _currentFacingDirection = HorizontalDirectionEnum.Right; _command = new Idle(); _animations = new Heroes.Core.Battle.Characters.Armies.ArmyAnimations(); _isBeginTurn = false; _isEndTurn = false; _isDead = false; _currentAnimationSeq = null; }
private void SetMovingAction(Action action, ArrayList path) { action._path = path; // moving seqs Cell prevCell = this._cell; HorizontalDirectionEnum facing = this.CurrentFacingDirection; // start moving { Animation animation = null; if (facing == HorizontalDirectionEnum.Right) animation = _animations._startMovingRight; else animation = _animations._startMovingLeft; // not all army has start moving if (animation != null) { AnimationSequence seq = new AnimationSequence(animation, AnimationPurposeEnum.StartMoving, facing); seq._destPoint = prevCell.GetStandingPoint(); action._animationSeqs.Add(seq); } } foreach (Cell cell in path) { // get direction Point prevPoint = prevCell.GetCenterPoint(); Point point = cell.GetCenterPoint(); CellPartEnum direction = BattleTerrain.FindDirection(prevPoint, point); Animation animation = null; facing = HorizontalDirectionEnum.None; switch (direction) { case CellPartEnum.CenterRight: case CellPartEnum.UpperRight: case CellPartEnum.LowerRight: animation = _animations._movingRight; facing = HorizontalDirectionEnum.Right; break; default: animation = _animations._movingLeft; facing = HorizontalDirectionEnum.Left; break; } if (animation == null) { Debug.WriteLine(""); } AnimationSequence seq = new AnimationSequence(animation, AnimationPurposeEnum.Moving, facing); seq._destPoint = cell.GetStandingPoint(); action._animationSeqs.Add(seq); prevCell = cell; } // stop moving { Animation animation = null; if (facing == HorizontalDirectionEnum.Right) animation = _animations._stopMovingRight; else animation = _animations._stopMovingLeft; // not all army has stop moving if (animation != null) { AnimationSequence seq = new AnimationSequence(animation, AnimationPurposeEnum.StopMoving, facing); seq._destPoint = prevCell.GetStandingPoint(); action._animationSeqs.Add(seq); } } }
public void SetAnimation(AnimationSequence seq) { SetAnimation(this, seq); }
public Action CreateStandingAction(StandardCharacter character, HorizontalDirectionEnum facing, bool isActive) { // no standing for dead character if (character._isDead) return null; Action action = new Action(ActionTypeEnum.Standing); Animation animation = null; if (facing == HorizontalDirectionEnum.Right) { if (isActive) animation = _animations._standingRightActive; else animation = _animations._standingRight; } else { if (isActive) animation = _animations._standingLeftActive; else animation = _animations._standingLeft; } if (animation == null) { Debug.WriteLine(""); } AnimationSequence seq = new AnimationSequence(animation, AnimationPurposeEnum.StandingStill, facing); action._animationSeqs.Add(seq); action._currentAnimationSeq = seq; return action; }
public Action CreateGettingHitAction(HorizontalDirectionEnum facing) { Action action = new Action(ActionTypeEnum.GettingHit); Animation animation = null; if (facing == HorizontalDirectionEnum.Right) { animation = _animations._gettingHitRight; } else { animation = _animations._gettingHitLeft; } AnimationSequence seq = new AnimationSequence(animation, AnimationPurposeEnum.GettingHit, facing); action._animationSeqs.Add(seq); action._currentAnimationSeq = seq; return action; }
public Action CreateFirstStandingAction(StandardCharacter character, HorizontalDirectionEnum facing) { Action action = new Action(ActionTypeEnum.Standing); Animation animation = null; if (facing == HorizontalDirectionEnum.Right) { animation = _animations._firstStandingRight; } else { animation = _animations._firstStandingLeft; } AnimationSequence seq = new AnimationSequence(animation, AnimationPurposeEnum.StandingStill, facing); action._animationSeqs.Add(seq); action._currentAnimationSeq = seq; return action; }
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 void AddStopMoving() { Heroes.Core.Battle.Characters.Armies.Army army = (Heroes.Core.Battle.Characters.Armies.Army)this._character; Animation animation = null; if (this._character.CurrentFacingDirection == HorizontalDirectionEnum.Right) animation = army._animations._stopMovingRight; else animation = army._animations._stopMovingLeft; // Not all army has stop moving animation if (animation == null) return; AnimationSequence animationSeq = new AnimationSequence(animation, AnimationPurposeEnum.StopMoving, this._character.CurrentFacingDirection); animationSeq._waitToTrigger = false; animationSeq._destPoint = ((Cell)this._path[this._path.Count - 1]).GetStandingPoint(); this._animationSeqs.Add(animationSeq); }
public void SetAnimation(AnimationSequence seq) { StandardCharacter.SetAnimation(this, seq); }
public bool NextAnimationSeq() { if (_currentAnimationSeq == null) return false; if (!_animationSeqs.Contains(_currentAnimationSeq)) { _currentAnimationSeq = null; return false; } int index = _animationSeqs.IndexOf(_currentAnimationSeq); index += 1; if (index >= _animationSeqs.Count) { // end of seq _isEnd = true; return true; } else { _currentAnimationSeq = (AnimationSequence)_animationSeqs[index]; } return false; }
public static void SetAnimation(ICharacter character, AnimationSequence seq) { if (character.CurrentAnimation != seq._animation) { character.CurrentAnimation = seq._animation; character.CurrentAnimationRunner = character.CurrentAnimation.CreateRunner(); } }