private static void FaceOppositeOf(GameObject source, Component target, SpellFacingOptions options) { FaceOppositeOf(source.transform, target.transform, options); }
private static void SetOrientation(Transform source, Vector3 sourcePosition, Vector3 targetPosition, SpellFacingOptions options) { if (!options.m_RotateX || !options.m_RotateY) { if (!options.m_RotateX) { if (!options.m_RotateY) { return; } targetPosition.y = sourcePosition.y; } else { targetPosition.x = sourcePosition.x; } } Vector3 forward = targetPosition - sourcePosition; if (forward.sqrMagnitude > Mathf.Epsilon) { source.rotation = Quaternion.LookRotation(forward); } }
public static bool SetOrientationFromFacing(Spell spell) { SpellFacing facing = spell.GetFacing(); if (facing == SpellFacing.NONE) { return(false); } SpellFacingOptions facingOptions = spell.GetFacingOptions(); if (facingOptions == null) { facingOptions = new SpellFacingOptions(); } switch (facing) { case SpellFacing.SAME_AS_SOURCE: { GameObject source = spell.GetSource(); if (source == null) { return(false); } FaceSameAs(spell, source, facingOptions); break; } case SpellFacing.SAME_AS_SOURCE_AUTO: { GameObject target = FindAutoObjectForSpell(spell.GetSource()); if (target == null) { return(false); } FaceSameAs(spell, target, facingOptions); break; } case SpellFacing.SAME_AS_SOURCE_HERO: { Card card2 = FindHeroCard(spell.GetSourceCard()); if (card2 == null) { return(false); } FaceSameAs((Component)spell, (Component)card2, facingOptions); break; } case SpellFacing.TOWARDS_SOURCE: { GameObject obj4 = spell.GetSource(); if (obj4 == null) { return(false); } FaceTowards(spell, obj4, facingOptions); break; } case SpellFacing.TOWARDS_SOURCE_AUTO: { GameObject obj5 = FindAutoObjectForSpell(spell.GetSource()); if (obj5 == null) { return(false); } FaceTowards(spell, obj5, facingOptions); break; } case SpellFacing.TOWARDS_SOURCE_HERO: { Card card4 = FindHeroCard(spell.GetSourceCard()); if (card4 == null) { return(false); } FaceTowards((Component)spell, (Component)card4, facingOptions); break; } case SpellFacing.TOWARDS_TARGET: { GameObject visualTarget = spell.GetVisualTarget(); if (visualTarget == null) { return(false); } FaceTowards(spell, visualTarget, facingOptions); break; } case SpellFacing.TOWARDS_TARGET_HERO: { Card card6 = FindHeroCard(FindBestTargetCard(spell)); if (card6 == null) { return(false); } FaceTowards((Component)spell, (Component)card6, facingOptions); break; } case SpellFacing.TOWARDS_CHOSEN_TARGET: { Card powerTargetCard = spell.GetPowerTargetCard(); if (powerTargetCard == null) { return(false); } FaceTowards((Component)spell, (Component)powerTargetCard, facingOptions); break; } case SpellFacing.OPPOSITE_OF_SOURCE: { GameObject obj7 = spell.GetSource(); if (obj7 == null) { return(false); } FaceOppositeOf(spell, obj7, facingOptions); break; } case SpellFacing.OPPOSITE_OF_SOURCE_AUTO: { GameObject obj8 = FindAutoObjectForSpell(spell.GetSource()); if (obj8 == null) { return(false); } FaceOppositeOf(spell, obj8, facingOptions); break; } default: { if (facing != SpellFacing.OPPOSITE_OF_SOURCE_HERO) { return(false); } Card card9 = FindHeroCard(spell.GetSourceCard()); if (card9 == null) { return(false); } FaceOppositeOf((Component)spell, (Component)card9, facingOptions); break; } } return(true); }
private static void FaceTowards(Transform source, Transform target, SpellFacingOptions options) { SetOrientation(source, source.position, target.position, options); }
private static void FaceTowards(GameObject source, GameObject target, SpellFacingOptions options) { FaceTowards(source.transform, target.transform, options); }
private static void FaceTowards(Component source, Component target, SpellFacingOptions options) { FaceTowards(source.transform, target.transform, options); }
private static void FaceSameAs(Transform source, Transform target, SpellFacingOptions options) { SetOrientation(source, target.position, target.position + target.forward, options); }
private static void FaceSameAs(Component source, GameObject target, SpellFacingOptions options) { FaceSameAs(source.transform, target.transform, options); }