Наследование: MonoBehaviour
Пример #1
0
        /// <summary>
        /// Stamp an image at the current turtle position.
        /// If the offsets are zero, the top left corner of the image will be placed at the turtle's hotspot.
        /// </summary>
        /// <param name="imgSrc">The image to be stamped</param>
        /// <param name="hotspotX">X offset of image that will be aligned to turtle's current X position.</param>
        /// <param name="hotspotY">Y offset of image that will be aligned to turtle's current Y position.</param>
        /// <param name="useRotation">If true, the image will be rotated to the same heading as the turtle.</param>
        /// <returns></returns>
        public virtual Footprint Stamp(ImageSource imgSrc, double hotspotX = 0.0, double hotspotY = 0.0, bool useRotation = false)
        {
            Image img = new Image()
            {
                Source = imgSrc
            };
            TransformGroup tfg = buildCurrentTurtleTransform();

            if (!useRotation)
            {
                tfg.Children.RemoveAt(0);
            }
            if (hotspotX != 0.0 || hotspotY != 0.0)
            {
                tfg.Children.Insert(0, new TranslateTransform(-hotspotX, -hotspotY));
            }
            img.RenderTransform = tfg;

            Canvas.SetZIndex(img, footprintlayer);
            Footprint fp = new Footprint(img);

            Footprints.Add(fp);
            pumpAnimation();
            return(fp);
        }
Пример #2
0
        /// <summary>
        /// Stamp a string at the current turtle position.
        /// </summary>
        /// <param name="str">The text to be written</param>
        /// <param name="offsetX">Relative X offset of text from turtle's current position.</param>
        /// <param name="offsetY">Relative Y offset of text from turtle's current position.</param>
        /// <param name="useRotation">If true, the text will rotate to the same heading as the turtle.</param>
        /// <returns></returns>
        public virtual Footprint Stamp(string str, double offsetX = 0.0, double offsetY = 0.0, bool useRotation = false)
        {
            Label lbl = new Label()
            {
                Content    = str,
                FontFamily = TextFontFamily,
                FontSize   = TextFontSize,
                FontWeight = TextFontWeight,
                Foreground = TextBrush
            };
            TransformGroup tfg = buildCurrentTurtleTransform();

            if (!useRotation)
            {
                tfg.Children.RemoveAt(0);
            }
            if (offsetX != 0.0 || offsetY != 0.0)
            {
                tfg.Children.Insert(0, new TranslateTransform(offsetX, offsetY));
            }
            lbl.RenderTransform = tfg;

            Canvas.SetZIndex(lbl, footprintlayer);
            Footprint fp = new Footprint(lbl);

            Footprints.Add(fp);
            pumpAnimation();
            return(fp);
        }
Пример #3
0
        /// <summary>
        /// Erase all this turtle's drawing, footprints and text without changing position or heading, or any properties.
        /// </summary>
        public virtual void Clear()
        {
            foreach (UIElement p in myUIElems)
            {
                playground.Children.Remove(p);
            }
            myUIElems.Clear();

            Footprints.Clear();
            closeCurrentFragment();
            pumpAnimation();
        }
Пример #4
0
        public Design Externals(Func <double> random, INamedDataCollection metadata, Func <KeyValuePair <string, string>[], Type[], ScriptReference> finder, BuildingSideInfo[] sides)
        {
            Contract.Requires(random != null);
            Contract.Requires(metadata != null);
            Contract.Requires(finder != null);
            Contract.Requires(sides != null);
            Contract.Ensures(Contract.Result <Design>() != null);

            //No footprints means no floors, early exit with an empty building
            if (!Footprints.Any())
            {
                return(new Design(new FloorSelection[0], new VerticalSelection[0], new Design.Wall[0]));
            }

            //Generate footprints up building
            var footprints = GenerateFootprints(random, metadata, sides.Select(a => a.EdgeEnd).ToArray(), Footprints, AboveGroundFloors.Count(), BelowGroundFloors.Count());

            //Results of facade selection
            var walls = new List <Design.Wall>();

            //Generate facades
            foreach (var run in _aboveGroundFloorRuns)
            {
                if (!run.Any())
                {
                    continue;
                }

                var bot = run.Min(a => a.Index);

                //Get the footprint for this run
                var footprint = footprints[bot];

                //Generate facades for each side
                for (var i = 0; i < footprint.Count; i++)
                {
                    //Get start and end points of this wall
                    var s = footprint[i];
                    var e = footprint[(i + 1) % footprint.Count];

                    //Select facades
                    Design.Wall w = new Design.Wall(i, bot, s, e, _designer.SelectFacadesForWall(random, finder, run, sides, s, e));

                    //Save results
                    walls.Add(w);
                }
            }

            return(new Design(Floors, Verticals, walls));
        }
