Esempio n. 1
0
    void OnTriggerEnter(Collider collider)
    {
        if (dying)
        {
            return;
        }
        IPickup pickup = collider.GetComponent <IPickup>();

        if (pickup != null)
        {
            pickup.AddPoints(ScoreConstants.EnemyKill);

            Collider[] colliders = GetComponentsInChildren <Collider>();
            for (int i = 0; i < colliders.Length; i++)
            {
                colliders[i].enabled = false;
            }


            animator.SetTrigger("die");
            dyingAudio.Play();

            GameObject.Destroy(this.gameObject, 1f);
            dying = true;
        }
    }
    public void Drop()
    {
        Vector3 vel = myTransform.GetComponent <Rigidbody>().velocity;

        pickup.Drop(vel);
        pickup = null;
    }
Esempio n. 3
0
    private void AddPickups()
    {
        if (pickups.Count == 0)
        {
            return;
        }
        float totalLootValue = lootValue * levelIndexMultiplier;
        int   iterations     = 9999;

        while (totalLootValue > 0 && iterations > 0)
        {
            iterations--;
            pickups = RandomUtil.ShuffleHostList(pickups.Cast <IGeneratedHostInhabitant>().ToList()).Cast <IPickup>().ToList();
            IPickup pickup = pickups.Find(p => p.GetLootValue() <= totalLootValue);
            if (pickup == null)
            {
                break;
            }
            if (!GetSpawnDirectory(out Directory directory, pickup as IGeneratedHostInhabitant))
            {
                continue;
            }
            PickupHandler.I.CreatePickup(directory.transform, pickup);
            totalLootValue -= pickup.GetLootValue();
        }
    }
Esempio n. 4
0
    public PickupEntity CreatePickup(Transform parent, IPickup pickup, bool invulnerable = false)
    {
        PickupEntity result = Instantiate(pickupEntityPrefab, parent) as PickupEntity;

        result.Init(pickup);
        return(result);
    }
Esempio n. 5
0
    void OnInteract(InputValue value)
    {
        var v = value.Get <float>();

        var newpress = v > 0.1f;

        if (newpress && newpress != press)
        {
            if (holdingItem != null)
            {
                var sewingtablehit = Physics2D.OverlapCircle(transform.position + new Vector3(0, 0.5f), 0.5f, SewingTableMask);

                if (sewingtablehit != null)
                {
                    var sewingTable = sewingtablehit.GetComponent <SewingTable>();
                    sewingTable.AddSewingKit();
                    Destroy(holdingItem.GetGameObject());
                    holdingItem = null;
                }
                else
                {
                    holdingItem.LetGo();
                    holdingItem = null;
                    goto finish;
                }
            }
        }

        var hitcol = Physics2D.OverlapCircle(transform.position + new Vector3(0, 0.5f), 0.5f, InteractableMask);

        if (hitcol != null && hitcol.TryGetComponent(out Interactable s))
        {
            if (newpress != press)
            {
                if (newpress)
                {
                    if (s is IPickup pickup)
                    {
                        pickup.Pickup(this);
                        holdingItem = pickup;
                    }
                    else
                    {
                        s.PressDown();
                        interactable = s;
                    }
                }
                else
                {
                    s.PressUp();
                    interactable = null;
                }
            }
        }

finish:

        press = newpress;
    }
Esempio n. 6
0
        public IPickup CreatePickup(ulong model, Vector position)
        {
            IPickup pickup = Wrapper.Server.PickupPool.GetEntity(Wrapper.ExecuteLua("COW_CreatePickup",
                                                                                    new { model, x = position.X, y = position.Y, z = position.Z }).Value <long>("pickup"));

            pickup.SetDimension(ID);
            return(pickup);
        }
Esempio n. 7
0
 public void DropItem()
 {
     if (holdingItem != null)
     {
         holdingItem.LetGo();
         holdingItem = null;
     }
 }
Esempio n. 8
0
 public void Init(IPickup pickup)
 {
     name = $"{pickup.GetComponentId()["name"]}.{pickup.GetComponentId()["pickupType"]}";
     pickupDescription = pickup.GetShortDescription();
     pickupType        = pickup.GetPickupType();
     ReflectionUtil.GetStoredObject(out StoredObject lootObject, pickup, pickup.GetComponentId());
     loot = lootObject;
 }
Esempio n. 9
0
        private void OnCollisionEnter2D(Collision2D collision)
        {
            IPickup pickup = collision.rigidbody?.GetComponent <IPickup>();

            if (pickup != null)
            {
                m_starCollector.Collect(pickup);
            }
        }
Esempio n. 10
0
    public void OnCollisionEnter(Collision collision)
    {
        IPickup pickup = collision.collider.GetComponent <IPickup>();

        if (pickup != null)
        {
            pickup.OnPickup(this);
        }
    }
Esempio n. 11
0
    private void OnTriggerEnter(Collider other)
    {
        IPickup pickup = other.GetComponent <IPickup>();

        if (pickup != null)
        {
            pickup.Pickup(); //Do something when you hit the object
        }
    }
