Inheritance: MonoBehaviour
Esempio n. 1
0
    //중복체크 X 아이템 삭제할때 땅에 똑같은거 버려주는 용도로 사용
    public void SpawnWeapon(Vector3 posit, WeaponType weaponType, Transform parent = null)
    {
        if (mapManager == null)
        {
            return;
        }
        WeaponType RandomWeapon = weaponType;


        DropItem item = MakeItemPrefab(posit);

        if (item == null)
        {
            return;
        }

        if (parent == null)
        {
            item.transform.parent = mapManager.transform;
        }
        else
        {
            item.transform.parent = parent;
        }

        item.SetItemToWeapon(RandomWeapon);

        if (spawnedObjectList != null)
        {
            spawnedObjectList.Add(item.gameObject);
        }
    }
Esempio n. 2
0
    ///////////////////임시코드



    public void SpawnWeapon(Vector3 posit, bool isSalesItem = false)
    {
        if (mapManager == null)
        {
            return;
        }
        WeaponType RandomWeapon = DatabaseLoader.Instance.GetRandomWeaponTypeByProbability();

        DropItem item = MakeItemPrefab(posit);

        if (item == null)
        {
            return;
        }
        item.transform.parent = mapManager.transform;
        item.SetItemToWeapon(RandomWeapon);

        if (spawnedObjectList != null)
        {
            spawnedObjectList.Add(item.gameObject);
        }

        if (isSalesItem == true)
        {
            item.SetItemToSales();
        }
    }
Esempio n. 3
0
    public void DropNewItem(string itemName)
    {
        GameObject go     = (GameObject)Instantiate(Resources.Load(itemName));
        Vector3    newPos = transform.position;

        newPos.z = go.transform.position.z;
        go.transform.position = newPos;

        DropItem dropItem = go.GetComponent <DropItem>();

        if (!Manager.S.itemPickups)
        {
            if (Manager.S.teamManas [team] >= 1 && dropItem.TryDrop(this))
            {
                Manager.S.teamManas [team] -= 1;
            }
            else
            {
                Destroy(go);
            }
        }
        else if (dropItem.TryDrop(this))
        {
            Destroy(itemIcon);
        }
    }
 /// <inheritdoc />
 public Task<bool> DeleteAsync(DropItem dropItem, bool synchronous, CancellationToken cancellationToken)
 {
     return RetryAsync(
         nameof(IDropServiceClient.DeleteAsync),
         (client, ct) => client.DeleteAsync(dropItem, synchronous, ct),
         cancellationToken);
 }
Esempio n. 5
0
        public static DropItem read(BinaryReader binaryReader)
        {
            DropItem newObj = new DropItem();

            newObj.i_item = binaryReader.ReadUInt32();
            return(newObj);
        }
Esempio n. 6
0
        public bool AddProp(Vector3 position, int dropId, float ex = 1)
        {
            //DropData dropData = Global.gApp.gGameData.GetDropData().Find(l => l.id == dropId);
            DropItem dropData = Global.gApp.gGameData.DropData.Get(dropId);

            if (dropData != null)
            {
                int curRate    = 0;
                int randomRate = Random.Range(0, 10001);
                int index      = 0;
                foreach (int rate in dropData.rate)
                {
                    curRate = curRate + (int)(rate * ex);
                    if (randomRate < curRate)
                    {
                        if (CheckCanAddProp(dropData.prop[index]))
                        {
                            string     path   = "Prefabs/Prop/" + dropData.prop[index];
                            GameObject propGo = Global.gApp.gResMgr.InstantiateObj(path);
                            propGo.transform.position = position;
                            m_Props.Add(propGo);
                        }
                        return(true);
                    }
                    index++;
                }
            }
            return(false);
        }
