public Chest GetConnectedChest(Point16 location)
        {
            Point16 back  = GetBackwardsOffset(location);
            int     index = ChestUtils.FindChestByGuessingImproved(back.X, back.Y);

            return(index > -1 ? Main.chest[index] : null);
        }
Beispiel #2
0
        public void Death()
        {
            //log.InfoFormat("create chest at position = {0}", transform.position);

            var damagable = GetComponent <DamagableObject>();

            if (damagable != null)
            {
                if (damagable.killed && damagable.createChestOnKilling)
                {
                    log.InfoFormat("generate chest for bot of level = {0} yellow", mCharacter.level);

                    Difficulty difficulty = Difficulty.none;
                    if (nebulaObject.HasTag((byte)PS.Difficulty))
                    {
                        difficulty = (Difficulty)(byte)nebulaObject.Tag((byte)PS.Difficulty);
                    }


                    if (ChestUtils.RollDropChest(difficulty))
                    {
                        log.InfoFormat("Successfully rolled chest for npc difficulty = {0} yellow", difficulty);

                        ChestSourceInfo sourceInfo = new ChestSourceInfo {
                            hasWorkshop = true, level = mCharacter.level, sourceWorkshop = (Workshop)mCharacter.workshop, difficulty = difficulty
                        };
                        var dropListComponent = GetComponent <DropListComponent>();
                        //ItemDropList itemDropList = null;
                        //if(dropListComponent != null ) {
                        //    itemDropList = dropListComponent.dropList;
                        //}

                        ObjectCreate.Chest(
                            nebulaObject.world as MmoWorld,
                            transform.position,
                            mChestLiveDuration,
                            GetComponent <DamagableObject>().damagers,
                            sourceInfo,
                            dropListComponent
                            ).AddToWorld();
                    }
                }
            }

            mDead = true;

            if (objectOwner != null)
            {
                objectOwner.HandleDeath(nebulaObject);
            }

            (nebulaObject.world as MmoWorld).npcManager.SetDestroyTime(nebulaObject.Id, Time.curtime());

            (nebulaObject as Item).Destroy();
        }