private void button1_Click(object sender, EventArgs e) { byte commandAddr = (byte)((comboBox1.Text == "X轴") ? 0x00 : 0x01); CmdMove ci = new CmdMove(); addrc = ci.GetVrateStillStepCmd(commandAddr, textBox1.Text, textBox2.Text, textBox4.Text, textBox3.Text); richTextBox1.Text = DataChange.byteToHexStr(addrc); }
/// <summary> /// 移动 /// </summary> void CreateMoveCmd() { CmdMove cmd = CmdFactory.Create(CmdFactory.E_CmdType.Move) as CmdMove; Owner.BlackBoard.DesiredDirection = Direction; Owner.BlackBoard.DesiredPosition = Owner.Position; Owner.BlackBoard.MoveSpeedModifier = Force; Owner.BlackBoard.AddCmd(cmd); }
private void button1_Click(object sender, EventArgs e) { byte commandAddr = (byte)((comboBox1.Text == "X轴") ? 0x00 : 0x01); bool pos = (comboBox2.Text == "正向") ? true : false; CmdMove ci = new CmdMove(); addrc = ci.GetOneStepCmd(commandAddr, pos); richTextBox1.Text = DataChange.byteToHexStr(addrc); }
protected void onDragging() { //如果鼠标到虚拟键盘原点的位置 < 半径r if (Vector3.Distance(Input.mousePosition, m_initPosition) < m_radius) { //虚拟键跟随鼠标 transform.position = Input.mousePosition; } else { //计算出鼠标和原点之间的向量 Vector3 dir = Input.mousePosition - m_initPosition; //这里dir.normalized是向量归一化的意思,实在不理解你可以理解成这就是一个方向,就是原点到鼠标的方向,乘以半径你可以理解成在原点到鼠标的方向上加上半径的距离 transform.position = m_initPosition + dir.normalized * m_radius; //transform.position = initPosition; } ; //float angle = Vector3.Angle(transform.position - initPosition, transform.right); Vector3 dir1 = transform.position - m_initPosition; int quadrant = 0; if (dir1.x >= 0) { if (dir1.y >= 0) { quadrant = 1; } else { quadrant = 4; } } else { if (dir1.y >= 0) { quadrant = 2; } else { quadrant = 3; } } float angle = Mathf.Atan(dir1.y / dir1.x) * 180 / Mathf.PI; //Debug.Log("x: " + dir1.x + "; y: " + dir1.y); float ratio = Vector3.Distance(transform.position, m_initPosition) / m_radius; CmdMove sCmd = new CmdMove(1); sCmd.Init(quadrant, Mathf.Abs(angle), ratio); m_sCmdMgr.CmdPush((CmdBase)sCmd); // todo zhou // InputController.Instance.notifyDpadDragging(quadrant, Mathf.Abs(angle), ratio); }
protected override void Initialize(ICmd cmd) { base.Initialize(cmd); Cmd = cmd as CmdMove; FinalRotation.SetLookRotation(Owner.BlackBoard.DesiredDirection); StartRotation = Owner.Transform.rotation; Owner.BlackBoard.MotionType = GetMotionType(); RotationProgress = 0; }
public override void Exit() { if (Cmd != null) { Cmd.SetSuccess(); Cmd = null; } Owner.BlackBoard.Speed = 0; base.Exit(); }
/// <summary> /// 创建命令 /// </summary> /// <param name="type">命令类型</param> public static ICmd Create(E_CmdType type) { ICmd cmd = null; if (UnusedCmds[type] != null && UnusedCmds[type].Count > 0) { cmd = UnusedCmds[type].Dequeue(); } else { switch (type) { case E_CmdType.Idle: cmd = new CmdIdle(); break; case E_CmdType.Move: cmd = new CmdMove(); break; case E_CmdType.Attack: cmd = new CmdAttack(); break; case E_CmdType.Death: cmd = new CmdDeath(); break; case E_CmdType.WeaponShow: cmd = new CmdWeaponShow(); break; default: Debug.LogError("No Cmd to Create!!! ICmd Type: " + type); break; } } if (cmd != null) { cmd.Reset(); cmd.SetActive(); #if DEBUG UsedCmds.Add(cmd); #endif } return(cmd); }
public void GetOneStepCmdTest() { //AA 06 01 B0 00 01 B6 //AA 06 01 B0 00 81 36 CmdMove cf = new CmdMove(); byte[] ret = cf.GetOneStepCmd(0x00, true); Assert.AreEqual(ret.Count(), 7); Assert.AreEqual(ret[6], 0xB6); Assert.AreEqual(ret[0], 0xAA); Assert.AreEqual(ret[1], 0x06); Assert.AreEqual(ret[2], 0x01); Assert.AreEqual(ret[3], 0xB0); byte[] ret1 = cf.GetOneStepCmd(0x00, false); Assert.AreEqual(ret1.Count(), 7); Assert.AreEqual(ret1[6], 0x36); Assert.AreEqual(ret1[0], 0xAA); Assert.AreEqual(ret1[1], 0x06); Assert.AreEqual(ret1[2], 0x01); Assert.AreEqual(ret1[3], 0xB0); }