Example #1
0
        // Use this for initialization
        public override void Start()
        {
            base.Start();
            World                  = PrefabRepository.Instance.World;
            BlockSelector          = PrefabRepository.Instance.BlockSelector;
            BlockSelector          = Instantiate(BlockSelector, new Vector3(0, 0), Quaternion.identity);
            SelectedItemGameObject = GameObject.Find("SelectedItemGameObject");
            Inventory              = new Inventory(this);
            ItemBar                = new ItemBar(this);
            ItemBar   loadedItemBar   = (ItemBar)ItemBar.Load();
            Inventory loadedInventory = (Inventory)Inventory.Load();

            if (loadedInventory != null)
            {
                Inventory.Slots = loadedInventory.Slots;
            }
            if (loadedItemBar != null)
            {
                ItemBar.Slots = loadedItemBar.Slots;
            }

            Inventory.Show = false;
            Inventory.DrawUi();
            Inventory.ToggleSlots(false);

            ItemBar.Show = true;
            ItemBar.DrawUi();
            ItemBar.UpdateSelectedItemGameObject();
        }
Example #2
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Player")
     {
         gameObject.GetComponent <SpriteRenderer>().enabled = false;
         gameObject.GetComponent <Light>().enabled          = false;
         gameObject.GetComponent <BoxCollider>().enabled    = false;
         Effect.EffectNBT enbt = new Effect.EffectNBT
         {
             el     = effectLevel,
             et     = effectType,
             color  = particleColor,
             isNull = false
         };
         nbt = new ItemBar.NBT
         {
             effectNBT = enbt,
             canUse    = true,
             nbtt      = ItemBar.NBTType.Effect
         };
         ItemBar.AddItem(ItemBar.ReturnCanUsedPosition(), index);
         ItemBar.nowSelectNbt = nbt;
         bt.enabled           = true;
         btImage.enabled      = true;
         btText.enabled       = true;
     }
 }
        //We want the selected bar to go to the top
        //to re-order the selected bar to leftmost content orientation
        //to collapse all others
        //to show the content browser and "back" viel over collapsed items
        //to populate the content browser
        void thisBar_ContentPressed(ItemBar sender, Uri uri)
        {
            if ((sender as ItemBar).barState == Enums.ItemBarState.FULL)
            {
                //Move selected to top, set proper layouts
                List <ItemBar> tmpPost = new List <ItemBar>();
                tmpPost.Add(sender);
                sender.changeToState(Enums.ItemBarState.COLLAPSED_FOCOUSED);

                foreach (UIElement child in unModeratedStack.Children)
                {
                    if (!tmpPost.Contains(child as ItemBar))
                    {
                        tmpPost.Add(child as ItemBar);
                        (child as ItemBar).changeToState(Enums.ItemBarState.COLLAPSED_UNFOCUSED);
                    }
                }

                unModeratedStack.Children.Clear();

                foreach (ItemBar itemBar in tmpPost)
                {
                    unModeratedStack.Children.Add(itemBar);
                }


                //Do content
                unmoderatedContentControl.Visibility = System.Windows.Visibility.Visible;
                unmoderatedContentControl.loadContent(uri);
            }
        }
 // Use this for initialization
 void Start()
 {
     iBar    = GameObject.FindGameObjectWithTag("ItemBarHolder").GetComponent <ItemBar>();
     iScreen = GameObject.FindGameObjectWithTag("UI").GetComponent <InventoryScreen>();
     swap    = false;
     stage   = false;
 }
Example #5
0
 private bool CheckForItemBar()
 {
     if (mh != null && item_bar == null)
     {
         item_bar = mh.hud.ui_instance.GetComponentInChildren <ItemBar>();
     }
     return(item_bar != null);
 }
Example #6
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
 }
 // Use this for initialization
 void Start()
 {
     blockResetTimer = 0;
     canBlock        = true;
     attacking       = false;
     playerStamina   = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerStamina> ();
     pMana           = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerMana> ();
     pHealth         = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerHealth> ();
     adl             = gameObject.GetComponent <AttackDamageLibrary> ();
     itmBar          = GameObject.FindGameObjectWithTag("ItemBarHolder").GetComponent <ItemBar>();
     pressedR        = 0;
 }