Esempio n. 7
0
        public void AddWpnChipPropByPass(Vector3 position, int dropId)
        {
            DropItem dropData = Global.gApp.gGameData.DropData.Get(dropId);

            if (dropData != null)
            {
                int curRate    = 0;
                int randomRate = Random.Range(0, 10001);
                int index      = 1;
                foreach (int rate in dropData.rate)
                {
                    curRate = curRate + rate;
                    if (randomRate < curRate)
                    {
                        if (CheckCanAddProp(dropData.prop[0]))
                        {
                            int dropCount = int.Parse(dropData.prop[index]);
                            if (dropCount > 0)
                            {
                                string     path   = "Prefabs/Prop/" + dropData.prop[0];
                                GameObject propGo = Global.gApp.gResMgr.InstantiateObj(path);
                                propGo.GetComponent <WeaponChipProp>().SetChipGainTypeTrigger(dropCount);
                                propGo.transform.position = position;
                                m_Props.Add(propGo);
                            }
                        }
                        break;
                    }
                    index++;
                }
            }
        }
Esempio n. 8
0
    public void initView()
    {
        NovicePacksPush novicePacksPush = NewPeoperGiftPackageManager.Instance.getNovicePacksPush();

        if (novicePacksPush == null)
        {
            Debug.LogWarning("服务器推送的NovicePacksPush数据null,检测客户端或者服务器推送的数据.");
            return;
        }
        base.FindTransform("ButtonBuyPro").FindChild("BtnConfirmText").GetComponent <Text>().set_text(GameDataUtils.GetChineseContent(301027, false));
        XinShouLiBao xinShouLiBao = DataReader <XinShouLiBao> .Get(novicePacksPush.pack.id);

        if (xinShouLiBao != null)
        {
            Icon icon = DataReader <Icon> .Get(xinShouLiBao.Chinese);

            if (icon != null)
            {
                ResourceManager.SetSprite(base.FindTransform("IconImage").GetComponent <Image>(), ResourceManager.GetIconSprite(icon.icon));
            }
        }
        base.FindTransform("Count").GetComponent <Text>().set_text("X" + novicePacksPush.pack.price);
        ListPool pool = this.m_ItemPool;

        pool.Release();
        pool.Create(novicePacksPush.pack.items.get_Count(), delegate(int index)
        {
            DropItem dropItem = novicePacksPush.pack.items.get_Item(index);
            int typeId        = dropItem.typeId;
            long count        = dropItem.count;
            ItemShow.SetItem(pool.Items.get_Item(index), typeId, count, false, UINodesManager.T2RootOfSpecial, 3000);
        });
    }
Esempio n. 9
0
        private void OnScrollerChange(Transform trans, int index)
        {
            MonoLevelDropIconButtonBox component = trans.GetComponent <MonoLevelDropIconButtonBox>();
            MonoLevelDropIconButton    button    = trans.Find("Item").GetComponent <MonoLevelDropIconButton>();
            Vector2 cellSize = this._dropScroller.grid.GetComponent <GridLayoutGroup>().cellSize;

            trans.SetLocalScaleX(cellSize.x / button.width);
            trans.SetLocalScaleY(cellSize.y / button.height);
            DropItem            item = this._dropItemList[index];
            StorageDataItemBase dummyStorageDataItem = Singleton <StorageModule> .Instance.GetDummyStorageDataItem((int)item.get_item_id(), 1);

            dummyStorageDataItem.level  = (int)item.get_level();
            dummyStorageDataItem.number = (int)item.get_num();
            button.SetupView(dummyStorageDataItem, new DropItemButtonClickCallBack(this.OnDropItemBtnClick), true, true, false, false);
            if (item == this._normalDropItem)
            {
                component.SetupTypeView(MonoLevelDropIconButtonBox.Type.NormalFinishChallengeReward, this._dropPanelBGAniamtionEnd);
            }
            else if (item == this._fastDropItem)
            {
                component.SetupTypeView(MonoLevelDropIconButtonBox.Type.FastFinishChallengeReward, this._dropPanelBGAniamtionEnd);
            }
            else if (item == this._sonicDropItem)
            {
                component.SetupTypeView(MonoLevelDropIconButtonBox.Type.SonicFinishChallengeReward, this._dropPanelBGAniamtionEnd);
            }
            else
            {
                component.SetupTypeView(MonoLevelDropIconButtonBox.Type.DefaultDrop, this._dropPanelBGAniamtionEnd);
            }
        }
