Esempio n. 1
0
 public bool PlayCard(PlayerManager pm, PlayZone pz)
 {
     Debug.Log(DebugName + " Card is being played.");
     _cardTimer = -Time.deltaTime;
     Execute(pm, pz);
     return(true);
 }
Esempio n. 2
0
 private void Awake()
 {
     cardManager = FindObjectOfType <CardManager>();
     displayArea = FindObjectOfType <UIManager>().futureSightDisplay;
     playZone    = FindObjectOfType <PlayZone>();
     hand        = FindObjectOfType <Hand>();
     summoner    = FindObjectOfType <Summoner>();
 }
Esempio n. 3
0
 public void Execute(PlayerManager pm, PlayZone pz)
 {
     _cardTimer += Time.deltaTime;
     Debug.Log(DebugName + " Executing Card.");
     if (Card.Execute(_cardTimer, pm))
     {
         Debug.Log(DebugName + " Discarding Executed card.");
         pz.Discard(this);
     }
 }
Esempio n. 4
0
    void DropIntoZone()
    {
        Ray        ScreenRay = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit raycastOut;

        if (_currentlyDragging && Physics.Raycast(ScreenRay, out raycastOut, Mathf.Infinity, CardSlotMask))
        {
            PlayZone dz = raycastOut.collider.gameObject.GetComponent <PlayZone>();
            if (dz && !dz.Locked)
            {
                dz.AddDraggable(_currentlyDragging);
            }
        }
    }
