예제 #1
0
 private void TryUnload()
 {
     if (!string.IsNullOrEmpty(EquippedWeapon) && BulletType != AmmoType.NoAmmo)
     {
         if (BulletsInMagazine > 0)
         {
             GameState.Instance.Player.AddItem(BulletType.ToString(), BulletsInMagazine);
             BulletsInMagazine = 0;
         }
     }
 }
예제 #2
0
    private void DisplayAmmo()
    {
        int currentAmmo = ammoSlot.GetCurrentAmmo(ammoType);

        ammoCount.text = currentAmmo.ToString();
        ammoKind.text  = ammoType.ToString();
    }
예제 #3
0
 public void PickupAmmo(Collider c)
 {
     if (c.tag == "Player")
     {
         //print(ammoType.ToString());
         c.GetComponent(ammoType.ToString()).SendMessage("AddAmmo", Quantity);
     }
 }
예제 #4
0
        public override void Attached()
        {
            if (entity.IsOwner)
            {
                state.AmmoType   = ammoType.ToString();
                state.AmmoAmount = amount;
            }

            state.AddCallback("AmmoAmount", VisualizeAmount);
        }
예제 #5
0
    public int GetAmmo(AmmoType ammoType)
    {
        AmmoConfig conf;

        if (ammoDict.TryGetValue(ammoType, out conf))
        {
            return(conf.currentAmmo);
        }
        Debug.LogError("Ammo Type Not Listed: " + ammoType.ToString());
        return(0);
    }
예제 #6
0
 public void SetSelected(AmmoType ammoType)
 {
     if (ammoData.TryGetValue(ammoType, out activeAmmo))
     {
         updateUIInfo(activeAmmo);
     }
     else
     {
         Debug.LogWarning("Item Type does not exists in the manager [" + ammoType.ToString() + "]");
     }
 }
예제 #7
0
    IEnumerator SendAmmoBuyToServer(AmmoType ammoType, int cost)
    {
        yield return(StartCoroutine(OnlineManager.Instance.StartBuyAmmo(ammoType.ToString().ToLower())));

        if (OnlineManager.Instance.ResponseData.Success)
        {
            Avatar.Instance.Spend(cost, 0);
            Avatar.Instance.AddAmmo(ammoType);
            AmmoBeltView.Instance.SetAmmo(_index, ammoType);
        }
        LoadingAlert.FinishLoading();
    }
