void GetFinalAction() { int giveValue = (targetVapireEnergy.EP - PowerPerc) > 0 ? (-PowerPerc / 2) : (-PowerPerc - (targetVapireEnergy.EP - PowerPerc)) / 2; marker.SetActive(false); targetVapireEnergy.GetDamage(PowerPerc, 0, (int)BasicUnit.DamageType.Energy); ClientReciverMK1.WriteMsg("/Damage" + ThisUnit.Manger.GetUnitId(targetVapireEnergy.transform.parent.GetComponent <NetworkElement> ()) + ":" + PowerPerc + ":" + 0 + ":" + (int)BasicUnit.DamageType.Energy); if (ThisUnit == targetGiveEnergy) { giveValue += PowerPerc + 5; } else { ThisUnit.GetDamage(PowerPerc, 0, (int)BasicUnit.DamageType.Energy); ClientReciverMK1.WriteMsg("/Damage" + ThisUnit.Manger.GetUnitId(transform.parent.GetComponent <NetworkElement> ()) + ":" + PowerPerc + ":" + 0 + ":" + (int)BasicUnit.DamageType.Energy); } targetGiveEnergy.GetDamage(giveValue, 0, (int)BasicUnit.DamageType.Energy); ClientReciverMK1.WriteMsg("/Damage" + ThisUnit.Manger.GetUnitId(targetGiveEnergy.transform.parent.GetComponent <NetworkElement> ()) + ":" + giveValue + ":" + 0 + ":" + (int)BasicUnit.DamageType.Energy); ThisUnit.Manger.ClearGrid(); ThisUnit.Manger.EndTurn(); ClientReciverMK1.WriteMsg("/EndTurn"); }
public virtual IEnumerator MoveBullet(NodeA targetNode) { _unit.unit.AttackUse(); yield return(new WaitForSeconds(0.25f)); for (int i = 0; i < BulletPerShoot; i++) { _target.Manger.PlaySpecific(Sound); Vector3 targetPosition = targetNode.Position + Vector3.up * (Random.Range(-5, 11) / 20f) + Vector3.up * 0.6f; Vector3 selfPosition = transform.position + (targetPosition - (transform.position + Vector3.up * 0.3f)).normalized * 0.25f + Vector3.up * 0.3f; NetworkElement targetUnit = targetNode.UnitOnNode; GameObject localBullet = Instantiate(_bullet, selfPosition, Quaternion.identity); float distantion = Vector3.Distance(selfPosition, targetPosition); while (Vector3.Distance(localBullet.transform.position, targetPosition) > 0.05f) { localBullet.transform.Translate((targetPosition - selfPosition) / valuespeedBullet); yield return(new WaitForFixedUpdate()); } float n = Random.Range(0, 100); Shelter shelter; float DistanceTarget = Vector3.Distance(selfPosition, targetUnit.transform.position + Vector3.up * (Random.Range(-5, 11) / 20f)); float Range = NormalDist / DistanceTarget; float targetShelterValue = targetUnit.GetShelterLevel(out shelter); if (Range > 1) { Range = 1; } if (n < Range * 100f - targetShelterValue) { FinalDamage += Damage; } else { if (Random.Range(0, 101) > targetShelterValue * 0.75f) { if (shelter != null) { Instantiate(shelter.FX, shelter.transform.position, Quaternion.identity); shelter.ShelterLevl -= Damage * 3; if (shelter.ShelterLevl < 1) { Destroy(shelter.gameObject); } } } } Ammo--; Destroy(localBullet); yield return(new WaitForSeconds(WaitTime)); } if (_unit.Controlled) { if (FinalDamage > 0) { ClientReciverMK1.WriteMsg("/Damage" + _unit.unit.Manger.GetUnitId(targetNode.UnitOnNode) + ":" + FinalDamage + ":" + 0 + ":" + 0); _target.GetDamage(FinalDamage); FinalDamage = 0; } else { ClientReciverMK1.WriteMsg("/Damage" + _unit.unit.Manger.GetUnitId(targetNode.UnitOnNode) + ":" + 0 + ":" + 0 + ":" + -1); _target.GetDamage(0, 0, -1); } } }