Esempio n. 10
0
 private void receiveFullObjectsUpdate(NetIncomingMessage im)
 {
     #region GameItems
     int count = im.ReadInt32();
     for (int i = 0; i < count; i++)
     {
         String   gameItemXML = im.ReadString();
         GameItem item        = GameItem.fromXML(XMLUtil.asXML(gameItemXML));
         if (!gameref.activeItems.ContainsKey(item.guid))
         {
             gameref.addGameItem(item);
         }
     }
     #endregion
     // TODO must remove picked up objects and implement updates for dropped items
     #region DropItems
     count = im.ReadInt32();
     for (int i = 0; i < count; i++)
     {
         DropItem item = DropItem.fromXML(XMLUtil.asXML(im.ReadString()));
         if (!gameref.activeItems.ContainsKey(item.guid))
         {
             gameref.addGameItem(item);
         }
     }
     #endregion
 }
Esempio n. 11
0
        public void AddDroppedItem(CharacterItemRecord record, ushort quantity, ushort cellid)
        {
            DropItem item = DropItem.Create(record, quantity, cellid, this);

            m_droppedItems.Add(item);
            this.Send(new ObjectGroundAddedMessage(cellid, record.GId));
        }
Esempio n. 12
0
        private void DoShowDropItem()
        {
            if (!treasureBox.gameObject.activeSelf)
            {
                return;
            }

            panelDrop.SetActive(true);
            treasureBox.gameObject.SetActive(false);

            TransformUtil.ClearChildren(tranDropRoot, true);
            int count = _dropHeroAndEquipList.Count;


            int   half                = count / 2;
            float scaleShakeTime      = 0.2f;
            float scaleShakeDelayTime = 0.1f;
            float allDelay            = 0.5f;
            float btnDelayShowTime    = count * scaleShakeTime + 0.5f + allDelay;


            //drop
            GameResData heroGRD = null;

            for (int i = 0; i < count; i++)
            {
                DropItem         dropItem = _dropHeroAndEquipList[i];
                CommonRewardIcon rewardIcon;
                rewardIcon = CommonRewardIcon.Create(tranDropRoot);
                GameResData resData = new GameResData((BaseResType)dropItem.itemType, dropItem.itemNo, dropItem.itemNum, dropItem.heroStar);

                rewardIcon.SetGameResData(resData);
                rewardIcon.SetDesButtonType(ShowDescriptionType.click);
                rewardIcon.ShowRewardCount(true);
                Transform  tran = rewardIcon.transform;
                GameObject go   = rewardIcon.gameObject;
                if (count % 2 == 0)
                {
                    tran.localPosition = new Vector3((i - half) * 120 + 60, 0, 0);
                }
                else
                {
                    tran.localPosition = new Vector3((i - half) * 120, 0, 0);
                }
                go.AddComponent <ScaleShake>().init(0, 1, scaleShakeTime, i * scaleShakeDelayTime + allDelay, ScaleShake.ScaleShakeType.ScleShake_After);
                if (resData.type == BaseResType.Hero)
                {
                    heroGRD = resData;
                }
            }

            ShowBtnRoot(btnDelayShowTime, heroGRD);

            //bg light

            Vector3 to = image_light.localScale;

            image_light.localScale = Vector3.zero;
            LeanTween.scale(image_light, to, scaleShakeTime).setDelay(allDelay);
        }
Esempio n. 13
0
        public void SetUp()
        {
            m_RandomDrop       = RandomDropLogic.GetInstance();
            m_Drop             = new DTDrop();
            m_Drop.Id          = 1;
            m_Drop.RepeatCount = 100;
            DropItem di = new DropItem();

            di.ItemId     = 100;
            di.ItemCount  = 1;
            di.ItemWeight = 10000;
            m_Drop.DropList.Add(di);
            DropItem di1 = new DropItem();

            di1.ItemId     = 101;
            di1.ItemCount  = 2;
            di1.ItemWeight = 20000;
            m_Drop.DropList.Add(di1);
            DropItem di2 = new DropItem();

            di2.ItemId     = 102;
            di2.ItemCount  = 3;
            di2.ItemWeight = 30000;
            m_Drop.DropList.Add(di2);
            DropItem di3 = new DropItem();

            di3.ItemId     = 103;
            di3.ItemCount  = 4;
            di3.ItemWeight = 40000;
            m_Drop.DropList.Add(di3);
        }
