// Update is called once per frame public override void Update() { base.Update(); if (currentTarget != null && currentTarget.isActiveAndEnabled) { if (attackTimer <= 0) { attackTimer = 1.0f / attackSpeed; mainLevelRef.audioRef.PlaySFX("BuildingAttack"); currentTarget.TakeDamage(damage); } else { attackTimer -= Time.deltaTime; } } else { if ((currentTarget == null || !currentTarget.isActiveAndEnabled) && nearbyEnemiesQueue.Count > 0) { currentTarget = nearbyEnemiesQueue[0]; nearbyEnemiesQueue.RemoveAt(0); } } }
public void OnTriggerExit(Collider col) { BaseUnitType enemy = col.gameObject.GetComponent <BaseUnitType>(); if (enemy != null) { if (col is BoxCollider) { // Enemy is within Range. nearbyEnemiesQueue.Remove(enemy); if (enemy == currentTarget) { if (nearbyEnemiesQueue.Count > 0) { currentTarget = nearbyEnemiesQueue[0]; } else { currentTarget = null; } } } } }
public BaseUnitType SetObjAtMapGridCoord(BaseUnitType obj, Quaternion rot, Vector2 coord) { if (!GetTileAtMapGridCoord(coord).isFlat || !IsCoordWithinMap(coord)) { return(null); } float posOffset = 0;// tileSize / 2.0f; float x_pos; float y_pos = GetTopOfTileYPosition(coord); float z_pos; // Decorations/objects on top should be spawned with a randomized offset. x_pos = Random.Range(coord.x * tileSize + tileSize * 0.25f, coord.x * tileSize + tileSize * 0.75f) + posOffset; z_pos = Random.Range(coord.y * tileSize + tileSize * 0.25f, coord.y * tileSize + tileSize * 0.75f) + posOffset; BaseUnitType newUnit = Instantiate(obj, new Vector3(x_pos, y_pos, z_pos), rot); newUnit.transform.parent = this.transform; if (!levelRef.PC.inEditMode) { levelRef.GetComponent <SpawnManager>().spawnedEnemies.Add(newUnit); } return(newUnit); }
public BaseUnitType SpawnEnemy(BaseUnitType unit) { spawnLocation = new Vector2(mainLevelRef.tileMapRef.size_x - 1, mainLevelRef.tileMapRef.size_z - 1); BaseUnitType enemyRef = this.GetComponent <MainLevel>().tileMapRef.SetObjAtMapGridCoord(unit, Quaternion.Euler(0, 0, 0), spawnLocation).GetComponent <BaseUnitType>(); return(enemyRef); }
/// <summary> /// Processes an IFC physical simple quantity. /// </summary> /// <param name="ifcPhysicalQuantity">The IfcPhysicalSimpleQuantity object.</param> /// <returns>The IFCPhysicalSimpleQuantity object.</returns> override protected void Process(IFCAnyHandle ifcPhysicalSimpleQuantity) { base.Process(ifcPhysicalSimpleQuantity); IFCAnyHandle unit = IFCImportHandleUtil.GetOptionalInstanceAttribute(ifcPhysicalSimpleQuantity, "Unit"); if (!IFCAnyHandleUtil.IsNullOrHasNoValue(unit)) { IFCUnit = IFCUnit.ProcessIFCUnit(unit); } // Process subtypes of IfcPhysicalSimpleQuantity here. string attributeName = ifcPhysicalSimpleQuantity.TypeName.Substring(11) + "Value"; Value = ifcPhysicalSimpleQuantity.GetAttribute(attributeName); BaseUnitType = IFCDataUtil.GetUnitTypeFromData(Value, new ForgeTypeId()); if (BaseUnitType.Empty()) { // Determine it from the attributeName. if (string.Compare(attributeName, "LengthValue", true) == 0) { BaseUnitType = SpecTypeId.Length; } else if (string.Compare(attributeName, "AreaValue", true) == 0) { BaseUnitType = SpecTypeId.Area; } else if (string.Compare(attributeName, "VolumeValue", true) == 0) { BaseUnitType = SpecTypeId.Volume; } else if (string.Compare(attributeName, "CountValue", true) == 0) { BaseUnitType = SpecTypeId.Number; } else if (string.Compare(attributeName, "WeightValue", true) == 0) { BaseUnitType = SpecTypeId.Mass; } else if (string.Compare(attributeName, "TimeValue", true) == 0) { BaseUnitType = SpecTypeId.Number; // No time unit type in Revit. } else { Importer.TheLog.LogWarning(Id, "Can't determine unit type for IfcPhysicalSimpleQuantity of type: " + attributeName, true); BaseUnitType = SpecTypeId.Number; } } if (IFCUnit == null) { IFCUnit = IFCImportFile.TheFile.IFCUnits.GetIFCProjectUnit(BaseUnitType); } }
public void AddUnit(string coord, BaseUnitType unitType) { if (Units.ContainsKey(coord)) { return; } Units.Add(coord, unitType); }
public void OnTriggerEnter(Collider col) { BaseUnitType enemy = col.gameObject.GetComponent <BaseUnitType>(); if (enemy != null) { if (col is BoxCollider) { if (nearbyEnemiesQueue == null) { Debug.Log("queue is null"); } // Enemy is within Range. nearbyEnemiesQueue.Add(enemy); if (nearbyEnemiesQueue.Count == 1) { currentTarget = enemy; } } } }