Пример #1
0
 public void DealDamage(SpaceObject victim, int damageAmount)
 {
     ObjectAnimated?.Invoke(this, new AnimationEventArgs(this.CaptureGameState(),
                                                         this.CombatMap.HexToPixel(victim.ObjectCoordinates), (int)(Math.Min(1, 1 - ((victim.CurrentHealth - damageAmount) / (double)victim.MaxHealth)) * CombatMap.HexagonSideLength)));
     victim.CurrentHealth -= damageAmount;
     if (victim.CurrentHealth <= 0)
     {
         this.DeleteObject(victim);
     }
 }
Пример #2
0
        public void AttackObject(SpaceObject attacker, SpaceObject victim)
        {
            var attackerShip = attacker as Ship;

            if (attackerShip != null)
            {
                var attackSprites = attackerShip.EquippedWeapon.GetAttackSprites(
                    this.CombatMap.HexToPixel(attackerShip.ObjectCoordinates) + attackerShip.WeaponPoint,
                    this.CombatMap.HexToPixel(victim.ObjectCoordinates));
                SoundPlayed?.Invoke(this, new SoundEventArgs(attackerShip.EquippedWeapon.AttackSound));
                ObjectAnimated?.Invoke(this, new AnimationEventArgs(this.CaptureGameState(attacker), attackSprites));
                this.DealDamage(victim, attackerShip.AttackDamage);
                attackerShip.ActionsLeft -= attackerShip.EquippedWeapon.EnergyСonsumption;
            }
        }
Пример #3
0
        public void MoveObjectTo(SpaceObject spaceObject, Hex.OffsetCoordinates destination, bool onlyAnimate = false)
        {
            if (spaceObject is Ship)
            {
                SoundPlayed?.Invoke(this, new SoundEventArgs(Properties.Resources.spaceShipFly));
            }
            ObjectAnimated?.Invoke(this, new AnimationEventArgs(this.CaptureGameState(spaceObject), this.CombatMap.HexToPixel(spaceObject.ObjectCoordinates), this.CombatMap.HexToPixel(destination)));
            if (destination.Column < 0 || destination.Column >= this.MapWidth ||
                destination.Row < 0 || destination.Row >= this.MapHeight)
            {
                // moving object outside bounds = deleting object
                this.DeleteObject(spaceObject);
                return;
            }

            if (onlyAnimate)
            {
                return;
            }

            this.SpaceObjects[this.OffsetCoordinatesToIndex(spaceObject.ObjectCoordinates)] = null;
            this.SpaceObjects[this.OffsetCoordinatesToIndex(destination)] = spaceObject;
            spaceObject.ObjectCoordinates = destination;
        }
Пример #4
0
 public void RotateObject(SpaceObject spaceObject, double angle)
 {
     ObjectAnimated?.Invoke(this, new AnimationEventArgs(this.CaptureGameState(spaceObject), angle));
     spaceObject.Rotate(angle);
 }