Esempio n. 14
0
        protected override IEnumerator Init()
        {
            CurrentDrag           = Drag.None;
            CurrentInventoryIndex = -1;
            CurrentDropItem       = null;

            InputController inputController = GetController <InputController>();

            inputController.OnClickTarget        += onMove;
            inputController.OnClickTargetNormal  += onShowMark;
            inputController.OnPlayerStartDrag    += OnPlayerStartDrag;
            inputController.OnEndDrag            += OnEndDrag;
            inputController.OnDropItemClick      += OnDropItemClick;
            inputController.OnDropItemStartDrag  += OnDropItemStartDrag;
            inputController.OnInventoryEnter     += OnInventoryEnter;
            inputController.OnInventoryExit      += OnInventoryExit;
            inputController.OnInventoryStartDrag += OnInventoryStartDrag;
            inputController.OnInventoryDrag      += OnInventoryDrag;
            inputController.OnInventoryEndDrag   += OnInventoryEndDrag;
            inputController.OnWorldEnter         += OnWorldEnter;
            inputController.OnWorldExit          += OnWorldExit;

            Player = new Player();

            inputController.OnInventory += Player.Inventory.OnInventory;

            Player.Inventory.AddEvents(GameGUI.Instance);
            Player.AddEvents(GameGUI.Instance);
            Player.Load(GetComponent <SaveController>().Instance.Player);
            yield return(null);
        }
Esempio n. 15
0
        /// <summary>
        /// pick up closest item and throw the equipped one on the ground
        /// </summary>
        /// <param name="player">player to pick up item</param>
        /// <returns>true if item picked up</returns>
        private bool pickupClosestItem(Being player)
        {
            DropItem dropItem = Game.instance.getClosestDropItem(player);

            if (dropItem != null && Vector2.DistanceSquared(dropItem.body.Position, player.body.Position) < Game.DROP_ITEM_MAX_DISTANCE)
            {
                Item playerItem = player.getItemManager().getItem(dropItem.getItem().getItemType());
                player.getItemManager().putItem(dropItem.getItem());
                if (playerItem != null)
                {
                    dropItem.setItem(playerItem);
                    dropItem.body.LinearVelocity.Y += 25f;
                    dropItem.body.ApplyTorque((float)Game.instance.rand.NextDouble() * .25f - .125f);
                }
                else
                {
                    Game.instance.activeItems.Remove(dropItem.guid);
                    Game.instance.physicsSimulator.BodyList.Remove(dropItem.body);
                }
            }
            else
            {
                return(false);
            }
            return(true);
        }
Esempio n. 16
0
        public BattleReward Reward(IBattleEntity victim)
        {
            MonsterBattleEntity monster = victim as MonsterBattleEntity;

            if (monster == null)
            {
                return(null);
            }

            context.GetModule <PlayerModule>().AddExperience(user.Service, user.Name, monster.Monster.Experience);
            context.GetModule <PlayerModule>().UpdateGold(PlayerID, monster.Monster.Gold);

            Item     item     = null;
            DropItem dropitem = monster.Monster.DroppedItems.FirstOrDefault(i => RNG.XORShift64.NextDouble() < i.Rate);

            if (dropitem != null)
            {
                item = context.GetModule <ItemModule>().GetItem(dropitem.ItemID);
                if (item != null)
                {
                    if (context.GetModule <InventoryModule>().AddItem(PlayerID, item.ID, 1) == AddInventoryItemResult.InventoryFull)
                    {
                        item = null;
                    }
                }
            }

            return(new BattleReward {
                XP = monster.Monster.Experience,
                Gold = monster.Monster.Gold,
                Item = item
            });
        }
Esempio n. 17
0
    public static void DropItemMake(int ItemID, float x, float y)
    {
        GameObject DropItem = GameObject.Instantiate(DropItemprefab, new Vector3(x, y, 0), Quaternion.identity);
        DropItem   dropitem = DropItem.GetComponent <DropItem>();

        dropitem.SetUp(ItemID, x, y);
    }
