public NodeDefinition(Node owner)
        {
            InitializeComponent();
            this.owner = owner;
            if (owner.Definitions.Length >= 2)
            {
                ValidDefinitions(true);
            }
            else
            {
                ValidDefinitions(false);
            }
            if (owner.Definitions != null && owner.Definitions.Length > 0)
            {
                foreach (string def in owner.Definitions)
                {
                    StackPanel sp = new StackPanel {
                        Orientation = Orientation.Horizontal
                    };
                    sp.Children.Add(new TextBox {
                        Text = def.Substring(owner.ID.Length + 1), Margin = new Thickness(2), MinWidth = 100
                    });
                    CrossButton removeBtn = new CrossButton {
                        Width = 15, Height = 15
                    };
                    removeBtn.Click += RemoveClick;
                    sp.Children.Add(removeBtn);
                    this.DefinitionContainer.Items.Add(sp);
                }
            }

            LayoutUpdated += NodeDefinition_LayoutUpdated;

            this.SetBinding(NodeDefinition.AnchorX1Property, new Binding()
            {
                Source = owner,
                Path   = new PropertyPath(Node.AnchorRightXProperty)
            });

            this.SetBinding(NodeDefinition.AnchorY1Property, new Binding()
            {
                Source = owner,
                Path   = new PropertyPath(Node.AnchorRightYProperty)
            });

            this.SetBinding(Canvas.LeftProperty, new Binding()
            {
                Source = this,
                Path   = new PropertyPath(NodeDefinition.AnchorX1Property)
            });

            this.SetBinding(Canvas.TopProperty, new Binding()
            {
                Source = this,
                Path   = new PropertyPath(NodeDefinition.AnchorY1Property)
            });

            MainWindow.GetCanvas.Children.Add(this);
        }
Exemplo n.º 2
0
        private void AddComboBox()
        {
            TControl comboBox = null;

            comboBox = new TControl(drawWindow1, () => new RectangleF(IndexOfCombo(comboBox) * (COMBO_WIDTH + drawWindow1.Height), 0, COMBO_WIDTH, drawWindow1.Height), true, m_comboBoxItems, Fonts.Default);
            comboBox.RequestedAreaChanged += () =>
            {
                MinimumSize      = new Size(0, (int)comboBox.RequestedArea.Height);
                Size             = m_comboBoxes.Select(b => b.RequestedArea.ToSize()).Aggregate(Size.Empty, (a, b) => new Size(a.Width + COMBO_WIDTH + drawWindow1.Height, Math.Max(a.Height, b.Height)));
                drawWindow1.Size = Size; //This should not be necessary, due to docking, but for some reason is.
            };

            comboBox.RegisterCallbacks(m_focusProvider, drawWindow1);
            m_focusProvider.LastFocused = comboBox;

            comboBox.SelectionChanged += () => SelectionChanged(comboBox);

            if (Scheme != null)
            {
                SetupColors(Scheme, comboBox);
            }

            //comboBox.EnterPressed += () => { Ok.Execute(); };
            m_comboBoxes.Add(comboBox);
            Size             = m_comboBoxes.Select(b => b.RequestedArea.ToSize()).Aggregate(Size.Empty, (a, b) => new Size(a.Width + COMBO_WIDTH + drawWindow1.Height, Math.Max(a.Height, b.Height)));
            drawWindow1.Size = Size; //This should not be necessary, due to docking, but for some reason is.

            if (m_comboBoxes.Count > 1)
            {
                int         i      = m_comboBoxes.Count - 2;
                CrossButton button = null;
                try
                {
                    button = new CrossButton(() => new RectangleF(i * (COMBO_WIDTH + drawWindow1.Height) + COMBO_WIDTH, 0, drawWindow1.Height, drawWindow1.Height), () => { Remove(i); }, Scheme.ControlBorder, Scheme.BackgroundBrush);
                    button.RegisterCallbacks(m_focusProvider, drawWindow1);
                    m_buttons.Add(button);
                    button = null;
                }
                finally
                {
                    if (button != null)
                    {
                        button.Dispose();
                    }
                }
            }
        }
        public void AddClick(object sender, RoutedEventArgs e)
        {
            StackPanel sp = new StackPanel {
                Orientation = Orientation.Horizontal
            };

            sp.Children.Add(new TextBox {
                Margin = new Thickness(2), MinWidth = 100
            });
            CrossButton removeBtn = new CrossButton {
                Width = 15, Height = 15
            };

            removeBtn.Click += RemoveClick;
            sp.Children.Add(removeBtn);
            this.DefinitionContainer.Items.Add(sp);
            ValidDefinitions(false);
        }
