Exemplo n.º 1
0
 //#----------------------------------------------------------
 //# * Process Magic Skill
 //#----------------------------------------------------------
 private void ProcessMagicSkill(Point2DEx srcPt)
 {
     Game_BattleUnit actingUnit = _units[srcPt.X, srcPt.Y];
     if (!actingUnit.HasMagicSkill()) return;
     if (actingUnit.IsReadyToAct(Game_UnitAction.Magic))
     {
         PlaySound(actingUnit.SoundLaunch);
         _effectMissiles.Add(new Effect_Magic(actingUnit, srcPt, new Point2DEx(START_X + srcPt.X * 40, START_Y + srcPt.Y * 40)));
     }
     else if (actingUnit.IsReadyToStartAct(Game_UnitAction.Magic))
     {
         foreach (Point2DEx magicVector in actingUnit.MagicVectors())
         {
             Point2DEx targetPt = srcPt.Add(magicVector);
             Game_Unit targetUnit = GetTarget(targetPt);
             if (actingUnit.IsLegalAttackTarget(targetUnit))
             {
                 actingUnit.StartAct(Game_UnitAction.Magic);
                 break;
             }
         }
     }
 }
Exemplo n.º 2
0
 //#======================================================================================
 //#----------------------------------------------------------
 //# * Process Projectile Skill
 //#----------------------------------------------------------
 private void ProcessProjectileSkill(Point2DEx srcPt)
 {
     Game_BattleUnit actingUnit = _units[srcPt.X, srcPt.Y];
     if (!actingUnit.HasProjectileSkill()) return;
     foreach (Point2DEx projectileVector in actingUnit.MissileVectors())
     {
         Point2DEx targetPt = srcPt.Add(projectileVector);
         Game_Unit targetUnit = GetTarget(targetPt);
         if (!actingUnit.IsLegalAttackTarget(targetUnit)) continue;
         if (actingUnit.IsReadyToAct(Game_UnitAction.Projectile))
         {
             PlaySound(actingUnit.SoundLaunch);
             _effectMissiles.Add(new Effect_Projectile(actingUnit, srcPt, new Point2DEx(START_X + srcPt.X * 40, START_Y + srcPt.Y * 40), projectileVector.X));
             break;
         }
         else if (actingUnit.IsReadyToStartAct(Game_UnitAction.Projectile))
         {
             actingUnit.StartAct(Game_UnitAction.Projectile);
             break;
         }
     }
 }
Exemplo n.º 3
0
 //#======================================================================================
 //#----------------------------------------------------------
 //# * Process Jump (knight)
 //#----------------------------------------------------------
 private void ProcessJump(Point2DEx srcPt)
 {
     Game_BattleUnit jumpingUnit = _units[srcPt.X, srcPt.Y];
     if (jumpingUnit == null) return;
     // check if unit is blocking
     Point2DEx movePt = srcPt.Add(jumpingUnit.MoveVector());
     Game_BattleUnit moveUnit = _units[movePt.X, movePt.Y];
     if (moveUnit == null || moveUnit.HasBlockSkill()) return;
     Point2DEx destPt = srcPt.Add(jumpingUnit.JumpVector());
     Game_BattleUnit destUnit = _units[destPt.X, destPt.Y];
     if (!jumpingUnit.HasJumpSkill()) return;
     if (!jumpingUnit.IsReadyToStartAct(Game_UnitAction.Jump)) return;
     if (destUnit != null && !destUnit.IsDead()) return;
     if (IsOnOpponentZone(jumpingUnit, destPt)) return;
     JumpUnit(srcPt);
 }
Exemplo n.º 4
0
 //#----------------------------------------------------------
 //# * Process Attack (of units)
 //#----------------------------------------------------------
 private void ProcessAttack(Point2DEx srcPt)
 {
     Game_BattleUnit actingUnit = _units[(int)srcPt.X, (int)srcPt.Y];
     if (actingUnit.IsReadyToAct(Game_UnitAction.Attack))
     {
         Point2DEx targetPt = srcPt.Add(actingUnit.AttackVector());
         DamageHandling(actingUnit.GetDamageAgent(), targetPt);
     }
     else if (actingUnit.IsReadyToStartAct(Game_UnitAction.Attack))
     {
         Point2DEx targetPt = srcPt.Add(actingUnit.AttackVector());
         Game_Unit targetUnit = GetTarget(targetPt);
         if (actingUnit.IsLegalAttackTarget(targetUnit))
         {
             PlaySound(actingUnit.SoundLaunch);
             actingUnit.StartAct(Game_UnitAction.Attack);
         }
     }
 }
Exemplo n.º 5
0
 //#----------------------------------------------------------
 //# * Move Unit
 //#----------------------------------------------------------
 private void MoveUnit(Point2DEx srcPt)
 {
     Game_BattleUnit unit = _units[srcPt.X, srcPt.Y];
     Point2DEx destPt = srcPt.Add(unit.MoveVector());
     unit.StartAct(Game_UnitAction.Move);
     _units[destPt.X, destPt.Y] = unit;
     _units[srcPt.X, srcPt.Y] = null;
 }
Exemplo n.º 6
0
 //#----------------------------------------------------------
 //# * Jump Unit
 //#----------------------------------------------------------
 private void JumpUnit(Point2DEx srcPt)
 {
     PlaySound("jump");
     Game_BattleUnit unit = _units[srcPt.X, srcPt.Y];
     Point2DEx destPt = srcPt.Add(unit.JumpVector());
     unit.StartAct(Game_UnitAction.Jump);
     _units[destPt.X, destPt.Y] = unit;
     _units[srcPt.X, srcPt.Y] = null;
 }
Exemplo n.º 7
0
 //#----------------------------------------------------------
 //# * Is Legal Move
 //#----------------------------------------------------------
 private bool IsLegalMove(Game_BattleUnit unit, Point2DEx srcPt, ref List<Point2DEx> checkedPts)
 {
     checkedPts.Add(srcPt);
     Point2DEx destPt = srcPt.Add(unit.MoveVector());
     if (!unit.IsReadyToStartAct(Game_UnitAction.Move)) return false; // check if unit is ready to move
     if (IsOnOpponentZone(unit, destPt)) return false; // if destination moves into reinforcement zone, return
     // if occupied, check conditions when move is still possible (dead unit or grouped unit that would move together)
     Game_BattleUnit destUnit = _units[destPt.X, destPt.Y];
     if (destUnit != null)
     {
         if (destUnit.IsAlly(unit))
         {
             // if moving pt is grouped unit
             if (!(unit.IsPlayerOwned ? unit.RightConnected : unit.LeftConnected)) return false;
         }
         else
         {
             // units can move over dead enemy units
             if (!destUnit.IsDead()) return false;
         }
     }
     // check group's ability to move
     List<Point2DEx> AdjPts = GetAdjacentPts(srcPt.X, srcPt.Y);
     for (int i = 0; i < 4; i++)
     {
         Point2DEx direction = AdjPts[i];
         if (!checkedPts.Contains(direction))
         {
             if (unit.Connections[i] && !IsLegalMove(_units[direction.X, direction.Y], direction, ref checkedPts)) return false;
         }
     }
     return true;
 }