Esempio n. 18
0
    public GameObject CreateMatchingMaterial(CollectBtnClick collectBtnClick, DropItem dropItem, DragItem dragitem)
    {
        GameObject objResource = Resources.Load("matching/" + collectBtnClick.material.ToString()) as GameObject;

        if (objResource == null)
        {
            return(null);
        }
        GameObject processBarObj = Instantiate(objResource, Vector3.zero, Quaternion.identity) as GameObject;
        // processBarObj.name = collectBtnClick.material.ToString();
        RectTransform rectans = processBarObj.GetComponent <RectTransform>();

        rectans.SetParent(this.GetComponent <RectTransform>());
        rectans.SetAsLastSibling();
        rectans.localScale       = Vector3.one;
        rectans.anchoredPosition = new Vector2(0, 0);
        // Destroy(processBarObj.gameObject, 1);
        //当动画播放完成,销毁刚才生成的对象
        //  dropItem.inUse = false;
        // 初始化数据
        // collectBtnClick.materialPanelIndex = 0;

        this.collectBtnClick = collectBtnClick;
        TextCountManager.Instance.UpdateTextCount(dragitem.gameObject);
        TextCountManager.Instance.UpdateCollectTextCount(dragitem.gameObject, dragitem.collectBtnClick);
        //数据配置,当拖放成功时进行数据配置
        dropItem.inUse = true;
        this.dropItem  = dropItem;
        //  CreateParts(collectBtnClick);
        return(objResource);
    }
Esempio n. 19
0
    void OnTriggerEnter(Collider collider)
    {
        string tag = collider.gameObject.tag;

        Debug.Log("Player.OnTriggerEnter " + tag);
        if (tag == "EnemyWeapon")
        {
            Enemy enemy = collider.transform.parent.GetComponent <Enemy>();
            Debug.Log("Enemy " + enemy.ID);
            ActHit();
            AttackEffect("Prefabs/Effect/Hit/Fx_hit", 1, new Vector3(0, 0.5f, 0));
            Vector3 offset = transform.position - enemy.transform.position;
            offset.y = 0;
            StartCoroutine(HitBack(offset.normalized));
            BattleManager.GetInstance().PlayerHit(ID, enemy.ID);
        }
        else if (tag == "NPC")
        {
            NPC npc = collider.GetComponent <NPC>();
            BattleManager.GetInstance().PlayerEnterNpc(ID, npc.ID);
        }
        else if (tag == "DropItem")
        {
            DropItem dropItem = collider.GetComponent <DropItem>();
            dropItem.OnHit();
            BattleManager.GetInstance().PlayerTakeItem(ID, dropItem.ID);
        }
    }
