Exemple #1
0
        /// <summary>
        /// Do not use this directly.
        /// Size is fixed to 150f, 150f.
        /// </summary>
        /// <param name="pos">Position</param>
        /// <param name="type">Creature Type</param>
        public UIcreature(Vector2 pos, CreatureTemplate.Type type) : base(pos, new Vector2(150f, 150f))
        {
            _inBox = true;
            if (!init)
            {
                return;
            }

            this.rect = new DyeableRect(menu, owner, pos + offset, size, true);
            this.subObjects.Add(this.rect);
            //owner.subObjects.Add(this.menuObj);

            this._type = type;

            cage = new FContainer();
            this.myContainer.AddChild(cage);
            cage.SetPosition(new Vector2(75f, 20f));
            fence = new FContainer();
            this.myContainer.AddChild(fence);
            fence.SetPosition(new Vector2(75f, 20f));
            fence.MoveToFront();

            absTemplate       = new OptionalCreatureTemplate(type);
            absCreature       = new OptionalAbstractCreature(world, absTemplate);
            absCreature.state = new OptionalCreatureState(absCreature);
        }
            public void Update(float timeStacker)
            {
                if (displaySprite.container != cam.ReturnFContainer("HUD2"))
                {
                    cam.ReturnFContainer("HUD2").AddChild(displaySprite);
                }

                // Create a delegate that gets the current inputs
                if (_getInputs == null)
                {
                    Type rwInput = Type.GetType("RWInput, Assembly-CSharp");
                    _getInputs = (GetRTInputs)Delegate.CreateDelegate(typeof(GetRTInputs), rwInput.GetMethod("PlayerInput", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static));
                }

                // Move the input display when left bracket is pressed
                if (Input.GetKey(KeyCode.LeftBracket))
                {
                    origin = Input.mousePosition;
                    Move();
                }

                // Allow dragging the input display
                if (_dragging)
                {
                    if (!Input.GetMouseButton(0))
                    {
                        _dragging = false;
                    }
                    else
                    {
                        origin = (Vector2)Input.mousePosition + _dragOffset;
                        Move();
                    }
                }
                else
                {
                    if (Input.GetMouseButtonDown(0) && IsMouseOver)
                    {
                        _dragging   = true;
                        _dragOffset = origin - (Vector2)Input.mousePosition;
                    }
                }

                // Change the lerp bar to display the current timeStacker
                _lerpBar.scaleX = timeStacker * _lerpBarWidth;

                // Cache the inputs at the start of the frame. It is not going to change while the buttons are updating
                rtInput = _getInputs(0, cam.game.rainWorld.options, cam.game.rainWorld.setup);
                foreach (InputButton button in buttons)
                {
                    button.Update();
                }

                // Update the analog input
                Vector2 aiCenter  = new Vector2(DrawOrigin.x + _analogRelPos.x + _analogBoxSize * 0.5f - 0.5f, DrawOrigin.y + _analogRelPos.y + _analogBoxSize * 0.5f - 0.5f);
                float   maxOffset = _analogBoxSize * 0.5f - 4f;

                _analogIndicator.SetPosition(aiCenter + CurrentInput.analogueDir * maxOffset);
                _analogRTIndicator.SetPosition(aiCenter + rtInput.analogueDir * maxOffset);
                _analogRTIndicator.isVisible = !hideRTIndicators;

                displaySprite.MoveToFront();
                offscreenContainer.MoveToFront();
            }