예제 #1
0
 //#----------------------------------------------------------
 //# * Initialize
 //#----------------------------------------------------------
 public Effect_Text(string text, Color color, int x, int y, int maxTick)
     : base(maxTick)
 {
     _text = text;
     _color = color;
     _startPt = new Point2DEx(x, y);
 }
예제 #2
0
 //#----------------------------------------------------------
 //# * Initialize
 //#----------------------------------------------------------
 public Effect_Missile(Game_BattleUnit unit, Point2DEx srcGridPt, Point2DEx startPt, int maxTick)
     : base(maxTick)
 {
     _bitmapName = unit.MissileBitmapName();
     _playerSide = unit.IsPlayerOwned;
     DamageAgent = unit.GetDamageAgent();
     _srcGridPt = srcGridPt;
     _startPt = startPt;
 }
예제 #3
0
 //#======================================================================================
 //#----------------------------------------------------------
 //# * Get Current Target Pts
 //#----------------------------------------------------------
 public override List<Point2DEx> GetCurrentTargetPts()
 {
     List<Point2DEx> list = new List<Point2DEx>();
     if (_tick == _maxTick)
     {
         Point2DEx targetPt = new Point2DEx(_srcGridPt.X + _range * (_playerSide ? 1 : -1), _srcGridPt.Y);
         list.Add(targetPt);
         if (IsSplash())
         {
             foreach (Point2DEx adjPt in GetAdjacentPts(targetPt.X, targetPt.Y)) list.Add(adjPt);
         }
     }
     return list;
 }
예제 #4
0
 private void GetConnectedUnits(Point2DEx srcPt, ref List<Point2DEx> checkedPts)
 {
     checkedPts.Add(srcPt);
     foreach (Point2DEx adjPt in GetValidAdjacentPts(srcPt.X, srcPt.Y))
     {
         if (!checkedPts.Contains(adjPt) && _unitIDs[adjPt.X, adjPt.Y] != -1) GetConnectedUnits(adjPt, ref checkedPts);
     }
 }
예제 #5
0
 //#======================================================================================
 //#----------------------------------------------------------
 //# * Add
 //#----------------------------------------------------------
 public Point2DEx Add(Point2DEx pt)
 {
     return new Point2DEx(X + pt.X, Y + pt.Y);
 }
예제 #6
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;
         }
     }
 }
예제 #7
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;
             }
         }
     }
 }
예제 #8
0
 //#======================================================================================
 //#----------------------------------------------------------
 //# * Process Morale Boost
 //#----------------------------------------------------------
 private void ProcessAura(Point2DEx srcPt)
 {
     Game_BattleUnit unit = _units[srcPt.X, srcPt.Y];
     foreach (Game_BattleUnit adjacentUnit in GetAdjacentUnits(srcPt))
     {
         if (!adjacentUnit.IsDead() && adjacentUnit.IsAlly(unit))
         {
             adjacentUnit.AuraMoraleBoost += unit.MoraleBoostAmount();
             adjacentUnit.AuraSpot += unit.SpotAmount();
             if (unit.IsReadyToCaseHeal()) adjacentUnit.HP += unit.HealAmount();
         }
     }
 }
예제 #9
0
 //#----------------------------------------------------------
 //# * Get Target
 //#----------------------------------------------------------
 private Game_Unit GetTarget(Point2DEx pt)
 {
     if (pt.X == 4) return Global.Player.Wall;
     else if (pt.X == 21) return Global.Enemy.Wall;
     else return _units[pt.X, pt.Y];
 }
예제 #10
0
 //#----------------------------------------------------------
 //# * Get Adjacent Units
 //#----------------------------------------------------------
 private List<Game_BattleUnit> GetAdjacentUnits(Point2DEx pt)
 {
     List<Game_BattleUnit> list = new List<Game_BattleUnit>();
     foreach (Point2DEx adjPt in GetAdjacentPts(pt.X, pt.Y))
     {
         if (IsValidPt(adjPt) && _units[adjPt.X, adjPt.Y] != null) list.Add(_units[adjPt.X, adjPt.Y]);
     }
     return list;
 }
