示例#1
0
    public async Task cancel_booked_slots_when_the_day_is_cancelled()
    {
        var slotOneId = new SlotId(Guid.NewGuid());
        var slotTwoId = new SlotId(Guid.NewGuid());

        var slotCancelledExpected            = new SlotBookingCancelled(_dayId.Value, slotOneId.Value, null);
        var slotOneScheduleCancelledExpected = new SlotScheduleCancelled(_dayId.Value, slotOneId.Value);
        var slotTwoScheduleCancelledExpected = new SlotScheduleCancelled(_dayId.Value, slotTwoId.Value);
        var dayCancelledExpected             = new DayScheduleCancelled(_dayId.Value);

        Given(
            new DayScheduled(_dayId.Value, _doctorId.Value, _date),
            new SlotScheduled(slotOneId.Value, _dayId.Value, _date, TimeSpan.FromMinutes(10)),
            new SlotScheduled(slotTwoId.Value, _dayId.Value, _date, TimeSpan.FromMinutes(10)),
            new SlotBooked(_dayId.Value, slotOneId.Value, "John Doe"));

        await When(new CancelDaySchedule(_dayId.Value));

        Then(e =>
        {
            Assert.IsType <SlotBookingCancelled>(e[0]);
            Assert.Equal(slotCancelledExpected, e[0]);

            Assert.IsType <SlotScheduleCancelled>(e[1]);
            Assert.Equal(slotOneScheduleCancelledExpected, e[1]);

            Assert.IsType <SlotScheduleCancelled>(e[2]);
            Assert.Equal(slotTwoScheduleCancelledExpected, e[2]);

            Assert.IsType <DayScheduleCancelled>(e[3]);
            Assert.Equal(dayCancelledExpected, e[3]);
        });
    }
示例#2
0
        public RSAParameters GetPublicRsaKey(SlotId slotId, int lengthInBytes = -1)
        {
            SendMessage(message: Message.GetPublicKey, slotNumber: RsaSlotIdToNumber(slotId));
            Thread.Sleep(1500);

            var publicKey = new byte[lengthInBytes == -1 ? 4096 / 8 : lengthInBytes];
            var chunk     = new byte[65];
            var position  = 0;

            while (position < lengthInBytes)
            {
                try
                {
                    _deviceCommunicationStream.Read(chunk);
                }
                catch (TimeoutException)
                {
                    if (lengthInBytes == -1)
                    {
                        publicKey = publicKey.Take(position).ToArray();
                        break;
                    }
                    throw new ArgumentOutOfRangeException($"The public key in slot {slotId} is less than the specified {lengthInBytes} bytes.");
                }

                Array.Copy(sourceArray: chunk, sourceIndex: 1, destinationArray: publicKey, destinationIndex: position,
                           length: 64);
                position += 64;
            }

            return(new RSAParameters {
                Modulus = publicKey, Exponent = new byte[] { 1, 0, 1 }
            });
        }
示例#3
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public override string ToString()
 {
     return((Id.ToString("x")) + ('~') +
            (TemplateId.ToString("x")) + ('~') +
            (Quantity.ToString("x")) + ('~') +
            ((SlotId != (int)ItemSlotEnum.SLOT_INVENTORY ? SlotId.ToString("x") : "")) + ('~') +
            (StringEffects) + (';'));
 }
示例#4
0
 public void DumpXml(XmlWriter writer)
 {
     writer.WriteElementString("slot-id", SlotId.ToString());
     if (Class != null)
     {
         writer.WriteElementString("class", Class.ToString());
     }
 }
示例#5
0
 public void DumpXml(XmlWriter writer)
 {
     writer.WriteElementString("slot-id", SlotId.ToString());
     if (Method != null && AbcDumpService.DumpMethods)
     {
         writer.WriteElementString("function", Method.ToString());
     }
 }
示例#6
0
 public void DumpXml(XmlWriter writer)
 {
     writer.WriteElementString("disp-id", SlotId.ToString());
     if (Method != null && AbcDumpService.DumpMethods)
     {
         Method.DumpXml(writer);
     }
 }
