本文整理汇总了C#中LevelEditorCore.ViewControl.As方法的典型用法代码示例。如果您正苦于以下问题:C# ViewControl.As方法的具体用法?C# ViewControl.As怎么用?C# ViewControl.As使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LevelEditorCore.ViewControl
的用法示例。
在下文中一共展示了ViewControl.As方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnDragging
public void OnDragging(ViewControl vc, Point scrPt)
{
m_hasHoverPt = HitTest(out m_hoverPt, scrPt, vc);
if (!m_hasHoverPt) return;
var nativeVC = vc as GUILayer.IViewContext;
if (nativeVC == null) return;
var game = vc.As<DesignViewControl>().DesignView.Context.As<IGame>();
if (game == null) return;
if (ManipulatorContext.Objects.Count == 0) return;
GUILayer.EditorInterfaceUtils.ScatterPlaceOperation op;
var sceneManager = nativeVC.SceneManager;
using (var editor = sceneManager.GetPlacementsEditor())
{
using (var scene = sceneManager.GetIntersectionScene())
{
op = GUILayer.EditorInterfaceUtils.CalculateScatterOperation(
editor, scene,
ManipulatorContext.Objects.Select(C => C.Model),
XLEBridgeUtils.Utils.AsVector3(m_hoverPt),
ManipulatorContext.Radius, ManipulatorContext.Density);
}
}
foreach (var d in op._toBeDeleted)
{
var adapter = m_nativeIdMapping.GetAdapter(d.Item1, d.Item2).As<DomNodeAdapter>();
if (adapter != null)
{
adapter.DomNode.RemoveFromParent();
}
}
var resourceResolvers = Globals.MEFContainer.GetExportedValues<IResourceResolver>();
var resourceConverter = Globals.MEFContainer.GetExportedValue<ResourceConverterService>();
foreach (var s in op._creationPositions)
{
// select a random entry from the list of objects
var o = ManipulatorContext.SelectRandomObject(m_rng);
IResource resource = null;
foreach (var d in resourceResolvers)
{
resource = d.Resolve(new Uri(
new Uri(System.Environment.CurrentDirectory + "\\"),
o.Model + "<model"));
if (resource != null) break;
}
if (resource != null)
{
var resGob = resourceConverter.Convert(resource);
if (resGob != null)
{
resGob.As<DomNode>().InitializeExtensions();
var hierarchical = game.AsAll<IHierarchical>();
foreach (var h in hierarchical)
if (h.AddChild(resGob)) break;
var transform = resGob.As<LevelEditorCore.ITransformable>();
transform.Translation = XLEBridgeUtils.Utils.AsVec3F(s);
transform.Rotation = new Sce.Atf.VectorMath.Vec3F(0.0f, 0.0f, (float)(m_rng.NextDouble()) * 2.0f * 3.14159f);
// set the material name (if we can)
var p = resGob.As<Placements.XLEPlacementObject>();
if (p != null)
{
p.Material = o.Material;
p.Supplements = o.Supplements;
}
}
}
}
}