Example #8
0
 // Use this for initialization
 void Start()
 {
     toggle = true;
     //this initially hides the inventory screen
     gameObject.GetComponent <Image>().color = new Color(255, 255, 255, 0);
     //this makes every single icon clear
     foreach (GameObject obj in GameObject.FindGameObjectsWithTag("slot"))
     {
         obj.GetComponent <Image>().color = new Color(0, 0, 0, 0);
     }
     errors = "";
     iBar   = GameObject.FindGameObjectWithTag("ItemBarHolder").GetComponent <ItemBar>();
 }
 //CharacterController cont;
 // Use this for initialization
 void Start()
 {
     playerStamina = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerStamina> ();
     rb            = gameObject.GetComponent <Rigidbody>();
     speed         = .2f;
     jumpTest      = false;
     doCommunicate = false;
     stunned       = false;
     //cont = gameObject.GetComponent<CharacterController>();
     iBar    = GameObject.FindGameObjectWithTag("ItemBarHolder").GetComponent <ItemBar>();
     iScreen = GameObject.FindGameObjectWithTag("UI").GetComponent <InventoryScreen>();
     pog     = gameObject.GetComponentInChildren <PlayerOnGround>();
 }
Example #10
0
    void Start()
    {
        itemBar  = GetComponentInChildren <ItemBar>();
        animator = spearAquirePanel.GetComponent <Animator>();
        spearAquirePanel.SetActive(false);
        info = GetComponent <EquippedInfo>();
        cam  = Camera.main;

        objectivePointer.SetActive(false);
        vehiclePointer.SetActive(false);
        recallPrompt.SetActive(true);
        lastFrameTime = Time.time;
        throwingChargePanel.SetActive(false);
        crosshair.gameObject.SetActive(false);
    }
Example #11
0
    private void SetItemBar(IItem itemToShow)
    {
        if (itemToShow != null)
        {
            ItemBar itemBar = GameUI.Instance.ItemBar;

            itemBar.ItemName   = itemToShow.GetName();
            itemBar.ItemHint   = itemToShow.GetHint();
            itemBar.ItemSprite = itemToShow.GetSprite();
        }
        else
        {
            GameUI.Instance.ItemBar.SetDefault();
        }
        GameUI.Instance.RotateUiText(GameUI.TextElements.IB_NAME);
    }
Example #12
0
 public void OnButtonClick()
 {
     ItemBar.NBT nowNBT = ItemBar.nowSelectNbt;
     if (nowNBT.nbtt == ItemBar.NBTType.Effect)
     {
         Effect.AddEffect(ItemBar.nowSelectNbt.effectNBT.et, ItemBar.nowSelectNbt.effectNBT.el);
         PlayerParticle.AddEffect(ItemBar.nowSelectNbt.effectNBT.color);
         ItemBar.nowSelectNbt = new ItemBar.NBT()
         {
             canUse = false
         };
     }
     ItemBar.UseItem();
     bt.enabled      = false;
     btImage.enabled = false;
     btText.enabled  = false;
 }
Example #13
0
    // Use this for initialization
    void Awake()
    {
        mUiTextElements = GetComponentsInChildren <Text>();
        mProgressBars   = GetComponentsInChildren <ProgressBar>();
        mItemBar        = GetComponentInChildren <ItemBar>();
        mObjectivesUI   = GetComponentInChildren <ObjectivesUI>();

        Debug.Assert(mObjectivesUI != null);
        Debug.Assert(mUiTextElements != null);
        Debug.Assert(mProgressBars != null);
        Debug.Assert(mItemBar != null);

        Debug.Assert(itemBar != null && objectiveBar != null && timeBar != null);

        mTextRotationCorutines = new IEnumerator[mUiTextElements.Length];

        Instance = this;
    }
