public override void Draw(Microsoft.Xna.Framework.Matrix world, Microsoft.Xna.Framework.Matrix view, Microsoft.Xna.Framework.Matrix projection) { if (shipmodel == null) { Console.WriteLine(getprefix() + modelstring); shipmodel = ShipModel.shipmodels[getprefix() + modelstring]; } //Console.WriteLine(angle); //update current angle, and hmove it closer to the target angle, double angleIncr = (Math.PI / 25.0); if (Math.Abs(currentAngle - targetangle) > (Math.PI / 20.0)) { //Then we need to modify depending on angle difference if (currentAngle < targetangle) { currentAngle += angleIncr; } else { currentAngle -= angleIncr; } } else { if (targetangles.Count() != 0) { if (percenttraveled == 100) targetangle = targetangles.Dequeue(); } if (percenttraveled < 100) { percenttraveled = percenttraveled + 4; } else { if (targetpositions.Count() != 0) { percenttraveled = 0; oldposition = targetvector; targetvector = targetpositions.Dequeue(); } else { targetvector = hex.getCenter(); } } } //Console.WriteLine("percenttaveled :: {0} ", percenttraveled); Vector3 currentvector = (targetvector - oldposition) * (percenttraveled / 100.0f) + oldposition; //Console.WriteLine("current vector :: {0} \n target vector :: {1} ", currentvector, targetvector); //Create translation gets hex world coordinates if (affiliation != null) { shipmodel.Draw(Matrix.CreateRotationZ((float)currentAngle) * Matrix.CreateTranslation(currentvector) * world, view, projection, affiliation.color, 1.6f, hoveringHeight); } else { shipmodel.Draw(Matrix.CreateRotationZ((float)currentAngle) * Matrix.CreateTranslation(currentvector) * world, view, projection, Color.Black, 1.6f, hoveringHeight); } //create illusion that ship is hovering in space hoveringHeight += hoveringAcc; if (hoveringHeight > 13 || hoveringHeight < 6) { hoveringAcc *= -1; } }
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()); } }