/// <summary> /// /// </summary> /// <param name="friends">周边相同的猫的集合</param> internal void RemoveCat(List <GameObject> friends) { // int score=Control.Instance.ScoreWithStartNumber(friends.Count); //GameLayer.Instance.AddScore(score); TouchLayer.isTouch = false; List <int> columnList = new List <int>();//存储被消掉的列 foreach (GameObject item in friends) { catsList.Remove(item); Point key = item.GetComponent <Cat>().point; catsDic[key] = null; CatManager.Instance.RemoveCat(item); columnList.Add(key.X); } float maxTime = 0; foreach (int column in columnList) { float t = RepairRaw(column);//找到每一空余的列,调整行; if (maxTime < t) { maxTime = t; } } //要等到行的操作完成后,才进行列的操作 this.transform.RunAction(CCSequence.Create(CCDelay.Create(maxTime), CCCallFunc.Create(RepairColumn))); }
public void RepairColumn() { int num = 0; float time = 0; for (int x = 0; x < 10; x++) { bool isNull = true;//当为true的时候说明整列都是空的 for (int y = 0; y < 10; y++) { Point key = new Point(x, y); if (catsDic[key] != null) { isNull = false; } } if (isNull) { num++; } if (!isNull) { if (num > 0) { for (int y = 0; y < 10; y++) { Point key = new Point(x, y); int dx = key.X - num; GameObject cat = catsDic[key]; catsDic[key] = null; if (cat != null) { time = cat.GetComponent <Cat>().RunToX(new Point(dx, y)); } } } } } var action = CCSequence.Create(CCDelay.Create(time), CCCallFunc.Create(() => { if (IsGameOver()) { //分数奖励 JiangLiScore(); StartCoroutine(IsPassGameLv()); } TouchLayer.isTouch = true; })); this.transform.RunAction(action); }
protected override void Step(float dt) { base.Step(dt); if (gameSuspended) { return; } var batchnode = GetChildByTag((int)Tags.SpriteManager) as CCSpriteBatchNode; var bird = batchnode.GetChildByTag((int)Tags.Bird) as CCSprite; var particles = GetChildByTag((int)Tags.Particles) as CCParticleSystem; bird_pos.X += bird_vel.X * dt; if (bird_vel.X < -30.0f && birdLookingRight) { birdLookingRight = false; bird.ScaleX = -1.0f; } else if (bird_vel.X > 30.0f && !birdLookingRight) { birdLookingRight = true; bird.ScaleX = 1.0f; } var bird_size = bird.ContentSize; float max_x = 320 - bird_size.Width / 2; float min_x = 0 + bird_size.Width / 2; if (bird_pos.X > max_x) { bird_pos.X = max_x; } if (bird_pos.X < min_x) { bird_pos.X = min_x; } bird_vel.Y += bird_acc.Y * dt; bird_pos.Y += bird_vel.Y * dt; var bonus = batchnode.GetChildByTag((int)Tags.BomusStart + currentBonusType); if (bonus.Visible) { var bonus_pos = bonus.Position; float range = 20.0f; if (bird_pos.X > bonus_pos.X - range && bird_pos.X < bonus_pos.Y + range && bird_pos.Y > bonus_pos.Y - range && bird_pos.Y < bonus_pos.Y + range) { switch (currentBonusType) { case (int)Bonus.Bonus5: score += 5000; break; case (int)Bonus.Bonus10: score += 10000; break; case (int)Bonus.Bonus50: score += 50000; break; case (int)Bonus.Bonus100: score += 100000; break; } var scorelabel = GetChildByTag((int)Tags.ScoreLabel) as CCLabelBMFont; scorelabel.SetString(score.ToString()); var a1 = new CCScaleTo(.2f, 1.5f, .08f); var a2 = new CCScaleTo(.2f, 1f, 1f); var a3 = CCSequence.Create(a1, a2, a1, a2, a1, a2); scorelabel.RunAction(a3); ResetBonus(); } } int t; if (bird_vel.Y < 0) { t = (int)Tags.PlatformsStart; for (t = (int)Tags.PlatformsStart; t < (int)Tags.PlatformsStart + numPlatforms; t++) { var platform = batchnode.GetChildByTag(t) as CCSprite; var platform_size = platform.ContentSize; var platform_pos = platform.Position; max_x = platform_pos.X - platform_size.Width / 2 - 10; min_x = platform_pos.X + platform_size.Width / 2 + 10; float min_y = platform_pos.Y + (platform_size.Height + bird_size.Height) / 2 - platformTopPadding; if (bird_pos.X > max_x && bird_pos.X < min_x && bird_pos.Y > platform_pos.Y && bird_pos.Y < min_y) { Jump(); } } if (bird_pos.Y < -bird_size.Height / 2) { ShowHighScores(); } } else if (bird_pos.Y > 240) { float delta = bird_pos.Y - 240; bird_pos.Y = 240; currentPlatformY -= delta; for (t = (int)Tags.CloudsStart; t < (int)Tags.CloudsStart + numClouds; t++) { var cloud = batchnode.GetChildByTag(t) as CCSprite; var pos = cloud.Position; pos.Y -= delta * cloud.ScaleY * 0.8f; if (pos.Y < -cloud.ContentSize.Height / 2) { currentCloudTag = t; ResetCloud(); } else { cloud.Position = pos; } } for (t = (int)Tags.PlatformsStart; t < (int)Tags.PlatformsStart + numPlatforms; t++) { var platform = batchnode.GetChildByTag(t) as CCSprite; var pos = platform.Position; pos = new CCPoint(pos.X, pos.Y - delta); if (pos.Y < -platform.ContentSize.Height / 2) { currentPlatformTag = t; ResetPlatform(); } else { platform.Position = pos; } } if (bonus.Visible) { var pos = bonus.Position; pos.Y -= delta; if (pos.Y < -bonus.ContentSize.Height / 2) { ResetBonus(); //[self resetBonus]; } else { bonus.Position = pos; } } score += (int)delta; var scoreLabel = GetChildByTag((int)Tags.ScoreLabel) as CCLabelBMFont; scoreLabel.SetString(score.ToString()); } bird.Position = bird_pos; if (particles != null) { var particle_pos = new CCPoint(bird_pos.X, bird_pos.Y - 17); particles.Position = particle_pos; } }