Example #1
0
        public bool IsAllowedSpace(IVector gridPosition, FieldCardOwnership playerIndex = FieldCardOwnership.Player1, bool movingDeckLeader = false)
        {
            if (p_ThisCardRenderer == null)
            {
                throw new Exception("Must have a card renderer component attached.");
            }

            IVector[] gridMovementOffsets =
                HasAdvantage() ? DORConstants.p_GridAdvantageMoveOffsets : DORConstants.p_GridMoveOffsets;

            // Check Advantage
            foreach (IVector allowedMove in gridMovementOffsets)
            {
                // Movement is valid
                if (allowedMove == gridPosition.Offset(allowedMove))
                {
                    IDORGridSpot leaderCheckGridSpot = p_ThisGridSpot.p_Parent.GetGridSpot(gridPosition);

                    if (leaderCheckGridSpot == null)
                    {
                        throw new NullReferenceException("Got a null grid spot back");
                    }

                    IFieldDeckLeader deckLeaderComponent = leaderCheckGridSpot.p_ContainedCard.p_GameObject.GetComponent <IFieldDeckLeader>();

                    if (leaderCheckGridSpot.p_TerrainType == TerrainType.Labyrinth)
                    {
                        // Check if we're moving monster card
                        if (p_ThisCardRenderer.p_CardToRender is DORMonsterCard)
                        {
                            return(((DORMonsterCard)p_ThisCardRenderer.p_CardToRender).p_AllowLabyrinthMovement);
                        }

                        return(false);
                    }
                }
            }

            return(false);
        }
Example #2
0
        public void CheckCardEffects(EffectExecutionTime thisExecutionTime, IFieldCard optionalSecondCard = null, IDORGridSpot optionalBattlingTerrain = null, bool checkEndEffects = false)
        {
            if (p_ThisCardRenderer.p_CardToRender is DOREffectMonsterCard)
            {
                DOREffectMonsterCard asEffectMonster = (DOREffectMonsterCard)p_ThisCardRenderer.p_CardToRender;

                //Debug.Log($"Checking {asEffectMonster.Effects.Count} effects for effects that can be triggered during /{thisExecution}/");

                foreach (IDORCardEffect effect in asEffectMonster.p_CardEffects)
                {
                    if (effect == null)
                    {
                        //Debug.LogError("Effect was null in list?");
                        continue;
                    }
                    if (effect.p_When.HasFlag(thisExecutionTime))
                    {
                        bool canExecute = effect.CardEffect_CanPerformEffect(this);

                        if (checkEndEffects || canExecute == false)
                        {
                            effect.CardEffect_EndEffect(this, p_ThisGridSpot.p_Parent, optionalSecondCard, optionalBattlingTerrain);
                        }
                        else
                        {
                            // TODO: Notify for animating the effect
                            effect.CardEffect_Perform(this, p_ThisGridSpot.p_Parent, optionalSecondCard, optionalBattlingTerrain);
                        }
                    }
                }
            }
        }