示例#7
0
        public virtual string GetProperty(string strPropertyName, string strFormat, System.Globalization.CultureInfo formatProvider, DotNetNuke.Entities.Users.UserInfo accessingUser, DotNetNuke.Services.Tokens.Scope accessLevel, ref bool propertyNotFound)
        {
            switch (strPropertyName.ToLower())
            {
            case "slotid": // Int
                return(SlotId.ToString(strFormat, formatProvider));

            case "conferenceid": // Int
                return(ConferenceId.ToString(strFormat, formatProvider));

            case "start": // Time
                return(Start.ToString(strFormat, formatProvider));

            case "durationmins": // Int
                return(DurationMins.ToString(strFormat, formatProvider));

            case "slottype": // Int
                return(SlotType.ToString(strFormat, formatProvider));

            case "title": // NVarChar
                if (Title == null)
                {
                    return("");
                }
                ;
                return(PropertyAccess.FormatString(Title, strFormat));

            case "description": // NVarCharMax
                if (Description == null)
                {
                    return("");
                }
                ;
                return(PropertyAccess.FormatString(Description, strFormat));

            case "daynr": // Int
                if (DayNr == null)
                {
                    return("");
                }
                ;
                return(((int)DayNr).ToString(strFormat, formatProvider));

            case "locationid": // Int
                if (LocationId == null)
                {
                    return("");
                }
                ;
                return(((int)LocationId).ToString(strFormat, formatProvider));

            default:
                propertyNotFound = true;
                break;
            }

            return(Null.NullString);
        }
 public static ActiveSound GetActiveSound(SlotId id)
 {
     //IL_000e: Unknown result type (might be due to invalid IL or missing references)
     if (!IsAudioSupported)
     {
         return(null);
     }
     return(_player.GetActiveSound(id));
 }
示例#9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="message"></param>
 public void SerializeAs_BagContent(StringBuilder message)
 {
     message
     .Append(Id.ToString("x")).Append('~')
     .Append(TemplateId.ToString("x")).Append('~')
     .Append(Quantity.ToString("x")).Append('~')
     .Append((SlotId != (int)ItemSlotEnum.SLOT_INVENTORY ? SlotId.ToString("x") : "")).Append('~')
     .Append(StringEffects).Append(';');
 }
示例#10
0
 public void DumpXml(XmlWriter writer)
 {
     writer.WriteElementString("slot-id", SlotId.ToString());
     writer.WriteElementString("type", Type.ToString());
     if (HasValue)
     {
         writer.WriteElementString("value", _value != null ? _value.ToString() : "null");
     }
 }
 public ActiveSound GetActiveSound(SlotId id)
 {
     //IL_0006: Unknown result type (might be due to invalid IL or missing references)
     //IL_0016: Unknown result type (might be due to invalid IL or missing references)
     if (!_trackedSounds.Has(id))
     {
         return(null);
     }
     return(_trackedSounds[id]);
 }
示例#12
0
    public async Task should_not_allow_to_book_an_unscheduled_slot()
    {
        var slotId = new SlotId(Guid.NewGuid());

        Given(new DayScheduled(_dayId.Value, _doctorId.Value, _date));

        await When(new BookSlot(_dayId.Value, slotId.Value, "John Doe"));

        Then <SlotNotScheduledException>();
    }
示例#13
0
    public async Task should_not_allow_to_book_slot_if_day_not_scheduled()
    {
        var slotId = new SlotId(Guid.NewGuid());

        Given();

        await When(new BookSlot(_dayId.Value, slotId.Value, "John Doe"));

        Then <DayNotScheduledException>();
    }
示例#14
0
    public async Task not_allow_to_cancel_unbooked_slot()
    {
        var slotId = new SlotId(Guid.NewGuid());

        Given(
            new DayScheduled(_dayId.Value, _doctorId.Value, _date),
            new SlotScheduled(slotId.Value, _dayId.Value, _date, TimeSpan.FromMinutes(10)));

        await When(new CancelSlotBooking(_dayId.Value, slotId.Value, "Some Reason"));

        Then <SlotNotBookedException>();
    }
示例#15
0
 public override int GetHashCode()
 {
     unchecked
     {
         // ReSharper disable NonReadonlyMemberInGetHashCode
         var hashCode = OpportunityType.GetHashCode();
         hashCode = (hashCode * 397) ^ FacilityUseId.GetHashCode();
         hashCode = (hashCode * 397) ^ SlotId.GetHashCode();
         hashCode = (hashCode * 397) ^ OfferId.GetHashCode();
         // ReSharper enable NonReadonlyMemberInGetHashCode
         return(hashCode);
     }
 }
