示例#1
0
    private void configureSprite(WeaponData.Slot slot)
    {
        switch (slot)
        {
        default:
        case WeaponData.Slot.Empty:
            SlotContentsObject.sprite = this.EmptySlotSprite;
            break;

        case WeaponData.Slot.Bounce:
            SlotContentsObject.sprite = this.BounceSlotSprite;
            break;

        case WeaponData.Slot.Spreadshot:
            SlotContentsObject.sprite = this.SpreadshotSlotSprite;
            break;

        case WeaponData.Slot.Laser:
            SlotContentsObject.sprite = this.LaserSlotSprite;
            break;

        case WeaponData.Slot.Bomb:
            SlotContentsObject.sprite = this.BombSlotSprite;
            break;
        }
    }
示例#2
0
    private void pickupWeaponSlot(WeaponData.Slot slotType)
    {
        int count = 0;

        foreach (ProgressData.SlotWrapper slot in this.Slots)
        {
            if (slot.SlotType == slotType)
            {
                ++count;
            }
        }

        if (count < WeaponData.GetMaxSlotsByType()[slotType])
        {
            this.Slots.Add(new ProgressData.SlotWrapper(slotType));
        }
        else
        {
            int shots      = WeaponData.GetSlotDurationsByType()[slotType];
            int shotsToAdd = shots;

            for (int i = this.Slots.Count - 1; i >= 0; --i)
            {
                ProgressData.SlotWrapper slot = this.Slots[i];
                if (slot.SlotType == slotType)
                {
                    slot.AmmoRemaining += shotsToAdd;
                    if (slot.AmmoRemaining > shots)
                    {
                        shotsToAdd         = slot.AmmoRemaining - shots;
                        slot.AmmoRemaining = shots;
                    }
                    else
                    {
                        break;
                    }
                }
            }
        }

        /*bool found = false;
         * for (int i = 0; i < this.Slots.Length; ++i)
         * {
         *  if (this.Slots[i] == WeaponData.Slot.Empty)
         *  {
         *      found = true;
         *      this.Slots[i] = slotType;
         *      _selectedSlot = i + 1 >= this.Slots.Length ? 0 : i + 1;
         *      break;
         *  }
         * }
         * if (!found)
         * {
         *  this.Slots[_selectedSlot] = slotType;
         *  _selectedSlot = _selectedSlot + 1 >= this.Slots.Length ? 0 : _selectedSlot + 1;
         * }*/

        updateSlots();
    }
示例#3
0
 public WeaponData.Slot[] GetRawSlots()
 {
     WeaponData.Slot[] slots = new WeaponData.Slot[this.Slots.Count];
     for (int i = 0; i < this.Slots.Count; ++i)
     {
         slots[i] = this.Slots[i].SlotType;
     }
     return(slots);
 }
示例#4
0
    private void updateSlotHelper(WeaponData.Slot slotType, int ammoRemaining, int weaponLevel)
    {
        configureSprite(slotType);

        if (slotType != WeaponData.Slot.Empty)
        {
            SlotObject.sprite = this.UnlockedSlotSprite;

            if (this.BaseAmmo != null && !this.BaseAmmo.activeInHierarchy)
            {
                this.BaseAmmo.SetActive(true);
            }
            if (this.AmmoBar != null)
            {
                this.AmmoBar.UpdateLength(ammoRemaining, WeaponData.GetSlotDurationsByType()[slotType]);
            }

            if (this.TierText != null)
            {
                if (weaponLevel == WeaponData.GetMaxSlotsByType()[slotType])
                {
                    this.TierText.text = "MAX";
                }
                else
                {
                    this.TierText.text = "Lv." + weaponLevel;
                }
            }
        }
        else
        {
            if (this.AmmoBar != null)
            {
                this.AmmoBar.EmptyCompletely();
            }
            if (this.BaseAmmo != null)
            {
                this.BaseAmmo.SetActive(false);
            }
            if (this.TierText != null)
            {
                this.TierText.text = "";
            }
            SlotObject.sprite = this.LockedSlotSprite;
        }
    }
示例#5
0
    public static void PickupSlot(int playerIndex, WeaponData.Slot slotType)
    {
        int count = 0;

        List <ProgressData.SlotWrapper> slots = new List <ProgressData.SlotWrapper>(WeaponSlotsByPlayer[playerIndex]);

        foreach (ProgressData.SlotWrapper slot in slots)
        {
            if (slot.SlotType == slotType)
            {
                ++count;
            }
        }

        if (count < WeaponData.GetMaxSlotsByType()[slotType])
        {
            slots.Add(new ProgressData.SlotWrapper(slotType));
        }
        else
        {
            int shots      = WeaponData.GetSlotDurationsByType()[slotType];
            int shotsToAdd = shots;

            for (int i = slots.Count - 1; i >= 0; --i)
            {
                ProgressData.SlotWrapper slot = slots[i];
                if (slot.SlotType == slotType)
                {
                    slot.AmmoRemaining += shotsToAdd;
                    if (slot.AmmoRemaining > shots)
                    {
                        shotsToAdd         = slot.AmmoRemaining - shots;
                        slot.AmmoRemaining = shots;
                    }
                    else
                    {
                        break;
                    }
                }
            }
        }

        UpdatePlayerSlots(playerIndex, slots.ToArray());
    }
