Ejemplo n.º 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);
     }
 }
Ejemplo n.º 2
0
        public override void Update(GameTime gameTime)
        {
            Camera.Update(Vector2.Zero);
            ObjectAnimated.Update(gameTime);

            if (_canPressStart)
            {
                ObjectAnimated.Play("StartScreen");

                if (ManageInput.playerStart)
                {
                    ManageScreens.LoadNewScreen(new ScreenLoad(ManageScreens), "Fading");
                }
            }
        }
Ejemplo n.º 3
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;
            }
        }
Ejemplo n.º 4
0
        public override void Update(GameTime gameTime)
        {
            Camera.Update(Vector2.Zero);
            ObjectAnimated.Update(gameTime);

            if (_timer <= 0)
            {
                _canPressStart = true;
            }


            if (_canPressStart)
            {
                if (ManageInput.playerStart)
                {
                    ManageScreens.LoadNewScreen(new ScreenWorld(ManageScreens, true), "Fading");
                }
            }
            _timer--;
        }
Ejemplo n.º 5
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;
        }
Ejemplo n.º 6
0
 public void RotateObject(SpaceObject spaceObject, double angle)
 {
     ObjectAnimated?.Invoke(this, new AnimationEventArgs(this.CaptureGameState(spaceObject), angle));
     spaceObject.Rotate(angle);
 }