Esempio n. 5
0
        public static TransitionResult TransitionAllowed(PlayZone from, PlayZone previous, PlayZone to, bool isInitialDraw, bool isLocalPlayer)
        {
            // Only allow additions to deck from stage during initial draw
            if (to == PlayZone.Deck)
            {
                if (isInitialDraw && from == PlayZone.Stage)
                {
                    return(TransitionResult.Proceed);
                }
                else if (from == PlayZone.Tossing && (previous == PlayZone.Windup || previous == PlayZone.Battle || previous == PlayZone.Hand))
                {
                    // This addresses cards that shuffle themselves back to deck
                    return(TransitionResult.Proceed);
                }
                return(TransitionResult.Disallow);
            }
            if (to == PlayZone.Stage && !isInitialDraw && isLocalPlayer)
            {
                return(TransitionResult.Stay);
            }

            switch (from)
            {
            case PlayZone.Deck:
                if (isInitialDraw)
                {
                    return((to == PlayZone.Hand || to == PlayZone.Stage) ? TransitionResult.Proceed : TransitionResult.Disallow);
                }
                else
                {
                    return((to == PlayZone.Zoom || to == PlayZone.Tossing) ? TransitionResult.Proceed : TransitionResult.Disallow);
                }

            case PlayZone.Tossing:
                switch (to)
                {
                case PlayZone.Stage:        // This is due to a bug
                case PlayZone.Hand:         // This is due to a bug
                case PlayZone.Field:        // This is due to a bug
                case PlayZone.Zoom:         // This is due to a bug
                    return(TransitionResult.Proceed);

                default:
                    return(TransitionResult.Disallow);
                }

            case PlayZone.Zoom:
                return((to == PlayZone.Hand) ? TransitionResult.Proceed : TransitionResult.Disallow);

            case PlayZone.Stage:
                if (isInitialDraw)
                {
                    // We only ever return to deck from initial draw
                    switch (to)
                    {
                    case PlayZone.Deck:
                    case PlayZone.Hand: return(TransitionResult.Proceed);

                    default: return(TransitionResult.Disallow);
                    }
                }
                else
                {
                    switch (to)
                    {
                    case PlayZone.Field: return(TransitionResult.Proceed);

                    case PlayZone.Hand: return(TransitionResult.Proceed);

                    default: return(TransitionResult.Disallow);
                    }
                }

            case PlayZone.Hand:
                switch (to)
                {
                case PlayZone.Field: return(TransitionResult.Proceed);

                case PlayZone.Cast: return(TransitionResult.Proceed);

                case PlayZone.Stage: return(TransitionResult.Proceed);

                case PlayZone.Attack: return(TransitionResult.Proceed);

                default: return(TransitionResult.Stay);
                }

            case PlayZone.Cast:
                return((to == PlayZone.Hand) ? TransitionResult.Proceed : TransitionResult.Disallow);

            case PlayZone.Field:
                switch (to)
                {
                case PlayZone.Hand: return(TransitionResult.Proceed);        // For recall mechanics

                case PlayZone.Battle: return(TransitionResult.Proceed);

                case PlayZone.Attack: return(TransitionResult.Stay);

                case PlayZone.Windup: return(TransitionResult.Stay);

                case PlayZone.Tossing: return(TransitionResult.Proceed);        // For spell summoning, likely a bug

                default: return(TransitionResult.Disallow);
                }

            case PlayZone.Battle:
                switch (to)
                {
                case PlayZone.Hand: return(TransitionResult.Proceed);        // For recall mechanics

                case PlayZone.Field: return(TransitionResult.Proceed);

                case PlayZone.Windup: return(TransitionResult.Proceed);

                case PlayZone.Attack: return(TransitionResult.Stay);

                default: return(TransitionResult.Disallow);
                }

            case PlayZone.Windup:
                switch (to)
                {
                case PlayZone.Field: return(TransitionResult.Proceed);

                case PlayZone.Battle: return(TransitionResult.Stay);

                case PlayZone.Attack: return(TransitionResult.Proceed);

                //case PlayZone.Zoom: return TransitionResult.Proceed;
                default: return(TransitionResult.Disallow);
                }

            case PlayZone.Attack:
                switch (to)
                {
                case PlayZone.Field: return(TransitionResult.Proceed);

                case PlayZone.Battle: return(TransitionResult.Stay);

                case PlayZone.Windup: return(TransitionResult.Proceed);

                case PlayZone.Hand: return(TransitionResult.Proceed);        // Katarina-style recall mechanics

                //case PlayZone.Zoom: return TransitionResult.Proceed;
                default: return(TransitionResult.Disallow);
                }

            case PlayZone.Graveyard:
                return(TransitionResult.Disallow);

            case PlayZone.Unknown:
                // We only allow cetain zones to accept cards from unknown
                switch (to)
                {
                case PlayZone.Field:
                case PlayZone.Battle:
                case PlayZone.Stage:
                case PlayZone.Cast:
                case PlayZone.Tossing:
                case PlayZone.Hand:
                    return(TransitionResult.Proceed);

                default: return(TransitionResult.Disallow);
                }

            case PlayZone.Ether:
                return(TransitionResult.Disallow);
            }
            return(TransitionResult.Disallow);
        }