예제 #11
0
 //#----------------------------------------------------------
 //# * Damage Handling
 //#----------------------------------------------------------
 private void DamageHandling(Game_DamageAgent damageAgent, Point2DEx pt)
 {
     Game_Unit targetUnit = GetTarget(pt);
     if (damageAgent.IsLegalAttackTarget(targetUnit))
     {
         PlaySound(damageAgent.SoundHit);
         int dealtDamage = targetUnit.ExecuteDamage(damageAgent);
         _effects.Add(new Effect_Text(dealtDamage.ToString(), Color.White, START_X + pt.X * 40, START_Y + pt.Y * 40 + 20, 30));
         if (targetUnit.IsDead() && targetUnit is Game_BattleUnit)
         {
             BreakConnections(pt); // break connections of unit
             if (targetUnit.IsPlayerOwned) UnitsLost++;
         }
     }
 }
예제 #12
0
 //#----------------------------------------------------------
 //# * Break Connections
 //#----------------------------------------------------------
 private void BreakConnections(Point2DEx pt)
 {
     Game_BattleUnit unit = _units[pt.X, pt.Y];
     List<Point2DEx> AdjPts = GetAdjacentPts(pt.X, pt.Y);
     // iterate through connections with the unit and break them
     for (int i = 0; i < 4; i++)
     {
         // if unit has a connection, break it and break the opposite one for connecting unit
         if (unit.Connections[i])
         {
             int toBreakId = 0;
             switch (i)
             {
                 case 0: toBreakId = 1; break;
                 case 1: toBreakId = 0; break;
                 case 2: toBreakId = 3; break;
                 case 3: toBreakId = 2; break;
             }
             _units[AdjPts[i].X, AdjPts[i].Y].Connections[toBreakId] = false;
             unit.Connections[i] = false;
         }
     }
 }
예제 #13
0
 //#----------------------------------------------------------
 //# * Initialize
 //#----------------------------------------------------------
 public Effect_Bitmap(string bitmapName, int x, int y)
     : base(16)
 {
     _bitmapName = bitmapName;
     _startPt = new Point2DEx(x, y);
 }
예제 #14
0
        private Point2DEx _start; // co-ord of menu

        #endregion Fields

        #region Constructors

        //#----------------------------------------------------------
        //# * Initialize
        //#----------------------------------------------------------
        public UI_Editor(int x, int y)
        {
            Images.LoadBitmapNamed("editor_selection", "editor_selection.png");
            _start = new Point2DEx(x, y);
        }
예제 #15
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;
 }
예제 #16
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);
         }
     }
 }
예제 #17
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;
 }
예제 #18
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);
 }
예제 #19
0
 //#----------------------------------------------------------
 //# * Is On Battle Zone (the field where fighting takes place)
 //#----------------------------------------------------------
 private bool IsOnBattleZone(Point2DEx pt)
 {
     if (pt.X < REINFORCEMENT_WIDTH) return false;
     if (pt.Y < 0) return false;
     if (pt.X > REINFORCEMENT_WIDTH + BATTLEZONE_WIDTH - 1) return false;
     if (pt.Y >= BATTLEFIELD_GRID_HEIGHT) return false;
     return true;
 }
예제 #20
0
 //#----------------------------------------------------------
 //# * Process Movement (of units)
 //#----------------------------------------------------------
 private void ProcessMovement(Point2DEx srcPt)
 {
     Game_BattleUnit movingUnit = _units[srcPt.X, srcPt.Y];
     if (movingUnit == null) return;
     List<Point2DEx> checkedPts = new List<Point2DEx>(); // holds collection of points that have been checked for the following recursive function
     if (IsLegalMove(movingUnit, srcPt, ref checkedPts)) // check if unit has reached end on battle zone
     {
         // draw units front to back or back to front depending on alliance, so units moving don't replace units in front
         checkedPts = (movingUnit.IsPlayerOwned ? checkedPts.OrderBy(pt => pt.X).Reverse().ToList<Point2DEx>() : checkedPts.OrderBy(pt => pt.X).ToList<Point2DEx>());
         foreach (Point2DEx pt in checkedPts) MoveUnit(pt);
     }
 }
