コード例 #1
0
 void FixedUpdate()
 {
     //子弹移动
     moveAction.Move(speed);
     //射线检测碰撞
     hitAciton.Hit(damage, hitEffect);
 }
コード例 #2
0
    public IEnumerator MoveCorutine()
    {
        while (true)
        {
            yield return(new WaitForSeconds(Random.Range(0.5f, 1.0f) * MoveDelaySec));

            if (Random.Range(0, 11) > 0)
            {
                MoveDirection = Vector3.zero;

                float   random            = Random.Range(0, 2) * 2 - 1;
                Vector3 prevMoveDirection = MoveDirection;

                if (Random.Range(0, 2) > 0)
                {
                    MoveDirection = new Vector3(random, prevMoveDirection.y, prevMoveDirection.z);
                }
                else
                {
                    MoveDirection = new Vector3(prevMoveDirection.x, random, prevMoveDirection.z);
                }

                if (!MoveAction.Move(MoveDirection))
                {
                    AttackAction.Attack(MoveDirection);
                }
            }
        }
    }
コード例 #3
0
ファイル: Designer.cs プロジェクト: ajupov/conceptual-graphs
        protected override void OnMouseMove(MouseEventArgs e)
        {
            if (e.Button == MouseButtons.None)
            {
                Cursor = Cursors.Arrow;
                var mousePoint = Gsc2Goc(new Point(e.X, e.Y));

                if ((_resizeAction != null) &&
                    ((Document.Action == DesignerAction.Select) ||
                     ((Document.Action == DesignerAction.Connect) &&
                      _resizeAction.IsResizingLink)))
                {
                    Cursor = _resizeAction.UpdateResizeCornerCursor(mousePoint);
                }

                if (Document.Action == DesignerAction.Connect)
                {
                    var mousePointerElementTMP = Document.FindElement(mousePoint);
                    if (_mousePointerElement != mousePointerElementTMP)
                    {
                        if (mousePointerElementTMP is ConnectorElement)
                        {
                            _mousePointerElement = mousePointerElementTMP;
                            _mousePointerElement.Invalidate();
                            Invalidate(_mousePointerElement, true);
                        }
                        else if (_mousePointerElement != null)
                        {
                            _mousePointerElement.Invalidate();
                            Invalidate(_mousePointerElement, true);
                            _mousePointerElement = null;
                        }
                    }
                }
                else
                {
                    Invalidate(_mousePointerElement, true);
                    _mousePointerElement = null;
                }
            }

            if (e.Button == MouseButtons.Left)
            {
                var dragPoint = Gsc2Goc(new Point(e.X, e.Y));

                if ((_resizeAction != null) && _resizeAction.IsResizing)
                {
                    _resizeAction.Resize(dragPoint);
                    Invalidate();
                }

                if ((_moveAction != null) && _moveAction.IsMoving)
                {
                    _moveAction.Move(dragPoint);
                    Invalidate();
                }

                if (_isMultiSelection || _isAddSelection)
                {
                    var p = Gsc2Goc(new Point(e.X, e.Y));
                    _selectionArea.Size = new Size(p.X - _selectionArea.Location.X, p.Y - _selectionArea.Location.Y);
                    _selectionArea.Invalidate();
                    Invalidate(_selectionArea, true);
                }

                if (_isAddLink)
                {
                    _selectedElement = Document.FindElement(dragPoint);
                    if (_selectedElement is ConnectorElement &&
                        Document.CanAddLink(_connStart, (ConnectorElement)_selectedElement))
                    {
                        _linkLine.Connector2 = (ConnectorElement)_selectedElement;
                    }
                    else
                    {
                        _linkLine.Connector2 = _connEnd;
                    }

                    var moveController = (IMoveController)((IControllable)_connEnd).GetController();
                    moveController.Move(dragPoint);

                    base.Invalidate();
                }
            }

            base.OnMouseMove(e);
        }
コード例 #4
0
    private void MoveInput()
    {
        Vector3 direction = Vector3.zero;

        if (Input.GetKeyDown(KeyCode.W))
        {
            direction.y += 1.0f;
        }
        else if (Input.GetKeyDown(KeyCode.S))
        {
            direction.y -= 1.0f;
        }
        else if (Input.GetKeyDown(KeyCode.A))
        {
            direction.x -= 1.0f;
        }
        else if (Input.GetKeyDown(KeyCode.D))
        {
            direction.x += 1.0f;
            if (transform.localScale.x < 0.0f)
            {
                GetComponent <Animator>().
                transform.localScale = new Vector3(-transform.localScale.x, transform.localScale.y, transform.localScale.z);
            }
        }
        else if (Input.GetKeyDown(KeyCode.Q))
        {
            SetMoveTime(_rollTimeSec);
            direction.x = -1.0f;
            direction.y = 1.0f;
        }
        else if (Input.GetKeyDown(KeyCode.Z))
        {
            SetMoveTime(_rollTimeSec);
            direction.x = -1.0f;
            direction.y = -1.0f;
        }
        else if (Input.GetKeyDown(KeyCode.E))
        {
            SetMoveTime(_rollTimeSec);
            direction.x = 1.0f;
            direction.y = 1.0f;
        }
        else if (Input.GetKeyDown(KeyCode.C))
        {
            SetMoveTime(_rollTimeSec);
            direction.x = 1.0f;
            direction.y = -1.0f;
        }

        if (direction != Vector3.zero)
        {
            bool moveResult = false;

            bool do_backstep = false;

            if (IsLockAction() && LockingAction.GetType() == typeof(AttackAction))
            {
                switch (Utility.VecToDir(MoveDirection))
                {
                case BaseAction.NormalDir.BESIDE:
                    if (GetSpriteRenderer().flipX)
                    {
                        if (direction.x > 0.0f)
                        {
                            do_backstep = true;
                        }
                    }
                    else
                    {
                        if (direction.x < 0.0f)
                        {
                            do_backstep = true;
                        }
                    }
                    break;

                case BaseAction.NormalDir.TOP:
                    if (direction.y < 0.0f)
                    {
                        do_backstep = true;
                    }
                    break;

                case BaseAction.NormalDir.DOWN:
                    if (direction.y > 0.0f)
                    {
                        do_backstep = true;
                    }
                    break;
                }
            }

            if (direction.x != 0 && direction.y != 0)
            {
                moveResult = RollAction.Move(direction);
            }
            else
            {
                if (do_backstep)
                {
                    moveResult = BackStepAction.Move(direction);
                }
                else
                {
                    moveResult = MoveAction.Move(direction);
                }
            }
        }

        if (Input.GetMouseButtonDown(0))
        {
            direction = Utility.GetMouseWorldPosition() - transform.position;
            direction = Utility.NormalizeIntVector(direction);

            AttackAction.Attack(direction);
        }
    }