Esempio n. 6
0
    private void XmlParserConfig(XElement tempElement, int waveNum)
    {
        if (Initialize)
        {
            foreach (XElement Cfg in tempElement.Elements("GameConfig"))
            {
                PlayZone.N = int.Parse(Cfg.Attribute("MapSizeN").Value);
                PlayZone.M = int.Parse(Cfg.Attribute("MapSizeM").Value);
                PlayZone.Instance().InitializeGameZone();
            }
            Initialize = false;
        }
        if (waveNum == 0)
        {
            foreach (XElement Cfg in tempElement.Elements("PlayerConfigForWave" + waveNum))
            {
                float  SizeX         = float.Parse(Cfg.Attribute("SizeX").Value);
                float  SizeY         = float.Parse(Cfg.Attribute("SizeY").Value);
                float  Speed         = float.Parse(Cfg.Attribute("Speed").Value);
                string MathExample   = Cfg.Attribute("Example").Value;
                int    ExampleAnswer = int.Parse(Cfg.Attribute("ExampleAnswer").Value);
                //string Example = Cfg.Attribute("Example").Value;

                URLPlayerConfig.SizeX            = SizeX;
                URLPlayerConfig.SizeY            = SizeY;
                URLPlayerConfig.Speed            = Speed;
                URLPlayerConfig.MathExample.text = MathExample;
                URLPlayerConfig.NeedNum          = ExampleAnswer;
                URLPlayerConfig.reSizePlayer();
            }
        }
        else
        {
            foreach (XElement Cfg in tempElement.Elements("PlayerConfigForWave" + waveNum))
            {
                float  Speed         = float.Parse(Cfg.Attribute("Speed").Value);
                string MathExample   = Cfg.Attribute("Example").Value;
                int    ExampleAnswer = int.Parse(Cfg.Attribute("ExampleAnswer").Value);
                //string Example = Cfg.Attribute("Example").Value;


                URLPlayerConfig.Speed            = Speed;
                URLPlayerConfig.MathExample.text = MathExample;
                URLPlayerConfig.NeedNum          = ExampleAnswer;

                print(MathExample);
            }
        }

        foreach (XElement Cfg in tempElement.Elements("BlockConfigForWave" + waveNum))
        {
            int   MaxFigure = int.Parse(Cfg.Attribute("MaxEnemy").Value);
            float SizeX     = float.Parse(Cfg.Attribute("SizeX").Value);
            float SizeY     = float.Parse(Cfg.Attribute("SizeY").Value);
            float Speed     = float.Parse(Cfg.Attribute("Speed").Value);
            int   Example   = int.Parse(Cfg.Attribute("ExampleAnswer").Value);

            URLFigureConfig.SizeX = SizeX;
            URLFigureConfig.SizeY = SizeY;
            URLFigureConfig.Speed = Speed;
            StartCoroutine(CreateNewFigure(MaxFigure, SizeX, SizeY, Speed, Example));
        }
    }
Esempio n. 7
0
 public static void DisposePlayZoneListener(this IPlayZoneListener Listener)
 {
     PlayZone.DisposePlayZoneListener(Listener);
 }
Esempio n. 8
0
 public static void RegisterPlayZoneListener(this IPlayZoneListener Listener)
 {
     PlayZone.RegisterPlayzoneListener(Listener);
 }
Esempio n. 9
0
 protected void InitializeBoard()
 {
     playBoard = new PlayZone();
 }
Esempio n. 10
0
        public static CardList <CardInPlay> ConvertDeck(List <CardWithCount> deck, PlayerType owner = PlayerType.LocalPlayer, PlayZone zone = PlayZone.Deck)
        {
            CardList <CardInPlay> result = new CardList <CardInPlay>();

            foreach (var c in deck)
            {
                for (int j = 0; j < c.Count; j++)
                {
                    result.Add(c.Cost, c.Name, new CardInPlay(owner, c.TheCard, zone, c.IsFromDeck));
                }
            }
            return(result);
        }
