Esempio n. 1
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;
            }
        }
Esempio n. 2
0
 public async Task Generate(byte[] buffer, int offset, int count)
 {
     try
     {
         Console.WriteLine("RenderStart");
         int   renderPeriod = count / WaveFormat.BitsPerSample * 8 / WaveFormat.Channels;
         float renderTime   = (float)renderPeriod / WaveFormat.SampleRate;
         var   renderLength = (renderTime) *
                              Project.current.tempo / 60;
         if (renderLength < 0)
         {
             renderLength = 0;
         }
         liveRenderingNow = true;
         var rendering = new Rendering()
         {
             renderingStart = position, renderingLength = (float)renderLength, project = Project.current, type = RenderngType.live
         };
         var soundReady = rendering.project.lines[0].getByRendering(rendering);
         rendering.project.Render(rendering);
         var sound = await soundReady;
         Console.WriteLine("ReturnedSound");
         ReturnedSound(sound, buffer);
         rendering.project.Clear(rendering);
         if (status == Status.playing)
         {
             position += (float)renderLength;
             positionChanged?.Invoke(position);
         }
         Console.WriteLine("RenderEnded");
         SoundPlayed?.Invoke(sound);
     }
     catch
     {
     }
 }
Esempio n. 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;
        }
Esempio n. 4
0
 private void PlaySound(object sender, ActionSound sound)
 {
     SoundPlayed?.Invoke(sender, sound);
 }
Esempio n. 5
0
 /// <summary>
 ///     Raises the <see cref="SoundPlayed" /> event.
 /// </summary>
 /// <seealso cref="EventArgs" />
 protected virtual void OnSoundPlayed()
 {
     SoundPlayed?.Invoke(this, EventArgs.Empty);
 }