Esempio n. 12
0
        /// <summary>
        /// Factory method to create a PickupFluent. Use instead of new(). Use at the start of the fluent method chain.
        /// </summary>
        /// <param name="pickup"></param>
        /// <returns></returns>
        public static PickupFluent <T> Create(IPickup pickup)
        {
            var a = new PickupFluent <T>
            {
                _pickup = (T)pickup
            };

            return(a);
        }
Esempio n. 13
0
        public void Pickup(IItem item)
        {
            IPickup itemPickup = item.GetPickup();
            bool    win        = itemPickup.Pickup(this);

            if (win)
            {
                game.SetState(game.WIN);
            }
        }
Esempio n. 14
0
 // Reset Pickup
 private static void ResetPickup()
 {
     if (dirtHair)
     {
         dirtHair        = false;
         tmpPickup       = null;
         prevHitCollider = null;
         crosshairMode   = ECrosshairMode.Point;
         HudElements.Crosshair.SetPointSprite(crosshairMode);
     }
 }
Esempio n. 15
0
    void OnCollisionEnter(Collision collision)
    {
        IPickup pickup = collision.transform.GetComponent <IPickup>();

        if (pickup != null)
        {
            pickup.AddPoints(ScoreConstants.HiddenPowerupScore);
            pickup.AddPowerup(PowerupType.Fireball);
            Destroy(this.gameObject, 0.01f);
        }
    }
Esempio n. 16
0
    void OnCollisionEnter(Collision collision)
    {
        IPickup pickup = collision.collider.GetComponent <IPickup>();

        if (pickup != null)
        {
            pickup.AddPoints(ScoreConstants.PowerupScore);
            pickup.AddPowerup(PowerupType.ExtraHealth);
            GameObject.Destroy(this.gameObject, 0.01f);
        }
    }
Esempio n. 17
0
 public static IPickup GetByCoords <T>(this List <T> list, int x, int y) where T : IPickup
 {
     try
     {
         IPickup temp = list.First(item => item.x == x && item.y == y);
         return(temp);
     }
     catch (Exception)
     {
         throw new KeyNotFoundException("nie znaleziono elementu o danym id");
     }
 }
Esempio n. 18
0
 public void OnTriggerEnter(Collider other)
 {
     if (other.CompareTag("Pickup"))
     {
         if (_pickup == null)
         {
             _pickup = other.GetComponent <PickupSpawner>().Pickup();
             _pickup.Use(this);
             _pickup = null;
         }
     }
 }
Esempio n. 19
0
        public static IPickup GetById <T>(this List <T> list, int id) where T : IPickup
        {
            try
            {
                IPickup temp = list.First(item => item.id == id);
                return(temp);
            }

            catch (Exception)
            {
                throw new KeyNotFoundException("nie znaleziono elementu o danym id");
            }
        }
Esempio n. 20
0
 public void CollectPickup(IPickup pickup)
 {
     if (pickup.Type == Pickup.PickupType.Experience)
     {
         polarStar.CollectExpereince(pickup.Value);
         experienceText.Value = pickup.Value;
         gunExperienceHud.ActivateFlash();
     }
     else if (pickup.Type == Pickup.PickupType.Health)
     {
         playerHealth.health.AddHealth(pickup.Value);
     }
 }
Esempio n. 21
0
 /// <summary>
 /// Validation method for IPickup
 /// </summary>
 /// <param name="p">IPickup object</param>
 /// <returns></returns>
 public static bool IsValid(this IPickup p)
 {
     if (p.PickupAddress == null)
     {
         return(false);
     }
     if (p.PackageLocation == PackageLocation.Other)
     {
         if (p.SpecialInstructions == null || p.SpecialInstructions == string.Empty)
         {
             return(false);
         }
     }
     return(true);
 }
Esempio n. 22
0
        private static bool CheckValidMove(int X, int Y, List <Key> ownedKeys, List <Key> keys, List <Door> doors, List <Coin> coins, ref object CoinLock,
                                           ref int points, List <LinkedList <IField> > readmap)
        {
            if (PickUps.PickUpCoin(X, Y, coins, ref CoinLock) == 1)
            {
                ++points;

                lock (CoinLock)
                {
                    Console.ForegroundColor = ConsoleColor.White;
                    Cursor.WriteString(readmap[0].Count + 11, 1, points.ToString());
                }
            }
            else
            {
                IPickup mapKey = PickUps.PickupKey(X, Y, keys);
                if (mapKey != null)
                {
                    ownedKeys.Add(mapKey as Key);

                    lock (CoinLock)
                    {
                        Console.ForegroundColor = ConsoleColor.White;
                        Cursor.WriteString(readmap[0].Count + 11, 2, ownedKeys.Count.ToString());
                    }
                }
                else
                {
                    bool status = PickUps.unlockTheDoor(X, Y, doors, ownedKeys);
                    if (status == true)
                    {
                        return(false);
                    }
                    else
                    {
                        lock (CoinLock)
                        {
                            Console.ForegroundColor = ConsoleColor.White;
                            Cursor.WriteString(readmap[0].Count + 11, 2, ownedKeys.Count.ToString() + " ");
                        }
                    }
                }
            }

            return(true);
        }
        private void Start()
        {
            _inventory = new InventoryModule();
            _pickuper  = new PickupModule();

            _inventoryUI = new PlayerInventoryUIModule(
                _player,
                _inventory.InventoryReadonly);

            _mover = new PlayerMoveModule(
                _player,
                _inventory.InventoryReadonly);

            _bulletLanuncher = new PlayerBulletLauncher(
                _player,
                _inventory.InventoryReadonly,
                _player.BulletLauncherTransform);
        }
