public VECTOR Normal(POSITION pos) { POSITION target = new POSITION { X = pos.X - X, Y = pos.Y - Y }; float Sum = (float)Math.Sqrt((target.X * target.X) + (target.Y * target.Y)); return(Sum != 0.0f ? new VECTOR { X = target.X / Sum, Y = target.Y / Sum } : new VECTOR { X = 0.0f, Y = 0.0f }); }
void login_callback(JObject json) { if (null != json) { position = new POSITION { X = random.Next(0, groupBox_users_location.Width - button_width), Y = random.Next(0, groupBox_users_location.Height - button_height) }; new_destination(); login_info = json; user_index = int.Parse(login_info["GUID"].ToString()); log("connected server. server[" + textBox_ip.Text + ":" + textBox_port.Text + "]"); } else { log("cannot connect server. server[" + textBox_ip.Text + ":" + textBox_port.Text + "]"); } }
public POSITION Force(float vForce, POSITION rhs) { return(Force(vForce, Normal(rhs))); }
void new_destination() { destination = new POSITION { X = random.Next(0, groupBox_users_location.Width - button_width), Y = random.Next(0, groupBox_users_location.Height - button_height) }; }