public void ReleaseMouseDown(int tag, int num, int button) { if (state == ControlState.BattleState) { if (button == (int)Mouse.Button.Left) { Tuple <double, double> vect; if (!server.Players[num].IsRemote) { vect = view.AngleByMousePos(); } else { vect = vect = Utily.MakePair <double>(server.Players[num].MousePos.Item1 - arena.map.players[tag].x, server.Players[num].MousePos.Item2 - arena.map.players[tag].y); } if (Utily.Hypot2(vect.Item1, vect.Item2) == 0) { return; } int tagArr = arena.FirePlayer(tag, vect); if (tagArr != -1) { view.AddArrow(tagArr); } } } }
public void MovePlayer(int tag, int num) { Tuple <double, double> vect; if (!server.Players[num].IsRemote) { vect = view.AngleByMousePos(); } else { vect = Utily.MakePair <double>(server.Players[num].MousePos.Item1 - arena.map.players[tag].x, server.Players[num].MousePos.Item2 - arena.map.players[tag].y); } if (Utily.Hypot2(vect.Item1, vect.Item2) < Map.RPlayer * Map.RPlayer * 2) { arena.MovePlayer(tag, Utily.MakePair <double>(0, 0)); view.MovePlayer(tag, Utily.MakePair <double>(0, 0)); } else { int Forw = server.Players[num].Forward, Left = server.Players[num].Left; var newvect = Utily.MakePair <double>(vect.Item1 * Forw + vect.Item2 * Left, vect.Item2 * Forw - vect.Item1 * Left); arena.MovePlayer(tag, newvect); view.MovePlayer(tag, newvect); } }
private double Length(double x, double y, double x1, double y1, double x2, double y2) { double len = ((y1 - y2) * x + (x2 - x1) * y + (x1 * y2 - x2 * y1)) * ((y1 - y2) * x + (x2 - x1) * y + (x1 * y2 - x2 * y1)) / ((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); if (mul(x - x1, y - y1, x2 - x1, y2 - y1) < 0 || mul(x - x2, y - y2, x2 - x1, y2 - y1) < 0) { return(Math.Min(Utily.Hypot2(x - x1, y - y1), Utily.Hypot2(x - x2, y - y2))); } return(len); }