Ejemplo n.º 1
0
        public void AddPossibility(Possibility block)
        {
            if (block.Model == null)
            {
                Vector3 start = block.Map.GetRelativePosition(block.StartCoord), end = block.Map.GetRelativePosition(block.EndCoord);

                Vector3 scale  = new Vector3(Math.Abs(end.X - start.X), Math.Abs(end.Y - start.Y), Math.Abs(end.Z - start.Z));
                Matrix  matrix = Matrix.CreateScale(scale) * Matrix.CreateTranslation(new Vector3(-0.5f) + (start + end) * 0.5f);

                ModelAlpha box = new ModelAlpha();
                box.Filename.Value    = "AlphaModels\\distortion-box";
                box.Distortion.Value  = true;
                box.Color.Value       = new Vector3(2.8f, 3.0f, 3.2f);
                box.Alpha.Value       = blockPossibilityInitialAlpha;
                box.Serialize         = false;
                box.DrawOrder.Value   = 11;               // In front of water
                box.BoundingBox.Value = new BoundingBox(new Vector3(-0.5f), new Vector3(0.5f));
                box.GetVector3Parameter("Scale").Value = scale;
                box.Add(new Binding <Matrix>(box.Transform, x => matrix * x, block.Map.Transform));
                this.Entity.Add(box);
                block.Model = box;
            }

            List <Possibility> mapList;

            if (!this.possibilities.TryGetValue(block.Map, out mapList))
            {
                mapList = new List <Possibility>();
                possibilities[block.Map] = mapList;
            }
            mapList.Add(block);
            blockPossibilityLifetime = 0.0f;
        }