Exemplo n.º 4
0
        public UnknownParameterEditor()
        {
            InitializeComponent();

            const int BUTTON_SIZE = 16;

            m_textBox = new MyTextBox(drawWindow1, () => new RectangleF(0, 0, drawWindow1.Width - BUTTON_SIZE, Math.Max(BUTTON_SIZE, drawWindow1.Height)), MyTextBox.InputFormEnum.None, null, x => MyTextBox.TextBoxBorderDaniel, 4, Fonts.Default);
            m_textBox.RequestedAreaChanged += () =>
            {
                //Draw window is the whole control so we can just modify the control
                MinimumSize = new Size(BUTTON_SIZE, (int)m_textBox.RequestedArea.Height);
                Size size = m_textBox.RequestedArea.ToSize();
                size.Width += BUTTON_SIZE;
                Size        = size;
            };
            m_textBox.RegisterCallbacks(this, drawWindow1);
            //MyTextBox.SetupCallbacks(drawWindow1, m_textBox);

            m_button = new CrossButton(() => new RectangleF(drawWindow1.Width - BUTTON_SIZE, (drawWindow1.Height - BUTTON_SIZE) / 2, BUTTON_SIZE, BUTTON_SIZE), () => { Remove.Execute(); m_remove = true; }, Pens.Magenta, Brushes.Magenta);
            m_button.RegisterCallbacks(this, drawWindow1);

            LastFocused = m_textBox;
        }
Exemplo n.º 5
0
    // Aqui moveremos y giraremos la araña en funcion del Input
    void FixedUpdate()
    {
        // Si estoy en pausa no hacer nada (no moverme ni atacar)
        if (paused)
        {
            return;
        }

        // Calculo de velocidad lineal (_speed) y angular (_angularSpeed) en función del Input
        // Si camino/corro hacia delante delante: _speed = walkSpeed   /  _speed = runSpeed
        if (Input.GetKey(KeyCode.UpArrow) || CrossButton.GetInput(InputType.UP))
        {
            if (Input.GetKey(KeyCode.LeftShift) || isPressingRunningButton)
            {
                _speed = runSpeed;
            }
            else
            {
                _speed = walkSpeed;
            }
        }
        // Si camino/corro hacia delante detras: _speed = -walkSpeed   /  _speed = -runSpeed
        else if (Input.GetKey(KeyCode.DownArrow) || CrossButton.GetInput(InputType.DOWN))
        {
            if (Input.GetKey(KeyCode.LeftShift) || isPressingRunningButton)
            {
                _speed = -runSpeed;
            }
            else
            {
                _speed = -walkSpeed;
            }
        }
        else
        {
            // Si no me muevo: _speed = 0
            _speed = 0;
        }



        // Si giro izquierda: _angularSpeed = -rotateSpeed;
        if (Input.GetKey(KeyCode.LeftArrow) || CrossButton.GetInput(InputType.LEFT))
        {
            _angularSpeed = -rotateSpeed;
        }
        // Si giro derecha: _angularSpeed = rotateSpeed;
        else if (Input.GetKey(KeyCode.RightArrow) || CrossButton.GetInput(InputType.RIGHT))
        {
            _angularSpeed = rotateSpeed;
        }
        // Si no giro : _angularSpeed = 0;
        else
        {
            _angularSpeed = 0;
        }

        // Actualizamos el parámetro "Speed" en función de _speed. Para activar la anicación de caminar/correr
        animator.SetFloat("Speed", _speed);

        // Movemov y rotamos el rigidbody (MovePosition y MoveRotation) en función de "_speed" y "_angularSpeed"
        rigidBody.MovePosition(transform.position + (transform.forward * _speed * Time.deltaTime));
        rigidBody.MoveRotation(rigidBody.rotation * Quaternion.Euler(0f, _angularSpeed * Time.deltaTime, 0f));

        // Mover el collider en función del parámetro "Distance" (necesario cuando atacamos)
        box.center = new Vector3(box.center.x, box.center.y, animator.GetFloat("Distance") * _originalColliderZ * 20);
    }
