public override int GetHashCode() { int hash = 1; if (Name.Length != 0) { hash ^= Name.GetHashCode(); } if (UnitName.Length != 0) { hash ^= UnitName.GetHashCode(); } hash ^= aliases_.GetHashCode(); if (dimension_ != null) { hash ^= Dimension.GetHashCode(); } if (SiMultiplier != 0D) { hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(SiMultiplier); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
/// <summary> /// Transforms each unit reference of the given <paramref name="unitReferenceSet"/> into a full qualified /// unit name. /// </summary> /// <param name="unitReferenceSet">Collection of unit references</param> /// <returns>Collection of full qualified unit names</returns> /// <exception cref="BuddyCompilerException">If a unit name could not be found</exception> private string[] ToQualifiedUnitNames(string[] unitReferenceSet) { if (unitReferenceSet == null) { return(new string[0]); } if (unitReferenceSet.Length == 0) { return(new string[0]); } IImportPathProvider importPathProvider = ImportPathProvider; string[] qualifiedUnitNames = new string[unitReferenceSet.Length]; for (int i = -1; ++i != unitReferenceSet.Length;) { string unitReference = unitReferenceSet[i].Replace('_', ' '); UnitName unitName = importPathProvider.GetUnitName(unitReference); if (unitName == null) { throw new BuddyCompilerException($"There is no unit registered for the given reference '{unitReference}'"); } string qualifiedUnitName = unitName.ToQualifiedString(); qualifiedUnitNames[i] = qualifiedUnitName; } return(qualifiedUnitNames); }
public static int GetUnitId(sc2dsstatsContext context, string name) { var unit = UnitNames.FirstOrDefault(f => f.Name == name); if (unit == null) { if (context == null) { return(-1); } else { int id = !UnitNames.Any() ? 0 : UnitNames.Last().sId + 1; unit = new UnitName() { sId = id, Name = name }; UnitNames.Add(unit); context.UnitNames.Add(unit); var info = context.DsInfo.First(f => f.Id == 1); var now = DateTime.UtcNow; info.UnitNamesUpdate = new DateTime(now.Year, now.Month, now.Day); } } return(unit.sId); }
public void SelectUnit() { RenderUnitRanges.CreateRanges(); if (SelectionManager.Current.Selection.Ids.Count <= 0) { } else { UnitInstance Uinst = SelectionManager.Current.AffectedGameObjects[SelectionManager.Current.Selection.Ids[0]].GetComponent <UnitInstance>(); if (Uinst != null) { UnitName.SetValue(Uinst.Owner.Name); SelectedUnitsGroup.text = Uinst.Owner.Parent.Name + " (" + Uinst.Owner.Parent.Owner.Name + ")"; UnitStats.text = Uinst.UnitRenderer.BP.CodeName + "\n" + "Reclaim: Mass: " + (Uinst.UnitRenderer.BP.BuildCostMass * Uinst.UnitRenderer.BP.Wreckage_MassMult) + ", Energy: " + (Uinst.UnitRenderer.BP.BuildCostEnergy * Uinst.UnitRenderer.BP.Wreckage_EnergyMult) + "\nVision radius: " + Uinst.UnitRenderer.BP.VisionRadius + ((Uinst.UnitRenderer.BP.MaxRange > 0) ? ("\nWeapon range: " + Uinst.UnitRenderer.BP.MaxRange) : ""); return; } } // Default UnitName.SetValue(""); SelectedUnitsGroup.text = ""; UnitStats.text = ""; }
/// <summary> /// Unit类初始化(该方法由GameCtrl.UnitBirth()方法或Gamef.UnitBirth()调用) /// </summary> public void Init(Unit unit) { if (isInit) { return; } isInit = true; //读取单位数据并赋初值 this.unit = unit; name = unit.unitName; data = Gamef.LoadUnitData(name); OriginalMaxV = data.MaxVelocity; OriginalMaxTurningV = data.MaxTurningVelocity; OriginalMaxSP = data.MaxSheildPoint; MaxManaPoint.OriginalValue = data.MaxManaPoint; ManaPoint.OriginalValue = data.MaxManaPoint; MPRegenerationRate.OriginalValue = data.ManaPointRegenerationRate; SPRegenerationRate.OriginalValue = data.ShieldPointRegenerationRate; //初始化速度 maxV_current = OriginalMaxV; Acceleration = maxV_current * GameDB.DAMPED_CONST; //初始化转向速度 maxTurningV_current = OriginalMaxTurningV; AngularAcceleration = maxTurningV_current * GameDB.ANGULAR_DAMPED_CONST; //初始化护盾 maxShieldPoint_current = OriginalMaxSP; sheildPoint_current = OriginalMaxSP; SPRegenerationRate.Init(this); //初始化魔法值 ManaPoint.setValueHandler = ClampMP; MaxManaPoint.setValueHandler = SetMP; MaxManaPoint.Init(this); ManaPoint.Init(this); MPRegenerationRate.Init(this); }
public override int GetHashCode() { unchecked { return(UnitName.GetHashCode()); } }
//UnitName unit, Vector3 position, Quaternion rotation public static void CreateObject(ProtocolBase protocol) { int start = 0; ProtocolBytes proto = (ProtocolBytes)protocol; proto.GetNameX(start, ref start); UnitName unitName = (UnitName)proto.GetByte(start, ref start); Vector3 pos = ParseVector3(proto, ref start); Quaternion rot = ParseQuaternion(proto, ref start); int unitId = proto.GetByte(start, ref start); bool isLocal = proto.GetByte(start, ref start) == 1; UnitData unitData = Gamef.LoadUnitData(unitName); GameObject prefab = isLocal ? unitData.LocalPrefab : unitData.NetPrefab; GameObject gameObj = Gamef.Instantiate(prefab, pos, rot); //set id Unit unit = gameObj.GetComponent <Unit>(); unit.InitAttributes(unitId); if (unitName == UnitName.Player && isLocal) { CameraGroupController.Instance.ResetTransform(pos, rot); GameCtrl.PlayerUnit = unit; } }
public string SetUnitName(UnitName unitName) { switch (unitName) { case UnitName.unit_warrior: return("전사"); case UnitName.unit_archer: return("궁수"); case UnitName.unit_halberdier: return("창병"); case UnitName.unit_barbarian: return("야만전사"); case UnitName.unit_monk: return("수도승"); case UnitName.unit_swordmaster: return("검객"); case UnitName.unit_highwarrior: return("상급 전사"); case UnitName.unit_higharcher: return("상급 궁수"); case UnitName.unit_highhalberdier: return("상급 창병"); case UnitName.unit_highbarbarian: return("상급 야만전사"); case UnitName.unit_highmonk: return("상급 수도승"); case UnitName.unit_highswordmaster: return("상급 검객"); case UnitName.unit_ultimatewarrior: return("불꽃전사"); case UnitName.unit_ultimatearcher: return("날개궁수"); case UnitName.unit_ultimatehalberdier: return("금빛미늘창병"); case UnitName.unit_ultimatebarbarian: return("악마야만"); case UnitName.unit_ultimatemonk: return("변이수도승"); case UnitName.unit_ultimateswordmaster: return("가면검객"); } return("알수없음"); }
private void Update() { bool left = Input.GetMouseButtonDown(0); bool right = Input.GetMouseButtonDown(1); if ((left || right) && !EventSystem.current.IsPointerOverGameObject()) { Ray inputRay = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(inputRay, out hit)) { YBEnum.eColorType colorType = YBEnum.eColorType.None; if (left) { colorType = YBEnum.eColorType.Yellow; } if (right) { colorType = YBEnum.eColorType.Green; } Toggle toggle = toggles.Find(t => t.isOn); if (toggle == null) { return; } YBEnum.eUnitName strToEnum = UnitName.ParseToEnum(toggle.name); listUnit.Add(UnitsPool.instance.CreateUnit(strToEnum, colorType, hit.point)); } } }
void CreateUnit() { // 유닛 생성 for (int i = 0; i < PlayData.listUnitInfos.Count; i++) { var info = PlayData.listUnitInfos[i]; YBEnum.eUnitName eUnitName = UnitName.ParseToEnum(info.unit_name); YBEnum.eColorType colorType = (YBEnum.eColorType)info.color; Vector2 pos = new Vector2(info.x, info.y); Unit unit = UnitsPool.instance.CreateUnit(eUnitName, colorType, pos); unit.transform.parent = unitsTr; var trModel = unit.transform.Find("Model").transform; // 왼쪽이 0 int dir = (0 - unit.transform.position.x < 0) ? 0 : 1; if (unit.status.name.CompareTo("Catapult") == 0) { dir = (0 - unit.transform.position.x < 0) ? 1 : 0; } trModel.rotation = Quaternion.Euler(new Vector3(0, 180 * dir, 0)); listEnemies.Add(unit); } }
private void SetBottomPlate() { var wl = WallPolygon.IfWall.IfLocation; var wd = WallPolygon.IfWall.IfDimension; var dim = IfSill.Setup.Get <IfDimension>("Dimension"); UnitName unit = WallPolygon.IfWall.IfModel.IfUnit.LengthUnit; switch (unit) { case UnitName.MILLIMETRE: //dim = dim.ToMilliMeters(); break; case UnitName.METRE: //dim = dim.ToMeters(); break; default: //dim = dim.ToFeet(); break; } var location = new IfLocation(wd.XDim.Inches / 2, 0, -dim.ZDim.Inches); var plate = new IfSill(WallPolygon.IfWall) { IfLocation = location, IfDimension = new IfDimension(wd.XDim, dim.YDim, dim.ZDim), IfMaterial = IfMaterial.Setup.Get <IfMaterial>("BottomPlate"), IfModel = WallPolygon.IfWall.IfModel, LocalPlacement = (IfcLocalPlacement)WallPolygon.IfWall.LocalPlacement }; plate.New(); plate.IfMaterial.AttatchTo(plate); }
//ユニットのステータスを設定する関数 public virtual void SetUnitStatus(UnitName name) { //位置情報を設定する transform.position = new Vector3(1, 0, 0); //thisをUnitというリストに加え、indexNumberを設定する unitList.Add(this); this.indexNumber = unitList.Count - 1; //全unitNameで共通のステータス設定を行う unitName = name; isAlive = true; //個別unitNameで異なるステータス設定を行う switch (name) { case UnitName.Player: hitPoint = 15; break; case UnitName.Skelton: hitPoint = 13; break; case UnitName.EliteSkelton: hitPoint = 20; break; default: Debug.Log("ERROR: Unit.SetUnitStatus => This unitName is invalid"); break; } }
public override int GetHashCode() { unchecked { return((UnitHoldeType.GetHashCode() * 397) ^ UnitName.GetHashCode()); } }
/// <inheritdoc /> public string GetPath(UnitName unitName) { if (unitName.ToQualifiedString() == "v.s.w.t1") { return(iFileSet[0].FullName); } return(iFileSet[1].FullName); }
public override void SetUnitStatus(UnitName name) { //Enemyをインスタンス化し、EnemyManagerの子要素にする transform.SetParent(Enemy.transform); //UnitクラスのSetUnitStatusを実行 base.SetUnitStatus(name); }
public TimeUnit GetSuggestedTimeUnit() { if (UnitName.EndsWith("Wh", StringComparison.Ordinal)) { return(TimeUnits.Hour); } return(TimeUnits.Second); }
public override int GetHashCode() { int hash = 271; hash = (hash * 7) ^ LessonName.GetHashCode(); hash = (hash * 7) ^ UnitName.GetHashCode(); return(hash); }
public void destroy() { Tile.destroy(); SquadButton.destroy(); UnitPicture.destroy(); UnitName.destroy(); SquadInfo.destroy(); }
/// <summary> /// Send a message to server, which includes the message of unit and applies for permission. /// </summary> /// <param name="unit">The unit type enum</param> /// <param name="isLocal">Is this object local</param> /// <param name="position">The position of the unit that would be created at</param> /// <param name="rotation">The rotation of the unit</param> public static void CreateObject(UnitName unit, Vector3 position, Quaternion rotation) { ProtocolBytes protocol = SF.GetProtocolHead(ProtoName.CreateObject); protocol.AddByte((byte)unit); //UnitName AppendVector3(protocol, position); //Position AppendQuaternion(protocol, rotation); //Rotation Client.Instance.Send(protocol); }
public UnitBase(Unit unit) { Name = new UnitName { Long = GetUnitNameLong(unit.Type), Short = GetUnitShortName(unit.Type) }; Factor = GetUnitFactor(unit.Type); }
//public static int CreateUnit(GameObject gameObject, Vector3 position, Quaternion rotation) //{ // Instantiate(gameObject, position, rotation); //} //public static class Command //{ // /// <summary> // /// 命令单位释放当前技能 // /// </summary> // /// <param name="unit">目标单位</param> // /// <param name="Params">技能参数</param> // public static void UnitReleaseCurrentSkill(UnitCtrl unit, params object[] Params) // { // if (unit != null) // unit.Spell(Params); // else // Debug.Log("不能命令 null 单位施法"); // } // /// <summary> // /// 命令单位切换技能 // /// </summary> // /// <param name="unit">目标单位</param> // /// <param name="index">技能序号(1,2,3,4)</param> // public static void UnitShiftSkill(UnitCtrl unit, int index) // { // unit.skillTable.CurrentIndex = index - 1; // } // /// <summary> // /// 令单位更换当前技能为目标技能 // /// </summary> // /// <param name="unit">目标单位</param> // /// <param name="skill">目标技能</param> // public static void UnitReplaceCurrentSkill(UnitCtrl unit, SkillName skill) // { // unit.skillTable.CurrentSkill.Name = skill; // } // /// <summary> // /// 尝试获取单位当前技能的技能效果类 // /// </summary> // /// <param name="unit">目标单位</param> // /// <param name="skillEffectBase">技能效果基类</param> // /// <returns></returns> // public static bool TryGetUnitSkillEffectBase(UnitCtrl unit, out SkillMgr.SkillEffectBase skillEffectBase) // { // skillEffectBase = unit.skillTable.CurrentSkill.skillEffectBase; // return skillEffectBase != null; // } // /// <summary> // /// 尝试获取单位目标技能栏的技能效果类 // /// </summary> // /// <param name="unit">目标单位</param> // /// <param name="index">技能序号</param> // /// <param name="skillEffectBase">技能效果基类</param> // /// <returns></returns> // public static bool TryGetUnitSkillEffectBase(UnitCtrl unit, int index, out SkillMgr.SkillEffectBase skillEffectBase) // { // skillEffectBase = unit.skillTable.skills[index].skillEffectBase; // return skillEffectBase != null; // } //} #endregion #region 函数曲线 ///// <summary> ///// 反正切函数(曲线优化) ///// </summary> ///// <param name="t">正切值</param> ///// <returns>对应的角度</returns> //public static float Atan(float t) //{ // if (t < 80.5f) // return GameDB.AtanCurve.Evaluate(t); // return Mathf.Atan(t) * Mathf.Rad2Deg; //} #endregion #region 存取数据 /// <summary> /// 读取单位数据 /// </summary> /// <param name="name">单位名称</param> /// <returns>单位数据</returns> public static UnitData LoadUnitData(UnitName name) { #if DEBUG if (name < 0 || (int)name >= GameDB.Instance.unitDataPath.paths.Length) { Debug.Log("单位名 name 没有对应路径"); return(null); } #endif return(Resources.Load <UnitData>(GameDB.Instance.unitDataPath.paths[(int)name])); //return unitCache.LoadData(name); }
public void reset() { Tile.reset(); UnitPicture.reset(); UnitName.reset(); Health.reset(); Attack.reset(); Range.reset(); LevelButton.reset(); SquadButton.reset(); SquadInfo.reset(); }
public void AsStringTest() { var unitBaseName = new UnitBaseName <ScalarFloat, float> { Name = "metre", AsciiSymbol = "m", Factor = new ScalarFloat(1), Symbol = "m" }; var unitPrefix = new UnitPrefix <ScalarFloat, float> { Name = "kilo", Symbol = "k", AsciiSymbol = "k", Factor = new ScalarFloat(1000), Invert = false }; var unitName = new UnitName <ScalarFloat, float>(unitPrefix, unitBaseName); Assert.AreEqual("km", unitName.AsString); }
private void SetWindowSills() { var wl = WallPolygon.IfWall.IfLocation; var wd = WallPolygon.IfWall.IfDimension; var dim = IfSill.Setup.Get <IfDimension>("Dimension"); UnitName unit = WallPolygon.IfWall.IfModel.IfUnit.LengthUnit; switch (unit) { case UnitName.MILLIMETRE: //dim = dim.ToMilliMeters(); break; case UnitName.METRE: //dim = dim.ToMeters(); break; default: //dim = dim.ToFeet(); break; } var regions = WallPolygon.RBottom; foreach (var region in regions) { var header = new IfSill(WallPolygon.IfWall); var l = region.IfLocation; var d = region.IfDimension; if (region.Direction == Direction.Positive) { header.IfLocation = new IfLocation(l.X + d.XDim.Inches / 2, l.Y, l.Z); } else { header.IfLocation = new IfLocation(l.X - d.XDim.Inches / 2, l.Y, l.Z); } header.IfDimension = new IfDimension(d.XDim.Inches, dim.YDim.Inches, d.ZDim.Inches / 4); header.IfModel = WallPolygon.IfWall.IfModel; header.LocalPlacement = region.LocalPlacement; header.New(); Headers.Add(header); header.IfMaterial = IfMaterial.Setup.Get <IfMaterial>("Header"); header.IfMaterial.AttatchTo(header); region.IfDimension.ZDim -= header.IfDimension.ZDim; region.IfLocation.Z += header.IfDimension.ZDim; } }
public KelvinTemperatureUnit GetKelvinTemperatureUnit() { // generator : InversedUnitGenerator.AddGetBaseUnit if (!(BaseUnit is null)) { return(BaseUnit); } // poor quality code :(, but should work for simple cases like 1/K if (UnitName.StartsWith("1/")) { return(new KelvinTemperatureUnit(UnitName.Substring(2))); } throw new NotImplementedException("Not implemented yet"); }
public void AddUnit(Unit unit) { if (unit.UnitCode != null && unit.UnitName != null) { if (unit.UnitName.Trim() != string.Empty && unit.UnitCode.Trim() != string.Empty) { UnitCodes.Add(unit); } else { UnitName = UnitName.Trim(); UnitCode = UnitCode.Trim(); } } }
void registerUnit(UnitName unit) { if (m_CurrentPos == m_MaxQueue - 1) { return; } m_UnitWaiting[m_CurrentPos] = unit; m_CurrentPos++; if (m_CurrentPos > m_MaxQueue - 1) { m_CurrentPos = m_MaxQueue - 1; } }
private GraphicsUnit ParseGraphicsUnits(string units) { UnitName name = null; for (int i = 0; i < UnitName.names.Length; i++) { if (string.Equals(UnitName.names[i].name, units, StringComparison.OrdinalIgnoreCase)) { name = UnitName.names[i]; break; } } if (name == null) { throw new ArgumentException(System.Drawing.SR.GetString("InvalidArgument", new object[] { "units", units })); } return(name.unit); }
/// <include file='doc\FontConverter.uex' path='docs/doc[@for="FontConverter.ParseGraphicsUnits"]/*' /> /// <devdoc> /// Parses the font units from the given text. /// </devdoc> private GraphicsUnit ParseGraphicsUnits(string units) { UnitName unitName = null; for (int i = 0; i < UnitName.names.Length; i++) { if (String.Compare(UnitName.names[i].name, units, true, CultureInfo.InvariantCulture) == 0) { unitName = UnitName.names[i]; break; } } if (unitName == null) { throw new ArgumentException(SR.GetString(SR.InvalidArgument, "units", units)); } return(unitName.unit); }
/// <include file='doc\FontConverter.uex' path='docs/doc[@for="FontConverter.ParseGraphicsUnits"]/*' /> /// <devdoc> /// Parses the font units from the given text. /// </devdoc> private GraphicsUnit ParseGraphicsUnits(string units) { UnitName unitName = null; for (int i = 0; i < UnitName.names.Length; i++) { if (String.Equals(UnitName.names[i].name, units, StringComparison.OrdinalIgnoreCase)) { unitName = UnitName.names[i]; break; } } if (unitName == null) { throw new ArgumentException(SR.GetString(SR.InvalidArgument, "units", units)); } return(unitName.unit); }
public static string UnitConversion(double value, UnitName from, UnitName to) { return string.Format("{0} {1} converted to {2} is {3}",value,from,to,value.Convert(from,to)); }
/// <sumary> /// Retrieves a Unit by its Name /// </summary> /// <param name="name">UnitName to be searched for </param> public static Unit GetByName(UnitName name) { var unit = Units.Find(u => u.Name.Equals(name)); return unit == null ? new NullUnit() : unit; }
public static double Convert(double value, UnitName from, UnitName to) { var fromUnit = GetByName(from); var toUnit = GetByName(to); if (fromUnit.Family != toUnit.Family) throw new Exception(string.Format("Error: Units of family {0} cannot be converted to units of family {1}.",fromUnit.Family, toUnit.Family)); // Temperature conversion formulas if(fromUnit.Family == UnitFamily.Temperature) { if(fromUnit == toUnit) { return value; } else if (fromUnit.Name == UnitName.Degree_Farenheit && toUnit.Name == UnitName.Degree_Celsius) { return (value - 32.0) * (5/9); } else if (fromUnit.Name == UnitName.Degree_Celsius && toUnit.Name == UnitName.Degree_Farenheit) { return (value - 32.0) / (1.8); } else if (fromUnit.Name == UnitName.Degree_Kelvin && toUnit.Name == UnitName.Degree_Celsius) { return value - 273.15; } else if (fromUnit.Name == UnitName.Degree_Celsius && toUnit.Name == UnitName.Degree_Kelvin) { return value + 273.15; } else if (fromUnit.Name == UnitName.Degree_Kelvin && toUnit.Name == UnitName.Degree_Farenheit) { return value.Convert(UnitName.Degree_Kelvin, UnitName.Degree_Celsius).Convert(UnitName.Degree_Celsius,UnitName.Degree_Farenheit); } else if (fromUnit.Name == UnitName.Degree_Farenheit && toUnit.Name == UnitName.Degree_Kelvin) { return value.Convert(UnitName.Degree_Farenheit, UnitName.Degree_Celsius).Convert(UnitName.Degree_Celsius,UnitName.Degree_Kelvin); } } // Default conversion return value * (fromUnit.Base / toUnit.Base); }