private void ChangeListener(AttributeInt arg1, int val, int oldVal) { int diff = oldVal - val; dmgSum += diff; txtDamageTaken.text = dmgSum + ""; dmgTimer = 1.5f; if (val == 0) { StartCoroutine(FadeOut(.4f)); } }
//=============== // General //=============== public override void Step() { if (this.manuallyControlled) { if (this.state != -1) { this.active.SetValues(Pack.UnpackBools(this.active.Count, this.state)); this.state = -1; } this.StepInput(); return; } if (!this.profile.IsNull() && !this.profile.name.IsEmpty()) { this.PrepareGamepad(); this.CheckInput(); this.StepInput(); } }
public async Task UpdateAsync(AttributeInt item) { await _repository.UpdateAsync(item); }
public async Task <int> InsertAsync(AttributeInt item) { await _repository.AddAsync(item); return(item.Id); }
public async Task DeleteAsync(AttributeInt item) { await _repository.DeleteAsync(item); }
public void Link(AttributeInt attr) { attr.OnChanged += OnChange; }
public static BlockType ReadBlockType(this StreamReader reader, int id, string name, string reference) { try { BlockType blockType = new BlockType(id, name, reference); reader.ReadAttributes(blockType, (key, value) => { EcfAttribute a = null; switch (key) { // bool case "AboveTerrainCheck": case "IsAccessible": case "IsIgnoreLC": case "IsLockable": case "ShowBlockName": case "TurretTargetIgnore": a = new AttributeBool(value == "true"); break; // int case "BlastDamage": case "BlastRadius": case "CPUIn": case "CPUOut": case "EnergyIn": case "EnergyInIdle": case "EnergyOut": case "FuelCapacity": case "HitPoints": case "MaxCount": case "O2Capacity": case "PanelAngle": case "RotSpeed": case "ShieldCapacity": case "ShieldCooldown": case "ShieldPerCrystal": case "ShieldRecharge": case "StackSize": case "Temperature": case "TemperatureGain": case "ThrusterForce": case "Torque": case "UnlockCost": case "UnlockLevel": case "XpFactor": a = new AttributeInt(int.Parse(value)); break; // colour case "BlockColor": Match cm = Regex.Match(value, "(?<red>\\d+)\\s*,\\s*(?<green>\\d+)\\s*,\\s*(?<blue>\\d+)"); if (cm.Success) { byte r = byte.Parse(cm.Groups["red"].Value); byte g = byte.Parse(cm.Groups["green"].Value); byte b = byte.Parse(cm.Groups["blue"].Value); a = new AttributeColour(r, g, b); } else { throw new Exception("Unable to parse BlockColor attribute."); } break; // string case "Category": case "Group": case "Info": case "IsOxygenTight": case "Material": case "TechTreeParent": case "TemplateRoot": case "WeaponItem": a = new AttributeString(value); break; // string[] case "ChildBlocks": case "FuelAccept": case "O2Accept": case "TechTreeNames": a = new AttributeStringArray(value != null ? Regex.Split(value, "\\s*,\\s*") : null); break; // float case "HVEngineDampCoef": case "HVEngineDampPow": case "Mass": case "MaxVolumeCapacity": case "Radiation": case "ReturnFactor": case "SolarPanelEfficiency": case "Volume": case "VolumeCapacity": case "Zoom": a = new AttributeFloat(float.Parse(value)); break; default: Console.WriteLine($"Unknown block attribute: {key}"); break; } return(a); }, null); return(blockType); } catch (System.Exception ex) { throw new Exception("Failed reading item", ex); } }
public static ItemType ReadItemType(this StreamReader reader, int id, string name, string reference) { try { ItemType itemType = new ItemType(id, name, reference); reader.ReadAttributes(itemType, (key, value) => { EcfAttribute a = null; switch (key) { // int case "Armor": case "BlastDamage": case "BlastRadius": case "Cold": case "Durability": case "FoodDecayTime": case "Heat": case "NrSlots": case "Oxygen": case "Radiation": case "StackSize": case "UnlockCost": case "UnlockLevel": a = new AttributeInt(int.Parse(value)); break; // string[] case "AllowAt": case "TechTreeNames": a = new AttributeStringArray(value != null ? Regex.Split(value, "\\s*,\\s*") : null); break; // bool case "PickupToToolbar": case "RadialMenu": a = new AttributeBool(value.ToLower() == "true"); break; // string case "Category": case "TechTreeParent": a = new AttributeString(value); break; // float case "DegradationProb": case "FallDamageFac": case "FoodFac": case "JetpackFac": case "JumpFac": case "Mass": case "PowerFac": case "Range": case "SpeedFac": case "StaminaFac": case "Volume": case "VolumeCapacity": a = new AttributeFloat(float.Parse(value)); break; default: Console.WriteLine($"Unknown item attribute: {key}"); break; } return(a); }, (s, o) => { if (ParseChildNodeHeader(s, out string childType, out string childName)) { // TODO: Verify that childType == "" and childName == "" OperationMode child = reader.ReadOperationMode(-1, childName, null); ((ItemType)o).OperationModes.Add(child); } }); return(itemType); }