void StarChangedHandler(object sender, StarChangedEventArgs e) { if (e.Removed) { StarControl starControl = _stars[e.StarThatChanged]; _stars.Remove(e.StarThatChanged); _fadedStars.Add(starControl); starControl.FadeOut(); } else { StarControl newStar; if (_stars.ContainsKey(e.StarThatChanged)) { newStar = _stars[e.StarThatChanged]; } else { newStar = new StarControl(); _stars[e.StarThatChanged] = newStar; newStar.FadeIn(); BeeStarHelper.SendToBack(newStar); _sprites.Add(newStar); } BeeStarHelper.SetCanvasLocation(newStar, e.StarThatChanged.Location.X, e.StarThatChanged.Location.Y); } }
// Tile, Enemy and PowerUp collisions go here. private void OnTriggerEnter2D(Collider2D collision) { StarControl star = collision.GetComponent <StarControl>(); if (star != null) { if (Time.time > _starTimer + 0.5f) { _starCount++; _starTimer = Time.time; } } EnemyTag enemy = collision.GetComponent <EnemyTag>(); if (enemy != null) { Destroy(gameObject); } TileControl tc = collision.transform.gameObject.GetComponent <TileControl>(); if (tc != null) { tc.Damage(); } }
void StarChangedHandler(object sender, StarChangedEventArgs e) { if (e.Removed)//if removed than move to faded stars collection { StarControl starControl = _stars[e.StarThatChanged]; _stars.Remove(e.StarThatChanged); _fadedStars.Add(starControl); starControl.FadeOut(); } else {//if exsits then take reference StarControl newStar; if (_stars.ContainsKey(e.StarThatChanged)) { newStar = _stars[e.StarThatChanged]; } else//else create one and add to sprites collection { newStar = new StarControl(); _stars[e.StarThatChanged] = newStar; newStar.Fadein(); Helper.SendToBack(newStar); _sprites.Add(newStar); } Helper.SetCanvasLocation(newStar, e.StarThatChanged.Location.X, e.StarThatChanged.Location.Y); } }
private void _model_StarChanged(object sender, StarChangedEventArgs e) { if (e.Removed && _stars.ContainsKey(e.StarThatChanged)) { StarControl starRemoved = _stars[e.StarThatChanged]; _fadedStars.Add(starRemoved); _stars.Remove(e.StarThatChanged); starRemoved.FadeOut(); } else { StarControl starToBeShown; if (_stars.ContainsKey(e.StarThatChanged)) { starToBeShown = _stars[e.StarThatChanged]; } else { starToBeShown = new StarControl(); starToBeShown.FadeIn(); _sprites.Add(starToBeShown); BeeStarHelper.SentToBack(starToBeShown); } BeeStarHelper.SetCanvasLocation(starToBeShown, e.StarThatChanged.Location.X, e.StarThatChanged.Location.Y); } }
// Use this for initialization private void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } }
public void PopulateSprites() { RecreateScanLines(); foreach (Point star in _model._stars) { StarControl newStar = InvadersHelper.StarControlFactory(star, Scale) as StarControl; _starDictionary.Add(star, newStar); // Obsolete: // InvadersHelper.SetCanvasLocation(newStar, star.X, star.Y, Scale); _sprites.Add(newStar); } }
/// <summary> /// Изменение положение звезды на карте /// </summary> private async void StarLogic() { var random = new Random(); while (true) { if (StarControl == null) { StarControl = new StarControl(); Panel.SetZIndex(StarControl, 11); } if (!Map.Children.Contains(StarControl)) { Map.Children.Add(StarControl); } Canvas.SetTop(StarControl, random.Next(0, (int)MapWidth)); Canvas.SetLeft(StarControl, random.Next(0, (int)MapWidth)); await Task.Delay(2000); } }
private void StarChangedHandler(object sender, StarChangedEventArgs e) { Point star = e.StarThatChanged; if (e.Removed) { if (_starDictionary.ContainsKey(e.StarThatChanged)) { StarControl starControl = _starDictionary[e.StarThatChanged]; _starDictionary.Remove(e.StarThatChanged); _fadedStars.Add(starControl, DateTime.Now); starControl.FadeOut(); //// not sure where to put this resize element method //InvadersHelper.ResizeElement(starControl, e.StarThatChanged.X * Scale, e.StarThatChanged.Y * Scale, // e.StarThatChanged.X * Scale, e.StarThatChanged.Y * Scale, Scale); } } else { StarControl newStar; if (_starDictionary.ContainsKey(e.StarThatChanged)) { newStar = _starDictionary[e.StarThatChanged]; } else { newStar = InvadersHelper.StarControlFactory(star, Scale) as StarControl; _starDictionary[e.StarThatChanged] = newStar; newStar.FadeIn(); _sprites.Add(newStar); } //InvadersHelper.SetCanvasLocation(newStar, e.StarThatChanged.X, e.StarThatChanged.Y, Scale); //// not sure where to put this resize element method //InvadersHelper.ResizeElement(newStar, e.StarThatChanged.X * Scale, e.StarThatChanged.Y * Scale, // e.StarThatChanged.X * Scale, e.StarThatChanged.Y * Scale, Scale); } }
void StarChangedHandler(object sender, StarChangedEventArgs e) { if (e.Removed) { StarControl starControl = _stars[e.StarThatChanged]; _stars.Remove(e.StarThatChanged); _fadedStars.Add(starControl); starControl.FadeOut(); } else { StarControl newStar; if (_stars.ContainsKey(e.StarThatChanged)) newStar = _stars[e.StarThatChanged]; else { newStar = new StarControl(); _stars[e.StarThatChanged] = newStar; newStar.FadeIn(); BeeStarHelper.SendToBack(newStar); _sprites.Add(newStar); } BeeStarHelper.SetCanvasLocation( newStar, e.StarThatChanged.Location.X, e.StarThatChanged.Location.Y); } }
void StarChangedHandler(object sender, StarChangedEventArgs e) { StarControl starControl = null; if (_stars.ContainsKey(e.StarThatChanged)) { starControl = _stars[e.StarThatChanged]; } if (e.Removed && starControl != null) { _fadedStars.Add(starControl); _stars.Remove(e.StarThatChanged); starControl.FadeOut(); return; } else if (starControl == null) { starControl = new StarControl(); if (_stars.ContainsKey(e.StarThatChanged)) { _stars[e.StarThatChanged] = starControl; } else { _stars.Add(e.StarThatChanged, starControl); } _sprites.Add(starControl); starControl.FadeIn(); BeeStarHelper.SendToBack(starControl); } BeeStarHelper.SetCanvasLocation(starControl, e.StarThatChanged.Location.X, e.StarThatChanged.Location.Y); }
public static void SendToBack(StarControl newStar) { Canvas.SetZIndex(newStar, -1000); }
private static void SetupStars(RatingsControl ratingsControl) { Decimal localValue = Convert.ToDecimal( ratingsControl.Value); Decimal edge = ratingsControl.Maximum/ratingsControl.NumberOfStars; ratingsControl.spStars.Children.Clear(); for (int i = 0; i < ratingsControl.NumberOfStars; i++) { StarControl star = new StarControl(); star.BackgroundColor = ratingsControl.BackgroundColor; star.StarForegroundColor = ratingsControl.StarForegroundColor; star.StarOutlineColor = ratingsControl.StarOutlineColor; if (localValue > edge) star.Value = 1.0m; else if (localValue > 0) { star.Value = localValue/edge; } else { star.Value = 0.0m; } localValue -= edge; ratingsControl.spStars.Children.Insert(i,star); } }
// Use this for initialization void Awake() { _childStar = GetComponentInChildren <StarControl> (); _level = GetComponentInParent <LevelGateControl> (); }