示例#16
0
        public string DecryptString(SlotId slotId, byte[] encrypted)
        {
            var bytes  = Decrypt(slotId, encrypted);
            var length = bytes.Length;

            Console.WriteLine($"Decrypt message received back {length} bytes.");
            while (length > 0 && bytes[length - 1] == 0)
            {
                --length;
            }
            Console.WriteLine($"Excluding tailing zeroes, the message's length is actually {length} bytes.");
            return(ASCII.GetString(bytes, 0, length));
        }
示例#17
0
    public async Task dont_to_schedule_overlapping_slots()
    {
        var slotOneId = new SlotId(Guid.NewGuid());
        var slotTwoId = new SlotId(Guid.NewGuid());

        Given(
            new DayScheduled(_dayId.Value, _doctorId.Value, _date),
            new SlotScheduled(slotOneId.Value, _dayId.Value, _date, TimeSpan.FromMinutes(10)));

        await When(new ScheduleSlot(slotTwoId.Value, _doctorId.Value, _date, TimeSpan.FromMinutes(10), _date));

        Then <SlotOverlappedException>();
    }
示例#18
0
    public async Task should_not_allow_to_book_slot_twice()
    {
        var slotId = new SlotId(Guid.NewGuid());

        Given(
            new DayScheduled(_dayId.Value, _doctorId.Value, _date),
            new SlotScheduled(slotId.Value, _dayId.Value, _date, TimeSpan.FromMinutes(10)),
            new SlotBooked(_dayId.Value, slotId.Value, "John Doe"));

        await When(new BookSlot(_dayId.Value, slotId.Value, "John Doe"));

        Then <SlotAlreadyBookedException>();
    }
示例#19
0
        public string SetPrivateKey(SlotId slotId, KeyFeatures features, RSAParameters key)
        {
            var keyLengthInBytes     = key.Modulus.Length;
            var halfKeyLengthInBytes = key.Q.Length;
            var keyLengthInKibibits  = keyLengthInBytes / 128;            // 1024 bits is 128 bytes
            var slotNumber           = RsaSlotIdToNumber(slotId);

            // payload is p then q
            var payload = new byte[MaxPayloadSize];

            payload[0] = (byte)((int)features | keyLengthInKibibits);
            var keyPos = 0;

            while (keyPos < keyLengthInBytes)
            {
                int length;
                if (keyPos < halfKeyLengthInBytes)
                {
                    // Deal with the fact that 57 is not evenly divisible into 128
                    length = Math.Min(halfKeyLengthInBytes - keyPos, MaxPayloadChunkSize);

                    Array.Copy(sourceArray: key.Q, sourceIndex: keyPos, destinationArray: payload, destinationIndex: 1,
                               length: length);

                    // If the end of Q was reached, start copying from P
                    if (length != MaxPayloadChunkSize)
                    {
                        Array.Copy(sourceArray: key.P, sourceIndex: 0, destinationArray: payload,
                                   destinationIndex: 1 + length, length: MaxPayloadChunkSize - length);
                        length = MaxPayloadChunkSize;
                    }
                }
                else
                {
                    var pPos = keyPos - halfKeyLengthInBytes;
                    length = Math.Min(halfKeyLengthInBytes - pPos, MaxPayloadChunkSize);
                    Array.Copy(sourceArray: key.P, sourceIndex: pPos, destinationArray: payload, destinationIndex: 1,
                               length: length);
                }

                keyPos += MaxPayloadChunkSize;

                SendMessage(message: Message.SetPrivateKey, slotNumber: slotNumber, payload: payload,
                            payloadLength: length + 1);
            }

            return(ReadString());
        }
示例#20
0
    public async Task allow_to_schedule_an_extra_slot()
    {
        var slotId   = new SlotId(Guid.NewGuid());
        var duration = TimeSpan.FromMinutes(10);
        var expected = new SlotScheduled(slotId.Value, _dayId.Value, _date, duration);

        Given(new DayScheduled(_dayId.Value, _doctorId.Value, _date));

        await When(new ScheduleSlot(slotId.Value, _doctorId.Value, _date, duration, _date));

        Then(e =>
        {
            Assert.IsType <SlotScheduled>(e.First());
            Assert.Equal(expected, e.First());
        });
    }
示例#21
0
        public IDictionary <String, String> GetValues()
        {
            var values = new Dictionary <String, String>
            {
                { nameof(Index), Index.ToString() },
                { nameof(SlotId), SlotId.ToString() },
                { nameof(PortId), PortId.ToString() },
            };

            foreach (var item in GetAdditonalValues())
            {
                values.Add(item.Key, item.Value);
            }

            return(values);
        }
