コード例 #1
0
    public void PickupItem(WorldItem worldItem)
    {
        int freeSlot = FindFreeSlot();

        if (freeSlot == -1)
        {
            return;
        }

        slots[freeSlot].SetItem(worldItem.GetItem());
        worldItem.Pickup();
    }
コード例 #2
0
 static void InitializeTemplate( )
 {
     foreach (GameObject go in Selection.gameObjects)
     {
         WorldItem wi = null;
         if (go.HasComponent <WorldItem> (out wi))
         {
             Debug.Log("Initializing template in " + wi.name);
             wi.InitializeTemplate();
         }
     }
 }
コード例 #3
0
        public IEnumerator SetUp()
        {
            player = MonoBehaviour.Instantiate(Resources.Load <GameObject>("Tests/Player"));
            yield return(null); // Wait for prefab to load

            character = player.GetComponent <Character>();
            worldItem = WorldItem.Create(Resources.Load <Item>("Items/item"), 1);
            yield return(null); // Wait for prefab to load

            character.Inventory.Give(worldItem);
            itemScript = character.HandItemContainer.gameObject.GetComponentInChildren <ItemScript>();
        }
コード例 #4
0
    public void Awake()
    {
        WorldItem w = gameObject.GetComponent <WorldItem>();

        w.OnGainPlayerFocus += OnGainPlayerFocus;
        w.OnLosePlayerFocus += OnLosePlayerFocus;

        if (IsSpecialObject)
        {
            OnBecomeSpecialObject();
        }
    }
コード例 #5
0
    protected void LoseAttention()
    {
        WorldItem worlditem = gameObject.GetComponent <WorldItem>();

        if (worlditem == null || worlditem.Destroyed)
        {
            return;
        }

        RemoveMatFromRenderers(worlditem.Renderers, Mats.Get.AttentionOutlineMaterial);
        mHasAddedAttentionMats = false;
    }
コード例 #6
0
        private void DownloadWorld(WorldItem world)
        {
            world.State = WorldState.Downloading;

            Remote.DownloadWorld(world.World.ID, o =>
            {
                SaveWorld(world.World, o);
                world.State = WorldState.Existing;

                Console.WriteLine(o.Length);
            });
        }
コード例 #7
0
    private void AddItem(ServerWorld world)
    {
        GameObject newItem = Instantiate(worldItemPrefab);

        // set parent
        newItem.transform.SetParent(contentPanel, false);

        // initialise
        WorldItem worldItem = newItem.GetComponent <WorldItem>();

        worldItem.Initialise(world, loader);
    }
コード例 #8
0
            protected override TreeViewItem BuildRoot()
            {
                _loadedStyle           = EditorStyles.boldLabel;
                _activeStyle           = new GUIStyle(EditorStyles.boldLabel);
                _activeStyle.fontStyle = FontStyle.BoldAndItalic;

                var id       = 0;
                var rootItem = new TreeViewItem {
                    id = id++, depth = -1, displayName = "Root"
                };

                var worldItem = new WorldItem {
                    Store = WorldManager.Instance.Variables, World = WorldManager.Instance, id = id++, displayName = "World"
                };

                rootItem.AddChild(worldItem);

                var playerItem = new PlayerItem {
                    Store = Player.Instance.Variables, Player = Player.Instance, id = id++, displayName = "Player"
                };

                rootItem.AddChild(playerItem);

                var zonesItem = new TreeViewItem {
                    id = id++, displayName = "Zones"
                };

                rootItem.AddChild(zonesItem);

                foreach (var zone in WorldManager.Instance.Zones)
                {
                    if (zone != null)
                    {
                        var zoneItem = new ZoneItem {
                            Store = zone.Variables, Zone = zone, id = id++, displayName = zone.Zone.Name
                        };
                        zonesItem.AddChild(zoneItem);

                        foreach (var npc in zone.Npcs)
                        {
                            var npcItem = new NpcItem {
                                Store = npc.Variables, Npc = npc, id = id++, displayName = string.IsNullOrEmpty(npc.Name) ? "(Npc)" : npc.Name
                            };
                            zoneItem.AddChild(npcItem);
                        }
                    }
                }

                SetExpanded(zonesItem.id, true);
                SetupDepthsFromParentsAndChildren(rootItem);

                return(rootItem);
            }
