예제 #1
0
        public void Spawn(int amount)
        {
            for (int i = 0; i < amount; i++) {
                string name = DirtSpeck + (++spawned);

                Triangle t = statueInformation.Triangles[r.Next(statueInformation.Triangles.Count)];

                Transform transform = new Transform();
                transform.Position = Triangle.GetRandomPointInside(r,
                    t.A,
                    t.B,
                    t.C);

                AddScale grow = new AddScale();
                grow.Maximum = statueInformation.StatueSettings.MaximumDirtScale;
                grow.Minimum = transform.Scale;

                float n = (float)r.NextDouble() * 0.05f;

                grow.Amount = new Vector3(n);

                Dirt blob = new Dirt();
                blob.TriangleHost = t;

                Repository.Delegater.Bind(name, transform);
                Repository.Delegater.Bind(name, grow);
                Repository.Delegater.Bind(name, blob);
            }
        }
예제 #2
0
        public override void Update(TimeSpan elapsed)
        {
            MouseState ms = Mouse.GetState();

            if (ms.RightButton == ButtonState.Released && msLast.RightButton == ButtonState.Pressed) {
                // place box, green transparent box

                if (placing) {
                    placing = false;

                    string group = String.Format("Crate #{0}", n++);

                    Repository.Delegater.Bind(group, new BoxCollider(false));
                    Repository.Delegater.Bind(group, new ReceiveWindGust());

                    currentBoxTransform = null;
                }
            }

            if (ms.RightButton == ButtonState.Pressed && msLast.RightButton == ButtonState.Released) {
                Vector3 position = WindStroker.MouseToWorld(ms, Cameras.Current.View, Cameras.Current.Projection, Matrix.CreateTranslation(0, 0, 0));

                if (rooftopArea.Contains(position) == ContainmentType.Contains || rooftopArea.Contains(position) == ContainmentType.Intersects) {
                    var results = Repository.Behaviors.Where
                        (
                            x => x is BoxCollider && x.Group.IndexOf("Crate #") != -1
                        );

                    if (results.Count() < MAX_CRATES) {
                        // start box placing
                        placing = true;

                        Vector3 initialPosition = Repository.Get<Transform>(Groups.MainBuildingRoof).Position;

                        float size = 1.75f;

                        string group = String.Format("Crate #{0}", n);

                        Repository.Delegater.Bind(group, new Transform()
                        {
                            Position = position
                        });
                        Repository.Delegater.Bind(group, new Box(size, size, size)
                        {
                            Color = Color.Beige
                        });

                        Repository.Delegater.Bind(group, new ScaleToDistanceFromFloor());

                        currentBoxTransform = Repository.Get<Transform>(group);
                    }
                }
            }

            if (currentBoxTransform != null) {
                string group = String.Format("Crate #{0}", n);
                Vector3 mouseWorld = WindStroker.MouseToWorld(ms, Cameras.Current.View, Cameras.Current.Projection, Matrix.CreateTranslation(0, 0, 0));
                currentBoxTransform.Position = WindStroker.MouseToWorld(ms, Cameras.Current.View, Cameras.Current.Projection, Matrix.CreateTranslation(0, 0, 0));
            }

            msLast = ms;
        }