示例#1
0
    public static WeaponType NewWeaponTypeFromSlots(Slot[] slots)
    {
        List <Slot> slotsList = new List <Slot>(slots);

        slotsList.RemoveAll(slot => slot == Slot.Empty);
        slotsList.Sort();

        WeaponType normalType       = StaticData.WeaponData.WeaponTypes[NORMAL_ID];
        int        spreadId         = NORMAL_ID;
        int        spreadMultiplier = 1;
        int        bombId           = NORMAL_ID;
        int        bombMultiplier   = 1;
        int        bounceId         = NORMAL_ID;
        int        bounceMultiplier = 1;
        int        laserId          = NORMAL_ID;
        int        laserMultiplier  = 1;

        foreach (Slot slot in slotsList)
        {
            switch (slot)
            {
            default:
                break;

            case Slot.Spreadshot:
                spreadId         += spreadMultiplier * (int)slot;
                spreadMultiplier *= 10;
                break;

            case Slot.Bomb:
                bombId         += bombMultiplier * (int)slot;
                bombMultiplier *= 10;
                break;

            case Slot.Bounce:
                bounceId         += bounceMultiplier * (int)slot;
                bounceMultiplier *= 10;
                break;

            case Slot.Laser:
                laserId         += laserMultiplier * (int)slot;
                laserMultiplier *= 10;
                break;
            }
        }

        WeaponType newType    = (WeaponType)normalType.Clone();
        WeaponType spreadType = StaticData.WeaponData.WeaponTypes[spreadId];
        WeaponType bombType   = StaticData.WeaponData.WeaponTypes[bombId];
        WeaponType bounceType = StaticData.WeaponData.WeaponTypes[bounceId];
        WeaponType laserType  = StaticData.WeaponData.WeaponTypes[laserId];

        newType.ShotCount               = spreadType.ShotCount;
        newType.SpecialEffect           = bombType.SpecialEffect;
        newType.SpecialEffectParameter1 = bombType.SpecialEffectParameter1;
        newType.SpecialEffectParameter2 = bombType.SpecialEffectParameter2;
        newType.ShotSpeed               = bombType.ShotSpeed;
        newType.VelocityFallOff         = bombType.VelocityFallOff;
        newType.ShotCooldown            = bombType.ShotCooldown;
        newType.DurationTime            = bombType.DurationTime;
        newType.Knockback               = bombType.Knockback;
        newType.MaximumBounces          = bounceType.MaximumBounces;
        newType.MinimumBounceAngle      = bounceType.MinimumBounceAngle;
        newType.TravelType              = laserType.TravelType;
        newType.TravelTypeParameter     = laserType.TravelTypeParameter;

        if (newType.TravelType == WeaponType.TRAVEL_TYPE_LASER)
        {
            newType.ShotSpeed                = laserType.ShotSpeed;
            newType.VelocityFallOff          = laserType.VelocityFallOff;
            newType.ShotCooldown             = laserType.ShotCooldown;
            newType.DurationTime             = laserType.DurationTime;
            newType.HitInvincibilityDuration = laserType.HitInvincibilityDuration;
            newType.Knockback                = laserType.Knockback;
            newType.AudioIndex               = laserType.AudioIndex;
            newType.AudioCooldown            = laserType.AudioCooldown;
        }

        return(newType);
    }