示例#6
0
 public void OnCollide(LocalEventNotifier.Event localEvent)
 {
     foreach (GameObject hit in ((CollisionEvent)localEvent).Hits)
     {
         if (((1 << hit.layer) & this.PickupLayer) != 0)
         {
             WeaponPickup pickup = hit.GetComponent <WeaponPickup>();
             if (pickup != null)
             {
                 if (pickup.PickupContents.Type == WeaponPickup.PickupType.WeaponSlot)
                 {
                     WeaponData.Slot          slotType   = (WeaponData.Slot)pickup.PickupContents.Parameter;
                     ProgressData.SmartSlot[] smartSlots = ProgressData.SmartSlotsFromWrappers(this.Slots.ToArray());
                     bool ok = true;
                     for (int i = 0; i < smartSlots.Length; ++i)
                     {
                         if (smartSlots[i].SlotType == slotType)
                         {
                             ok = smartSlots[i].Level < WeaponData.GetMaxSlotsByType()[slotType] || smartSlots[i].Ammo < WeaponData.GetSlotDurationsByType()[slotType];
                             break;
                         }
                     }
                     if (ok)
                     {
                         pickupWeaponSlot(slotType);
                         Destroy(hit);
                     }
                 }
                 else
                 {
                     if (_damagable.Health < ProgressData.MAX_HEALTH)
                     {
                         _damagable.Heal(pickup.PickupContents.Parameter);
                         Destroy(hit);
                     }
                 }
             }
         }
     }
 }
示例#7
0
    public static SmartSlot GetSmartSlot(SlotWrapper[] slots, int slotId)
    {
        bool[] weaponTypesFound = { false, false, false, false };
        int[]  ammoRemaining    = { 0, 0, 0, 0 };
        int[]  weaponLevel      = { 0, 0, 0, 0 };
        int    numTypesFound    = 0;

        WeaponData.Slot chosenSlotType    = WeaponData.Slot.Empty;
        int             chosenWeaponIndex = -1;

        for (int i = 0; i < slots.Length; ++i)
        {
            if (slots[i].SlotType == WeaponData.Slot.Empty)
            {
                continue;
            }
            int weaponIndex = (int)slots[i].SlotType - 1;
            ++weaponLevel[weaponIndex];
            if (chosenSlotType == WeaponData.Slot.Empty && !weaponTypesFound[weaponIndex])
            {
                ++numTypesFound;
                weaponTypesFound[weaponIndex] = true;
                ammoRemaining[weaponIndex]    = slots[i].AmmoRemaining;

                if (numTypesFound > slotId)
                {
                    chosenSlotType    = slots[i].SlotType;
                    chosenWeaponIndex = weaponIndex;
                }
            }
        }

        int ammo  = chosenSlotType != WeaponData.Slot.Empty ? ammoRemaining[chosenWeaponIndex] : 0;
        int level = chosenSlotType != WeaponData.Slot.Empty ? weaponLevel[chosenWeaponIndex] : 0;

        return(new SmartSlot(chosenSlotType, ammo, level));
    }
示例#8
0
 public SlotWrapper(SlotWrapper other)
 {
     this.SlotType = other.SlotType;
     this.AmmoRemaining = other.AmmoRemaining;
 }
示例#9
0
 public SlotWrapper(WeaponData.Slot slotType)
 {
     this.SlotType = slotType;
     this.AmmoRemaining = WeaponData.GetSlotDurationsByType()[slotType];
 }
示例#10
0
 public SlotWrapper()
 {
     this.SlotType = WeaponData.Slot.Empty;
     this.AmmoRemaining = 0;
 }
示例#11
0
 public SmartSlot(WeaponData.Slot slotType, int ammo, int level)
 {
     this.SlotType = slotType;
     this.Ammo = ammo;
     this.Level = level;
 }
示例#12
0
 public WeaponData.Slot[] GetRawSlots()
 {
     WeaponData.Slot[] slots = new WeaponData.Slot[this.Slots.Count];
     for (int i = 0; i < this.Slots.Count; ++i)
         slots[i] = this.Slots[i].SlotType;
     return slots;
 }
示例#13
0
 public SlotWrapper(SlotWrapper other)
 {
     this.SlotType      = other.SlotType;
     this.AmmoRemaining = other.AmmoRemaining;
 }
示例#14
0
 public SlotWrapper(WeaponData.Slot slotType)
 {
     this.SlotType      = slotType;
     this.AmmoRemaining = WeaponData.GetSlotDurationsByType()[slotType];
 }
示例#15
0
 public SlotWrapper()
 {
     this.SlotType      = WeaponData.Slot.Empty;
     this.AmmoRemaining = 0;
 }
示例#16
0
 public SmartSlot(WeaponData.Slot slotType, int ammo, int level)
 {
     this.SlotType = slotType;
     this.Ammo     = ammo;
     this.Level    = level;
 }