public void DisplayToolTip(CJStarDomain domain, Player player, Player opponent) { this.SpriteColor = new Color(0, 0, 0, 0); this.PlayAnimation(0); this.IsActive = true; if (domain.PlayerToPoints.TryGetValue(player, out int pointsPlayer)) { this.textParagraph2Ds[1].UpdateParameterText(0, pointsPlayer.ToString()); } else { this.textParagraph2Ds[1].UpdateParameterText(0, "0"); } if (domain.PlayerToPoints.TryGetValue(opponent, out int pointsOpponent)) { this.textParagraph2Ds[1].UpdateParameterText(1, pointsOpponent.ToString()); } else { this.textParagraph2Ds[1].UpdateParameterText(1, "0"); } this.textParagraph2Ds[1].UpdateParameterColor(0, player.PlayerColor); this.textParagraph2Ds[1].UpdateParameterColor(1, opponent.PlayerColor); this.LaunchTextOfParagraphScrolling(0, 100); this.LaunchTextOfParagraphScrolling(1, 100); }
public AICJStarDomain(AAILayer parentLayer, IAIObjectFactory factory, AEntity entity) : base(parentLayer, factory, entity) { CJStarDomain starDomain = entity as CJStarDomain; this.StarEntities = new HashSet <AIStarEntity>(); this.DomainOwnerName = starDomain.DomainOwner != null ? starDomain.DomainOwner.PlayerName : null; }
public void OnMouseFocused(ALayer2D parentLayer, ControlEventType eventType) { CJStarDomain domainEntity = parentLayer.GetEntityFromEntity2D(this) as CJStarDomain; if (domainEntity != null) { parentLayer.SendEventToWorld(Model.Event.EventType.FOCUS_DOMAIN_BOARD, domainEntity, null); } }
public override IObject2D CreateObject2D(World2D world2D, ALayer2D layer2D, IObject obj) { if (obj is CJStarDomain) { CJStarDomain entity = obj as CJStarDomain; return(new CJStarDomain2D(layer2D, this, entity)); } return(null); }
public override IAIObject CreateObjectAI(AIWorld worldAI, AAILayer layerAI, IObject obj) { if (obj is CJStarDomain) { CJStarDomain entity = obj as CJStarDomain; return(new AICJStarDomain(layerAI, this, entity)); } return(null); }
private void OnDomainFocused(CJStarDomain obj) { if (obj != null) { this.DomainFocused = this.objectToObject2Ds[obj] as CJStarDomain2D; } else { this.DomainFocused = null; } }
public void UpdateReference() { if (this.parentLayer.TryGetTarget(out AAILayer parentLayer)) { CJStarDomain starDomain = parentLayer.GetEntityFromAIEntity(this) as CJStarDomain; this.StarEntities.Clear(); foreach (StarEntity starEntity in starDomain.Domain) { this.StarEntities.Add(parentLayer.GetAIEntityFromEntity(starEntity) as AIStarEntity); } } }
protected virtual void UpdateScaling(CJStarDomain entity) { Vector2f topLeft = new Vector2f(0, 0); Vector2f bottomRight = new Vector2f(0, 0); bool firstPoint = true; foreach (StarEntity starEntity in entity.Domain) { if (firstPoint || topLeft.X > starEntity.Position.X) { topLeft.X = starEntity.Position.X; } if (firstPoint || topLeft.Y > starEntity.Position.Y) { topLeft.Y = starEntity.Position.Y; } if (firstPoint || bottomRight.X < starEntity.Position.X) { bottomRight.X = starEntity.Position.X; } if (firstPoint || bottomRight.Y < starEntity.Position.Y) { bottomRight.Y = starEntity.Position.Y; } firstPoint = false; } float width = bottomRight.X - topLeft.X + MARGIN_DOMAIN * 3; float height = bottomRight.Y - topLeft.Y + MARGIN_DOMAIN * 3; //topLeft -= new Vector2f(MARGIN_DOMAIN, MARGIN_DOMAIN); this.ObjectSprite.TextureRect = new IntRect(0, 0, (int)width, (int)height); this.ObjectSprite.Origin = new Vector2f(width / 2, height / 2); this.ObjectSprite.Position = (bottomRight + topLeft) / 2; //this.WidthRatio = ((float)width) / this.ObjectSprite.Texture.Size.X; //this.HeightRatio = ((float)height) / this.ObjectSprite.Texture.Size.Y; this.DomainPoints = this.PopulateNewDomainPoints3(entity); //entity.Domain.Select(pElem => pElem.Position).ToList(); this.render.Shader.SetUniform("margin", ((float)MARGIN_DOMAIN) / this.ObjectSprite.Texture.Size.X); }
private void OnDomainFocusedChanged(IDomainsLayer obj) { this.domainLayerFocused = obj as ALayer2D; if (obj.DomainFocused != null) { CJStarDomain domainFocused = (obj as ALayer2D).GetEntityFromEntity2D(obj.DomainFocused) as CJStarDomain; BoardBannerLayer parentBannerLayer = this.parentLayer as BoardBannerLayer; this.domainToolTip.DisplayToolTip(domainFocused, parentBannerLayer.Player, parentBannerLayer.Opponent); } else { this.domainToolTip.HideToolTip(); } }
public CJStarDomain2D(ALayer2D layer2D, IObject2DFactory factory, CJStarDomain entity) : base(layer2D, factory, entity) { // TO REMOVE //this.Test(); //this.widthRatio = 0; //this.heightRatio = 0; this.targetedColor = Color.Black; Shader shader = new Shader(null, null, @"Assets\Graphics\Shaders\StarDomain.frag"); Texture distortionMap = factory.GetTextureById("distorsionTexture"); this.ObjectSprite.Texture = factory.GetTextureById("distorsionTexture"); this.ObjectSprite.Texture.Repeated = true; distortionMap.Repeated = true; distortionMap.Smooth = true; shader.SetUniform("currentTexture", new Shader.CurrentTextureType()); render = new RenderStates(BlendMode.Alpha); render.Shader = shader; this.isFocused = true; this.IsFocused = false; this.Priority = entity.Priority; this.domainStars = entity.Domain.Select(pElem => layer2D.GetEntity2DFromEntity(pElem) as StarEntity2D).ToList(); this.isFilled = entity.IsFilled; shader.SetUniform("isFilled", this.isFilled); SequenceAnimation sequence = new SequenceAnimation(Time.FromSeconds(6), AnimationType.ONETIME); IAnimation anim = new ZoomAnimation(1f, 2f, Time.FromSeconds(2), AnimationType.ONETIME, InterpolationMethod.SQUARE_ACC); sequence.AddAnimation(0, anim); anim = new ZoomAnimation(2f, 1f, Time.FromSeconds(3), AnimationType.ONETIME, InterpolationMethod.SQUARE_ACC); sequence.AddAnimation(2, anim); this.animationsList.Add(sequence); this.UpdateScaling(entity); this.StartNotActiveState(); }
protected override void OnEntityPropertyChanged(AEntity obj, string propertyName) { base.OnEntityPropertyChanged(obj, propertyName); switch (propertyName) { case "CardSocketed": StarEntity starEntity = obj as StarEntity; StarEntity2D starEntity2D = this.objectToObject2Ds[obj] as StarEntity2D; starEntity2D.SetCardSocketed(starEntity.CardSocketed); break; case "IsSocketed": (this.objectToObject2Ds[obj] as CardEntity2D).IsSocketed = ((obj as CardEntity).ParentStar != null); break; case "IsFliped": (this.objectToObject2Ds[obj] as CardEntity2D).IsFliped = (obj as CardEntity).IsFliped; break; case "IsSelected": (this.objectToObject2Ds[obj] as CardEntity2D).IsSelected = (obj as CardEntity).IsSelected; break; case "IsAwakened": CardEntity2D cardAwakened = this.objectToObject2Ds[obj] as CardEntity2D; cardAwakened.IsAwakened = (obj as CardEntity).Card.IsAwakened; cardAwakened.Priority = 2000 + this.maxAwakenedPriority++; break; case "IsActive": this.objectToObject2Ds[obj].IsActive = (obj as AEntity).IsActive; break; case "CurrentOwner": CardEntity cardConcerned = obj as CardEntity; (this.objectToObject2Ds[cardConcerned] as CardEntity2D).PlayerColor = cardConcerned.Card.CurrentOwner.PlayerColor; (this.objectToObject2Ds[cardConcerned.ParentStar] as StarEntity2D).SetCardSocketed(cardConcerned); break; case "Value": CardEntity2D card2DChanged = this.objectToObject2Ds[obj] as CardEntity2D; CardEntity cardChanged = obj as CardEntity; card2DChanged.CardValue = cardChanged.Card.Value; card2DChanged.CardValueModifier = cardChanged.Card.ValueModifier; break; case "DomainOwner": CJStarDomain2D domain2DChanged = this.objectToObject2Ds[obj] as CJStarDomain2D; CJStarDomain domainChanged = (obj as CJStarDomain); if (domainChanged.DomainOwner != null) { domain2DChanged.TargetedColor = domainChanged.DomainOwner.PlayerColor; } else { domain2DChanged.TargetedColor = Color.Black; } break; } }
protected bool CheckFocusDomainBoardEvent(World world, BoardPlayerLayer boardPlayerLayer, out CJStarDomain domainEntity, out string detailsFocused) { domainEntity = null; detailsFocused = null; bool encounterGameEvent = false; if (this.pendingGameEvents.TryGetValue(EventType.FOCUS_DOMAIN_BOARD, out List <GameEvent> gameEventsList)) { foreach (GameEvent gameEvent in gameEventsList) { if (boardPlayerLayer == null || gameEvent.Layer == boardPlayerLayer) { if (domainEntity == null || gameEvent.Entity != null) { domainEntity = gameEvent.Entity as CJStarDomain; detailsFocused = gameEvent.Details; encounterGameEvent = true; } } } } return(encounterGameEvent); }
private List <Vector2f> PopulateNewDomainPoints3(CJStarDomain entity) { List <Vector2f> pointsToReturn = new List <Vector2f>(); for (int i = 0; i < entity.Domain.Count; i++) { StarEntity currentStarEntity = entity.Domain[i]; StarEntity nextStarEntity = entity.Domain[(i + 1) % entity.Domain.Count]; pointsToReturn.Add(currentStarEntity.Position); if (entity.DomainLinks.TryGetValue(currentStarEntity, out StarLinkEntity currentLink) && currentLink is CurvedStarLinkEntity) { int sign = currentLink.StarFrom == currentStarEntity ? 1 : -1; float radiusLink = (currentLink as CurvedStarLinkEntity).Radius * sign; Vector2f currentToNextNorm = nextStarEntity.Position - currentStarEntity.Position; float lenCurrentToNext = currentToNextNorm.Len(); currentToNextNorm = currentToNextNorm / lenCurrentToNext; float angleToRotate = (float)Math.Acos(lenCurrentToNext / (2 * radiusLink)); Vector2f currentToCenter = currentToNextNorm.Rotate(angleToRotate) * radiusLink; Vector2f centerPoint = currentStarEntity.Position + currentToCenter; Vector2f newPoint = centerPoint + (-currentToCenter).Rotate(Math.Sign(radiusLink) * sign * (Math.PI / 2 - angleToRotate)); pointsToReturn.Add(newPoint); } else { Vector2f firstPoint; if (i == 0) { firstPoint = entity.Domain[entity.Domain.Count - 1].Position; } else { firstPoint = entity.Domain[i - 1].Position; } Vector2f secondPoint = entity.Domain[i].Position; Vector2f thirdPoint = entity.Domain[(i + 1) % entity.Domain.Count].Position; Vector2f fourthPoint = entity.Domain[(i + 2) % entity.Domain.Count].Position; Vector2f normVector1 = secondPoint - firstPoint; normVector1 = normVector1 / normVector1.Len(); Vector2f normVector2 = thirdPoint - secondPoint; normVector2 = normVector2 / normVector2.Len(); Vector2f normVector3 = fourthPoint - thirdPoint; normVector3 = normVector3 / normVector3.Len(); float distX1 = normVector1.X != 0 ? (secondPoint.X - firstPoint.X) / normVector1.X : (secondPoint.Y - firstPoint.Y) / normVector1.Y; float distX2 = normVector2.X != 0 ? distX1 + (thirdPoint.X - secondPoint.X) / normVector2.X : distX1 + (thirdPoint.Y - secondPoint.Y) / normVector2.Y; float distX3 = normVector3.X != 0 ? distX2 + (fourthPoint.X - thirdPoint.X) / normVector3.X : distX2 + (fourthPoint.Y - thirdPoint.Y) / normVector3.Y; Vector2f firstPointX = new Vector2f(0, firstPoint.X); Vector2f secondPointX = new Vector2f(distX1, secondPoint.X); Vector2f thirdPointX = new Vector2f(distX2, thirdPoint.X); Vector2f fourthPointX = new Vector2f(distX3, fourthPoint.X); float x = (distX2 + distX1) / 2; float newPointX = this.CubicInterpolate(x, firstPointX, secondPointX, thirdPointX, fourthPointX); Vector2f firstPointY = new Vector2f(0, firstPoint.Y); Vector2f secondPointY = new Vector2f(distX1, secondPoint.Y); Vector2f thirdPointY = new Vector2f(distX2, thirdPoint.Y); Vector2f fourthPointY = new Vector2f(distX3, fourthPoint.Y); float newPointY = this.CubicInterpolate(x, firstPointY, secondPointY, thirdPointY, fourthPointY); pointsToReturn.Add(new Vector2f(newPointX, newPointY)); } } return(pointsToReturn); }
public SecureDomainAction(CJStarDomain domainToSecure, Player.Player domainOwner) { this.DomainToSecure = domainToSecure; this.DomainOwner = domainOwner; }
protected override void OnEntityPropertyChanged(AEntity obj, string propertyName) { base.OnEntityPropertyChanged(obj, propertyName); AAIEntity entityAI; lock (this.objectLock) { switch (propertyName) { case "CardSocketed": StarEntity starEntity = obj as StarEntity; AIStarEntity starEntityAI = this.objectToObjectAIs[obj] as AIStarEntity; lock (starEntityAI.objectLock) { if (starEntity.CardSocketed != null) { starEntityAI.CardEntitySocketed = this.objectToObjectAIs[starEntity.CardSocketed] as AICardEntity; } else { starEntityAI.CardEntitySocketed = null; } } break; case "IsSocketed": if (this.objectToObjectAIs.TryGetValue(obj, out entityAI)) { lock (entityAI.objectLock) { (entityAI as AICardEntity).IsSocketed = (obj as CardEntity).ParentStar != null; } } break; case "IsFliped": if (this.objectToObjectAIs.TryGetValue(obj, out entityAI)) { lock (entityAI.objectLock) { (entityAI as AICardEntity).IsFliped = (obj as CardEntity).IsFliped; } } break; case "IsSelected": if (this.objectToObjectAIs.TryGetValue(obj, out entityAI)) { lock (entityAI.objectLock) { (entityAI as AICardEntity).IsSelected = (obj as CardEntity).IsSelected; } } break; case "IsAwakened": if (this.objectToObjectAIs.TryGetValue(obj, out entityAI)) { lock (entityAI.objectLock) { (entityAI as AICardEntity).IsAwakened = (obj as CardEntity).Card.IsAwakened; } } break; case "CurrentOwner": if (this.objectToObjectAIs.TryGetValue(obj, out entityAI)) { lock (entityAI.objectLock) { (entityAI as AICardEntity).CardOwnerName = (obj as CardEntity).Card.CurrentOwner.PlayerName; } } break; case "Value": if (this.objectToObjectAIs.TryGetValue(obj, out entityAI)) { lock (entityAI.objectLock) { (entityAI as AICardEntity).Value = (obj as CardEntity).Card.Value; } } break; case "DomainOwner": CJStarDomain starDomain = obj as CJStarDomain; if (this.objectToObjectAIs.TryGetValue(obj, out entityAI)) { lock (entityAI.objectLock) { (entityAI as AICJStarDomain).DomainOwnerName = starDomain.DomainOwner != null ? starDomain.DomainOwner.PlayerName : null; } } break; } } }