예제 #21
0
 //#----------------------------------------------------------
 //# * Is On Enemy Zone (where enemy reinforcements are sent in)
 //#----------------------------------------------------------
 private bool IsOnEnemyZone(Point2DEx pt)
 {
     if (pt.X < ENEMY_REINFORCEMENT_START_X) return false;
     if (pt.Y < 0) return false;
     if (pt.Y >= BATTLEFIELD_GRID_HEIGHT) return false;
     return true;
 }
예제 #22
0
 public Point2DEx MovePosition()
 {
     Point2DEx pos = new Point2DEx();
     if (_currentAction == Game_UnitAction.Move) pos.X += _aniAction * 5;
     else if (_currentAction == Game_UnitAction.Jump) pos.X += _aniAction * 10;
     pos.X *= (IsPlayerOwned ? -1 : 1);
     return pos;
 }
예제 #23
0
 //#----------------------------------------------------------
 //# * Is On Opponent's Zone (opponent's side, dependant on unit alliance)
 //#----------------------------------------------------------
 private bool IsOnOpponentZone(Game_Unit unit, Point2DEx pt)
 {
     return (unit.IsPlayerOwned ? IsOnEnemyZone(pt) : IsOnPlayerZone(pt));
 }
예제 #24
0
 //#----------------------------------------------------------
 //# * Initialize
 //#----------------------------------------------------------
 public Effect_Magic(Game_BattleUnit unit, Point2DEx srcPt, Point2DEx startPt)
     : base(unit, srcPt, startPt, 10)
 {
 }
예제 #25
0
 //#----------------------------------------------------------
 //# * Is On Enemy Zone (where player reinforcements are sent in)
 //#----------------------------------------------------------
 private bool IsOnPlayerZone(Point2DEx pt)
 {
     if (pt.X > REINFORCEMENT_WIDTH - 1) return false;
     if (pt.Y < 0) return false;
     if (pt.Y >= BATTLEFIELD_GRID_HEIGHT) return false;
     return true;
 }
예제 #26
0
 //#----------------------------------------------------------
 //# * Initialize
 //#----------------------------------------------------------
 public Effect_Projectile(Game_BattleUnit unit, Point2DEx srcPt, Point2DEx startPt, int range)
     : base(unit, srcPt, startPt, range * 5)
 {
     _splash = unit.HasSplashSkill();
     _range = Math.Abs(range);
 }
예제 #27
0
 //#======================================================================================
 //#----------------------------------------------------------
 //# * Is In The Battlefield
 //#----------------------------------------------------------
 private bool IsValidPt(Point2DEx pt)
 {
     if (pt.X < 0 || pt.X > 25) return false;
     if (pt.Y < 0 || pt.Y > 6) return false;
     return true;
 }
예제 #28
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;
 }
예제 #29
0
 //#----------------------------------------------------------
 //# * Is Valid
 //#     checking if group is valid (all units connected) as
 //#     one group
 //#----------------------------------------------------------
 public bool IsValid()
 {
     if (IsEmpty()) return true;
     Point2DEx startPt = new Point2DEx(-1, -1);
     List<Point2DEx> checkedPts = new List<Point2DEx>();
     // find starting pt
     foreach (Point2DEx pt in GetUnitPts())
     {
         if (_unitIDs[pt.X, pt.Y] != -1)
         {
             startPt = pt;
             break;
         }
     }
     GetConnectedUnits(startPt, ref checkedPts);
     return (checkedPts.Count == NumberOfUnits);
 }