Exemple #1
0
 public WaitingToCast(SpellLocation location, float secondsDelayStart, string effectName, string spellId, string creatureId, float enlargeTime, float lifeTime = 0, Vector3?position = null, float shrinkTime = 0, float rotation = 0, bool isMoveable = false, Action <GameObject> conditioning = null)
 {
     Conditioning    = conditioning;
     CreationTime    = Time.time + secondsDelayStart;
     EffectName      = effectName;
     SpellId         = spellId;
     CreatureId      = creatureId;
     EnlargeTime     = enlargeTime;
     ShrinkTime      = shrinkTime;
     RotationDegrees = rotation;
     LifeTime        = lifeTime;
     if (position.HasValue)
     {
         Position = position.Value;
     }
     Location   = location;
     IsMoveable = isMoveable;
 }
    public static GameObject GetLocationObject(Spell spell)
    {
        SpellLocation location = spell.GetLocation();

        if (location == SpellLocation.NONE)
        {
            return(null);
        }
        GameObject parentObject = null;

        switch (location)
        {
        case SpellLocation.SOURCE:
            parentObject = spell.GetSource();
            break;

        case SpellLocation.SOURCE_AUTO:
            parentObject = FindAutoObjectForSpell(spell.GetSource());
            break;

        case SpellLocation.SOURCE_HERO:
        {
            Card card2 = FindHeroCard(spell.GetSourceCard());
            if (card2 == null)
            {
                return(null);
            }
            parentObject = card2.gameObject;
            break;
        }

        case SpellLocation.SOURCE_HERO_POWER:
        {
            Card card4 = FindHeroPowerCard(spell.GetSourceCard());
            if (card4 == null)
            {
                return(null);
            }
            parentObject = card4.gameObject;
            break;
        }

        case SpellLocation.SOURCE_PLAY_ZONE:
        {
            Card sourceCard = spell.GetSourceCard();
            if (sourceCard == null)
            {
                return(null);
            }
            Player   controller = sourceCard.GetEntity().GetController();
            ZonePlay play       = ZoneMgr.Get().FindZoneOfType <ZonePlay>(controller.GetSide());
            if (play == null)
            {
                return(null);
            }
            parentObject = play.gameObject;
            break;
        }

        case SpellLocation.TARGET:
            parentObject = spell.GetVisualTarget();
            break;

        case SpellLocation.TARGET_AUTO:
            parentObject = FindAutoObjectForSpell(spell.GetVisualTarget());
            break;

        case SpellLocation.TARGET_HERO:
        {
            Card card7 = FindHeroCard(spell.GetVisualTargetCard());
            if (card7 == null)
            {
                return(null);
            }
            parentObject = card7.gameObject;
            break;
        }

        case SpellLocation.TARGET_HERO_POWER:
        {
            Card card9 = FindHeroPowerCard(spell.GetVisualTargetCard());
            if (card9 == null)
            {
                return(null);
            }
            parentObject = card9.gameObject;
            break;
        }

        case SpellLocation.TARGET_PLAY_ZONE:
        {
            Card visualTargetCard = spell.GetVisualTargetCard();
            if (visualTargetCard == null)
            {
                return(null);
            }
            Player   player2 = visualTargetCard.GetEntity().GetController();
            ZonePlay play2   = ZoneMgr.Get().FindZoneOfType <ZonePlay>(player2.GetSide());
            if (play2 == null)
            {
                return(null);
            }
            parentObject = play2.gameObject;
            break;
        }

        case SpellLocation.BOARD:
            if (Board.Get() == null)
            {
                return(null);
            }
            parentObject = Board.Get().gameObject;
            break;

        case SpellLocation.FRIENDLY_HERO:
        {
            Player player3 = FindFriendlyPlayer(spell);
            if (player3 == null)
            {
                return(null);
            }
            Card heroCard = player3.GetHeroCard();
            if (heroCard == null)
            {
                return(null);
            }
            parentObject = heroCard.gameObject;
            break;
        }

        case SpellLocation.FRIENDLY_HERO_POWER:
        {
            Player player4 = FindFriendlyPlayer(spell);
            if (player4 == null)
            {
                return(null);
            }
            Card heroPowerCard = player4.GetHeroPowerCard();
            if (heroPowerCard == null)
            {
                return(null);
            }
            parentObject = heroPowerCard.gameObject;
            break;
        }

        case SpellLocation.FRIENDLY_PLAY_ZONE:
        {
            ZonePlay play3 = FindFriendlyPlayZone(spell);
            if (play3 == null)
            {
                return(null);
            }
            parentObject = play3.gameObject;
            break;
        }

        case SpellLocation.OPPONENT_HERO:
        {
            Player player5 = FindOpponentPlayer(spell);
            if (player5 == null)
            {
                return(null);
            }
            Card card13 = player5.GetHeroCard();
            if (card13 == null)
            {
                return(null);
            }
            parentObject = card13.gameObject;
            break;
        }

        case SpellLocation.OPPONENT_HERO_POWER:
        {
            Player player6 = FindOpponentPlayer(spell);
            if (player6 == null)
            {
                return(null);
            }
            Card card14 = player6.GetHeroPowerCard();
            if (card14 == null)
            {
                return(null);
            }
            parentObject = card14.gameObject;
            break;
        }

        case SpellLocation.OPPONENT_PLAY_ZONE:
        {
            ZonePlay play4 = FindOpponentPlayZone(spell);
            if (play4 == null)
            {
                return(null);
            }
            parentObject = play4.gameObject;
            break;
        }

        case SpellLocation.CHOSEN_TARGET:
        {
            Card powerTargetCard = spell.GetPowerTargetCard();
            if (powerTargetCard == null)
            {
                return(null);
            }
            parentObject = powerTargetCard.gameObject;
            break;
        }
        }
        if (parentObject == null)
        {
            return(null);
        }
        string locationTransformName = spell.GetLocationTransformName();

        if (!string.IsNullOrEmpty(locationTransformName))
        {
            GameObject obj3 = SceneUtils.FindChildBySubstring(parentObject, locationTransformName);
            if (obj3 != null)
            {
                return(obj3);
            }
        }
        return(parentObject);
    }
