/// <summary> /// Insert a <see cref="ILevelObject"/> to mapping store table LEVEL. /// </summary> /// <param name="state"> /// The state. /// </param> /// <param name="level"> /// The level. /// </param> /// <param name="hierarchyId"> /// The hierarchy id. /// </param> /// <param name="parentID"> /// The parent level id. /// </param> /// <returns> /// The <see cref="ArtefactImportStatus"/>. /// </returns> private long InsertLevel(DbTransactionState state, ILevelObject level, long hierarchyId, long parentID) { long artefactImportStatus; var artefactStoredProcedure = _storedProcedures.InsertHlevel; using (DbCommand command = artefactStoredProcedure.CreateCommandWithDefaults(state)) { DbParameter hierarchyIdParameter = artefactStoredProcedure.CreateHIdParameter(command); hierarchyIdParameter.Value = hierarchyId; DbParameter parentLevelIdParameter = artefactStoredProcedure.CreateParentLevelIdParameter(command); if (parentID > 0) { parentLevelIdParameter.Value = parentID; } if (level.Uri != null) { artefactStoredProcedure.CreateUriParameter(command).Value = level.Uri.ToString(); } artefactImportStatus = this.RunNameableArtefactCommand(level, command, artefactStoredProcedure); } return(artefactImportStatus); }
protected override void Execute() { Vector2 worldPosition = Camera.main.ScreenToWorldPoint(screenPosition); GenerateableLevelObjectNode generateableLevelObjectNode = SelectedLevelObjectNodeStatus.LevelObjectNode; GameObject levelObjectGameObject = LevelObjectHelper.InstantiateLevelObject(generateableLevelObjectNode, worldPosition, context); ILevelObject levelObject = levelObjectGameObject.GetComponent <ILevelObject>(); levelObject.Select(); }
/////////////////////////////////////////////////////////////////////////////////////////////////// ////////////BUILD FROM MUTABLE OBJECT ////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// #region Constructors and Destructors /// <summary> /// Initializes a new instance of the <see cref="LevelCore"/> class. /// </summary> /// <param name="parent"> /// The parent. /// </param> /// <param name="levelMutable"> /// The level mutable. /// </param> public LevelCore(IIdentifiableObject parent, ILevelMutableObject levelMutable) : base(levelMutable, parent) { if (levelMutable.CodingFormat != null) { this.textFormat = new TextFormatObjectCore(levelMutable.CodingFormat, this); } if (levelMutable.ChildLevel != null) { this.childLevel = new LevelCore(this, levelMutable.ChildLevel); } }
/// <summary> /// Initializes a new instance of the <see cref="LevelMutableCore"/> class. /// </summary> /// <param name="level"> /// The level. /// </param> public LevelMutableCore(ILevelObject level) : base(level) { if (level.HasChild()) { this.childLevel = new LevelMutableCore(level.ChildLevel); } if (level.CodingFormat != null) { this.codingFormat = new TextFormatMutableCore(level.CodingFormat); } }
/// <summary> /// Populate <see cref="HierarchyType"/> from <paramref name="buildFrom"/>. /// </summary> /// <param name="hierarchyType"> /// The hierarchy type. /// </param> /// <param name="buildFrom"> /// The build from. /// </param> public void BuildList(HierarchyType hierarchyType, ILevelObject buildFrom) { int order = 1; do { var builtObj = new LevelType(); hierarchyType.Level.Add(builtObj); string value = buildFrom.Id; if (!string.IsNullOrWhiteSpace(value)) { builtObj.id = buildFrom.Id; } if (ObjectUtil.ValidString(buildFrom.Urn)) { builtObj.urn = buildFrom.Urn; } IList<ITextTypeWrapper> names = buildFrom.Names; if (ObjectUtil.ValidCollection(names)) { builtObj.Name = this.GetTextType(names); } IList<ITextTypeWrapper> descriptions = buildFrom.Descriptions; if (ObjectUtil.ValidCollection(descriptions)) { builtObj.Description = this.GetTextType(descriptions); } if (this.HasAnnotations(buildFrom)) { builtObj.Annotations = this.GetAnnotationsType(buildFrom); } builtObj.Order = order; if (buildFrom.CodingFormat != null) { var textFormatType = new TextFormatType(); this.PopulateTextFormatType(textFormatType, buildFrom.CodingFormat); builtObj.CodingType = textFormatType; } buildFrom = buildFrom.ChildLevel; order++; } while (buildFrom != null); }
protected override void Execute() { List <Transform> transforms = RaycastHelper.GetTransformOnPosition2D(Input.mousePosition); foreach (Transform transform in transforms) { bool isLevelObject = GenerateableLevelObjectLibrary.IsLevelObject(transform.name); if (isLevelObject) { ILevelObject levelObject = transform.GetComponent <ILevelObject>(); levelObject.Select(); return; } } }
/// <summary> /// Insert levels to Mapping Store database. /// </summary> /// <param name="state"> /// The state. /// </param> /// <param name="rootLevel"> /// The root level. /// </param> /// <param name="parentHierarchyID"> /// The parent hierarchy id. /// </param> /// <returns> /// The <see cref="IDictionary{String, Long}"/> with the level id as key and the mapping store level primary key as value. /// </returns> private IDictionary <string, long> InsertLevels(DbTransactionState state, ILevelObject rootLevel, long parentHierarchyID) { var levelIds = new Dictionary <string, long>(StringComparer.Ordinal); ILevelObject level = rootLevel; long parentLevel = 0; while (level != null) { var id = this.InsertLevel(state, level, parentHierarchyID, parentLevel); levelIds.Add(level.Id, id); parentLevel = id; level = level.HasChild() ? level.ChildLevel : null; } return(levelIds); }
void GenerateLevel(LevelData levelData_) { if (_debug) { Debug.Log("Generating"); } if (_PlaceableBlocks != null) { _PlaceableBlocks.Clear(); } BotManager.instance.ResetBotCount(); List <ILevelObject> _tempILevelObjectList = new List <ILevelObject>(); foreach (LevelObjectData lod in levelData_._levelObjects) { Vector3 pos = GetVectorFromData(lod); Vector3 rot = new Vector3(0, lod._rotationY, 0); if (lod._blockType == BlockType.Undefined) { _tempILevelObjectList.Add(Instantiate(_bot, _botHolder.transform.position + pos, Quaternion.Euler(rot), _botHolder)); BotManager.instance.IncrementBotCount(); } else { ILevelObject iLevelObj = (Instantiate(_blockList[(int)lod._blockType], _blockHolder.transform.position + pos, Quaternion.Euler(rot), _blockHolder)); iLevelObj.IsPlaceable = lod._isPlaceable; _tempILevelObjectList.Add(iLevelObj); if (Application.isPlaying && iLevelObj.IsPlaceable) { _PlaceableBlocks.Add(iLevelObj.GetTransform.GetComponent <Block>()); } } } foreach (ILevelObject obj in _tempILevelObjectList) { if (Application.isPlaying && obj != null) { obj.InitializeILevelObject(_spawnTimer); } } _levelLoadedEffect.Play(); }
/// <summary> /// Insert a <see cref="IHierarchicalCode"/> to mapping store table <c>HCL_CODE</c>. /// </summary> /// <param name="state"> /// The state. /// </param> /// <param name="coderef"> /// The Hierarchical code reference. /// </param> /// <param name="hierarchyID"> /// The hierarchy ID. /// </param> /// <param name="parentID"> /// The parent id. /// </param> /// <param name="codelistReferences"> /// The codelist references. /// </param> /// <param name="levelIds"> /// The level Ids. /// </param> /// <returns> /// The primary key of the ne /// </returns> private long InsertCodeReference(DbTransactionState state, IHierarchicalCode coderef, long hierarchyID, long parentID, StructureCache codelistReferences, IDictionary <string, long> levelIds) { var artefactStoredProcedure = _storedProcedures.InsertHclCode; long artefactImportStatus; using (DbCommand command = artefactStoredProcedure.CreateCommandWithDefaults(state)) { DbParameter parentHcodeIDIdParameter = artefactStoredProcedure.CreateParentHcodeIdParameter(command); parentHcodeIDIdParameter.Value = parentID > 0 ? (object)parentID : null; DbParameter lcdIddParameter = artefactStoredProcedure.CreateLcdIdParameter(command); ItemSchemeFinalStatus itemSchemeFinalStatus = codelistReferences.GetStructure(state, coderef.CodeReference); ItemStatus codeStatus; if (itemSchemeFinalStatus.ItemIdMap.TryGetValue(coderef.CodeReference.ChildReference.Id, out codeStatus)) { lcdIddParameter.Value = codeStatus.SysID; } DbParameter hierarchyIdParameter = artefactStoredProcedure.CreateHIdParameter(command); hierarchyIdParameter.Value = hierarchyID; DbParameter levelIdParameter = artefactStoredProcedure.CreateLevelIdParameter(command); ILevelObject levelObject = coderef.GetLevel(false); long levelPrimaryKey; if (levelObject != null && levelIds.TryGetValue(levelObject.Id, out levelPrimaryKey)) { levelIdParameter.Value = levelPrimaryKey; } if (coderef.Uri != null) { artefactStoredProcedure.CreateUriParameter(command).Value = coderef.Uri.ToString(); } artefactImportStatus = this.RunIdentifiableArterfactCommand(coderef, command, artefactStoredProcedure); } return(artefactImportStatus); }
public override bool manageCollision(ILevelObject obj) { if (obj.Equals(this.Target)) { this.collisionedTarget(); return true; } /* Commando commando; if (this.canSeeACommando(out commando)) { this.setState(new Chasing(this, commando)); return true; } */ return false; }
private bool thereIsSphereCollision(ILevelObject collider, ILevelObject o) { if (o == collider) return false; //Ver Unidad 6, pagina 13 Vector3 distance = collider.Center - o.Center; float radiusSum = collider.Radius + o.Radius; return distance.LengthSq() <= radiusSum * radiusSum; }
protected override void OnButtonPressed(VirtualButtons button) { switch (button) { case VirtualButtons.Select: prevPosition = Controller.Point; target = FindTarget(Controller.Point); break; case VirtualButtons.Delete: editableLevel.MoveablePlatforms.Remove((Platform)FindTarget(Controller.Point)); break; } }
public bool thereIsCollision(Character ch, out ILevelObject obj, out Vector3 n) { obj = null; foreach (ILevelObject colisionable in this.getPosibleColliders(ch)) if (colisionable.collidesWith(ch, out n)){ obj = colisionable; return true; } n = Vector3.Empty; return false; }
private IEnumerable<ILevelObject> getPosibleColliders(ILevelObject collider) { List<ILevelObject> collisionables = new List<ILevelObject>(); //Solo agrego a colisionables aquellos cuyas esferas chocan con el collider foreach (Character c in this.Characters) if(thereIsSphereCollision(collider, c)) collisionables.Add(c); foreach (ILevelObject o in this.Objects) if (thereIsSphereCollision(collider, o)) collisionables.Add(o); return collisionables; }
public void addObjectIfCollides(ILevelObject obj) { if (obj.collidesWith(this.tp.BoundingBox)) this.objs.Add(obj); }
public void add(ILevelObject levelObject) { objects.Add(levelObject); this.regularGrid.add(levelObject); }
/////////////////////////////////////////////////////////////////////////////////////////////////// ////////////BUILD FROM V2.1 SCHEMA ////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Initializes a new instance of the <see cref="LevelCore"/> class. /// </summary> /// <param name="parent"> /// The parent. /// </param> /// <param name="level"> /// The level. /// </param> public LevelCore(IIdentifiableObject parent, Org.Sdmx.Resources.SdmxMl.Schemas.V21.Structure.LevelType level) : base(level, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Level), parent) { if (level.CodingFormat != null) { this.textFormat = new TextFormatObjectCore(level.CodingFormat, this); } if (level.Level != null) { this.childLevel = new LevelCore(this, level.Level); } }
public void add(ILevelObject obj) { foreach (GridCell sector in this.sectors) sector.addObjectIfCollides(obj); }
private bool objectInsideRadius(float radius, ILevelObject o) { //Ver Unidad 6, pagina 13 Vector3 distance = this.Position - o.Center; float radiusSum = radius + o.Radius; return distance.LengthSq() <= radiusSum * radiusSum; }
/////////////////////////////////////////////////////////////////////////////////////////////////// ////////////BUILD FROM V2 SCHEMA ////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Initializes a new instance of the <see cref="LevelCore"/> class. /// </summary> /// <param name="parent"> /// The parent. /// </param> /// <param name="levels"> /// The levels. /// </param> /// <param name="pos"> /// The pos. /// </param> public LevelCore(IIdentifiableObject parent, IList<LevelType> levels, int pos) : base( GetLevel(levels, pos), SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Level), GetLevel(levels, pos).id, null, GetLevel(levels, pos).Name, GetLevel(levels, pos).Description, GetLevel(levels, pos).Annotations, parent) { LevelType level = GetLevel(levels, pos); if (level.CodingType != null) { this.textFormat = new TextFormatObjectCore(level.CodingType, this); } if (levels.Count > pos + 1) { this.childLevel = new LevelCore(this, levels, ++pos); } }
protected override void OnButtonPressed(VirtualButtons button) { switch (button) { case VirtualButtons.Select: prevPosition = Controller.Point; target = FindTarget(Controller.Point); break; case VirtualButtons.Delete: delete(Controller.Point); break; } }
/////////////////////////////////////////////////////////////////////////////////////////////////// ////////////BUILD FROM V2.1 SCHEMA ////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Initializes a new instance of the <see cref="HierarchyCore"/> class. /// </summary> /// <param name="parent"> /// The parent. /// </param> /// <param name="hierarchy"> /// The hierarchy. /// </param> /// <exception cref="SdmxSemmanticException"> /// Throws Validate exception. /// </exception> public HierarchyCore(IHierarchicalCodelistObject parent, HierarchyType hierarchy) : base(hierarchy, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Hierarchy), parent) { this._codeRefs = new List<IHierarchicalCode>(); // LEVELS MUST BE SET BEFORE ANYTHING ELSE this._hasFormalLevels = hierarchy.leveled; if (hierarchy.Level != null) { this._level = new LevelCore(this, hierarchy.Level); } if (hierarchy.HierarchicalCode != null) { foreach (HierarchicalCodeType currentCoderef in hierarchy.HierarchicalCode) { this._codeRefs.Add(new HierarchicalCodeCore(currentCoderef, this)); } } try { if (hierarchy.leveled) { if (this._level == null) { throw new SdmxSemmanticException( "Hierarchy declares itself as levelled, but does not define any levels"); } } this.Validate(); } catch (SdmxSemmanticException ex) { throw new SdmxSemmanticException(ex, ExceptionCode.ObjectStructureConstructionError, this.Urn); } catch (Exception th) { throw new SdmxException(th, ExceptionCode.ObjectStructureConstructionError, this.Urn); } }
/// <summary> /// Handle user input. /// </summary> /// <param name="button"></param> protected override void OnButtonReleased(VirtualButtons button) { switch (button) { case VirtualButtons.Context: if (!editableLevel.FindCollision()) ScreenList.AddScreen(new GameplayScreen(TopLevel, CreateLevel(), LevelName)); break; case VirtualButtons.Pause: ScreenList.AddScreen(new PauseMenuScreen(TopLevel, editableLevel, LevelName)); break; case VirtualButtons.Select: target = null; break; } }
/////////////////////////////////////////////////////////////////////////////////////////////////// ////////////BUILD FROM MUTABLE OBJECT ////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// #region Constructors and Destructors /// <summary> /// Initializes a new instance of the <see cref="HierarchyCore"/> class. /// </summary> /// <param name="parent"> /// The parent. /// </param> /// <param name="hierarchy"> /// The hierarchy. /// </param> /// <exception cref="SdmxSemmanticException"> /// Throws Validate exception. /// </exception> public HierarchyCore(IHierarchicalCodelistObject parent, IHierarchyMutableObject hierarchy) : base(hierarchy, parent) { // LEVELS MUST BE SET BEFORE ANYTHING ELSE this._hasFormalLevels = hierarchy.FormalLevels; if (hierarchy.ChildLevel != null) { this._level = new LevelCore(this, hierarchy.ChildLevel); } this._codeRefs = new List<IHierarchicalCode>(); if (hierarchy.HierarchicalCodeObjects != null) { foreach (ICodeRefMutableObject currentCoderef in hierarchy.HierarchicalCodeObjects) { this._codeRefs.Add(new HierarchicalCodeCore(currentCoderef, this)); } } try { this.Validate(); } catch (SdmxSemmanticException ex) { throw new SdmxSemmanticException(ex, ExceptionCode.ObjectStructureConstructionError, this.Urn); } catch (Exception th) { throw new SdmxException(th, ExceptionCode.ObjectStructureConstructionError, this.Urn); } }
/////////////////////////////////////////////////////////////////////////////////////////////////// ////////////BUILD FROM V2 SCHEMA ////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Initializes a new instance of the <see cref="HierarchyCore"/> class. /// </summary> /// <param name="parent"> /// The parent. /// </param> /// <param name="hierarchy"> /// The hierarchy. /// </param> /// <exception cref="SdmxSemmanticException"> /// Throws Validate exception. /// </exception> public HierarchyCore( IHierarchicalCodelistObject parent, Org.Sdmx.Resources.SdmxMl.Schemas.V20.structure.HierarchyType hierarchy) : base( hierarchy, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Hierarchy), hierarchy.id, null, hierarchy.Name, hierarchy.Description, hierarchy.Annotations, parent) { // LEVELS MUST BE SET BEFORE ANYTHING ELSE this._codeRefs = new List<IHierarchicalCode>(); if (ObjectUtil.ValidCollection(hierarchy.Level)) { var levelMap = new SortedList<int, LevelType>(); foreach (LevelType levl in hierarchy.Level) { levelMap.Add(Convert.ToInt32(levl.Order), levl); } IList<LevelType> levelList = new List<LevelType>(); for (int i = 1; i <= levelMap.Count; i++) { if (levelMap.ContainsKey(i)) { levelList.Add(levelMap[i]); } else { // %%% .Factory.NewInstance(); var defaultLevel = new LevelType(); // %%% defaultLevel.AddNewName().SetStringValue("Default"); defaultLevel.id = "DEFAULT"; var t = new TextType(); t.TypedValue = "Default"; defaultLevel.Name.Add(t); levelList.Add(defaultLevel); } } this._level = new LevelCore(this, levelList, 0); this._hasFormalLevels = true; } if (hierarchy.CodeRef != null) { foreach (CodeRefType currentCoderef in hierarchy.CodeRef) { this._codeRefs.Add(new HierarchicalCodeCore(currentCoderef, this)); } } try { this.Validate(); } catch (SdmxSemmanticException ex) { throw new SdmxSemmanticException(ex, ExceptionCode.ObjectStructureConstructionError, this.Urn); } catch (Exception th) { throw new SdmxException(th, ExceptionCode.ObjectStructureConstructionError, this.Urn); } }
protected override void Execute() { ILevelObject levelObject = previousSelectedLevelObjectRef.Get(); levelObject.DestroyLevelObject(); }
/// <summary> /// Accion a realizar en caso de choque /// </summary> public virtual bool manageCollision(ILevelObject obj) { if (obj.Equals(this.target)) { this.collisionedTarget(); return true; } //TgcCollisionUtils.BoxBoxResult result = TgcCollisionUtils.classifyBoxBox(this.marcaDePicking.BoundingBox, obj.BoundingBox); //Si la cosa con la que choqué está sobre mi objetivo. //if (result != TgcCollisionUtils.BoxBoxResult.Afuera) if(obj.isOver(this.Target.Position)) { this.targetReached(); return true; } return false; }