示例#22
0
    public async Task should_allow_to_book_slot()
    {
        var slotId   = new SlotId(Guid.NewGuid());
        var expected = new SlotBooked(_dayId.Value, slotId.Value, "John Doe");

        Given(
            new DayScheduled(_dayId.Value, _doctorId.Value, _date),
            new SlotScheduled(slotId.Value, _dayId.Value, _date, TimeSpan.FromMinutes(10)));

        await When(new BookSlot(_dayId.Value, slotId.Value, "John Doe"));

        Then(e =>
        {
            Assert.IsType <SlotBooked>(e.First());
            Assert.Equal(expected, e.First());
        });
    }
示例#23
0
    public async Task allow_to_cancel_booking()
    {
        var slotId   = new SlotId(Guid.NewGuid());
        var reason   = "Cancel Reason";
        var expected = new SlotBookingCancelled(_dayId.Value, slotId.Value, reason);

        Given(
            new DayScheduled(_dayId.Value, _doctorId.Value, _date),
            new SlotScheduled(slotId.Value, _dayId.Value, _date, TimeSpan.FromMinutes(10)),
            new SlotBooked(_dayId.Value, slotId.Value, "John Doe"));

        await When(new CancelSlotBooking(_dayId.Value, slotId.Value, reason));

        Then(e =>
        {
            Assert.IsType <SlotBookingCancelled>(e.First());
            Assert.Equal(expected, e.First());
        });
    }
示例#24
0
    public void BookSlot(SlotId slotId, PatientId patientId)
    {
        IsCancelledOrArchived();
        IsNotScheduled();

        var slotStatus = _slots.GetStatus(slotId);

        switch (slotStatus)
        {
        case SlotStatus.Available:
            Raise(new SlotBooked(Id, slotId.Value, patientId.Value));
            break;

        case SlotStatus.Booked:
            throw new SlotAlreadyBookedException();

        case SlotStatus.NotScheduled:
            throw new SlotNotScheduledException();
        }
    }
示例#25
0
        public string SetField(SlotId slotId, Field field, byte[] contents, int contentLength = -1)
        {
            if (contentLength == -1)
            {
                contentLength = contents.Length;

                // too-long contents will cause exception
                // in order to allow API consumer to give a byte array that is bigger than limit, but which doesn't
                // actually contain data that fills the whole thing, calculate the length excluding trailing 0s
                while (contentLength != 0 && contents[contentLength - 1] == 0)
                {
                    --contentLength;
                }

                // automatically calculate length if only start-index is provided
                contentLength = Math.Max(1, contentLength);
            }

            SendMessage(message: Message.SetSlot, slotNumber: (byte)slotId, field: field,
                        payload: contents, payloadLength: contentLength);
            return(ReadString());
        }