Exemplo n.º 6
0
    // Aqui moveremos y giraremos la araña en funcion del Input
    void FixedUpdate()
    {
        // Si estoy en pausa no hacer nada (no moverme ni atacar)
        if (paused)
        {
            return;
        }

        /////////////////////////////////////////////////////////////////////////////////////
        // Si giro izquierda: _angularSpeed = -rotateSpeed;
        // Calculo de velocidad lineal (_speed) y angular (_angularSpeed) en función del Input
        // Si camino/corro hacia delante delante: _speed = walkSpeed   /  _speed = runSpeed
        // Si camino / corro hacia delante detras: _speed = -walkSpeed / _speed = -runSpeed
        // Si no me muevo: _speed = 0
        /////////////////////////////////////////////////////////////////////////////////////

        /////////////////////////////////////////////////////////////////////////////////////
        // Si giro izquierda: _angularSpeed = -rotateSpeed;
        // Si giro izquierda: _angularSpeed = -rotateSpeed;
        // Si giro derecha: _angularSpeed = rotateSpeed;
        // Si no giro : _angularSpeed = 0;
        /////////////////////////////////////////////////////////////////////////////////////
#if UNITY_IOS || UNITY_ANDROID
        float direction = 0f;
        if (CrossButton.GetInput(InputType.UP))
        {
            direction = 1f;
        }
        else if (CrossButton.GetInput(InputType.DOWN))
        {
            direction = -1f;
        }

        if (RunButton.IsRun())
        {
            _speed = direction * runSpeed;
        }
        else
        {
            _speed = direction * walkSpeed;
        }

        float torqueDirection = 0f;
        if (CrossButton.GetInput(InputType.RIGHT))
        {
            torqueDirection = 1f;
        }
        else if (CrossButton.GetInput(InputType.LEFT))
        {
            torqueDirection = -1f;
        }
        _angularSpeed = torqueDirection * rotateSpeed;
#else
        float verticalAxis = Input.GetAxis("Vertical");
        if (Input.GetButton("Run"))
        {
            _speed = verticalAxis * runSpeed;
        }
        else
        {
            _speed = verticalAxis * walkSpeed;
        }


        _angularSpeed = Input.GetAxis("Horizontal") * rotateSpeed;
#endif

        // Actualizamos el parámetro "Speed" en función de _speed. Para activar la anicación de caminar/correr
        _animator.SetFloat(SpeedHash, _speed);

        // Movemov y rotamos el rigidbody (MovePosition y MoveRotation) en función de "_speed" y "_angularSpeed"
        _rigidbody.MovePosition(transform.position + transform.forward * _speed * Time.deltaTime);
        _rigidbody.MoveRotation(transform.rotation * Quaternion.Euler(0, _angularSpeed * Time.deltaTime, 0));

        // Mover el collider en función del parámetro "Distance" (necesario cuando atacamos)
        Vector3 center = _boxCollider.center;
        center.z            = _originalColliderZ + _animator.GetFloat(DistanceHash) * _boxCollider.size.z;
        _boxCollider.center = center;
    }
Exemplo n.º 7
0
    // En este bucle solamente comprobaremos si el Input nos indica "atacar" y activaremos el trigger "Attack"
    private void Update()
    {
        // Si estoy en pausa no hacer nada (no moverme ni atacar)
        // TODO
        if (paused)
        {
            return;
        }

        // movimiento por teclado
        _h = Input.GetAxis("Horizontal");
        _v = Input.GetAxis("Vertical");

        // movimiento con crossbutton (a lo cutre)
        if (CrossButton.GetInput(InputType.UP) ||
            (UIButton.GetInput(ButtonType.RUN)))
        {
            _v = 1;                                                     // AUTORUN push button
        }
        if (CrossButton.GetInput(InputType.DOWN))
        {
            _v = -1;
        }
        if (CrossButton.GetInput(InputType.RIGHT))
        {
            _h = 1;
        }
        if (CrossButton.GetInput(InputType.LEFT))
        {
            _h = -1;
        }

        if (CrossButton.GetInput(InputType.UP_LEFT))
        {
            _v = 1; _h = -1;
        }
        if (CrossButton.GetInput(InputType.UP_RIGHT))
        {
            _v = 1; _h = 1;
        }
        if (CrossButton.GetInput(InputType.DOWN_LEFT))
        {
            _v = -1; _h = -1;
        }
        if (CrossButton.GetInput(InputType.DOWN_RIGHT))
        {
            _v = -1; _h = 1;
        }

        // Si detecto Input tecla/boton ataque ==> Activo disparados 'Attack'
        // UIbutton
        if (Input.GetKeyDown(KeyCode.Space) || UIButton.GetInput(ButtonType.ATTACK))
        {
            if (Time.time >= _nextAttackTime)
            {
                if (_an.GetCurrentAnimatorStateInfo(1).fullPathHash != damageHash)
                {
                    _an.SetTrigger(attackHash);
                    _nextAttackTime = Time.time + 1f / _attackRate;
                }
            }
        }
        if (_an.GetFloat("Distance") > 0.02)
        {
            play(_sourceAttack, FxAttack);
        }
    }