Example #14
0
    private void OnUpdate(object obj)
    {
        num.text = DataManager.Instance.itemModel._dataList.Count + "/" + DataManager.Instance.roleVo.maxItemNum;
        Tools.ClearChildFromParent(scrollRect.content);
        barList.Clear();
        int count = 0;

        for (int i = 0; i < DataManager.Instance.itemModel._dataList.Count; i++)
        {
            if (StaticDataPool.Instance.staticItemPool.GetStaticDataVo(DataManager.Instance.itemModel._dataList[i].id).type == nowTab)
            {
                GameObject Obj = Tools.CreateGameObject("UI/ItemPanel/ItemBar", scrollRect.content);
                ItemBar    bar = Obj.GetComponent <ItemBar>();
                barList.Add(bar);
                bar.Create(DataManager.Instance.itemModel._dataList[i], SelectItem);
                count++;
            }
        }
        scrollRect.content.sizeDelta = new Vector2(scrollRect.content.sizeDelta.x, 150 * count);
    }
    // Use this for initialization
    void Start()
    {
        myHotbar    = hotbar.GetComponent <ItemBar>();
        myInventory = inventory.GetComponent <InventoryScreen>();
        myLoadout   = loadoutPrefab.GetComponent <Loadout>();

        int i = 0;

        foreach (GameObject obj in myLoadout.GetHotbar())
        {
            myHotbar.AddItemAtSpot(obj, "h" + i);
            i++;
        }

        i = 0;
        foreach (GameObject obj in myLoadout.GetInventory())
        {
            myInventory.AddItemAtSpot(obj, "i" + i);
            i++;
        }
    }
Example #16
0
 void Update()
 {
     if (Input.GetButton(actionButton) && !mAcionPending)
     {
         if (mHoldingItem)
         {
             if (mTimeAccumulator < itemUseTime)
             {
                 mTimeAccumulator += Time.deltaTime;
             }
             else
             {
                 //item action
                 mTimeAccumulator = 0.0f;
                 StartCoroutine(StartItemAction());
             }
             if (mItemBar != null)
             {
                 mItemBar.ProgressBarPct = mTimeAccumulator / itemUseTime;
             }
             else
             {
                 mItemBar = GameUI.Instance.ItemBar;
             }
         }
     }
     else
     {
         mTimeAccumulator = 0.0f;
         if (mItemBar != null)
         {
             mItemBar.ProgressBarPct = 0.0f;
         }
     }
     if (Input.GetButtonDown(dropButton) && mHoldingItem)
     {
         DropItem();
     }
 }
        public void populateUnmoddedBars()
        {
            //TODO examine if this is really how I want to do this.
            //It probably isn't. This method reeks of pretending to be useful in more than one case.
            foreach (UIElement child in unModeratedStack.Children)
            {
                (child as ItemBar).RemovePressed  -= thisBar_RemovePressed;
                (child as ItemBar).ContentPressed -= thisBar_ContentPressed;
            }
            unModeratedStack.Children.Clear();

            ItemBar thisBar;

            foreach (Post post in unmoderatedLinks)
            {
                thisBar = new ItemBar();
                thisBar.populate(post);
                thisBar.RemovePressed  += thisBar_RemovePressed;
                thisBar.ContentPressed += thisBar_ContentPressed;

                thisBar.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                unModeratedStack.Children.Add(thisBar);
            }
        }
Example #18
0
 public Inventory(ItemBar bar)
 {
     Instance = this;
     ItemBar  = bar;
 }
 void thisBar_RemovePressed(ItemBar sender, string fullName, List <int> infractions)
 {
     removePost(fullName, infractions);
 }
Example #20
0
 void Init()
 {
     gameObject.GetComponent <SpriteRenderer>().sprite = prefabToCopy.GetComponent <attackLibrary>().icon;
     iBar    = GameObject.FindGameObjectWithTag("ItemBarHolder").GetComponent <ItemBar>();
     iScreen = GameObject.FindGameObjectWithTag("UI").GetComponent <InventoryScreen>();
 }