Esempio n. 24
0
    public void CreatePickups(ILootDropper lootDropper)
    {
        List <IPickup> possiblePickups       = lootDropper.GetPickups();
        float          currentLootValueTotal = lootDropper.GetChallengeRating() * HostHandler.I.currentHost.lootValueMultiplier;
        bool           canAfford             = true;

        while (canAfford)
        {
            canAfford = false;
            if (possiblePickups.Count == 0)
            {
                continue;
            }
            IPickup pickup = possiblePickups[UnityEngine.Random.Range(0, possiblePickups.Count)];
            if (pickup.GetLootValue() > currentLootValueTotal)
            {
                continue;
            }
            canAfford              = true;
            currentLootValueTotal -= pickup.GetLootValue();
            possiblePickups.Remove(pickup);
            CreatePickup(lootDropper.GetTransform().parent, pickup);
        }
    }
    private void OnTriggerEnter(Collider other)
    {
        // Already holding something
        if (pickup != null)
        {
            return;
        }

        IPickup otherPickup = other.GetComponent <IPickup>();

        if (otherPickup == null)
        {
            otherPickup = other.GetComponentInParent <IPickup>();
        }

        if (otherPickup != null && otherPickup != lastPickup)
        {
            // Attempt Pickup
            if (otherPickup.Pickup(this))
            {
                pickup = otherPickup;
            }
        }
    }
Esempio n. 26
0
 public void CollectPickup(IPickup pickup)
 {
     if (pickup.Type == Pickup.PickupType.Experience)
     {
         polarStar.CollectExpereince(pickup.Value);
         experienceText.Value = pickup.Value;
         gunExperienceHud.ActivateFlash();
     }
     else if (pickup.Type == Pickup.PickupType.Health)
     {
         playerHealth.health.AddHealth(pickup.Value);
     }
 }
Esempio n. 27
0
 private PickupFluent(IPickup p)
 {
     _pickup = (T)p;
 }
Esempio n. 28
0
 public void Add(IPickup pickup)
 {
     pickups.Add(pickup);
 }
Esempio n. 29
0
 public void Add(IPickup pickup)
 {
     pickups.Add(pickup);
 }
Esempio n. 30
0
        // Pickup Activity
        private static void PickupActivity()
        {
            if (inputUse)
            {
                if (checkPickup)
                {
                    tmpPickup.PickupItem();
                }

                inputUse = false;
                ResetPickup();
            }
            else
            {
                if (hitCollider != prevHitCollider || tmpPickup == null)
                {
                    tmpPickup = hitCollider.GetComponent <IPickup>();
                    HudElements.Crosshair.SetColor(ECrosshairColor.Normal);
                }

                if (!checkPickup)
                {
                    return;
                }

                switch (tmpPickup.PickupType)
                {
                case EPickupType.Melee:
                case EPickupType.Firearms:
                case EPickupType.Thrown:
                    if (WeaponsManager.WeaponIsAvailable(tmpPickup.WeaponIndex))
                    {
                        if ((tmpPickup.PickupType != EPickupType.Melee) && (tmpPickup.Amount > 0) && !AmmoBackpack.IsFull(tmpPickup.AmmoIndex))
                        {
                            crosshairMode = ECrosshairMode.Ammo;
                        }
                        else
                        {
                            crosshairMode = ECrosshairMode.Cancel;
                        }
                    }
                    else if (WeaponsManager.WeaponTypeIsStandart(tmpPickup.WeaponIndex) && WeaponsManager.crowded)
                    {
                        crosshairMode = ECrosshairMode.Swap;
                    }
                    else
                    {
                        crosshairMode = ECrosshairMode.Hand;
                    }
                    break;

                case EPickupType.Ammo:
                    if (AmmoBackpack.IsFull(tmpPickup.AmmoIndex))
                    {
                        crosshairMode = ECrosshairMode.Cancel;
                    }
                    else
                    {
                        crosshairMode = ECrosshairMode.Ammo;
                    }
                    break;

                case EPickupType.Health:
                    if (PlayerCharacter.Instance.isFull)
                    {
                        crosshairMode = ECrosshairMode.Cancel;
                    }
                    else
                    {
                        crosshairMode = ECrosshairMode.Health;
                    }
                    break;

                default:
                    crosshairMode = ECrosshairMode.Hand;
                    break;
                }

                //crosshairMode
                HudElements.Crosshair.SetPointSprite(crosshairMode);
            }
        }
Esempio n. 31
0
 void ICollector.Collect(IPickup pickupItem)
 {
     pickupItem.Acquire();
 }
Esempio n. 32
0
 public void InitPickup(IPickup pickup)
 {
 }