Example #1
0
        private void CreateSlots(int slotAmount)
        {
            if (Slots != null)
            {
                foreach (Item.ItemSlot slot in Slots)
                {
                    Destroy(slot.gameObject);
                }
            }

            Slots = new Item.ItemSlot[slotAmount];

            //float xtent = slotPrefab.GetComponent<SpriteRenderer>().sprite.bounds.size.x*slotPrefab.transform.localScale.x;
            float width = UsefulStuff.GetScreenWidth();
            float y     = UsefulStuff.CalculateScreenPosition(new Vector2(0, -60)).y;

            for (int i = 0; i < slotAmount; i++)
            {
                Slots[i] = Instantiate(slotPrefab).GetComponent <Item.ItemSlot>();
                Slots[i].transform.SetParent(this.transform);
                Slots[i].transform.localPosition = new Vector3(
                    (-width / 2) + (width / (slotAmount + 1)) * (i + 1)
                    , y
                    );
                //new Vector3(slotPos.x + xtent * i+slotPosSpace*i, slotPos.y, 0);
            }
        }
Example #2
0
        private void OnEnable()
        {
            //Calculates the width of screen and positions the box
            Vector2 xy       = Box.GetComponent <SpriteRenderer>().sprite.bounds.size;
            float   frustumH = UsefulStuff.GetScreenHeight();
            float   frustumW = frustumH * Camera.main.aspect;

            Box.transform.localScale    = new Vector2(frustumW / xy.x, (frustumH / 3) / xy.y);
            Box.transform.localPosition = UsefulStuff.CalculateScreenPosition(new Vector2(0, -70));
            //Box.transform.localPosition = new Vector3(0, -frustumH/2 + xy.y*Box.transform.localScale.y+xy.y*Box.transform.localScale.y*0.5f, 0);
            //Filling a sprite 1/4 of a screenxy.y*Box.transform.localScale.y
            //Hardcoding is bad DYNAMIC HARDCODE EVERYTHING
            P.transform.localPosition     = UsefulStuff.CalculateScreenPosition(new Vector2(65, -70));
            TextM.transform.localPosition = UsefulStuff.CalculateScreenPosition(new Vector2(-90, -45));
            //DisablePlayer();
        }
Example #3
0
 private void OnEnable()
 {
     HPBar.transform.localPosition = UsefulStuff.CalculateScreenPosition(HPpos);
     ABar.transform.localPosition  = UsefulStuff.CalculateScreenPosition(Ammopos);
 }