示例#26
0
        public override void AI()
        {
            Lighting.AddLight(projectile.Center, 0f, .7f, 0f);
            ActiveSound activeSound = Main.GetActiveSound(SlotId.FromFloat(projectile.localAI[0]));

            if (activeSound != null)
            {
                if (activeSound.Volume == 0f)
                {
                    activeSound.Stop();
                    projectile.localAI[0] = SlotId.Invalid.ToFloat();
                }
                activeSound.Volume = Math.Max(0f, activeSound.Volume - 0.05f);
            }
            else
            {
                projectile.localAI[0] = SlotId.Invalid.ToFloat();
            }
            if (projectile.ai[1] == 1f)
            {
                if (projectile.alpha < 255)
                {
                    projectile.alpha += 51;
                }
                if (projectile.alpha >= 255)
                {
                    projectile.alpha = 255;
                    projectile.Kill();
                    return;
                }
            }
            else
            {
                if (projectile.alpha > 0)
                {
                    projectile.alpha -= 50;
                }
                if (projectile.alpha < 0)
                {
                    projectile.alpha = 0;
                }
            }
            float num726 = 30f;
            float num727 = num726 * 4f;

            projectile.ai[0] += 1f;
            if (projectile.ai[0] > num727)
            {
                projectile.ai[0] = 0f;
            }
            Vector2 vector62 = -Vector2.UnitY.RotatedBy(6.28318548f * projectile.ai[0] / num726, default);
            float   val      = 0.75f + vector62.Y * 0.25f;
            float   val2     = 0.8f - vector62.Y * 0.2f;
            float   num728   = Math.Max(val, val2);

            projectile.position += new Vector2(projectile.width, projectile.height) / 2f;
            projectile.width     = (projectile.height = (int)(80f * num728));
            projectile.position -= new Vector2(projectile.width, projectile.height) / 2f;
            projectile.frameCounter++;
            if (projectile.frameCounter >= 3)
            {
                projectile.frameCounter = 0;
                projectile.frame++;
                if (projectile.frame >= 4)
                {
                    projectile.frame = 0;
                }
            }
            for (int num729 = 0; num729 < 1; num729++)
            {
                float num730 = 55f * num728;
                float num731 = 11f * num728;
                float num732 = 0.5f;
                int   num733 = Dust.NewDust(projectile.position, projectile.width, projectile.height, ModContent.DustType <Dusts.StarDust>(), 0f, 0f, 100, default, 0.5f);
示例#27
0
        public override void AI()
        {
            npc.rotation = npc.velocity.ToRotation();
            float num          = 0.4f;
            float num2         = 10f;
            float scaleFactor  = 200f;
            float num3         = 750f;
            float num4         = 30f;
            float num5         = 30f;
            float scaleFactor2 = 0.95f;
            int   num6         = 50;
            float scaleFactor3 = 14f;
            float num7         = 30f;
            float num8         = 100f;
            float num9         = 20f;
            float num10        = 0f;
            float num11        = 7f;
            bool  flag         = true;
            bool  flag2        = true;
            int   num12        = 120;
            bool  flag3        = false;
            bool  flag4        = false;
            float num13        = 0.05f;
            float num14        = 0f;
            bool  flag5        = false;
            int   num15        = npc.type;

            switch (num15)
            {
            case 558:
            case 559:
            case 560:
                flag4 = true;
                num   = 0.7f;
                if (npc.type == 559)
                {
                    num = 0.5f;
                }
                if (npc.type == 560)
                {
                    num = 0.2f;
                }
                num2         = 3f;
                scaleFactor  = 400f;
                num3         = 500f;
                num4         = 90f;
                num5         = 20f;
                scaleFactor2 = 0.95f;
                num6         = 0;
                scaleFactor3 = 8f;
                num7         = 30f;
                num8         = 150f;
                num9         = 60f;
                num10        = 0.05f;
                num11        = 6f;
                flag2        = false;
                flag5        = true;
                break;

            default:
                switch (num15)
                {
                case 574:
                case 575:
                    flag4 = true;
                    num   = 0.6f;
                    if (npc.type == 575)
                    {
                        num = 0.4f;
                    }
                    num2         = 4f;
                    scaleFactor  = 400f;
                    num3         = 500f;
                    num4         = 90f;
                    num5         = 30f;
                    scaleFactor2 = 0.95f;
                    num6         = 3;
                    scaleFactor3 = 8f;
                    num7         = 30f;
                    num8         = 150f;
                    num9         = 10f;
                    num10        = 0.05f;
                    num11        = 0f;
                    num14        = -0.1f;
                    flag3        = true;
                    flag5        = true;
                    break;
                }
                break;
            }
            NPCAimedTarget targetData = npc.GetTargetData(true);

            if (flag5)
            {
                if (npc.localAI[0] == 0f)
                {
                    npc.alpha = 255;
                }
                if (npc.localAI[0] < 60f)
                {
                    npc.localAI[0] += 1f;
                    npc.alpha      -= 5;
                    if (npc.alpha < 0)
                    {
                        npc.alpha = 0;
                    }
                    int   num16 = (int)npc.localAI[0] / 10;
                    float num17 = npc.Size.Length() / 2f;
                    num17 /= 20f;
                    int maxValue = 5;
                    if (npc.type == 576 || npc.type == 577)
                    {
                        maxValue = 1;
                    }
                    for (int i = 0; i < num16; i++)
                    {
                        if (Main.rand.Next(maxValue) == 0)
                        {
                            Dust dust = Dust.NewDustDirect(npc.position, npc.width, npc.height, 27, npc.velocity.X * 1f, 0f, 100, default(Color), 1f);
                            dust.scale     = 0.55f;
                            dust.fadeIn    = 0.7f;
                            dust.velocity *= 0.1f * num17;
                            dust.velocity += npc.velocity;
                        }
                    }
                }
            }
            if (flag4)
            {
                for (int j = 0; j < 200; j++)
                {
                    if (j != npc.whoAmI && Main.npc[j].active && Main.npc[j].type == npc.type && Math.Abs(npc.position.X - Main.npc[j].position.X) + Math.Abs(npc.position.Y - Main.npc[j].position.Y) < (float)npc.width)
                    {
                        if (npc.position.X < Main.npc[j].position.X)
                        {
                            npc.velocity.X = npc.velocity.X - num13;
                        }
                        else
                        {
                            npc.velocity.X = npc.velocity.X + num13;
                        }
                        if (npc.position.Y < Main.npc[j].position.Y)
                        {
                            npc.velocity.Y = npc.velocity.Y - num13;
                        }
                        else
                        {
                            npc.velocity.Y = npc.velocity.Y + num13;
                        }
                    }
                }
            }
            if (Math.Sign(npc.velocity.X) != 0)
            {
                npc.spriteDirection = -Math.Sign(npc.velocity.X);
            }
            if (npc.rotation < -1.57079637f)
            {
                npc.rotation += 3.14159274f;
            }
            if (npc.rotation > 1.57079637f)
            {
                npc.rotation -= 3.14159274f;
            }
            num10 *= num9;
            if (Main.expertMode)
            {
                num *= Main.expertKnockBack;
            }
            if (npc.ai[0] == 0f)
            {
                npc.knockBackResist = num;
                float   scaleFactor4 = num2;
                Vector2 center       = npc.Center;
                Vector2 center2      = targetData.Center;
                Vector2 vector       = center2 - center;
                Vector2 vector2      = vector - (Vector2.UnitY * scaleFactor);
                float   num18        = vector.Length();
                vector  = Vector2.Normalize(vector) * scaleFactor4;
                vector2 = Vector2.Normalize(vector2) * scaleFactor4;
                bool flag6 = Collision.CanHit(npc.Center, 1, 1, targetData.Center, 1, 1);
                if (npc.ai[3] >= (float)num12)
                {
                    flag6 = true;
                }
                float num19 = 8f;
                flag6 = (flag6 && vector.ToRotation() > 3.14159274f / num19 && vector.ToRotation() < 3.14159274f - (3.14159274f / num19));
                if (num18 > num3 || !flag6)
                {
                    npc.velocity.X = ((npc.velocity.X * (num4 - 1f)) + vector2.X) / num4;
                    npc.velocity.Y = ((npc.velocity.Y * (num4 - 1f)) + vector2.Y) / num4;
                    if (!flag6)
                    {
                        npc.ai[3] += 1f;
                        if (npc.ai[3] == (float)num12)
                        {
                            npc.netUpdate = true;
                        }
                    }
                    else
                    {
                        npc.ai[3] = 0f;
                    }
                }
                else
                {
                    npc.ai[0]     = 1f;
                    npc.ai[2]     = vector.X;
                    npc.ai[3]     = vector.Y;
                    npc.netUpdate = true;
                }
            }
            else if (npc.ai[0] == 1f)
            {
                npc.knockBackResist = 0f;
                npc.velocity       *= scaleFactor2;
                npc.velocity.Y      = npc.velocity.Y + num14;
                npc.ai[1]          += 1f;
                if (npc.ai[1] == num5)
                {
                    npc.localAI[1] = Main.PlayTrackedSound(SoundID.DD2_WyvernDiveDown, npc.Center).ToFloat();
                    if (Main.rand.Next(5) == 0)
                    {
                        npc.localAI[2] = Main.PlayTrackedSound(SoundID.DD2_WyvernScream, npc.Center).ToFloat();
                    }
                }
                if (npc.ai[1] >= num5)
                {
                    npc.ai[0]     = 2f;
                    npc.ai[1]     = 0f;
                    npc.netUpdate = true;
                    Vector2 velocity = new Vector2(npc.ai[2], npc.ai[3]) + (new Vector2((float)Main.rand.Next(-num6, num6 + 1), (float)Main.rand.Next(-num6, num6 + 1)) * 0.04f);
                    velocity.Normalize();
                    velocity    *= scaleFactor3;
                    npc.velocity = velocity;
                }
            }
            else if (npc.ai[0] == 2f)
            {
                npc.knockBackResist = 0f;
                float num20 = num7;
                npc.ai[1] += 1f;
                bool flag7 = Vector2.Distance(npc.Center, targetData.Center) > num8 && npc.Center.Y > targetData.Center.Y;
                if (flag3)
                {
                    flag7 = false;
                }
                if ((npc.ai[1] >= num20 && flag7) || npc.velocity.Length() < num11)
                {
                    npc.ai[0]     = 0f;
                    npc.ai[1]     = 0f;
                    npc.ai[2]     = 0f;
                    npc.ai[3]     = 0f;
                    npc.velocity /= 2f;
                    npc.netUpdate = true;
                    if (flag)
                    {
                        npc.ai[1] = 45f;
                        npc.ai[0] = 4f;
                    }
                }
                else
                {
                    Vector2 center3 = npc.Center;
                    Vector2 center4 = targetData.Center;
                    Vector2 vec     = center4 - center3;
                    vec.Normalize();
                    if (vec.HasNaNs())
                    {
                        vec = new Vector2((float)npc.direction, 0f);
                    }
                    npc.velocity = ((npc.velocity * (num9 - 1f)) + (vec * (npc.velocity.Length() + num10))) / num9;
                }
                if (flag2 && Collision.SolidCollision(npc.position, npc.width, npc.height))
                {
                    npc.ai[0]     = 3f;
                    npc.ai[1]     = 0f;
                    npc.ai[2]     = 0f;
                    npc.ai[3]     = 0f;
                    npc.netUpdate = true;
                }
            }
            else if (npc.ai[0] == 4f)
            {
                npc.ai[1] -= 3f;
                if (npc.ai[1] <= 0f)
                {
                    npc.ai[0]     = 0f;
                    npc.ai[1]     = 0f;
                    npc.netUpdate = true;
                }
                npc.velocity *= 0.95f;
            }
            ActiveSound activeSound2 = Main.GetActiveSound(SlotId.FromFloat(npc.localAI[1]));

            if (activeSound2 != null)
            {
                activeSound2.Position = npc.Center;
            }
            else
            {
                npc.localAI[1] = SlotId.Invalid.ToFloat();
            }
            activeSound2 = Main.GetActiveSound(SlotId.FromFloat(npc.localAI[2]));
            if (activeSound2 != null)
            {
                activeSound2.Position = npc.Center;
            }
            else
            {
                npc.localAI[2] = SlotId.Invalid.ToFloat();
            }
            if (flag2 && npc.ai[0] != 3f && Vector2.Distance(npc.Center, targetData.Center) < 64f)
            {
                npc.ai[0]     = 3f;
                npc.ai[1]     = 0f;
                npc.ai[2]     = 0f;
                npc.ai[3]     = 0f;
                npc.netUpdate = true;
            }
            if (npc.ai[0] == 3f)
            {
                npc.position   = npc.Center;
                npc.width      = (npc.height = 192);
                npc.position.X = npc.position.X - (float)(npc.width / 2);
                npc.position.Y = npc.position.Y - (float)(npc.height / 2);
                npc.velocity   = Vector2.Zero;
                npc.damage     = (int)(80f * Main.damageMultiplier);
                npc.alpha      = 255;
                if (npc.ai[1] == 0f && (npc.type == 574 || npc.type == 575))
                {
                    for (int k = 0; k < 4; k++)
                    {
                        int num21 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 31, 0f, 0f, 100, default(Color), 1.5f);
                        Main.dust[num21].position = npc.Center + (Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)npc.width / 2f);
                    }
                    for (int l = 0; l < 20; l++)
                    {
                        int num22 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 6, 0f, 0f, 200, default(Color), 3.7f);
                        Main.dust[num22].position  = npc.Center + (Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)npc.width / 2f);
                        Main.dust[num22].noGravity = true;
                        Main.dust[num22].velocity *= 3f;
                        num22 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 6, 0f, 0f, 100, default(Color), 1.5f);
                        Main.dust[num22].position  = npc.Center + (Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)npc.width / 4f);
                        Main.dust[num22].velocity *= 2f;
                        Main.dust[num22].noGravity = true;
                        Main.dust[num22].fadeIn    = 2.5f;
                    }
                    for (int m = 0; m < 6; m++)
                    {
                        int num23 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 6, 0f, 0f, 0, default(Color), 2.7f);
                        Main.dust[num23].position  = npc.Center + (Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy((double)npc.velocity.ToRotation(), default(Vector2)) * (float)npc.width / 2f);
                        Main.dust[num23].noGravity = true;
                        Main.dust[num23].velocity *= 3f;
                    }
                    for (int n = 0; n < 12; n++)
                    {
                        int num24 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 31, 0f, 0f, 0, default(Color), 1.5f);
                        Main.dust[num24].position  = npc.Center + (Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy((double)npc.velocity.ToRotation(), default(Vector2)) * (float)npc.width / 2f);
                        Main.dust[num24].noGravity = true;
                        Main.dust[num24].velocity *= 3f;
                    }
                    for (int num25 = 0; num25 < 5; num25++)
                    {
                        int num26 = Gore.NewGore(npc.position + new Vector2((float)(npc.width * Main.rand.Next(100)) / 100f, (float)(npc.height * Main.rand.Next(100)) / 100f) - (Vector2.One * 10f), default(Vector2), Main.rand.Next(61, 64), 1f);
                        Main.gore[num26].position  = npc.Center + (Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)npc.width / 2f);
                        Main.gore[num26].velocity *= 0.3f;
                        Gore expr_128A_cp_0 = Main.gore[num26];
                        expr_128A_cp_0.velocity.X = expr_128A_cp_0.velocity.X + ((float)Main.rand.Next(-10, 11) * 0.05f);
                        Gore expr_12B8_cp_0 = Main.gore[num26];
                        expr_12B8_cp_0.velocity.Y = expr_12B8_cp_0.velocity.Y + ((float)Main.rand.Next(-10, 11) * 0.05f);
                    }
                }
                npc.ai[1] += 1f;
                if (npc.ai[1] >= 3f)
                {
                    Main.PlaySound(SoundID.Item14, npc.position);
                    npc.life = 0;
                    npc.HitEffect(0, 10.0);
                    npc.active = false;
                }
            }
        }
        public virtual string GetProperty(string strPropertyName, string strFormat, System.Globalization.CultureInfo formatProvider, DotNetNuke.Entities.Users.UserInfo accessingUser, DotNetNuke.Services.Tokens.Scope accessLevel, ref bool propertyNotFound)
        {
            switch (strPropertyName.ToLower())
            {
            case "sessionid": // Int
                return(SessionId.ToString(strFormat, formatProvider));

            case "conferenceid": // Int
                return(ConferenceId.ToString(strFormat, formatProvider));

            case "locationid": // Int
                if (LocationId == null)
                {
                    return("");
                }
                ;
                return(((int)LocationId).ToString(strFormat, formatProvider));

            case "level": // NVarChar
                if (Level == null)
                {
                    return("");
                }
                ;
                return(PropertyAccess.FormatString(Level, strFormat));

            case "sort": // Int
                if (Sort == null)
                {
                    return("");
                }
                ;
                return(((int)Sort).ToString(strFormat, formatProvider));

            case "capacity": // Int
                if (Capacity == null)
                {
                    return("");
                }
                ;
                return(((int)Capacity).ToString(strFormat, formatProvider));

            case "slotid": // Int
                return(SlotId.ToString(strFormat, formatProvider));

            case "title": // NVarChar
                if (Title == null)
                {
                    return("");
                }
                ;
                return(PropertyAccess.FormatString(Title, strFormat));

            case "subtitle": // NVarChar
                if (SubTitle == null)
                {
                    return("");
                }
                ;
                return(PropertyAccess.FormatString(SubTitle, strFormat));

            case "description": // NVarCharMax
                if (Description == null)
                {
                    return("");
                }
                ;
                return(PropertyAccess.FormatString(Description, strFormat));

            case "status": // Int
                if (Status == null)
                {
                    return("");
                }
                ;
                return(((int)Status).ToString(strFormat, formatProvider));

            case "isplenary": // Bit
                return(IsPlenary.ToString());

            case "daynr": // Int
                return(DayNr.ToString(strFormat, formatProvider));

            case "notes": // NVarCharMax
                if (Notes == null)
                {
                    return("");
                }
                ;
                return(PropertyAccess.FormatString(Notes, strFormat));

            case "trackid": // Int
                if (TrackId == null)
                {
                    return("");
                }
                ;
                return(((int)TrackId).ToString(strFormat, formatProvider));

            default:
                propertyNotFound = true;
                break;
            }

            return(Null.NullString);
        }
示例#29
0
 public static ActiveSound GetActiveSound(SlotId id)
 {
     return(null);
 }
示例#30
0
 public Slot(SlotId id, ParticipantId participantId = null)
 {
     Id            = id;
     ParticipantId = participantId;
 }