コード例 #1
0
        public ConvergeObject(ConvergeCardSpec original, ConvergeZone zone)
        {
            this.original  = original;
            this.art       = original.art;
            this.power     = original.power;
            this.toughness = original.toughness;
            this.keywords  = original.keywords;
            GenerateKeywordsText();
            this.owner      = zone.owner;
            this.controller = owner;
            this.originalActivatedAbilities = new List <ConvergeActivatedAbility>();
            foreach (ConvergeActivatedAbilitySpec spec in original.activatedAbilities)
            {
                originalActivatedAbilities.Add(new ConvergeActivatedAbility(spec, this));
            }
            activatedAbilities = originalActivatedAbilities;

            this.originalTriggeredAbilities = new List <ConvergeTriggeredAbility>();
            foreach (ConvergeTriggeredAbilitySpec spec in original.triggeredAbilities)
            {
                originalTriggeredAbilities.Add(new ConvergeTriggeredAbility(spec, this));
            }
            this.triggeredAbilities = originalTriggeredAbilities;
            MoveZone(zone);
        }
コード例 #2
0
        public void Add(ConvergeObject newObj)
        {
            ConvergeZone oldZone = newObj.zone;

            if (oldZone != null)
            {
                oldZone.Remove(newObj);
            }

            newObj.slot = contents.Count;
            newObj.zone = this;
            contents.Add(newObj);
            newlyAdded.Add(newObj);

            RenumberAll();

            if (!inPlay && oldZone != null && oldZone.inPlay)
            {
                newObj.OnLeavingPlay();
            }
            else if (inPlay && (oldZone == null || !oldZone.inPlay))
            {
                newObj.OnEnteringPlay();
            }
        }
コード例 #3
0
        public ConvergePlayer(JSONTable template, ContentManager Content)
        {
            this.home         = new ConvergeZone(template.getJSON("home"), this, ConvergeZoneId.Home);
            this.resourceZone = new ConvergeZone(template.getJSON("resources"), this, ConvergeZoneId.Resources);
            this.attack       = new ConvergeZone(template.getJSON("attack"), this, ConvergeZoneId.Attack);
            this.defense      = new ConvergeZone(template.getJSON("defense"), this, ConvergeZoneId.Defense);
            this.hand         = new ConvergeZone(template.getJSON("hand"), this, ConvergeZoneId.Hand);
            this.homeBase     = new ConvergeObject(new ConvergeCardSpec(template.getJSON("homebase"), Content), home);
            this.discardPile  = new ConvergeZone(template.getJSON("discardPile"), this, ConvergeZoneId.DiscardPile);
            this.laboratory   = new ConvergeZone(template.getJSON("laboratory"), this, ConvergeZoneId.Laboratory);

            zones = new Dictionary <ConvergeZoneId, ConvergeZone>()
            {
                { ConvergeZoneId.Home, home },
                { ConvergeZoneId.Resources, resourceZone },
                { ConvergeZoneId.Attack, attack },
                { ConvergeZoneId.Defense, defense },
                { ConvergeZoneId.Hand, hand },
                { ConvergeZoneId.DiscardPile, discardPile },
                { ConvergeZoneId.Laboratory, laboratory },
            };

            this.life     = template.getInt("startingLife");
            this.faceLeft = template.getBool("faceLeft", false);
        }
コード例 #4
0
 public override void Run(ConvergeEffectContext context)
 {
     foreach (ConvergeObject player in players.GetList(context))
     {
         ConvergeZone   spawnZone  = player.controller.GetZone(zoneId);
         ConvergeObject newSpawned = new ConvergeObject(cardSpec, spawnZone);
         if (spawnZone.inPlay && newSpawned.cardType.HasFlag(ConvergeCardType.Unit))
         {
             newSpawned.tapped = true;
         }
     }
 }
コード例 #5
0
        void UpdateZoneChanges()
        {
            bool didAnything = zoneChanges.Count > 0;

            for (int Idx = 0; Idx < zoneChanges.Count; ++Idx)
            {
                KeyValuePair <ConvergeObject, ConvergeZone> kv = zoneChanges[Idx];
                ConvergeObject obj     = kv.Key;
                ConvergeZone   newZone = kv.Value;
                ConvergeZone   oldZone = obj.zone;

                if (newZone.zoneId == ConvergeZoneId.DiscardPile && TriggerSystem.HasTriggers(ConvergeTriggerType.Discarded))
                {
                    TriggerSystem.CheckTriggers(ConvergeTriggerType.Discarded, new TriggerData(newZone.owner, null, obj, 0));
                }

                newZone.Add(obj);

                if (newZone.inPlay && (oldZone == null || !oldZone.inPlay) && TriggerSystem.HasTriggers(ConvergeTriggerType.EnterPlay))
                {
                    TriggerSystem.CheckTriggers(ConvergeTriggerType.EnterPlay, new TriggerData(newZone.owner, obj, null, 0));
                }

                if (obj.ui == null && !newZone.isHidden && obj.zone == newZone)
                {
                    obj.ui = new ConvergeUIObject(obj);
                    ui.Add(obj.ui);
                }
                else if (obj.ui != null && newZone.isHidden && obj.zone == newZone)
                {
                    ui.Remove(obj.ui);
                    obj.ui = null;
                }
            }
            zoneChanges.Clear();
        }
