Example #1
0
 public static void RenderPickable(Unit u)
 {
     BaseRender.RenderPickable(u);
 }
Example #2
0
        public static void RenderViewable(Unit u)
        {
            if (u.Health < 0) {
                return;
            }

            //Console.WriteLine(String.Format("Drawunit{0} {1} == {2} {3} != {4} = {5}",SharedResources.MouseIsDown,u.glId ,Game.Selection.SelectedId ,Game.Selection.Maploc , Game.Selection.NONE, SharedResources.MouseIsDown && u.glId == Game.Selection.SelectedId && Game.Selection.Maploc != Game.Selection.NONE));
            //draw the path to the hovered location.
            if (SharedResources.MouseIsDown &&
                u.glId == Game.Selection.SelectedId
                && Game.Selection.Maploc != Game.Selection.NONE) {

                /*foreach(ITask task in u.Plan){
                    if(task is Path){
                        Path p = (Path)task;

                        GL.PushMatrix();
                        GL.Color3(1.0f,0.0f,0.0f);
                        for(int i = 1; i < p.Coords.Count;i++){
                            GL.Begin(BeginMode.Lines);

                            GL.Vertex3(p.Coords[i].X,p.Coords[i].Y, p.Coords[i].Z);
                            GL.Vertex3(p.Coords[i-1].X,p.Coords[i-1].Y, p.Coords[i-1].Z);

                            GL.End ();
                        }
                        GL.PopMatrix();
                    }
                }*/
                if(u.Team == Game.Game.Instance.LocalPlayer.Team){
                    List<Coords> Coords = Render.Instance.theGame.Manager.World.GetPath(u.X, u.Z, Game.Selection.MapX,Game.Selection.MapZ);
                    //Console.WriteLine("drawpath to "+x+","+z+" is "+Coords.Count);
                    GL.PushMatrix();
                        GL.Translate(0,1,0);

                    for(int i = 1; i < Coords.Count;i++){

                        //	Console.WriteLine(String.Format("Lines: {0},{1},{2}",Coords[i].X,Coords[i].Y, Coords[i].Z));
                        //GL.Begin(BeginMode.Quads);
                            if(i> u.ActionPoints){
                                GL.Color3(1.0f,0.0f,0.0f);
                            }
                            else{
                                GL.Color3(0.0f,1.0f,0.0f);
                            }
                        /*	GL.Vertex3(Coords[i].X,Coords[i].Y, Coords[i].Z);
                            GL.Vertex3(Coords[i].X+.1f,Coords[i].Y, Coords[i].Z+.1f);
                            GL.Vertex3(Coords[i-1].X,Coords[i-1].Y, Coords[i-1].Z+.1f);
                            GL.Vertex3(Coords[i].X+.1f,Coords[i].Y, Coords[i].Z);
                        GL.End ();*/
                        //show a number of moves at each spot.

                        //GL.Color3 (1f, 1f, 1f);
                        GL.Enable(EnableCap.Texture2D);

                        GL.BindTexture(TextureTarget.Texture2D, SharedResources.StringTextureCache [i.ToString ()].glId);
                        GL.Begin(BeginMode.Quads);
                        //do
                                GL.TexCoord2(0,1);
                                GL.Vertex3(Coords[i].X-.5f,Coords[i].Y-.9f, Coords[i].Z+.5f);
                                GL.TexCoord2(1,1);
                                GL.Vertex3(Coords[i].X+.5f,Coords[i].Y-.9f, Coords[i].Z+.5f);
                                GL.TexCoord2(1,0);
                                GL.Vertex3(Coords[i].X+.5f,Coords[i].Y-.9f, Coords[i].Z-.5f);
                                GL.TexCoord2(0,0);
                                GL.Vertex3(Coords[i].X-.5f,Coords[i].Y-.9f, Coords[i].Z-.5f);
                        //	GL.Disable(EnableCap.Texture2D);

                        GL.End ();
                    //	Console.WriteLine (GL.GetError ());
                    }
                    GL.PopMatrix();

                }
            }

            GL.PushMatrix ();
            {
                GL.Translate (u.X, u.Y, u.Z);
                GL.Rotate (u.Rotation*360/6.283f, Renderer.Render.UP);
                GL.Scale (.75f, .75f, .75f);
                GL.Translate (u.SizeX / -2f, 0f, u.SizeZ / -2f);

                GL.Begin (BeginMode.QuadStrip);
                {
                    GL.Color3 (Game.Game.Instance.Manager.GetTeamColor(u.Team));

                    GL.Vertex3 (0, 0, 0);
                    GL.Vertex3 (0, u.SizeY, 0);

                    GL.Vertex3 (u.SizeX, 0, 0);
                    GL.Vertex3 (u.SizeX, u.SizeY, 0);

                    GL.Vertex3 (u.SizeX, 0, u.SizeZ);
                    GL.Vertex3 (u.SizeX, u.SizeY, u.SizeZ);

                    GL.Vertex3 (0, 0, u.SizeZ);
                    GL.Vertex3 (0, u.SizeY, u.SizeZ);

                    GL.Vertex3 (0, 0, 0);
                    GL.Vertex3 (0, u.SizeY, 0);
                }

                GL.End ();

                GL.Begin (BeginMode.Quads);
                {
                    GL.Vertex3 (0, u.SizeY, 0);
                    GL.Vertex3 (0, u.SizeY, u.SizeZ);
                    GL.Vertex3 (u.SizeX, u.SizeY, u.SizeZ);
                    GL.Vertex3 (u.SizeX, u.SizeY, 0);
                }
                GL.End ();

                if (u.glId == Game.Selection.SelectedId) {

                    GL.Color3(System.Drawing.Color.PaleVioletRed);
                    GL.Begin(BeginMode.Lines);

                    GL.Vertex3 (0, 0, 0);
                    GL.Vertex3 (u.SizeX, 0, 0);
                    GL.Vertex3 (u.SizeX, 0, u.SizeZ);
                    GL.Vertex3 (0, 0, u.SizeZ);
                    GL.Vertex3 (0,0,0);
                    GL.End ();

                }
            }
            WeaponRenderer.RenderViewable(u.Weapon);

            GL.PopMatrix();
        }
Example #3
0
 public void updateSelectedUnit(Unit selected)
 {
     unitInfo.Draw();
 }
Example #4
0
 public bool DidHit(Unit target, Weapon w)
 {
     return Game.Instance.RandomNumberGenerator.NextDouble() <= w.HitPct;
 }
Example #5
0
 public bool CanAttack(Unit target)
 {
     return 	this.Weapon.InRange(this.Position, target.Position);
 }
Example #6
0
        public int AddUnit(Unit unit)
        {
            Int32 glID = getGLID();
            unit.glId = glID;
            this.units.Add (glID, unit);
            this.unitNames.Add (unit.Name, glID);

            return glID;
        }
Example #7
0
        public void Fire(Unit Shooter, Unit Target)
        {
            if (Shooter.CanAttack(Target) ) {
                if (usesAmmo) {
                    remainingAmmo--;
                }

                //skills and what not
                if(Shooter.DidHit(Target, this)){

                    //Calculate Damage
                    int dam = Game.Game.Instance.RandomNumberGenerator.Next(minDamage, maxDamage);
                    //apply to the Target
                    Target.TakeDamage(dam, this.damageType);

                }

            }
        }