Exemple #1
0
        private void FindTargetsList()
        {
            Echo("Sensor Range: " + sensor.MaxRange);
            //Echo("Running");
            sensor.DetectedEntities(entities);

            foreach (MyDetectedEntityInfo entity in entities)
            {
                Target t = new Target(entity, Me.GetPosition());
                targets.Add(t);
            }

            Echo("Entities: " + entities.Count);
            Echo("Screens: " + screens.Count);
            Echo("Used Screens: " + usedScreens.Count);

            targets.Sort((x, y) => x.Distance.CompareTo(y.Distance));

            foreach (IMyTextPanel screen in usedScreens)
            {
                using (var frame = screen.DrawFrame()) {
                    float point = 10;
                    foreach (Target target in targets)
                    {
                        Echo("start");
                        Echo("sensor: " + sensor.ToString());

                        Vector2 pos2       = new Vector2(256, 256);
                        Vector2 size       = new Vector2(512, 512);
                        var     background = MySprite.CreateSprite("SquareSimple", pos2, size);
                        background.Color = Color.Black;
                        frame.Add(background);

                        if (point == 10)
                        {
                            target.Selected = true;
                        }

                        StringBuilder textEnt = new StringBuilder();
                        if (target.Selected)
                        {
                            textEnt.Append("*| ");
                        }
                        else
                        {
                            textEnt.Append(" | ");
                        }
                        textEnt.Append(target.Info.Name + " " + target.Distance.ToString("0.00") + "m");

                        //string textEnt = target.Info.Name + ": " + target.Distance.ToString("0.00");
                        Echo("textent: " + textEnt);
                        Vector2 pos  = new Vector2(10, point);
                        var     text = MySprite.CreateText(textEnt.ToString(), "Monospace", Color.White, 0.8f, TextAlignment.LEFT);

                        if (target.Info.Relationship.Equals(MyRelationsBetweenPlayerAndBlock.Enemies))
                        {
                            text.Color = Color.Red;
                        }

                        text.Position = pos;
                        frame.Add(text);
                        point += 25;
                    }
                }
            }

            targets.Clear();
        }