コード例 #6
0
 public void MoveZone(ConvergeZone newZone)
 {
     Game1.zoneChanges.Add(new KeyValuePair <ConvergeObject, ConvergeZone>(this, newZone));
 }
コード例 #7
0
        public override void Update(InputState inputState, Vector2 origin)
        {
            if (abilityUIs.Count != represented.activatedAbilities.Count)
            {
                UpdateAbilityUIs();
            }

            isBadDrag = false;
            isVisible = represented.zone.zoneId == ConvergeZoneId.Hand ? (represented.zone.owner.isActivePlayer) : true;

            if (!isVisible)
            {
                return;
            }

            isMouseOver = (inputState.hoveringElement == this);
            if (isMouseOver && inputState.mouseLeft.justPressed && represented.controller.isActivePlayer)
            {
                isMousePressing = true;
                mousePressedPos = inputState.MousePos;
            }

            if (isMousePressing && isMouseOver && inputState.mouseLeft.justReleased)
            {
                represented.Play(Game1.activePlayer); // clicked
            }
            if (!inputState.mouseLeft.isDown)
            {
                isMousePressing = false;
            }

            float MINDRAG    = 5;
            float MINDRAGSQR = MINDRAG * MINDRAG;

            if (isDragging)
            {
                Game1.ticking = false;
                if (isMousePressing)
                {
                    this.gfxFrame = new Rectangle((int)inputState.MousePos.X - 25, (int)inputState.MousePos.Y - 30, 50, 60);

                    if (inputState.hoveringElement != null && inputState.hoveringElement is ConvergeUIObject)
                    {
                        isBadDrag = !represented.CanTarget(((ConvergeUIObject)inputState.hoveringElement).represented, represented.controller);
                    }
                }
                else
                {
                    //dragged onto = inputState.hoveringElement
                    if (inputState.hoveringElement != null)
                    {
                        if (inputState.hoveringElement is ConvergeUIObject)
                        {
                            represented.UseOn(((ConvergeUIObject)inputState.hoveringElement).represented);
                        }
                    }
                    else
                    {
                        ConvergeZone currentZone = represented.zone;
                        ConvergeZone attackZone  = represented.controller.attack;
                        ConvergeZone defenseZone = represented.controller.defense;
                        if (currentZone.zoneId == ConvergeZoneId.Defense && attackZone.bounds.Contains(inputState.MousePos))
                        {
                            represented.EnterAttack();
                        }
                        else if (currentZone.zoneId == ConvergeZoneId.Attack && defenseZone.bounds.Contains(inputState.MousePos))
                        {
                            represented.WithdrawAttack();
                        }
                        else if (currentZone.zoneId == ConvergeZoneId.Hand && defenseZone.bounds.Contains(inputState.MousePos))
                        {
                            represented.Play(represented.controller);
                        }
                    }

                    isDragging = false;
                }
            }
            else
            {
                if (isMousePressing && (inputState.MousePos - mousePressedPos).LengthSquared() > MINDRAGSQR)
                {
                    isDragging = true;
                }

                const float MOVESPEED  = 15.0f;
                Vector2     targetPos  = represented.nominalPosition;
                Vector2     moveOffset = targetPos - this.gfxFrame.XY();
                if (moveOffset.LengthSquared() < MOVESPEED * MOVESPEED)
                {
                    this.gfxFrame = new Rectangle(targetPos.ToPoint(), new Point(50, 60));
                }
                else
                {
                    moveOffset.Normalize();
                    this.gfxFrame = new Rectangle((this.gfxFrame.XY() + moveOffset * MOVESPEED).ToPoint(), new Point(50, 60));
                }
            }

            Vector2 offset = new Vector2(this.gfxFrame.Width / 2, 12);

            foreach (ConvergeUIAbility abilityUI in abilityUIs)
            {
                if (abilityUI.isActive)
                {
                    abilityUI.offset = offset;
                    abilityUI.Update(inputState);
                    offset.X += 32.0f;
                }
            }
        }