コード例 #1
0
        protected ControlableWave(ControlableWave copy)
            : base(copy)
        {
            this.Killed       = Functions.Clone <EventHandler>(copy.Killed);
            this.shipState    = new ShipState(copy.shipState);
            this.movementInfo = new ShipMovementInfo(copy.movementInfo);
            foreach (IControler controler in copy.controlers)
            {
                AddControler(null, (IControler)controler.Clone());
            }
            this.target         = copy.target;
            this.ControlHandler = Functions.Clone <IControlHandler>(copy.ControlHandler);

            this.currentControlInput              = copy.currentControlInput;
            this.direction                        = copy.direction;
            this.controlableType                  = copy.controlableType;
            this.controlableSounds                = copy.controlableSounds;
            this.attachedEffectCollection         = new EffectCollection(copy.attachedEffectCollection);
            this.contFlags                        = copy.contFlags;
            this.CollisionState.GenerateRayEvents = true;


            this.colors       = copy.colors;
            this.primaryColor = copy.primaryColor;
            if (copy.weaponInfo != null)
            {
                this.weaponInfo = (IWeaponsLogic)copy.weaponInfo.Clone();
            }
        }
コード例 #2
0
        void DrawVertexes(WindowState state)
        {
            List <IControlable> BODIES = new List <IControlable>(world.Collidables);
            float baseradiusInc        = (float)(MathHelper.PI * 2) / ((float)numberofCircleVertexes);
            float radiusInc            = baseradiusInc;
            int   numerofCV            = numberofCircleVertexes;
            float sizedCV = 100;

            int       color  = defaultColor1.ToArgb();
            int       color2 = defaultColor2.ToArgb();
            Matrix3x3 matrix = Matrix3x3.FromScale(new Vector2D(state.Scale, state.Scale)) * Matrix3x3.FromTranslate2D(state.Offset);

            foreach (IControlable body in BODIES)
            {
                if (body.BoundingBox2D == null || !body.IgnoreInfo.IsCollidable)
                {
                    body.CalcBoundingBox2D();
                }
                if (!state.ScreenBoundingBox.TestIntersection(body.BoundingBox2D) || body.IsExpired || body.IsInvisible)
                {
                    continue;
                }
                ControlableWave wave = body as ControlableWave;

                if (body.ControlHandler != null &&
                    body.Target != null && !body.Target.IsExpired && !body.Target.IsInvisible &&
                    body.Controlers != null && body.Controlers.Length > 0)
                {
                    Vector2D   direction = Vector2D.Normalize(body.Target.Current.Position.Linear - body.Current.Position.Linear);
                    Vector2D[] vertexes  = new Vector2D[3];
                    vertexes[0] = body.Current.Position.Linear + direction * (body.BoundingRadius + 60);
                    vertexes[1] = body.Current.Position.Linear + Vector2D.Rotate(MathHelper.PI / 24, direction) * (body.BoundingRadius + 20);
                    vertexes[2] = body.Current.Position.Linear + Vector2D.Rotate(-MathHelper.PI / 24, direction) * (body.BoundingRadius + 20);

                    //Vector2D.Transform(matrix, ref vertexes);
                    OperationHelper.ArrayRefOp <Matrix3x3, Vector2D, Vector2D>(
                        ref matrix,
                        vertexes,
                        vertexes,
                        Vector2D.Multiply);


                    Gl.glBegin(Gl.GL_POLYGON);
                    SetColor(teamcolors[body.FactionInfo.FactionNumber]);
                    Gl.glVertex3f(vertexes[0].X, vertexes[0].Y, 0);
                    SetColor(teamcolors[0]);
                    Gl.glVertex3f(vertexes[1].X, vertexes[1].Y, 0);
                    Gl.glVertex3f(vertexes[2].X, vertexes[2].Y, 0);
                    Gl.glEnd();
                }
                foreach (Physics2D.ICollidableBodyPart part in body.CollidableParts)
                {
                    //Gl.glLoadIdentity();
                    Gl.glBegin(Gl.GL_POLYGON);
                    //IColoredPart colored = part as IColoredPart;
                    if (part.UseCircleCollision)
                    {
                        if (part.BaseGeometry.BoundingRadius > sizedCV)
                        {
                            numerofCV = numberofCircleVertexes + (int)MathHelper.Sqrt(part.BaseGeometry.BoundingRadius - sizedCV);
                            if (numerofCV > 100)
                            {
                                numerofCV = 100;
                            }
                            radiusInc = (float)(MathHelper.PI * 2) / ((float)numerofCV);
                        }
                        else
                        {
                            numerofCV = numberofCircleVertexes;
                            radiusInc = baseradiusInc;
                        }

                        for (int angle = 0; angle != numerofCV; ++angle)
                        {
                            Vector2D vect = matrix * (Vector2D.FromLengthAndAngle(part.BaseGeometry.BoundingRadius, ((float)angle) * radiusInc + part.GoodPosition.Angular) + part.GoodPosition.Linear);

                            int vectColor = color2;
                            if (angle == 0)
                            {
                                vectColor = color;
                                if (body != null)
                                {
                                    vectColor = teamcolors[body.FactionInfo.FactionNumber];
                                }
                            }
                            if (wave != null)
                            {
                                if (wave.Colors.Length > angle)
                                {
                                    vectColor = (wave.Colors[angle]);
                                }
                                else
                                {
                                    if (wave.PrimaryColor != 0)
                                    {
                                        vectColor = (wave.PrimaryColor);
                                    }
                                }
                            }
                            SetColor(vectColor);

                            Gl.glVertex3f((float)vect.X, (float)vect.Y, 0);
                        }

                        //soundInfo.Add(points);
                    }
                    else
                    {
                        Vector2D[] vects = part.DisplayVertices;
                        if (vects != null)
                        {
                            vects = OperationHelper.ArrayRefOp <Matrix3x3, Vector2D, Vector2D>(
                                ref matrix,
                                part.DisplayVertices,
                                Vector2D.Multiply);

                            //vects = Vector2D.Transform(matrix, part.DisplayVertices);
                            for (int pos = 0; pos != vects.Length; ++pos)
                            {
                                int vectColor = color2;
                                if (pos == 0)
                                {
                                    vectColor = color;
                                    if (body != null)
                                    {
                                        vectColor = teamcolors[body.FactionInfo.FactionNumber];
                                    }
                                }
                                SetColor(vectColor);
                                Gl.glVertex3f((float)vects[pos].X, (float)vects[pos].Y, 0);
                            }
                        }
                    }
                    Gl.glEnd();
                }
            }
        }