public void InitFromLineInfo(HitScanInfo hsi, GameObject parent, FactionHolder fh = null) { float deg = Mathf.Deg2Rad * parent.transform.rotation.eulerAngles.y; aimPoint = Orientation.OrientToVectorZ(hsi.AimDirection, deg); if (hsi.FollowCharacter) { transform.SetParent(parent.transform); transform.localPosition = hsi.CreatePos; transform.localRotation = Quaternion.identity; } else { transform.position += Orientation.OrientToVectorZ(hsi.CreatePos, deg); } setRange(hsi.MaxRange); Damage = hsi.Damage; setAimPoint(aimPoint); Duration = hsi.HitboxDuration; Knockback = Orientation.OrientToVectorZ(hsi.Knockback, deg); IsFixedKnockback = true; CanPenetrateWall = hsi.CanPenetrateWall; Creator = parent; EnemiesCanPenetrate = hsi.PenetrativePower; if (fh != null) { fh.SetFaction(gameObject); } hitCallback = hsi.hitCallback; AddElement(hsi.Element); Stun = hsi.Stun; Init(); }
public void InitFromProjectileInfo(ProjectileInfo pi, GameObject parent, FactionHolder fh = null) { float deg = Mathf.Deg2Rad * parent.transform.rotation.eulerAngles.y; if (pi.AimTowardsTarget) { } else { transform.localPosition = transform.position + Orientation.OrientToVectorZ(pi.ProjectileCreatePos, deg); } AimPoint = Orientation.OrientToVectorZ(pi.ProjectileAimDirection, deg); ProjectileSpeed = pi.ProjectileSpeed; SetAimPoint(AimPoint); PenetrativePower = pi.PenetrativePower; Damage = pi.Damage; Stun = pi.Stun; Duration = pi.HitboxDuration; AddElement(pi.Element); Knockback = Orientation.OrientToVectorZ(pi.Knockback, deg); hitCallback = pi.hitCallback; if (fh != null) { fh.SetFaction(gameObject); } Creator = parent; Init(); }
public void InitFromHitboxInfo(HitboxInfo hbi, GameObject parent, FactionHolder fh = null) { if (hbi.FollowCharacter) { transform.SetParent(parent.transform); transform.localScale = new Vector3(hbi.HitboxScale.x / transform.localScale.x, hbi.HitboxScale.y / transform.localScale.y, hbi.HitboxScale.z / transform.localScale.z); transform.localPosition = hbi.HitboxOffset; transform.localRotation = Quaternion.identity; } else { SetScale(hbi.HitboxScale);// : orient.OrientVectorToDirection2D(hbi.HitboxScale, false)); } Damage = hbi.Damage; OriginSource = hbi.OriginSource; FocusDamage = hbi.FocusDamage; Penetration = hbi.Penetration; Duration = hbi.HitboxDuration; float deg = Mathf.Deg2Rad * parent.transform.rotation.eulerAngles.y; Knockback = Orientation.OrientToVectorZ(hbi.Knockback, deg);// (orient == null) ? hbi.Knockback : orient.OrientVectorToDirection2D(hbi.Knockback); IsFixedKnockback = hbi.FixedKnockback; Stun = hbi.Stun; FreezeTime = hbi.FreezeTime; AddElement(hbi.Element); Creator = parent; hitCallback = hbi.hitCallback; if (fh != null) { fh.SetFaction(gameObject); } IsResetKnockback = hbi.ResetKnockback; if (hbi.FollowCharacter) { SetFollow(parent, hbi.HitboxOffset); } hitCallback = hbi.hitCallback; if (hbi.MyNoiseType != NoiseType.NONE) { if (GetComponent <NoiseAI>() == null) { gameObject.AddComponent <NoiseAI>(); } NoiseAI noise = GetComponent <NoiseAI>(); noise.PlaySound(hbi.MyNoiseType, hbi.NoiseRange); } Init(); }