Пример #5
0
 // Use this for initialization
 private void Start()
 {
     m_CharacterController = GetComponent <CharacterController>();
     m_Camera = Camera.main;
     m_OriginalCameraPosition = m_Camera.transform.localPosition;
     m_FovKick.Setup(m_Camera);
     m_HeadBob.Setup(m_Camera, m_StepInterval);
     m_StepCycle   = 0f;
     m_NextStep    = m_StepCycle / 2f;
     m_Jumping     = false;
     m_AudioSource = GetComponent <AudioSource>();
     m_MouseLook.Init(transform, m_Camera.transform);
     m_footprints  = GameObject.Find("Footprints").GetComponent <Footprints>();
     m_dustEmitter = m_dustEmitterObject.GetComponent <ParticleSystem>();
 }
Пример #6
0
    // Use this for initialization
    void Start()
    {
        wpm      = GameObject.FindObjectOfType <WaypointManager>();
        gm       = GameObject.FindObjectOfType <GameManager>();
        player   = GameObject.FindObjectOfType <Player>();
        animator = gameObject.GetComponentInChildren <Animator>();

        attackDist = WaypointManager.scale / 8;
        lastPos    = transform.position;

        if (!footprints)
        {
            footprints = GameObject.FindObjectOfType <Footprints>();
        }

        teleportTime = UpdateTeleportTimer(gm.objectiveItemCount, GameManager.objectiveCount, 3f);
        StartCoroutine(TeleportTimer(teleportTime));
    }
Пример #7
0
        /// <summary>
        /// Stamp a uiElement at the current position, as a footprint.   The opacity settings for footprints are not applied here.
        /// </summary>
        /// <param name="theUIE"></param>
        /// <returns>The Footprint that was created.</returns>
        public virtual Footprint Stamp(UIElement theUIE)
        {
            TransformGroup tfg = theUIE.RenderTransform as TransformGroup;

            if (tfg == null)
            {
                tfg = new TransformGroup();
            }

            tfg.Children.Add(new RotateTransform(heading));
            tfg.Children.Add(new TranslateTransform(Position.X, Position.Y));
            theUIE.RenderTransform = tfg;

            Canvas.SetZIndex(theUIE, footprintlayer);
            Footprint fp = new Footprint(theUIE);

            Footprints.Add(fp);
            pumpAnimation();
            return(fp);
        }
Пример #8
0
        public MedinaSiteSectorBuilder CategorizeObjects()
        {
            foreach (var obj in Objects)
            {
                var layerName = File.AllLayers.FindIndex(obj.Attributes.LayerIndex).Name;

                //Console.WriteLine(layerName);

                var geo = obj.Geometry as Brep;
                var pt  = Point3d.Unset;

                if (geo == null)
                {
                    if (layerName != "ruins__points")
                    {
                        if (layerName == "mass__object--building")
                        {
                            //Console.WriteLine(obj.Geometry.ObjectType);
                            var extrusion = obj.Geometry as Extrusion;
                            geo = extrusion.ToBrep();
                        }
                        else
                        {
                            continue;
                        }
                    }
                    else
                    {
                        var ptRef = obj.Geometry as Point;

                        if (ptRef != null)
                        {
                            RuinPoints.Add(ptRef.Location);
                            continue;
                        }

                        continue;
                    }
                }

                switch (layerName)
                {
                case "base":
                    Base = geo;
                    break;

                case "datum__ground--footprints":
                    Footprints.Add(geo);
                    break;

                case "datum__ground--courtyard":
                    Courtyards.Add(geo);
                    break;

                case "datum_ground--public":
                    Plazas.Add(geo);
                    break;

                case "datum__floor":
                    Floors.Add(geo);
                    break;

                case "datum__roof":
                    Roofs.Add(geo);
                    break;

                case "datum__balcony":
                    Balconies.Add(geo);
                    break;

                case "mass__object--building":
                    Massing.Add(geo);
                    break;

                case "mass__space--openings":
                    Windows.Add(geo);
                    break;

                case "mass__space--doors":
                    Doors.Add(geo);
                    break;

                default:
                    break;
                }
            }

            return(this);
        }
Пример #9
0
 /// <summary>
 /// Gets a PCB footprint by name.
 /// </summary>
 public Pattern GetFootprint(string name) =>
 Footprints.FirstOrDefault(f => f.Name?.Equals(name, StringComparison.InvariantCultureIgnoreCase) == true);