Esempio n. 11
0
        void MoveToNext(ref CardList <CardInPlay>[] current, CardList <CardInPlay> next, double timestamp, bool isInitialDraw, bool isLocalPlayer)
        {
            CardList <CardInPlay> stationaryResult = new CardList <CardInPlay>();
            CardList <CardInPlay> movedResult      = new CardList <CardInPlay>();

            // For each card in 'next', look for a card in 'current' that's in the same zone
            // If found, remove from both and add to stationaryCards set
            for (int i = 0; i < NumZones; i++)
            {
                stationaryResult.AddRange(CardList <CardInPlay> .Extract(ref next, ref current[i], (x, y) =>
                {
                    // Skip values in next that are incorrect zone
                    if ((int)x.CurrentZone != i)
                    {
                        return(-1);
                    }
                    int z = x.TheCard.Cost - y.TheCard.Cost;
                    if (z == 0)
                    {
                        z = x.TheCard.Name.CompareTo(y.TheCard.Name);
                    }
                    return(z);
                }, (x, y) =>
                {
                    y.BoundingBox           = x.BoundingBox;
                    y.NormalizedBoundingBox = x.NormalizedBoundingBox;
                    y.NormalizedCenter      = x.NormalizedCenter;
                    return(y);
                }));
            }

            // For each card in next, look for a card in 'current' Ether zone that may have returned to the same zone
            movedResult.AddRange(CardList <CardInPlay> .Extract(ref next, ref current[(int)PlayZone.Ether], (x, y) =>
            {
                // Skip values in next that are incorrect zone
                if (y.CurrentZone != PlayZone.Ether)
                {
                    return(-1);
                }
                int z = x.TheCard.Cost - y.TheCard.Cost;
                if (z == 0)
                {
                    z = x.TheCard.Name.CompareTo(y.TheCard.Name);
                }
                // Skip values in current that are incorrect zone
                if (z == 0 && x.CurrentZone != y.LastNonEtherZone)
                {
                    z = 1;
                }
                return(z);
            }, (x, y) =>
            {
                y.BoundingBox           = x.BoundingBox;
                y.NormalizedBoundingBox = x.NormalizedBoundingBox;
                y.NormalizedCenter      = x.NormalizedCenter;
                y.MoveToZone(x.CurrentZone, timestamp);
                return(y);
            }));

            // For each card in next, look for a card in 'current' Ether zone that may has an approved transition
            movedResult.AddRange(CardList <CardInPlay> .Extract(ref next, ref current[(int)PlayZone.Ether], (x, y) =>
            {
                // Skip values in next that are incorrect zone
                if (y.CurrentZone != PlayZone.Ether)
                {
                    return(-1);
                }
                int z = x.TheCard.Cost - y.TheCard.Cost;
                if (z == 0)
                {
                    z = x.TheCard.Name.CompareTo(y.TheCard.Name);
                }
                // Skip values in current that are incorrect zone
                if (z == 0 && GameBoard.TransitionResult.Proceed != GameBoard.TransitionAllowed(y.LastNonEtherZone, PlayZone.Unknown, x.CurrentZone, isInitialDraw, isLocalPlayer))
                {
                    z = -1;
                }
                return(z);
            }, (x, y) =>
            {
                x.LastNonEtherZone = y.LastNonEtherZone;
                x.LastZone         = PlayZone.Ether;
                x.IsFromDeck       = y.IsFromDeck;
                x.ChampionCode     = y.ChampionCode;
                return(x);
            }));

            // For each card in next, look for approved transitions, skipping current in deck
            for (int i = 0; i < NumZones; i++)
            {
                if (i == (int)PlayZone.Deck)
                {
                    continue;
                }

                movedResult.AddRange(CardList <CardInPlay> .Extract(ref next, ref current[i], (x, y) =>
                {
                    // Skip values in next that are incorrect zone
                    int z = x.TheCard.Cost - y.TheCard.Cost;
                    if (z == 0)
                    {
                        z = x.TheCard.Name.CompareTo(y.TheCard.Name);
                    }
                    if (z == 0 && GameBoard.TransitionResult.Proceed != GameBoard.TransitionAllowed(y.CurrentZone, y.LastNonEtherZone, x.CurrentZone, isInitialDraw, isLocalPlayer))
                    {
                        z = -1;
                    }
                    return(z);
                }, (x, y) =>
                {
                    x.SetLastZone(y.CurrentZone);
                    x.IsFromDeck   = y.IsFromDeck;
                    x.ChampionCode = y.ChampionCode;
                    return(x);
                }));
            }

            // For each card in next, look for declined transitions
            for (int i = 0; i < NumZones; i++)
            {
                stationaryResult.AddRange(CardList <CardInPlay> .Extract(ref next, ref current[i], (x, y) =>
                {
                    // Skip values in next that are incorrect zone
                    int z = x.TheCard.Cost - y.TheCard.Cost;
                    if (z == 0)
                    {
                        z = x.TheCard.Name.CompareTo(y.TheCard.Name);
                    }
                    if (z == 0 && GameBoard.TransitionResult.Stay != GameBoard.TransitionAllowed(y.CurrentZone, y.LastNonEtherZone, x.CurrentZone, isInitialDraw, isLocalPlayer))
                    {
                        z = -1;
                    }
                    return(z);
                }, (x, y) =>
                {
                    y.BoundingBox           = x.BoundingBox;
                    y.NormalizedBoundingBox = x.NormalizedBoundingBox;
                    y.NormalizedCenter      = x.NormalizedCenter;
                    return(y);
                }));
            }

            // For each card in 'hand', look for champion transformations
            stationaryResult.AddRange(CardList <CardInPlay> .Extract(ref next, ref current[(int)PlayZone.Hand], (x, y) =>
            {
                // Skip values in next that are incorrect zone
                if ((int)x.CurrentZone != (int)PlayZone.Hand)
                {
                    return(-1);
                }
                if (y.ChampionCode.Length == 0)
                {
                    return(-1);
                }
                if (y.TheCard.SuperType == "Champion")
                {
                    var spellCode = y.TheCard.AssociatedCardCodes.Last();
                    var spellCard = CardLibrary.GetCard(spellCode);
                    if (spellCard.FlavorText == x.TheCard.FlavorText)
                    {
                        return(0);
                    }
                }
                else if (x.TheCard.SuperType == "Champion")
                {
                    if (x.CardCode == y.ChampionCode)
                    {
                        return(0);
                    }
                }
                return(-1);
            }, (x, y) =>
            {
                x.LastZone     = y.CurrentZone;
                x.IsFromDeck   = y.IsFromDeck;
                x.ChampionCode = y.ChampionCode;
                return(x);
            }));


            // For each card in next, look for approved transitions from deck
            movedResult.AddRange(CardList <CardInPlay> .Extract(ref next, ref current[(int)PlayZone.Deck], (x, y) =>
            {
                // Skip values in next that are incorrect zone
                int z = x.TheCard.Cost - y.TheCard.Cost;
                if (z == 0)
                {
                    z = x.TheCard.Name.CompareTo(y.TheCard.Name);
                }
                if (z == 0 && GameBoard.TransitionResult.Proceed != GameBoard.TransitionAllowed(y.CurrentZone, y.LastNonEtherZone, x.CurrentZone, isInitialDraw, isLocalPlayer))
                {
                    z = -1;
                }
                return(z);
            }, (x, y) =>
            {
                x.SetLastZone(y.CurrentZone);
                x.IsFromDeck   = y.IsFromDeck;
                x.ChampionCode = y.ChampionCode;
                return(x);
            }));

            // Move not in deck to ether
            for (int i = 0; i < NumZones; i++)
            {
                PlayZone newZone = PlayZone.Ether;
                if (i == (int)PlayZone.Deck || i == (int)PlayZone.Graveyard || i == (int)PlayZone.Ether)
                {
                    continue;
                }
                if (i == (int)PlayZone.Stage && isInitialDraw)
                {
                    newZone = PlayZone.Deck;
                }

                for (int j = 0; j < current[i].Count; j++)
                {
                    current[i][j].MoveToZone(newZone, timestamp);
                }
                movedResult.AddRange(current[i]);
                current[i].Clear();
            }

            // Remove cards in next that are in a zone that does not accept from Unknown
            next = next.GetSubset(x => GameBoard.TransitionResult.Proceed == GameBoard.TransitionAllowed(x.LastNonEtherZone, PlayZone.Unknown, x.CurrentZone, isInitialDraw, isLocalPlayer));

            // Add remaining cards to the moved set
            movedResult.AddRange(next);

            // Log all moves
            foreach (var card in movedResult)
            {
                LogMove(card, card.CurrentZone != PlayZone.Ether);
            }

            // Re-add all the cars to the zones
            for (int i = 0; i < NumZones; i++)
            {
                current[i].AddRange(stationaryResult.GetSubset(x => (int)x.CurrentZone == i));
                current[i].AddRange(movedResult.GetSubset(x => (int)x.CurrentZone == i));
            }
        }