public void move(Hex3D target) { hex.RemoveObject(); //oldposition = hex.getCenter(); //percenttraveled = 0; if (ghosthex != null) ghosthex.ClearGhostObject(); line = null; targetpositions.Enqueue(target.getCenter()); double x = target.getCenter().X - hex.getCenter().X; double y = hex.getCenter().Y - target.getCenter().Y; double newangle = Math.Atan(x / y); //Console.WriteLine(" x " + x); //Console.WriteLine(" y " + y); if (y < 0) newangle = newangle + Math.PI; //Console.WriteLine("angle -> " + newangle); targetangles.Enqueue(newangle); SetHex(target); }
public void SetGhost(Hex3D target) { //Console.WriteLine("setting ghost"); double x = target.getCenter().X - hex.getCenter().X; double y = hex.getCenter().Y - target.getCenter().Y; targetangle = Math.Atan(x / y); //Console.WriteLine(" x " + x); //Console.WriteLine(" y " + y); if (y < 0) targetangle = targetangle + Math.PI; //Console.WriteLine("angle -> " + targetangle); if (ghosthex != null) ghosthex.SetGhostObject(null); ghosthex = target; target.SetGhostObject(this); if (this.hex.hexgrid == ghosthex.hexgrid) { //Console.WriteLine("creating new linemodel"); line = new LineModel(getCenter(), ghosthex.getCenter()); } }
public override void DrawGhost(Microsoft.Xna.Framework.Matrix world, Microsoft.Xna.Framework.Matrix view, Microsoft.Xna.Framework.Matrix projection) { if (shipmodel == null) { shipmodel = ShipModel.shipmodels[getprefix() + modelstring]; } if (ghosthex == null) { return; } shipmodel.Draw(Matrix.CreateRotationZ((float)targetangle) * Matrix.CreateTranslation(ghosthex.getCenter()) * world, view, projection, Color.Multiply(affiliation.color, .2f), 1.6f, hoveringHeight); if (this.hex.hexgrid == ghosthex.hexgrid) { if (line != null) line.Draw(world, view, projection, affiliation.color); else line = new LineModel(getCenter(), ghosthex.getCenter()); } }