Esempio n. 20
0
    private void OnTriggerEnter(Collider coll)                // 공격 충돌 처리
    {
        if (coll.gameObject.tag == "enemy")                   // 충돌 대상이 적 태그를 가지고 있으면
        {
            CROWD_CONTROL  cc = CROWD_CONTROL.NONE;           // 특수 공격상태
            SPECIAL_DAMAGE sd = SPECIAL_DAMAGE.NONE;          // 특수 추가 데미지
            int            criticalPercent = 20;              // 기본 치명타 확률

            int             str         = CharacterInfoManager.instance.m_iCurStr;
            EnemyInfomation enemyScript = coll.GetComponentInParent <EnemyInfomation>();                                                        // 적 스크립트를 받아와서

            if (Vector3.Dot(coll.transform.forward, (transform.position - coll.transform.position).normalized) < Mathf.Cos(90 * Mathf.Deg2Rad)) // 내적을 구해서 적의 정면에서 90도내에 플레이어가 없으면 (좌우 합쳐 180도)
            {
                cc = CROWD_CONTROL.BACK_ATTACK;                                                                                                 // 백어택 발동
                criticalPercent *= 2;                                                                                                           // 크리티컬 확률 2배
            }

            if (Random.Range(0, 100) < criticalPercent)                                                                                           // 크리티컬 확률 안에 들어오면
            {
                if (cc == CROWD_CONTROL.BACK_ATTACK)
                {
                    sd = SPECIAL_DAMAGE.CRITICAL_BACK_ATTACK;
                }
                else
                {
                    sd = SPECIAL_DAMAGE.CRITICAL;
                }
            }
            enemyScript.attacted(m_fCurAttackDamage * str, sd, cc); // 그 적은 내 현재 공격모션의 데미지를 부여함
        }
        if (coll.gameObject.tag == "Potal")                         // 충돌 대상이 스테이지를 넘어가는 포탈이면
        {
            if (s_eventPlayerState == null)
            {
                GameManager.instance.nextDungeonLoad();
            }
            else
            {
                GameManager.instance.stateExplain(1);
            }
        }
        if (coll.gameObject.tag == "DropItem")                   // 충돌 대상이 아이템이면
        {
            DropItem dropItemScripte = coll.GetComponent <DropItem>();
            ItemManager.Instance.putInventroyItem(dropItemScripte.getItenName()); // 인벤토리에 아이템을 넣음
            ObjectPoolManager.Instance.PushToPool("DropItem", coll.gameObject);
        }
        if (coll.gameObject.tag == "DropGold")
        {
            DropGold dropGoldScripte = coll.GetComponent <DropGold>();
            CharacterInfoManager.instance.m_playerInfo.m_iGold += coll.GetComponent <DropGold>().getGoldAmount();
            ProfileUIManager.Instance.changeGold();
            ObjectPoolManager.Instance.PushToPool("DropGold", coll.gameObject);
        }
        if (coll.gameObject.tag == "Barrigate")
        {
            GameManager.instance.stateExplain(0);
        }
    }
Esempio n. 21
0
 public Entry(
     DropItem dropEntryItem,
     DropItemConditionDelegate condition,
     double probability)
     : this(condition, probability)
 {
     this.EntryItem = dropEntryItem;
 }
Esempio n. 22
0
 public Entry(
     DropItem dropEntryItem,
     DropItemConditionDelegate condition,
     DropItemRollFunctionDelegate rollFunction)
     : this(condition, rollFunction)
 {
     this.EntryItem = dropEntryItem;
 }
Esempio n. 23
0
    public DropItem generateitemdrop(Items _data)
    {
        GameObject _itemprefab = GameObject.Instantiate(Resources.Load("UIFrame/DropItem", typeof(GameObject))) as GameObject;
        DropItem   _uiitem     = _itemprefab.GetComponent <DropItem> ();

        _uiitem.Init(_data);
        return(_uiitem);
    }
Esempio n. 24
0
        private static int ComputeDropItemExpiration(DropItem dropItem)
        {
            DateTime?expirationDate;

            return(dropItem.TryGetExpirationTime(out expirationDate) || expirationDate.HasValue
                ? (int)expirationDate.Value.Subtract(DateTime.UtcNow).TotalDays
                : -1);
        }
 public bool OriginalPutDown(bool fake, bool drop, bool equipPrevious, GameObject preSpawned)
 {
     if (this._infiniteLogHack)
     {
         return(true);
     }
     if (!fake)
     {
         if (this._logs <= 0)
         {
             return(false);
         }
         this.RemoveLog(equipPrevious);
     }
     if (drop)
     {
         bool       flag       = this._logs == 1;
         Transform  transform  = this._logsHeld[Mathf.Min(this._logs, 1)].transform;
         Vector3    vector     = transform.position + transform.forward * -2f;
         Quaternion quaternion = LocalPlayer.Transform.rotation;
         quaternion *= Quaternion.AngleAxis(90f, Vector3.up);
         if (LocalPlayer.FpCharacter.PushingSled)
         {
             vector += transform.forward * -1.25f + transform.right * -2f;
         }
         Vector3 origin = vector;
         origin.y += 3f;
         if (Physics.Raycast(origin, Vector3.down, out RaycastHit raycastHit, 5f, this._layerMask))
         {
             vector.y = raycastHit.point.y + 2.2f;
         }
         if (flag)
         {
             vector.y += 1f;
         }
         if (BoltNetwork.isRunning)
         {
             DropItem dropItem = DropItem.Create(GlobalTargets.OnlyServer);
             dropItem.PrefabId   = BoltPrefabs.Log;
             dropItem.Position   = vector;
             dropItem.Rotation   = quaternion;
             dropItem.PreSpawned = ((!preSpawned) ? null : preSpawned.GetComponent <BoltEntity>());
             dropItem.Send();
         }
         else if (preSpawned)
         {
             preSpawned.transform.position = vector;
             preSpawned.transform.rotation = quaternion;
         }
         else
         {
             Instantiate(this._logPrefab, vector, quaternion);
         }
         FMODCommon.PlayOneshotNetworked("event:/player/foley/log_drop_exert", transform, FMODCommon.NetworkRole.Any);
     }
     this.UpdateLogCount();
     return(true);
 }
