public void add(InPlay obj) { bool haveAdded = false; if (!AdditionalMath.contains(Area, obj.getRekt()) && parent != null) { parent.add(obj); return; } for (int x = 0; x < 2; x++) { for (int y = 0; y < 2; y++) { RectangleF rect = obj.getRekt(); if (AdditionalMath.contains(innerQuads[x, y], rect)) { haveAdded = true; if (children[x, y] == null && Area.Height * Area.Width * .25 > minimum) { children[x, y] = new QuadNode(this, innerQuads[x, y], minimum, quadLevel + 1); } children[x, y].add(obj); } } } if (!haveAdded) { dict.Add(obj); } }
/// <summary> /// If in hand, allows discarding instead of forgetting. /// </summary> public override void Forget(PowerCard card) { // (Source-1) Purchased / Active if (InPlay.Contains(card)) { foreach (var el in card.Elements) { Elements[el.Key] -= el.Value; // lose elements from forgotten card } InPlay.Remove(card); DiscardPile.Add(card); return; } if (Hand.Contains(card)) { Hand.Remove(card); DiscardPile.Add(card); return; } if (DiscardPile.Contains(card)) { base.Forget(card); return; } throw new System.Exception("Can't find card to forget:" + card.Name); }
// Move a card from Hand to InPlay Pile public Card Play(int idxOfCardFromHand) { Card cardToPlay = Hand[idxOfCardFromHand]; Hand.RemoveAt(idxOfCardFromHand); InPlay.Add(cardToPlay); return(cardToPlay); }
public void PlayCardFromHand(Card card) { if (Hand.Contains(card)) { InPlay.Add(card); Hand.Remove(card); } }
// Move all cards in InPlay to DiscardPile (To be called end of each turn) public void Flush() { while (InPlay.Count > 0) { Card cardToFlush = InPlay[0]; InPlay.RemoveAt(0); DiscardPile.Add(cardToFlush); } return; }
public void AITryToAttack() { foreach (CardInstance c in InPlay.Cards.Where(c => c.Model.Types == CardTypes.Creature)) { if (c.CanAttack) { c.Combating = true; } } InPlay.UpdateLayout(); }
public void collision(InPlay other) { GameObject obj = (GameObject)other; string nome = "player"; if (obj.getName().GetHashCode() == nome.GetHashCode()) { inPlatCounter++; //Console.WriteLine("Collision between " + name + " and " + obj.getName() + " " + inPlatCounter); } RectangleF rect = obj.getRekt(); RectangleF overside = gravityZone(rect.Height, rect.Width); RectangleF under_side = underside(rect.Height, rect.Width); bool inPlat = AdditionalMath.intersects(overside, rect); /*&& platform.Contains(rect)*/; bool underPlat = AdditionalMath.intersects(under_side, rect); if (underPlat) { obj.removeForce("speed up"); RectangleF newRect = new RectangleF(rect.X, under_side.Y - under_side.Height, rect.Width, rect.Height); obj.setRekt(newRect); } if (inPlat) { //Console.WriteLine("Actually in Plat"); obj.InPlat = true; rect = new RectangleF(rect.X, hitbox.Y + rect.Height, rect.Width, rect.Height); obj.setRekt(rect); obj.removeForce("gravity"); Vector v = obj.getVelocity(); double[] comps = v.getComponent(); comps[1] = 0; v.setComponent(comps); if (Universe.keysDown[0] && obj.getName().Equals("player")) { obj.addForce(new Vector(1000, Math.PI / 2, VectorType.FORCE, "jump up")); } //Console.WriteLine(obj.getVelocityMagnitude() + "-speed"); if (Math.Abs(obj.getVelocityMagnitude()) > .3) { //Console.WriteLine(obj.getName() + " friction direction " + (obj.getVelocityDirection() + Math.PI)); obj.addForce(new Vector(kineticFriction * Universe.g * obj.getMass(), obj.getVelocityDirection() + Math.PI, VectorType.FRICTION, "friction with " + name)); } else { obj.removeForce("friction with " + name); } } }
public void collisions() { List <InPlay> allPossibleCollisions = new List <InPlay>(); queueUpInPlays(allPossibleCollisions); for (int x = 0; x < dict.Count; x++) { for (int y = x + 1; y < allPossibleCollisions.Count; y++) { InPlay obj1 = dict.ElementAt(x); InPlay obj2 = allPossibleCollisions.ElementAt(y); if (obj1 is GameObject && obj2 is GameObject) { if (AdditionalMath.intersects(obj1.getRekt(), obj2.getRekt())) { obj1.collision(obj2); } } else { //Console.WriteLine("Comparison between {0} and {1}", obj1.toString(), obj2.toString()); if (obj1 is Platform) { Platform plat = (Platform)(obj1); RectangleF rect = obj2.getRekt(); RectangleF overside = plat.gravityZone(rect.Height, rect.Width); RectangleF underside = plat.gravityZone(rect.Height, rect.Width); if (AdditionalMath.intersects(rect, overside)) { plat.collision(obj2); } } if (obj2 is Platform) { Platform plat = (Platform)(obj2); RectangleF rect = obj1.getRekt(); RectangleF overside = plat.gravityZone(rect.Height, rect.Width); RectangleF underside = plat.gravityZone(rect.Height, rect.Width); if (AdditionalMath.intersects(rect, overside)) { plat.collision(obj1); } } } } } }
public void traverse(ObjectDelegate del, List <QuadNode> queue, bool movementChange) { for (int a = 0; a < dict.Count; a++) { InPlay obj = dict.ElementAt(a); del(obj); if (movementChange && !AdditionalMath.contains(Area, obj.getRekt())) { if (parent != null) { dict.Remove(obj); parent.add(obj); } } for (int x = 0; x < 2; x++) { for (int y = 0; y < 2; y++) { if (movementChange && AdditionalMath.contains(innerQuads[x, y], obj.getRekt())) { if (children[x, y] == null) { children[x, y] = new QuadNode(this, innerQuads[x, y], minimum, quadLevel + 1); } children[x, y].add(obj); dict.Remove(obj); } } } } for (int x = 0; x < 2; x++) { for (int y = 0; y < 2; y++) { if (children[x, y] != null) { queue.Add(children[x, y]); } } } }
/// <summary> /// Returns true if MarketDefinition instances are equal /// </summary> /// <param name="other">Instance of MarketDefinition to be compared</param> /// <returns>Boolean</returns> public bool Equals(MarketDefinition other) { // credit: http://stackoverflow.com/a/10454552/677735 if (other == null) { return(false); } return((Venue == other.Venue || Venue != null && Venue.Equals(other.Venue)) && (SettledTime == other.SettledTime || SettledTime != null && SettledTime.Equals(other.SettledTime)) && (Timezone == other.Timezone || Timezone != null && Timezone.Equals(other.Timezone)) && (EachWayDivisor == other.EachWayDivisor || EachWayDivisor != null && EachWayDivisor.Equals(other.EachWayDivisor)) && (Regulators == other.Regulators || Regulators != null && Regulators.SequenceEqual(other.Regulators)) && (MarketType == other.MarketType || MarketType != null && MarketType.Equals(other.MarketType)) && (MarketBaseRate == other.MarketBaseRate || MarketBaseRate != null && MarketBaseRate.Equals(other.MarketBaseRate)) && (NumberOfWinners == other.NumberOfWinners || NumberOfWinners != null && NumberOfWinners.Equals(other.NumberOfWinners)) && (CountryCode == other.CountryCode || CountryCode != null && CountryCode.Equals(other.CountryCode)) && (InPlay == other.InPlay || InPlay != null && InPlay.Equals(other.InPlay)) && (BetDelay == other.BetDelay || BetDelay != null && BetDelay.Equals(other.BetDelay)) && (BspMarket == other.BspMarket || BspMarket != null && BspMarket.Equals(other.BspMarket)) && (BettingType == other.BettingType || BettingType != null && BettingType.Equals(other.BettingType)) && (NumberOfActiveRunners == other.NumberOfActiveRunners || NumberOfActiveRunners != null && NumberOfActiveRunners.Equals(other.NumberOfActiveRunners)) && (EventId == other.EventId || EventId != null && EventId.Equals(other.EventId)) && (CrossMatching == other.CrossMatching || CrossMatching != null && CrossMatching.Equals(other.CrossMatching)) && (RunnersVoidable == other.RunnersVoidable || RunnersVoidable != null && RunnersVoidable.Equals(other.RunnersVoidable)) && (TurnInPlayEnabled == other.TurnInPlayEnabled || TurnInPlayEnabled != null && TurnInPlayEnabled.Equals(other.TurnInPlayEnabled)) && (SuspendTime == other.SuspendTime || SuspendTime != null && SuspendTime.Equals(other.SuspendTime)) && (DiscountAllowed == other.DiscountAllowed || DiscountAllowed != null && DiscountAllowed.Equals(other.DiscountAllowed)) && (PersistenceEnabled == other.PersistenceEnabled || PersistenceEnabled != null && PersistenceEnabled.Equals(other.PersistenceEnabled)) && (Runners == other.Runners || Runners != null && Runners.SequenceEqual(other.Runners)) && (Version == other.Version || Version != null && Version.Equals(other.Version)) && (EventTypeId == other.EventTypeId || EventTypeId != null && EventTypeId.Equals(other.EventTypeId)) && (Complete == other.Complete || Complete != null && Complete.Equals(other.Complete)) && (OpenDate == other.OpenDate || OpenDate != null && OpenDate.Equals(other.OpenDate)) && (MarketTime == other.MarketTime || MarketTime != null && MarketTime.Equals(other.MarketTime)) && (BspReconciled == other.BspReconciled || BspReconciled != null && BspReconciled.Equals(other.BspReconciled)) && (Status == other.Status || Status != null && Status.Equals(other.Status))); }
public void add(InPlay toAdd) { tree.add(toAdd); }
public void collision(InPlay otherOne) { if (otherOne is GameObject) { GameObject other = (GameObject)otherOne; double[] components = velocity.getComponent(); double[] theirComponents = other.velocity.getComponent(); double momentumX = components[0] * mass + theirComponents[0] * other.mass; double momentumY = components[1] * mass + theirComponents[1] * other.mass; double ourXVelocity, ourYVelocity, theirXVelocity, theirYVelocity; if (other.elastic || elastic) { //kinetic energy when only taking into account velocity in the x direction double xJoules = .5 * Math.Pow(components[0], 2) * mass + .5 * Math.Pow(theirComponents[0], 2) * other.mass; //formula I figured out double a = .5 * (other.mass + other.mass * other.mass / mass); double b = -momentumX * other.mass / mass; double c = .5 * momentumX * momentumX / mass - xJoules; double[] theirPossibleVxs = AdditionalMath.quadraticFormula(a, b, c); if (Math.Round(theirPossibleVxs[0], 5) == Math.Round(theirComponents[0], 5)) { theirXVelocity = theirPossibleVxs[1]; } else { theirXVelocity = theirPossibleVxs[0]; if (Double.IsNaN(theirXVelocity)) { theirXVelocity = 0; } } double yJoules = .5 * Math.Pow(components[1], 2) * mass + .5 * Math.Pow(theirComponents[1], 2) * other.mass; double aa = .5 * (other.mass + other.mass * other.mass / mass); double bb = -momentumY * other.mass / mass; double cc = .5 * momentumY * momentumY / mass - yJoules; //formula I figured out don't question it double[] theirPossibleVys = AdditionalMath.quadraticFormula(aa, bb, cc); if (Math.Round(theirPossibleVys[0], 5) == Math.Round(theirComponents[1], 5)) { theirYVelocity = theirPossibleVys[1]; } else { theirYVelocity = theirPossibleVys[0]; if (Double.IsNaN(theirYVelocity)) { theirYVelocity = 0; } } ourYVelocity = (momentumY - theirYVelocity * other.mass) / mass; ourXVelocity = (momentumX - theirXVelocity * other.mass) / mass; } else { ourXVelocity = theirXVelocity = momentumX / (mass + other.mass); ourYVelocity = theirYVelocity = momentumY / (mass + other.mass); } double velocityMag = Math.Sqrt(Math.Pow(ourXVelocity, 2) + Math.Pow(ourYVelocity, 2)); double otherVelocityMag = Math.Sqrt(Math.Pow(theirXVelocity, 2) + Math.Pow(theirYVelocity, 2)); double otherDirection = Math.Atan2(theirYVelocity, theirXVelocity); double direction = Math.Atan2(ourYVelocity, ourXVelocity); velocity = new Vector(velocityMag, direction, VectorType.VELOCITY, "velocity"); other.velocity = new Vector(otherVelocityMag, otherDirection, VectorType.VELOCITY, "velocity"); if (momentumX > 0) { if (rekt.X < other.rekt.X) { float change = ((rekt.X + rekt.Width) - other.rekt.X) / 2; rekt = new RectangleF(rekt.X - change, rekt.Y, rekt.Width, rekt.Height); other.rekt = new RectangleF(other.rekt.X + change, other.rekt.Y, other.rekt.Width, other.rekt.Height); } if (rekt.X > other.rekt.X) { float change = ((other.rekt.X + other.rekt.Width) - rekt.X) / 2; other.rekt = new RectangleF(other.rekt.X - change, other.rekt.Y, other.rekt.Width, other.rekt.Height); rekt = new RectangleF(rekt.X + change, rekt.Y, rekt.Width, rekt.Height); } } if (momentumY > 0) { if (rekt.Y < other.rekt.Y) { float change = (rekt.Y - (other.rekt.Y - other.rekt.Height)) / 2; other.rekt = new RectangleF(other.rekt.X, other.rekt.Y + change, other.rekt.Width, other.rekt.Height); rekt = new RectangleF(rekt.X + change, rekt.Y - change, rekt.Width, rekt.Height); } if (rekt.Y > other.rekt.Y) { float change = (other.rekt.Y - (rekt.Y - rekt.Height)) / 2; other.rekt = new RectangleF(other.rekt.X, other.rekt.Y - change, other.rekt.Width, other.rekt.Height); rekt = new RectangleF(rekt.X + change, rekt.Y + change, rekt.Width, rekt.Height); } } } }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { // credit: http://stackoverflow.com/a/263416/677735 unchecked // Overflow is fine, just wrap { var hash = 41; // Suitable nullity checks etc, of course :) if (Venue != null) { hash = hash * 59 + Venue.GetHashCode(); } if (SettledTime != null) { hash = hash * 59 + SettledTime.GetHashCode(); } if (Timezone != null) { hash = hash * 59 + Timezone.GetHashCode(); } if (EachWayDivisor != null) { hash = hash * 59 + EachWayDivisor.GetHashCode(); } if (Regulators != null) { hash = hash * 59 + Regulators.GetHashCode(); } if (MarketType != null) { hash = hash * 59 + MarketType.GetHashCode(); } if (MarketBaseRate != null) { hash = hash * 59 + MarketBaseRate.GetHashCode(); } if (NumberOfWinners != null) { hash = hash * 59 + NumberOfWinners.GetHashCode(); } if (CountryCode != null) { hash = hash * 59 + CountryCode.GetHashCode(); } if (InPlay != null) { hash = hash * 59 + InPlay.GetHashCode(); } if (BetDelay != null) { hash = hash * 59 + BetDelay.GetHashCode(); } if (BspMarket != null) { hash = hash * 59 + BspMarket.GetHashCode(); } if (BettingType != null) { hash = hash * 59 + BettingType.GetHashCode(); } if (NumberOfActiveRunners != null) { hash = hash * 59 + NumberOfActiveRunners.GetHashCode(); } if (EventId != null) { hash = hash * 59 + EventId.GetHashCode(); } if (CrossMatching != null) { hash = hash * 59 + CrossMatching.GetHashCode(); } if (RunnersVoidable != null) { hash = hash * 59 + RunnersVoidable.GetHashCode(); } if (TurnInPlayEnabled != null) { hash = hash * 59 + TurnInPlayEnabled.GetHashCode(); } if (SuspendTime != null) { hash = hash * 59 + SuspendTime.GetHashCode(); } if (DiscountAllowed != null) { hash = hash * 59 + DiscountAllowed.GetHashCode(); } if (PersistenceEnabled != null) { hash = hash * 59 + PersistenceEnabled.GetHashCode(); } if (Runners != null) { hash = hash * 59 + Runners.GetHashCode(); } if (Version != null) { hash = hash * 59 + Version.GetHashCode(); } if (EventTypeId != null) { hash = hash * 59 + EventTypeId.GetHashCode(); } if (Complete != null) { hash = hash * 59 + Complete.GetHashCode(); } if (OpenDate != null) { hash = hash * 59 + OpenDate.GetHashCode(); } if (MarketTime != null) { hash = hash * 59 + MarketTime.GetHashCode(); } if (BspReconciled != null) { hash = hash * 59 + BspReconciled.GetHashCode(); } if (Status != null) { hash = hash * 59 + Status.GetHashCode(); } return(hash); } }
public override async Task <PowerCard> ForgetPowerCard_UserChoice(IEnumerable <PowerCard> options2, Present present = Present.Always) { IEnumerable <SingleCardUse> options = SingleCardUse.GenerateUses(CardUse.Discard, InPlay.Union(Hand)) .Union(SingleCardUse.GenerateUses(CardUse.Forget, DiscardPile)) .Where(u => options2.Contains(u.Card)); var decision = new Select.PowerCard("Select card to forget or discard", options, present); PowerCard cardToForgetOrDiscard = await this.Action.Decision(decision); if (cardToForgetOrDiscard != null) { Forget(cardToForgetOrDiscard); } return(cardToForgetOrDiscard != null && !DiscardPile.Contains(cardToForgetOrDiscard) ? cardToForgetOrDiscard // card not in discard pile, must have been forgotten : null); }
public void quadMovement(InPlay obj) { obj.determineMovement(fps, g); }
private void DiscardCardsInPlay() { DiscardPile.AddRange(InPlay); InPlay.Clear(); }
public void add(InPlay obj) { rootNode.add(obj); }
public static bool IsInPlay(this OrderStatus orderStatus) { return(InPlay.Contains(orderStatus)); }