コード例 #1
0
        //Deal damages to the destructible, if it reaches 0 HP it will be killed
        private void ApplyDamage(int damage)
        {
            if (!dead)
            {
                int adamage = Mathf.Max(damage - armor, 1);
                hp -= adamage;

                PlayerData.Get().SetCustomValue(GetHpUID(), hp);

                if (shake_on_hit)
                {
                    ShakeFX();
                }

                if (select.IsActive() && select.IsNearCamera(20f))
                {
                    if (hit_fx != null)
                    {
                        Instantiate(hit_fx, transform.position, Quaternion.identity);
                    }

                    TheAudio.Get().PlaySFX("destruct", hit_sound);
                }

                onDamaged?.Invoke();
            }
        }
コード例 #2
0
        void Update()
        {
            if (TheGame.Get().IsPaused())
            {
                return;
            }

            if (was_spawned && selectable.IsActive())
            {
                PlayerData      pdata        = PlayerData.Get();
                DroppedItemData dropped_item = pdata.GetDroppedItem(GetUID());
                if (dropped_item != null)
                {
                    if (data.HasDurability() && dropped_item.durability <= 0f)
                    {
                        DestroyItem(); //Destroy item from durability
                    }
                }
            }

            if (auto_collect_range > 0.1f)
            {
                PlayerCharacter player = PlayerCharacter.GetNearest(transform.position, auto_collect_range);
                if (player != null)
                {
                    player.Inventory.AutoTakeItem(this);
                }
            }
        }
コード例 #3
0
        void Update()
        {
            if (select && !select.IsActive())
            {
                return;
            }

            timer += Time.deltaTime;

            if (timer > refresh_rate)
            {
                timer = 0f;
                UpdateSlow();
            }
        }
コード例 #4
0
        void Update()
        {
            if (target == null)
            {
                Destroy(gameObject);
                return;
            }

            if (icon_group.activeSelf)
            {
                icon_group.SetActive(false);
            }

            if (!target.IsActive())
            {
                return;
            }

            transform.position = target.transform.position;
            transform.rotation = Quaternion.LookRotation(TheCamera.Get().transform.forward, Vector3.up);

            ItemSlot selected = ItemSlotPanel.GetSelectedSlotInAllPanels();

            if (selected != null && selected.GetItem() != null)
            {
                MAction action = selected.GetItem().FindMergeAction(target);
                foreach (PlayerCharacter player in PlayerCharacter.GetAll())
                {
                    if (player != null && action != null && action.CanDoAction(player, selected, target))
                    {
                        icon.sprite = selected.GetItem().icon;
                        title.text  = action.title;
                        icon_group.SetActive(true);
                    }
                }
            }
        }