Esempio n. 26
0
    void UpdateLoot()
    {
        Vector2 pos       = transform.position;
        var     colliders = Physics2D.OverlapCircleAll(pos, m_lootDistance * PlayerStats.Instance().GetStatValue("LootDistanceMultiplier"));

        DropItem bestItem     = null;
        float    bestDistance = float.MaxValue;

        for (int i = 0; i < colliders.Length; i++)
        {
            var item = colliders[i].GetComponent <DropItem>();
            if (item == null || item.autoloot)
            {
                continue;
            }

            Vector2 itemPos  = item.transform.position;
            float   distance = (itemPos - pos).sqrMagnitude;
            if (distance < bestDistance)
            {
                bestDistance = distance;
                bestItem     = item;
            }
        }

        float currentItemDist = float.MaxValue;

        if (m_currentLoot != null)
        {
            Vector2 currentItemPos = m_currentLoot.transform.position;
            currentItemDist = (currentItemPos - pos).sqrMagnitude;
            if (currentItemDist > m_lootDistance)
            {
                m_currentLoot.HideTooltip();
                m_currentLoot   = null;
                currentItemDist = float.MaxValue;
            }
        }

        if (bestDistance < currentItemDist)
        {
            if (m_currentLoot != null)
            {
                m_currentLoot.HideTooltip();
                m_currentLoot = null;
            }

            m_currentLoot = bestItem;
            m_currentLoot.ShowTooltip();
        }

        if (Input.GetButtonDown(pickupButton) && m_currentLoot != null)
        {
            m_currentLoot.HideTooltip();
            PickubLoot(m_currentLoot);
            m_currentLoot = null;
        }
    }
Esempio n. 27
0
    public void Droping(GameObject thing)
    {
        GameObject drop        = Instantiate(thing, transform.position, Quaternion.identity);
        Vector3    pos         = transform.position;
        Vector3    destination = new Vector3(pos.x + Random.Range(-dropRange, dropRange), transform.position.y, pos.z + Random.Range(-dropRange, dropRange));
        DropItem   dropItem    = drop.GetComponent <DropItem>();

        dropItem.dropMove(destination);
    }
Esempio n. 28
0
 // Use this for initialization
 void Start()
 {
     rigidbody       = GetComponent <Rigidbody>();
     capsuleCollider = GetComponent <CapsuleCollider>();
     anim            = GetComponent <Animator>();
     isAlive         = true;
     currentHealth   = startingHealth;
     dropItem        = GetComponent <DropItem>();
 }
Esempio n. 29
0
        // 绑定套餐
        private void BindDictProduct(object customerid)
        {
            List <Dicttestitem> TestItemList = dicttestservice.GetProduct(customerid);

            DropItem.DataSource     = TestItemList;
            DropItem.DataTextField  = "Testname";
            DropItem.DataValueField = "Dicttestitemid";
            DropItem.DataBind();
            DropItem.Items.Insert(0, new ExtAspNet.ListItem("请选择", "-1"));
        }
