public void Initialize(HitboxInfo info) { if (_owner == null) { _owner = _ownerGO.GetComponent <Damageable>(); } _info = info; _hitData = new HitData(_info, _owner, _powerScale, transform.position); }
public HitData(HitboxInfo info, Damageable owner, float powerScale, Vector3 origin) { Power = info.Power; Element = info.Element; Effects = info.Effects; KnockBackDir = info.KnockBackDir; Owner = owner; PowerScale = powerScale; Origin = origin; }
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(); }
public Hitbox CreateHitbox(HitboxInfo hbi) { if (ListHitboxes.Instance == null) { Debug.LogWarning("LIstHitboxes not found. Please add a Gameobject with the ListHItboxes prefab"); return(null); } var go = GameObject.Instantiate(ListHitboxes.Instance.Hitbox, transform.position, Quaternion.identity); hbi.hitCallback.Add(RegisterHit); Hitbox newBox = go.GetComponent <Hitbox>(); newBox.InitFromHitboxInfo(hbi, gameObject, GetComponent <FactionHolder>()); return(newBox); }
protected override void OnAttack() { HitboxInfo hi = m_HitboxInfo [0]; FollowTime = 0f; if (m_HitboxInfo.Count > 0) { DetectionBox = m_hitboxMaker.CreateHitboxMulti(hi.HitboxScale, hi.HitboxOffset, hi.Damage, hi.Stun, m_AttackAnimInfo.AttackTime, hi.Knockback, hi.FixedKnockback, true, hi.Element, m_autoAttack.RefreshTime); DetectionBox.IsResetKnockback = hi.ResetKnockback; } OldFloating = m_physics.Floating; lastFacingLeft = GetComponent <PhysicsSS> ().FacingLeft; DirectionOrient(); base.OnAttack(); }
public Hitbox CreateHitbox(HitboxInfo hbi) { Vector2 cOff = (m_physics == null) ? hbi.HitboxOffset : m_physics.OrientVectorToDirection(hbi.HitboxOffset); Vector3 newPos = transform.position + (Vector3)cOff; var go = GameObject.Instantiate(HitboxList.Instance.Hitbox, newPos, Quaternion.identity); Hitbox newBox = go.GetComponent <Hitbox>(); if (hbi.FollowCharacter) { go.transform.SetParent(gameObject.transform); newBox.transform.localScale = m_physics.OrientVectorToDirection(new Vector2(hbi.HitboxScale.x / transform.localScale.x, hbi.HitboxScale.y / transform.localScale.y), false); } else { newBox.SetScale((m_physics == null) ? hbi.HitboxScale : m_physics.OrientVectorToDirection(hbi.HitboxScale, false)); } newBox.Damage = hbi.Damage; newBox.FocusDamage = hbi.FocusDamage; newBox.Penetration = hbi.Penetration; newBox.Duration = hbi.HitboxDuration; newBox.Knockback = (m_physics == null) ? hbi.Knockback : m_physics.OrientVectorToDirection(hbi.Knockback); newBox.IsFixedKnockback = hbi.FixedKnockback; newBox.Stun = hbi.Stun; newBox.FreezeTime = hbi.FreezeTime; newBox.AddElement(hbi.Element); newBox.Creator = gameObject; newBox.Faction = Faction; newBox.IsResetKnockback = hbi.ResetKnockback; if (hbi.FollowCharacter) { newBox.SetFollow(gameObject, hbi.HitboxOffset); } if (hbi.ApplyProps) { ExecuteEvents.Execute <ICustomMessageTarget> (gameObject, null, (x, y) => x.OnHitboxCreate(newBox)); } newBox.Init(); return(newBox); }
public Hitbox CreateHitbox(HitboxInfo hbi) { Vector3 cOff = (m_charBase == null) ? hbi.HitboxOffset : m_orient.OrientVectorToDirection2D(hbi.HitboxOffset); //Debug.Log("Initial offset is: " + cOff); Vector3 newPos = transform.position + (Vector3)cOff; //Debug.Log("Instantiated at: " + newPos); var go = GameObject.Instantiate(ListHitboxes.Instance.Hitbox, newPos, Quaternion.identity); Hitbox newBox = go.GetComponent <Hitbox>(); newBox.InitFromHitboxInfo(hbi, m_orient, Faction); /* * if (hbi.FollowCharacter) { * go.transform.SetParent (gameObject.transform); * newBox.transform.localScale = new Vector3 (hbi.HitboxScale.x / transform.localScale.x, hbi.HitboxScale.y / transform.localScale.y, hbi.HitboxScale.z / transform.localScale.z); * } else { * newBox.SetScale ((m_charBase == null) ? hbi.HitboxScale : m_orient.OrientVectorToDirection2D(hbi.HitboxScale,false)); * } * newBox.Damage = hbi.Damage; * newBox.SourceEqp = hbi.SourceEqp; * * newBox.FocusDamage = hbi.FocusDamage; * newBox.Penetration = hbi.Penetration; * newBox.Duration = hbi.HitboxDuration; * newBox.Knockback = (m_charBase == null) ? hbi.Knockback : m_orient.OrientVectorToDirection2D(hbi.Knockback); * newBox.IsFixedKnockback = hbi.FixedKnockback; * newBox.Stun = hbi.Stun; * newBox.FreezeTime = hbi.FreezeTime; * newBox.AddElement(hbi.Element); * newBox.Creator = gameObject; * newBox.Faction = Faction; * newBox.IsResetKnockback = hbi.ResetKnockback; * if (hbi.FollowCharacter) * newBox.SetFollow (gameObject,hbi.HitboxOffset); * if (hbi.ApplyProps) * ExecuteEvents.Execute<ICustomMessageTarget> (gameObject, null, (x, y) => x.OnHitboxCreate(newBox)); * newBox.Init();*/ return(newBox); }
public void InitFromHitboxInfo(HitboxInfo hbi, Orientation orient, FactionType f = FactionType.NEUTRAL) { Vector3 cOff = (orient == null) ? hbi.HitboxOffset : orient.OrientVectorToDirection2D(hbi.HitboxOffset); //Debug.Log("Initial offset is: " + cOff); Vector3 newPos = transform.position + (Vector3)cOff; //Debug.Log("Instantiated at: " + newPos); transform.localPosition = newPos; if (hbi.FollowCharacter) { transform.SetParent(gameObject.transform); transform.localScale = new Vector3(hbi.HitboxScale.x / transform.localScale.x, hbi.HitboxScale.y / transform.localScale.y, hbi.HitboxScale.z / transform.localScale.z); } else { SetScale((orient == null) ? hbi.HitboxScale : orient.OrientVectorToDirection2D(hbi.HitboxScale, false)); } Damage = hbi.Damage; SourceEqp = hbi.SourceEqp; FocusDamage = hbi.FocusDamage; Penetration = hbi.Penetration; Duration = hbi.HitboxDuration; Knockback = (orient == null) ? hbi.Knockback : orient.OrientVectorToDirection2D(hbi.Knockback); IsFixedKnockback = hbi.FixedKnockback; Stun = hbi.Stun; FreezeTime = hbi.FreezeTime; AddElement(hbi.Element); Creator = gameObject; Faction = Faction; IsResetKnockback = hbi.ResetKnockback; if (hbi.FollowCharacter) { SetFollow(gameObject, hbi.HitboxOffset); } Init(); }
public HitboxInfo ToHitboxInfo() { HitboxInfo hbi = new HitboxInfo(); return(hbi); }
public void QueueHitbox(HitboxInfo hi, float delay) { m_queuedHitboxes.Add(hi, Time.timeSinceLevelLoad + delay); }
private void ApplyHitboxInfo(HitboxInfo info) { HitboxCollider.size = new Vector2(info.X, info.Y); HitboxCollider.offset = new Vector2(info.OffsetX, info.OffsetY); currentHitboxInfo = info; }
public void Ink(HitboxInfo info) { audioPlayer.PlaySound("Steal"); ApplyHitboxInfo(info); animator.SetTrigger("Ink"); }
public void SuperAttack(HitboxInfo info) { audioPlayer.PlaySound("Slash"); ApplyHitboxInfo(info); animator.SetTrigger("SuperAttack"); }