Exemple #3
0
            private static void PlayEffect(string effectName, string spellId, string creatureId, float lifeTime, float enlargeTimeSeconds, float secondsDelayStart, float shrinkTime, SpellLocation location, float rotationDegrees, bool isMoveable)
            {
                if (secondsDelayStart > 0)
                {
                    Log.Debug($"QueueEffect \"{effectName}\" for {secondsDelayStart} seconds...");
                    QueueEffect(new WaitingToCast(location, secondsDelayStart, effectName, spellId, creatureId, enlargeTimeSeconds, lifeTime, null, shrinkTime, rotationDegrees, isMoveable));
                    return;
                }

                CreatureBoardAsset creatureBoardAsset = Minis.GetCreatureBoardAsset(creatureId);

                if (creatureBoardAsset == null)
                {
                    Log.Error($"CreatureBoardAsset matching id {creatureId} not found!");
                    return;
                }

                GameObject spell = GetSpell(effectName, spellId, lifeTime, enlargeTimeSeconds, shrinkTime, rotationDegrees, isMoveable);

                if (spell == null)
                {
                    Log.Error($"Spell name \"{effectName}\" not found!");
                    return;
                }

                GameObject creatureBase = creatureBoardAsset.GetBase();

                if (location == SpellLocation.CreatureCastSpell)
                {
                    Log.Vector("creatureBoardAsset.HookSpellCast.position", creatureBoardAsset.HookSpellCast.position);
                    spell.transform.position = creatureBoardAsset.HookSpellCast.position;
                }
                else                  // Default to base position...
                {
                    spell.transform.position = creatureBase.transform.position;
                }

                float creatureRotationDegrees = creatureBoardAsset.GetRotationDegrees();

                spell.transform.Rotate(Vector3.up, creatureRotationDegrees);
                //spell.transform.localEulerAngles = new Vector3(spell.transform.localEulerAngles.x, rotationDegrees, spell.transform.localEulerAngles.z);
                //Log.Vector("spell.transform.localEulerAngles", spell.transform.localEulerAngles);
                //spell.transform.Rotate(creatureBoardAsset.GetRotation());
                //Log.Vector("spell.transform.localEulerAngles2", spell.transform.localEulerAngles);

                if (isMoveable)
                {
                    Log.Warning($"EffectParameters.ApplyAfterPositioning(spell) on moveable effect {effectName}");
                }
                EffectParameters.ApplyAfterPositioning(spell, isMoveable);
            }