Esempio n. 30
0
 private void Start()
 {
     rb            = GetComponent <Rigidbody>();
     boxCollider   = GetComponent <BoxCollider>();
     anim          = GetComponent <Animator>();
     isAlive       = true;
     currentHealth = startingHealth;
     audio         = GetComponent <AudioSource>();
     dropItem      = GetComponent <DropItem>();
 }
 public void GetItem(DropItem.ItemKind itemKind)
 {
     switch (itemKind)
     {
     case DropItem.ItemKind.Attack:
         powerBoostTime = 5.0f;
         break;
     case DropItem.ItemKind.Heal:
         HP = Mathf.Min(HP + MaxHP / 2, MaxHP);
         break;
     }
 }
Esempio n. 32
0
 public void GetItem( DropItem.ItemKind itemKind )
 {
     switch( itemKind )
     {
     case DropItem.ItemKind.Attack:
         attackPowerTime = 5.0f;
         break;
     case DropItem.ItemKind.Speed:
         speedTime = 5.0f;
         break;
     };
 }
Esempio n. 33
0
 // アイテム取得
 public void GetItem(DropItem.ItemKind itemKind)
 {
     switch (itemKind)
     {
     case DropItem.ItemKind.Attack:
         powerBoostTime = 30.0f;
         powerUpEffect.Play ();
         break;
     case DropItem.ItemKind.Heal:
         // MaxHPの半分回復
         HP = Mathf.Min(HP + MaxHP / 2, MaxHP);
         break;
     }
 }
	public void Whatsindex(int _index,int _level,DropItem item)
	{
		itemindex= _index;
		itemlevel = _level;
		m_item = item;
		
		float x = Random.Range(-30,30);
		float z = Random.Range(-30,30);
		m_dir.y = 0;
		m_dir.x = x;
		m_dir.z = z;
		m_dir.Normalize();
		
		m_flying = false;
	}
 public void Init(DropItem item, bool isFree)
 {
     this.item = item;
     Debug.Log("------------------the item id is " + item.id);
     Refresh(0, isFree);
 }
Esempio n. 36
0
 public override void OnEvent(DropItem evnt)
 {
     BoltNetwork.Instantiate(evnt.PrefabId, evnt.Position, evnt.Rotation);
 }
Esempio n. 37
0
 private void placeItemInContainer(Item item, ContainerScript container)
 {
     container.addItem(item.gameObject);
     item.setState(Item.ItemState.contained);
     inventory.Remove(item.gameObject);
     DropItem e = new DropItem(pg.timeSteps, this, currentRoom, item);
     Timeline.addEvent(new DropItem(pg.timeSteps, this, currentRoom, item));
 }
    public void GetItem(int itemidx, int level, DropItem item)
    {
        Transform obj = null;
        Transform fx = null;

        switch (item.type)
        {
            case (int)GlobalDef.ItemType.ITEM_FOOD:
                fx = PrefabManager.Instance().GetFx("ef_other_jiaxue_01", PrefabManager.enEfPathType.EF_OTHER);
                obj = Instantiate(fx, m_transform.position, Quaternion.identity) as Transform;
                OnHp((int)GetCurCharData().getMaxHP() / 10);
                break;

            case (int)GlobalDef.ItemType.ITEM_GOLD:
                fx = PrefabManager.Instance().GetFx("ef_other_jinbi_01", PrefabManager.enEfPathType.EF_OTHER);
                obj = Instantiate(fx, m_transform.position, Quaternion.identity) as Transform;
                break;

            case (int)GlobalDef.ItemType.ITEM_EQUIPMENT:
                fx = PrefabManager.Instance().GetFx("ef_other_xiangzi_01", PrefabManager.enEfPathType.EF_OTHER);
                obj = Instantiate(fx, m_transform.position, Quaternion.identity) as Transform;
                break;

            default:
                return;
        }
        obj.parent = m_transform;
        obj.gameObject.SetActive(true);

        obj.gameObject.AddComponent<AutoDestroyParticle>();

        //item.type;
    }
Esempio n. 39
0
 // Use this for initialization
 void Start()
 {
     anim = GetComponent<Animator> ();
     drop = GetComponentInChildren<DropItem> ();
 }
Esempio n. 40
0
 public void DespawnDrop(DropItem _drop) {
    
     _drop.OnDespawn();
     dropItemPool.Return(_drop.gameObject);
 }