예제 #8
0
 /// <summary>
 /// Taking away certain type ammo from container
 /// </summary>
 /// <param name="type">Ammunition type</param>
 /// <param name="amount">How many take</param>
 /// <returns></returns>
 public override bool GetAmmo(AmmoType type, int amount)
 {
     print($"TYPE: {type.ToString()}");
     if (Ammo[type] >= amount)
     {
         Ammo[type]      -= amount;
         currentCapacity += amount * AmmoSize[type];
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #9
0
    /*
     *  Adding ammo based on type.
     */
    public bool AddAmmo(AmmoType type, int amountToAdd)
    {
        for (int i = 0; i < ammos.Length; i++)
        {
            Ammo a = ammos[i];
            if (a.type == type)
            {
                inventoryUpdated = true;
                return(a.AddAmmo(amountToAdd));
            }
        }

        print($"Cannot add ammo of type {type.ToString()} as it doesn't exist in our inventory!");
        return(false);
    }
예제 #10
0
 void Update()
 {
     if (showStatusText)
     {
         if (isHealth)
         {
             isHealth = false;
             pickupStatusText.text = healthText;
         }
         else
         {
             pickupStatusText.text = "+" + ammoAmount.ToString() + " " + ammoType.ToString();
         }
         ShowStatusText();
     }
 }
예제 #11
0
 public void DrawCustomization(SpriteBatch spriteBatch)
 {
     spriteBatch.Draw(TextureManager.inventorySlot, new Rectangle((int)Camera.Position.X - HUD_W / 2, (int)Camera.TotalOffset.Y + HUD_Y, HUD_W, HUD_H), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, 0.0000005f);
     foreach (CustomizationSlot s in partSlots)
     {
         s.Draw(spriteBatch);
     }
     if (useWeapon != null)
     {
         useWeapon.Draw(spriteBatch, 0.0000003f);
     }
     spriteBatch.DrawString(TextureManager.font, "Using Ammo: " + currentAmmoType.ToString(), Camera.Center - new Vector2(100, 200), Color.Black, 0, Vector2.Zero, 1, SpriteEffects.None, 0.0000004f);
     if (!ContainsType(WeaponPart.PartType.Base))
     {
         spriteBatch.DrawString(TextureManager.font, "Your weapon needs a base!", Camera.Center - new Vector2(175, 220), Color.Red, 0, Vector2.Zero, 1, SpriteEffects.None, 0.0000004f);
     }
 }
예제 #12
0
파일: Weapon.cs 프로젝트: quajak/StartGame
 public RangedWeapon(int AttackDamage, BaseDamageType damageType, int Range, string Name, int Attacks, bool Discardeable, AmmoType ammoType, int AttackCost = 1)
     : base(AttackDamage, BaseAttackType.range, damageType, Range, Name, Attacks, Discardeable, AttackCost)
 {
     AmmoType = ammoType;
     ammo.Add(new Ammo(ammoType, new Buff(BuffType.Absolute, 0), ammoType.ToString(), "", Attacks));
 }
예제 #13
0
 public override string GetStatsString()
 {
     return($"<b>Ranged Weapon ({SkillType})</b>\n" + base.GetStatsString() + $"\nSpeed: {(1 / FireInterval):F1}\nMagazine: {MagazineSize}\nAmmo Type{InventoryModel.GetNiceName(AType.ToString())}");
 }
예제 #14
0
 private void UpdateAmmoText(AmmoType type, string weapon)
 {
     ammoAmountText.text = ammoAmount.RequestAmmoAmount(type).ToString();
     weaponNameText.text = weapon;
     ammoNameText.text   = type.ToString();
 }
예제 #15
0
 public void GiveAmmo(AmmoType type, int amount)
 {
     variableStore.SetInt(type.ToString() + "_count", GetAmmoCount(type) + amount);
 }
예제 #16
0
 public int GetAmmoCount(AmmoType type)
 {
     return(variableStore.GetInt(type.ToString() + "_count"));
 }
예제 #17
0
파일: InkBehaviour.cs 프로젝트: xCISACx/BOP
    // Update is called once per frame
    void Update()
    {
        AmmoNameText.text = ammoType.ToString();

        /*var ammo_type = (int) ammoType;
         *
         * if (ammo_type >= _numberOfAmmoTypes)
         * {
         *      ammo_type = 1;
         * }
         *
         * ammoType = (AmmoType) ammo_type;
         *
         * if(Input.GetKeyDown(KeyCode.L))
         * {
         *      ammoType += 1;
         *      Debug.Log("Ammo type: " + ammoType);
         * }*/


        if (Input.GetKeyDown(KeyCode.J))
        {
            ammoType = AmmoType.Bouncy;
            Debug.Log("Ammo type: " + ammoType);
        }

        if (Input.GetKeyDown(KeyCode.K))
        {
            ammoType = AmmoType.Speedy;
            Debug.Log("Ammo type: " + ammoType);
        }

        if (Input.GetKeyDown(KeyCode.L))
        {
            ammoType = AmmoType.Sticky;
            Debug.Log("Ammo type: " + ammoType);
        }

        if (Input.GetKeyDown(KeyCode.P))
        {
            ammoType = AmmoType.Clear;
            Debug.Log("Ammo type: " + ammoType);
        }

        switch (ammoType)
        {
        case AmmoType.Bouncy:
            ColourIndicator.GetComponent <SpriteRenderer>().color = FB.BouncyColour;
            AmmoNameText.color = FB.BouncyColour;
            break;

        case AmmoType.Speedy:
            //ColourIndicator.GetComponent<SpriteRenderer>().color = new Color(255, 153, 0);
            ColourIndicator.GetComponent <SpriteRenderer>().color = FB.SpeedyColour;
            AmmoNameText.color = FB.SpeedyColour;
            //SPC.playerSpeed = 10;
            break;

        case AmmoType.Sticky:
            //ColourIndicator.GetComponent<SpriteRenderer>().color = new Color(125, 38, 205);
            ColourIndicator.GetComponent <SpriteRenderer>().color = FB.StickyColour;
            AmmoNameText.color = FB.StickyColour;
            //ColourIndicator.GetComponent<SpriteRenderer>().color = new Color32(135, 36, 183, 255);
            break;

        case AmmoType.Clear:
            ColourIndicator.GetComponent <SpriteRenderer>().color = FB.ClearColour;
            AmmoNameText.color = FB.ClearColour;
            break;
        }
    }
예제 #18
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            #region Update HUD with AmmoInfo
            if (this == manager.PrimaryWeapon)
            {
                IHudTextControl control = game.GameStates.Hud.GetControl("weapon1_magazine") as IHudTextControl;
                if (control != null)
                {
                    control.Text = AmmoInMagazine.ToString();
                    if (state == WeaponState.FIRING || state == WeaponState.FIRING_LOOP)
                    {
                        control.Effect = HUDEffectType.PULSE;
                    }
                    else
                    {
                        control.Effect = HUDEffectType.NONE;
                    }
                }


                IHudTextControl control2 = game.GameStates.Hud.GetControl("weapon1_ammo") as IHudTextControl;
                if (control2 != null)
                {
                    control2.Text = ammoType.ToString() + ": " + Ammo.ToString();
                }
            }

            if (this == manager.SecondaryWeapon)  //TODO: Irgendwie updated der das nicht richtig
            {
                IHudTextControl control = game.GameStates.Hud.GetControl("weapon2_magazine") as IHudTextControl;
                if (control != null)
                {
                    control.Text = AmmoInMagazine.ToString();
                    if (state == WeaponState.FIRING || state == WeaponState.FIRING_LOOP)
                    {
                        control.Effect = HUDEffectType.PULSE;
                    }
                    else
                    {
                        control.Effect = HUDEffectType.NONE;
                    }
                }

                IHudTextControl control2 = game.GameStates.Hud.GetControl("weapon2_ammo") as IHudTextControl;
                if (control2 != null)
                {
                    control2.Text = ammoType.ToString() + ": " + Ammo.ToString();
                }
            }
            #endregion

            #region WEAPON_STATE_MACHINE
            switch (state)
            {
            case WeaponState.NOTHING:
                break;

            case WeaponState.AMMO_EMPTY:
                // Stop Firing-Loop Sound if playing
                if (soundFiring != null)
                {
                    soundFiring.Loop = false;
                    soundFiring.Stop();
                    isLooping = false;
                }

                if (isEmpty)
                {
                    if (!WaitFor("AmmoEmpty", TimeSpan.FromMilliseconds(desc.SoundAmmoEmptyMilliseconds)))
                    {
                        break;
                    }
                    else
                    {
                        isEmpty = false;
                    }
                }
                if (!isEmpty)
                {
                    isEmpty = true;
                    ResetWait("AmmoEmpty");
                    // Play AmmoEmpty Sound
                    if (soundAmmoEmpty != null)
                    {
                        soundAmmoEmpty.Play();
                    }
                    OnAmmoEmpty();
                }

                break;

            case WeaponState.RELOADING:
                if (isReloading)
                {
                    if (!WaitFor("Reloading", TimeSpan.FromMilliseconds(desc.SoundReloadMilliseconds)))
                    {
                        break;
                    }
                    else
                    {
                        isReloading = false;
                        if (desc.LoopedFire)
                        {
                            state = WeaponState.FIRING_LOOP;
                        }
                        else
                        {
                            state = WeaponState.FIRING;
                        }
                        OnReload();
                    }
                }
                if (!isReloading)
                {
                    isReloading = true;
                    ResetWait("Reloading");
                    // Play AmmoEmpty Sound
                    if (soundReload != null)
                    {
                        soundReload.Play();
                    }
                }
                // Update player HUD crosshair by ELC
                break;

            case WeaponState.START_FIRE:
                // Update player HUD crosshair by ELC
                if (isStarted)
                {
                    if (!WaitFor("StartFire", TimeSpan.FromMilliseconds(desc.SoundStartMilliseconds)))
                    {
                        break;
                    }
                    else
                    {
                        if (desc.LoopedFire)
                        {
                            state = WeaponState.FIRING_LOOP;
                        }
                        else
                        {
                            state = WeaponState.FIRING;
                        }
                        isStarted = false;
                        OnFireStarted(Vector3.Transform(desc.ProjectileOffset, GlobalTransformation), direction);
                        break;
                    }
                }
                if (!isStarted)
                {
                    isStarted = true;
                    ResetWait("StartFire");
                    // Play StartFire Sound
                    if (soundStartFire != null)
                    {
                        soundStartFire.Play();
                    }
                    OnFireStart(Vector3.Transform(desc.ProjectileOffset, GlobalTransformation), direction);
                }
                break;

            case WeaponState.FIRING_LOOP:
                if (!DescreaseAmmo())
                {
                    break;
                }

                if (!isLooping)
                {
                    // Play Firing-Loop Sound
                    isLooping = true;
                    if (soundFiring != null)
                    {
                        soundFiring.Loop = true;
                    }
                }
                OnFiring(Vector3.Transform(desc.ProjectileOffset, GlobalTransformation), direction);
                state = WeaponState.FIRE_PAUSED;
                break;



            case WeaponState.FIRING:
                if (!DescreaseAmmo())
                {
                    break;
                }

                if (soundFiring != null)
                {
                    soundFiring.Stop();
                    soundFiring.Play();
                }
                OnFiring(Vector3.Transform(desc.ProjectileOffset, GlobalTransformation), direction);
                state = WeaponState.FIRE_PAUSED;
                break;



            case WeaponState.FIRE_PAUSED:
                if (WaitFor("FirePause", TimeSpan.FromMilliseconds(desc.FirePause)))
                {
                    ResetWait("FirePause");
                    if (desc.LoopedFire)
                    {
                        state = WeaponState.FIRING_LOOP;
                    }
                    else
                    {
                        state = WeaponState.FIRING;
                    }
                }

                break;



            case WeaponState.STOP_FIRE:
                isStarted = false;
                if (desc.LoopedFire && isLooping)
                {
                    // Stop Firing-Loop Sound
                    if (soundFiring != null)
                    {
                        soundFiring.Loop = false;
                        soundFiring.Stop();
                    }
                    isLooping = false;
                }

                if (isStopping)
                {
                    if (!WaitFor("StopFire", TimeSpan.FromMilliseconds(desc.SoundStopMilliseconds)))
                    {
                        break;
                    }
                    else
                    {
                        state      = WeaponState.NOTHING;
                        isStopping = false;
                        break;
                    }
                }
                if (!isStopping)
                {
                    isStopping = true;
                    ResetWait("StopFire");
                    //Play StartFire Sound
                    if (soundStopFire != null)
                    {
                        soundStopFire.Play();
                    }
                    OnFireStop(GlobalPosition, direction);
                }
                break;


            default:
                break;
            }
            #endregion
        }
예제 #19
0
    public int bulletCount;   // 40 - 80


    void Start()
    {
        spriteRenderer        = GetComponent <SpriteRenderer>();
        spriteRenderer.sprite = Resources.Load <Sprite>(ammoType.ToString());
    }