public async Task TestUpdatePost() { // Create a post UnitRoot post = new UnitRoot { Unit = new Unit { Code = "XXX", Description = "Testing" } }; // Update the post FortnoxResponse<UnitRoot> fr = await config.fortnox_client.Update<UnitRoot>(post, "units/XXX"); // Log the error if (fr.model == null) { config.logger.LogError(fr.error); } // Test evaluation Assert.AreNotEqual(null, fr.model); } // End of the TestUpdatePost method
public void Set(int damage, float forceValue, float hitRateRange, UnitRoot target, UnitRoot attacker) { this.damage = damage; this.attacker = attacker; this.forceValue = forceValue; Vector3 dir = target.transform.position - attacker.transform.position; dir = new Vector3(dir.x, 0, dir.z).normalized; float randomHitDir = Random.Range(-hitRateRange, hitRateRange); dir = Quaternion.Euler(0, randomHitDir, 0) * dir; this.transform.forward = dir; this.rbody.velocity = dir * (shootSpeed + Random.Range(0, shootSpeedRange)); // Ignore collision versus caster. for (int i = 0; i < attacker.colliders.Length; i++) { for (int y = 0; y < colliders.Length; y++) { Physics.IgnoreCollision(attacker.colliders[i], colliders[y]); } } Destroy(this.gameObject, 3); }
public override void OnDeath(UnitRoot killer) { base.OnDeath(killer); StopAllCoroutines(); // Play death animation. StartCoroutine(DeathIE((this.transform.position - killer.transform.position).normalized)); }
public float hitRateRange = 3; // How many degrees that the aim can vary. public override void Attack(UnitRoot target, UnitRoot attacker) { int damage = GetDamageRoll(); WeaponProjectile weaponProjectile = Instantiate(projectilePrefab.gameObject).GetComponent <WeaponProjectile>(); weaponProjectile.transform.position = this.transform.position; weaponProjectile.Set(damage, baseStats.forceValue, hitRateRange, target, attacker); }
public void OnTriggerEnter(Collider other) { UnitRoot unitRoot = other.GetComponent <UnitRoot>(); if (unitRoot != null) { unitRoot.health.Attack(damage, forceValue, attacker); Destroy(this.gameObject); } }
public void Init(UnitRoot unitRoot) { if (isInit) { return; } this.unitRoot = unitRoot; this.unitRoot.statHandler.RegisterOnStatsChanged(OnStatsChanged); isInit = true; OnInit(); }
public void SignalDeath(UnitRoot killer) { if (!alive) { return; } alive = false; for (int i = 0; i < myChildren.Length; i++) { myChildren[i].OnDeath(killer); } }
public void Attack(int damage, float forceValue, UnitRoot attacker) { // Calculate whether it missed or not. const int minDamageFontSize = 10; const int maxDamageFontSize = 25; int minMaxFontDiff = maxDamageFontSize - minDamageFontSize; const int deathFontSize = 8; float damageSize = (float)damage / maxHealth; // How big the damage was for this unit. int fontSize = minDamageFontSize + ((int)(damageSize * minMaxFontDiff)); currHealth = System.Math.Max(0, currHealth - damage); unitUIDisplay.SetHealth((float)currHealth / maxHealth); if (currHealth <= 0) { unitUIDisplay.DisplayHitText("<color=red><b>DEAD</b></color>", deathFontSize); Die(attacker); } else { Vector3 attackDir = (this.transform.position - attacker.transform.position).normalized; unitUIDisplay.DisplayHitText(damage.ToString(), fontSize); if (damage > 0) { unitEffects.DisplayHit(attackDir, damageSize); // Apply velocity depending on weapon force value and the damage size. unitRoot.AddVelocityExternal((attackDir * damageSize * 350) * forceValue); unitRoot.AddVelocityExternal(Vector3.up * damageSize * 110 * forceValue); } } }
public override void OnDeath(UnitRoot killer) { base.OnDeath(killer); displayer.gameObject.SetActive(false); }
private void Die(UnitRoot killer) { unitRoot.SignalDeath(killer); Destroy(this.gameObject, 2f); }
public void Heal(int heal, UnitRoot healer) { currHealth = System.Math.Min(maxHealth, currHealth - heal); }
public virtual void OnDeath(UnitRoot killer) { alive = false; }
public Target(UnitRoot target, UnitRoot owner) { this.target = target; this.owner = owner; }
public override void OnDeath(UnitRoot killer) { base.OnDeath(killer); allActiveUnits.Remove(this); }
public virtual void Attack(UnitRoot unit, UnitRoot attacker) { int damage = GetDamageRoll(); unit.health.Attack(damage, baseStats.forceValue, attacker); }