コード例 #9
0
 public void GhostFadeOut(WorldItem ghost)
 {
     if (ghost.hasInstance)
     {
         GhostFadeAnim anim = ghost.Instance.gameObject.GetComponent <GhostFadeAnim>();
         if (anim != null)
         {
             pendingActions++;
             anim.StartGhostFade(false, true);
         }
     }
 }
コード例 #10
0
    public void DestroyItem()
    {
        if (this.item == null)
        {
            return;
        }
        WorldItem worldItem = this;

        this.item.OnDirty -= new Action <Item>(worldItem.OnItemDirty);
        this.item.Remove(0f);
        this.item = null;
    }
コード例 #11
0
 public void LoadWorlds()
 {
     GameManager.LoadData();
     ClearActiveChildren(worldsHolder);
     foreach (GameManager.World world in GameManager.worlds.Values)
     {
         WorldItem item = Instantiate(worldItemTemplate, worldsHolder);
         item.gameObject.SetActive(true);
         item.world = world;
     }
     LayoutRebuilder.MarkLayoutForRebuild(worldsHolder.parent as RectTransform);
 }
コード例 #12
0
        public virtual bool IsObjectPermitted(WorldItem potentialOccupant, ReceptacleSettings settings)
        {
            if (State.Locked)
            {
                return(false);
            }

            if (potentialOccupant == null)
            {
                return(false);
            }

            if (((int)potentialOccupant.Size) > ((int)settings.MaxSize))
            {
                //TODO use Stacks size comparison, this is error prone
                Debug.Log("Too big");
                return(false);
            }

            if (settings.PermittedScripts.Count > 0)
            {
                if (!potentialOccupant.HasAtLeastOne(settings.PermittedScripts))
                {
                    return(false);
                }
            }
            if (settings.PermittedSubcats.Count > 0)
            {
                if (!settings.PermittedSubcats.Contains(potentialOccupant.Subcategory))
                {
                    return(false);
                }
            }
            if (settings.PermittedMaterials != WIMaterialType.None)
            {
                if (!Flags.Check((uint)settings.PermittedMaterials, (uint)potentialOccupant.Props.Global.MaterialType, Flags.CheckType.MatchAny))
                {
                    return(false);
                }
            }
            if (settings.PermittedItems.Count > 0)
            {
                foreach (string permittedItemName in settings.PermittedItems)
                {
                    if (!Stacks.Can.Stack(potentialOccupant, permittedItemName))
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
コード例 #13
0
 public void                             Update( )
 {
     while (mIncoming.Count > 0)
     {
         WorldItem deadWorldItem = mIncoming.Dequeue( );
         deadWorldItem.transform.parent        = transform;
         deadWorldItem.gameObject.layer        = Globals.LayerNumHidden;
         deadWorldItem.transform.localPosition = Vector3.zero;
         //deadWorldItem.StopAllCoroutines ();
         //deadWorldItem.gameObject.SetActive (false);
         GameObject.Destroy(deadWorldItem.gameObject, 1.0f);
     }
 }
コード例 #14
0
        protected Vector3 GetPos(Transform t)
        {
            Vector3 pos = t.position;

            WorldItem item = t.GetComponent <WorldItem>();

            if (item != null)
            {
                pos = item.GetPosition();
            }

            return(pos);
        }
コード例 #15
0
        public override void OnActivated()
        {
            WorldItem structureWorldItem = null;
            StackItem structureStackitem = null;

            if (WIGroups.FindChildItem(StructurePath, out structureWorldItem))
            {
                if (Player.Local.Surroundings.IsVisitingStructure(structureWorldItem.Get <Structure> ()))
                {
                    HasCompleted = true;
                }
            }
        }
コード例 #16
0
ファイル: Chest.cs プロジェクト: OkashiKami/Gina
    private void Start()
    {
        var table = new List <string>();

        for (int i = 0; i < loottable.Count; i++)
        {
            table.Add(loottable[UnityEngine.Random.Range(0, loottable.Count)]);
        }
        foreach (var item in table)
        {
            WorldItem.Create(Database.GetItemByID(item), transform.Find("spawnpoint").position, -1, atPoint: true);
        }
    }
コード例 #17
0
 public void CallForHelp(WorldItem creatureInNeed, IItemOfInterest sourceOfTrouble)
 {
     if (sourceOfTrouble != null)
     {
         for (int i = 0; i < SpawnedCreatures.Count; i++)
         {
             if (SpawnedCreatures[i] != null && SpawnedCreatures[i].worlditem != creatureInNeed)
             {
                 SpawnedCreatures[i].AttackThing(sourceOfTrouble);
             }
         }
     }
 }
コード例 #18
0
ファイル: Demolishable.cs プロジェクト: yazici/FRONTIERS
        public void LookForDemolitionController( )
        {
            WorldItem demolitionControllerWorldItem = null;

            if (WIGroups.FindChildItem(State.DemolitionControllerPath, out demolitionControllerWorldItem))
            {
                DemolitionController = demolitionControllerWorldItem.Get <StructureDemolitionController> ();
                DemolitionController.AddDemolishable(this);
                //don't let our colliders turn off
                worlditem.ActiveState       = WIActiveState.Active;
                worlditem.ActiveStateLocked = true;
            }
        }
コード例 #19
0
        public override void CheckIfCompleted()
        {
            WorldItem questItem = null;

            if (GameWorld.Get.QuestItem(ItemName, out questItem))
            {
                if (questItem.State == State)
                {
                    HasCompleted = true;
                    Status      |= MissionStatus.Completed;
                }
            }
        }
コード例 #20
0
    public void OpenSellWindow(WorldItem itemToSell) // Called from GM. The window that pops up: "Do you want to sell this item"?
    {
        sellWindow.SetActive(true);
        sellWindowItemImage.sprite     = itemToSell.GetWorldItemSprites().normalSprites[0];
        sellWindowItemName.text        = itemToSell.myGameItem.itemProperties.displayedName;
        sellWindowItemPrice.text       = itemToSell.myGameItem.itemProperties.sellPriceFlorets.ToString();
        sellWindowItemDescription.text = itemToSell.myGameItem.itemProperties.itemDescription;

        selectedWorldItem = itemToSell;

        //instancesOfCurrentItem = GM.GetInstancesOfGameItemOwnedWorldAndInv(itemToSell.gameItem.itemProperties.itemID);
        //currentItem = itemToSell[0];
    }
コード例 #21
0
    private void HandleItemPickup(WorldItem targetItem)
    {
        Vector3 local_pos = targetItem.transform.position - cam_controller.transform.position;

        if (Physics.Raycast(cam_controller.transform.position, local_pos, out RaycastHit hit_info, local_pos.magnitude))
        {
            if (!hit_info.transform.GetComponentsInChildren <WorldItem>().Contains(targetItem))
            {
                return;
            }
        }
        AddItemToInventory(targetItem);
    }
コード例 #22
0
ファイル: PlayerCarrier.cs プロジェクト: yazici/FRONTIERS
        public bool CanEquip()
        {
            if (Holstered)
            {
                return(false);
            }

            if (!HasWorldItem && player.Inventory.HasActiveCarryItem)
            {
                worlditem = player.Inventory.ActiveCarryItem;
                return(true);
            }
            return(false);
        }
コード例 #23
0
    bool CheckForWorldDuplicate(WorldItem loadedItem) // Called at load to stop world items duplicating
    {
        PlacePoint point = GameObject.Find(loadedItem.myGameItem.placedPointName).GetComponent <PlacePoint>();

        if (point.empty == false)
        {
            Destroy(loadedItem.gameObject);
            return(true);
        }
        else
        {
            return(false);
        }
    }
コード例 #24
0
    protected IEnumerator FadeOutDetect()
    {
        WorldItem worlditem = gameObject.GetComponent <WorldItem>();

        mFadingOutDetection = true;
        yield return(null);

        while (mDetectionIntensity > 0.001f)
        {
            mDetectionIntensity -= (float)WorldClock.ARTDeltaTime;
        }
        RemoveMatFromRenderers(worlditem.Renderers, mDetectionMaterial);
        mFadingOutDetection = false;
        yield break;
    }
コード例 #25
0
ファイル: Dynamic.cs プロジェクト: yazici/FRONTIERS
 public override void OnEditorRefresh()
 {
     if (Triggers.Count > 0)
     {
         State.TriggerNames.Clear();
         for (int i = 0; i < Triggers.Count; i++)
         {
             if (Triggers[i] != null)
             {
                 WorldItem TriggerWorlditem = Triggers[i].GetComponent <WorldItem>();
                 State.TriggerNames.Add(TriggerWorlditem.FileName);
             }
         }
     }
 }
コード例 #26
0
ファイル: RemoverTool.cs プロジェクト: SHOrdr/Rust
 void Refund(BasePlayer player, BaseEntity entity)
 {
     if (entity as WorldItem)
     {
         WorldItem worlditem = entity as WorldItem;
         if (worlditem.item != null && worlditem.item.info != null)
         {
             player.inventory.GiveItem(worlditem.item.info.itemid, 1, true);
         }
     }
     else if (entity as BuildingBlock)
     {
         RefundBuildingBlock(player, entity as BuildingBlock);
     }
 }
コード例 #27
0
ファイル: FishDen.cs プロジェクト: yazici/FRONTIERS
        public void OnItemOfInterestLeave()
        {
            Visitable visitable = null;

            if (worlditem.Is <Visitable> (out visitable))
            {
                Creature  creature           = null;
                WorldItem lastItemOfInterest = visitable.LastItemOfInterestToLeave;
                WaterTrap waterTrap          = null;
                if (lastItemOfInterest.Is <WaterTrap> (out waterTrap))
                {
                    waterTrap.IntersectingDens.Remove(this);
                }
            }
        }
コード例 #28
0
        public override void OnHitByProjectile(CellFace cellFace, WorldItem worldItem)
        {        //收集掉落物
            ++ll; if (ll >= 2)
            {
                ll = 0; return;
            }
            int value  = subsystemTerrain.Terrain.GetCellValueFast(cellFace.Point.X, cellFace.Point.Y, cellFace.Point.Z);
            int level  = ILibrary.getItemId(value);
            int maxcnt = (int)Math.Pow((double)2, (double)level) * 128;        //计算最大容量

            if (Terrain.ExtractContents(value) == HandledBlocks[0])
            {
                try {
                    ComponentBlockEntity componentBlockEntity = subsystemBlockEntities.GetBlockEntity(cellFace.X, cellFace.Y, cellFace.Z);
                    if (componentBlockEntity == null)
                    {
                        toast("没有找到Blockentity"); return;
                    }
                    ComponentSingleChest singleChestData = componentBlockEntity.Entity.FindComponent <ComponentSingleChest>(true);
                    if (singleChestData == null)
                    {
                        toast("没有找到componentchest"); return;
                    }
                    if (worldItem.ToRemove)
                    {
                        return;
                    }
                    Pickable pickable = worldItem as Pickable;
                    int      num      = pickable?.Count ?? 1;
                    int      num2     = saveInventory(singleChestData, worldItem.Value, num, maxcnt);
                    if (num2 < num)
                    {
                        subsystemAudio.PlaySound("Audio/PickableCollected", 1f, 0f, worldItem.Position, 3f, autoDelay: true);
                    }
                    if (num2 <= 0)
                    {
                        worldItem.ToRemove = true;
                    }
                    else if (pickable != null)
                    {
                        pickable.Count = num2;
                    }
                }
                catch (Exception e) {
                    toast(e.ToString());
                }
            }
        }
コード例 #29
0
    /// <summary>
    /// Clear any dialogue lines or choices
    /// currently shown.
    /// </summary>
    public void ClearDialogue()
    {
        currentNode = null;
        foreach (DialogueUIChoice choice in choiceView.GetComponentsInChildren <DialogueUIChoice>())
        {
            Destroy(choice.gameObject);
        }
        choiceView.SetActive(false);
        lineView.SetActive(false);

        if (currentSpeaker != null)
        {
            currentSpeaker.ShowSpeechBubble(false);
            currentSpeaker = null;
        }
    }
コード例 #30
0
        protected virtual bool AddToReceptaclePivot(WorldItem potentialOccupant, ReceptaclePivot pivotInFocus)
        {
            if (State.Locked || mAddingToReceptaclePivot)
            {
                return(false);
            }

            if (pivotInFocus.IsOccupied || !IsObjectPermitted(potentialOccupant, pivotInFocus.Settings))
            {
                return(false);
            }

            mAddingToReceptaclePivot = true;
            StartCoroutine(AddToReceptaclePivotOverTime(potentialOccupant, pivotInFocus));
            return(true);
        }
コード例 #31
0
 private static void myUpdateLastObject(int parentTag, WorldItem worldItem)
 {
     TreeViewItem t = GetParentByTag(parentTag);
     lock (myTreeView)
     {
         if (t != null)
         {
             TreeViewItem lastActions = t.Items[1] as TreeViewItem;
             if (lastActions != null)
             {
                 TreeViewItem lastObject = lastActions.Items[0] as TreeViewItem;
                 if (lastObject != null)
                 {
                     TreeViewItem newLastObject = new TreeViewItem();
                     TreeViewItem oldLastObject = lastActions.Items[0] as TreeViewItem;
                     newLastObject.Header = "Last object";
                     newLastObject.IsExpanded = lastObject.IsExpanded;
                     newLastObject.Items.Add("Serial = " + worldItem.Serial);
                     newLastObject.Items.Add("ID = " + worldItem.ID);
                     if (!string.IsNullOrEmpty(worldItem.Name)) newLastObject.Items.Add("Name = " + worldItem.Name);
                     newLastObject.Items.Add("X = " + worldItem.X);
                     newLastObject.Items.Add("Y = " + worldItem.Y);
                     newLastObject.Items.Add("Z = " + worldItem.Z);
                     lastActions.Items[0] = newLastObject;
                     lastActions.Items.Refresh();
                 }
             }
         }
     }
 }
コード例 #32
0
 public static void UpdateLastObject(int parentTag, WorldItem worldItem)
 {
     if (myTreeView.CheckAccess()) myUpdateLastObject(parentTag, worldItem);
     else myTreeView.Dispatcher.BeginInvoke(myUpdateLastObjectDelegate, new object[] { parentTag, worldItem });
 }
コード例 #33
0
ファイル: ObjectPencil.cs プロジェクト: eickegao/Blazera
        protected override Boolean Paint(Vector2f point)
        {
            switch (Mode)
            {
                case EMode.Normal:
                    String baseType = CurrentObject.GetType().Name;

                    WorldObject currentObject = null;
                    switch (baseType)
                    {
                        case "Element": currentObject = new Element((Element)CurrentObject); break;
                        case "DisplaceableElement": currentObject = new DisplaceableElement((DisplaceableElement)CurrentObject); break;
                        case "GroundElement": currentObject = new GroundElement((GroundElement)CurrentObject); break;
                        case "WorldItem": currentObject = new WorldItem((WorldItem)CurrentObject); break;
                    }

                    Int32 x = (Int32)(point.X - currentObject.Halfsize.X);
                    Int32 y = (Int32)(point.Y - currentObject.Halfsize.Y);

                    currentObject.SetMap(MapMan.GetCurrent(), x, y);

                    return true;

                default: return false;
            }
        }
コード例 #34
0
        void FillWorldsList()
        {
            var loadListRes = (MyLoadListResult)m_loadWorldsAsync;
            var availableSaves = loadListRes.AvailableSaves;

            availableSaves.Sort((x, y) =>
            {
                return x.Item1.CompareTo(y.Item1);
            });

            gamesListBox.Items.Clear();
            if (availableSaves.Count != 0)
            {
                foreach (var save in availableSaves)
                {
                    WorldItem worldItem = new WorldItem()
                    {
                        SessionName = save.Item2.SessionName,
                        SessionPath = save.Item1,
                        SessionDir = System.IO.Path.GetFileName(save.Item1)
                    };
                    gamesListBox.Items.Add(worldItem);

                    if (MySandboxGame.ConfigDedicated.LoadWorld == worldItem.SessionPath)
                        gamesListBox.SelectedIndex = gamesListBox.Items.Count - 1;
                }
            }

            startTypeRadio_CheckedChanged(null, null);

            gamesListBox.Sorted = true;
        }