public static bool cb(CSVReader csv_reader, DamageDistanceData data, ref uint key) { data.id = key; float num = 0f; List <DamagePoint> list = new List <DamagePoint>(); DamagePoint damagePoint = new DamagePoint(); damagePoint.distance = 0f; csv_reader.Pop(ref damagePoint.rate); list.Add(damagePoint); for (int i = 0; i < 10; i++) { DamagePoint damagePoint2 = new DamagePoint(); CSVReader.PopResult result = csv_reader.Pop(ref damagePoint2.distance); CSVReader.PopResult result2 = csv_reader.Pop(ref damagePoint2.rate); if (!(bool)result || !(bool)result2 || (float)damagePoint2.distance <= 0f || num >= (float)damagePoint2.distance) { break; } num = damagePoint2.distance; list.Add(damagePoint2); } data.points = list.ToArray(); data.CalcMaxRate(); return(true); }
public float GetRate(float distance) { DamagePoint damagePoint = points[0]; DamagePoint damagePoint2 = points[points.Length - 1]; for (int i = 0; i < points.Length; i++) { DamagePoint damagePoint3 = points[i]; if ((float)damagePoint3.distance > distance) { damagePoint2 = damagePoint3; break; } damagePoint = damagePoint3; } float num = distance - (float)damagePoint.distance; float num2 = (float)damagePoint2.distance - (float)damagePoint.distance; float num3 = 1f; if (distance <= 0f) { num3 = 0f; } else if (num2 > 0f) { num3 = num / num2; } return(Mathf.Lerp((float)damagePoint.rate, (float)damagePoint2.rate, num3)); }
public void CalcMaxRate() { for (int i = 0; i < points.Length; i++) { DamagePoint damagePoint = points[i]; max = Mathf.Max(max, (float)damagePoint.rate); } }
private void FinishRepairAction() { //Debug.Log("Robot " + name + " executing repair action!"); DamagePoint dp = goal.GetComponent <DamagePoint>(); if (null == dp) { Debug.LogError("not a ContainerPoint object!"); } //Debug.Log("Goal Damage = " + goal.damage); switch (goal.damage) { case DamageType.REPAIR_NONE: BeConfused(); break; case DamageType.REPAIR_WELD: if (carriedItem != null) { BeConfused(); } else { RepairDone(dp); } break; case DamageType.REPAIR_MECHANIC: case DamageType.REPAIR_BATTERY: case DamageType.REPAIR_BERYLLIUM: case DamageType.REPAIR_FLUX: if (carriedItem == null) { BeConfused(); } else { if (carriedItem.damageType == goal.damage) { RepairDone(dp); } else { BeConfused(); } } break; } }
private static DamagePoint FindUnusedDamagePoint() { List <DamagePoint> unusedPoints = FindAllUnusedDamagePoints(); if (unusedPoints.Count == 0) { Debug.Log("No unused damaged points!"); return(null); } int index = Random.Range(0, unusedPoints.Count); DamagePoint p = unusedPoints[index]; return(p); }
private void FinishDamageAction() { PlaySound(Speech.KAPUTT_GEMACHT); //Debug.Log("Robot " + name + " executing damage action!"); DamagePoint dp = goal.GetComponent <DamagePoint>(); if (null == dp) { Debug.LogError("not a ContainerPoint object!"); } dp.Activate(); BeConfused(); SetAnimState(AnimState.STUNNED); }
void Start() { this.Inject(); damagePoint = firePoint.gameObject.GetComponent <DamagePoint>(); if (damagePoint == null) { damagePoint = firePoint.gameObject.AddComponent <DamagePoint>(); } damagePoint.enabled = false; damagePoint.damageHP = Damage; }
private void RepairDone(DamagePoint dp) { if (carriedItem != null) { DestroyImmediate(carriedItem.gameObject); carriedItem = null; } Waypoint wp = dp.GetComponent <Waypoint>(); switch (wp.damage) { case DamageType.REPAIR_WELD: PlaySound(Speech.SCHWEISSGERAET); break; case DamageType.REPAIR_MECHANIC: PlaySound(Speech.WERKZEUG_INSTALLIERT); break; case DamageType.REPAIR_BATTERY: PlaySound(Speech.BATTERIE_INSTALLIERT); break; case DamageType.REPAIR_BERYLLIUM: PlaySound(Speech.BERYLLIUMKUGEL_INSTALLIERT); break; case DamageType.REPAIR_FLUX: PlaySound(Speech.FLUX_COMPENSATOR_INSTALLIERT); break; default: case DamageType.REPAIR_NONE: break; } dp.Deactivate(); state = RobotState.IDLE; goal = null; }
void BeConfused() { //PlaySound(Speech.I_AM_CONFUSED); if (carriedItem != null) { SetAnimState(AnimState.THROW); carriedItem.FloatToSpace(); carriedItem = null; } DamagePoint p = FindUnusedDamagePoint(); if (null == p) { Debug.Log("no more damage points!"); return; } Waypoint wp = p.GetComponent <Waypoint>(); SetTarget(wp, true); }
private void SpawnDamages(int count) { List <DamagePoint> listDamages = InactiveDamages(); Debug.Log("inactive damages " + listDamages.Count); for (int i = 0; i < count; i++) { if (listDamages.Count == 0) { if (localTime > 30.0f) { GameOver(); } return; } int index = Random.Range(0, listDamages.Count); DamagePoint dmg = listDamages[index]; dmg.Activate(); listDamages.Remove(dmg); totalDamagesForLevel--; } }