Beispiel #1
0
 public override void Run()
 {
     base.Run();
     if (Bullet.IsObjectInGameArea())
     {
         StarBonus starBonus = new StarBonus(Danmaku, Bullet.Position, Bullet.TargetObjects[0],
                                             Danmaku.SliceOfLifeBase.Shinigami, Danmaku.SliceOfLifeBase.Shinigami.OnCollision);
         Danmaku.SliceOfLifeBase.Shinigami.Add(starBonus);
     }
 }
Beispiel #2
0
    /// <summary>
    /// Поиск пути движения для кристалов
    /// </summary>
    private void FindWayFromCrystals()
    {
        bool move = false;

        if (!CheckCellFromBonusActive())
        {
            return;
        }

        if (moveComplite)
        {
            if (combinations.Count != 0)
            {
                SortCombination();

                foreach (Combination combo in combinations)
                {
                    switch (combo.cellsInCombination.Count)
                    {
                    case 3:
                    {
                        foreach (Cell cell in combo.cellsInCombination)
                        {
                            cell.DestroyCrystal();
                        }
                        break;
                    }

                    case 4:
                    {
                        if (combo.activeCell.crystal.bonus == null)
                        {
                            LineBonus lineBonus = combo.activeCell.crystal.gameObject.AddComponent <LineBonus>();
                            lineBonus.Line(combo.activeCell.crystal.typeOfLine, this, combo.activeCell.crystal);
                            lineBonus.SetEffect(combo.activeCell.crystal.InitLineEffect(), combo.activeCell.crystal.lineSprite);
                            combo.activeCell.crystal.bonus = lineBonus;
                            combo.activeCell.destroyEffect.Activate(combo.activeCell.gameObject, false, 250);
                            foreach (Cell cell in combo.cellsInCombination)
                            {
                                if (cell != combo.activeCell)
                                {
                                    cell.DestroyCrystal();
                                }
                            }
                            combo.activeCell.cellInCombination.Clear();
                        }
                        else
                        {
                            foreach (Cell cell in combo.cellsInCombination)
                            {
                                cell.DestroyCrystal();
                            }
                            break;
                        }
                        break;
                    }

                    default:
                    {
                        int x      = combo.activeCell.x;
                        int y      = combo.activeCell.y;
                        int xCount = 0;
                        int yCount = 0;
                        for (int i = 0; i < combo.cellsInCombination.Count; i++)
                        {
                            if (combo.cellsInCombination[i].x != x)
                            {
                                xCount++;
                            }
                            if (combo.cellsInCombination[i].y != y)
                            {
                                yCount++;
                            }
                        }
                        if (xCount < 4 && yCount < 4)
                        {
                            if (combo.activeCell.crystal.bonus == null)
                            {
                                BoxBonus lineBonus = combo.activeCell.crystal.gameObject.AddComponent <BoxBonus>();
                                lineBonus.Box(this, combo.activeCell.crystal);
                                lineBonus.SetEffect(combo.activeCell.crystal.InitBoxEffect(), combo.activeCell.crystal.colorsBoxBonus[combo.activeCell.crystal.colorID]);
                                combo.activeCell.crystal.bonus = lineBonus;
                                combo.activeCell.crystal.spriteRenderer.sortingOrder += 2;
                                combo.activeCell.crystal.spriteRenderer.sprite        = combo.activeCell.crystal.spriteOfBoxEffect[combo.activeCell.crystal.colorID];
                                combo.activeCell.destroyEffect.Activate(combo.activeCell.gameObject, false, 500);
                                foreach (Cell cell in combo.cellsInCombination)
                                {
                                    if (cell != combo.activeCell)
                                    {
                                        cell.DestroyCrystal();
                                    }
                                }
                                combo.activeCell.cellInCombination.Clear();
                            }
                            else
                            {
                                foreach (Cell cell in combo.cellsInCombination)
                                {
                                    cell.DestroyCrystal();
                                }
                                break;
                            }
                        }
                        else
                        {
                            if (combo.activeCell.crystal.bonus == null)
                            {
                                StarBonus starBonus = combo.activeCell.crystal.gameObject.AddComponent <StarBonus>();
                                combo.activeCell.crystal.bonus = starBonus;
                                starBonus.Star(this, combo.activeCell.crystal);
                                starBonus.SetType(combo.activeCell.crystal.type);
                                starBonus.SetEffect(combo.activeCell.crystal.lizerPrefab, combo.activeCell.crystal.InitStarArialEffect(), combo.activeCell.crystal.InitStarArialEffect(), combo.activeCell.crystal.firstColorArial, combo.activeCell.crystal.secondColorArial);
                                combo.activeCell.crystal.spriteRenderer.sprite       = combo.activeCell.crystal.starSprite;
                                combo.activeCell.crystal.spriteRenderer.sortingOrder = 1;
                                combo.activeCell.crystal.type = TypeOfCrystal.star;
                                combo.activeCell.destroyEffect.Activate(combo.activeCell.gameObject, false, 1000);
                                foreach (Cell cell in combo.cellsInCombination)
                                {
                                    if (cell != combo.activeCell)
                                    {
                                        cell.DestroyCrystal();
                                    }
                                }
                                combo.activeCell.cellInCombination.Clear();
                            }
                            else
                            {
                                foreach (Cell cell in combo.cellsInCombination)
                                {
                                    cell.DestroyCrystal();
                                }
                                break;
                            }
                        }
                        break;
                    }
                    }
                }

                combinations.Clear();

                if (!CheckCellFromBonusActive())
                {
                    return;
                }
            }

            for (int j = 0; j < size; j++)
            {
                for (int i = 0; i < size; i++)
                {
                    if (cells[i, j].crystal != null)
                    {
                        if (cells[i, j].isCrystalMove)
                        {
                            return;
                        }

                        if (j < size - 1)
                        {
                            if (cells[i, j + 1].crystal == null && !cells[i, j + 1].isBarrier)
                            {
                                move = true;
                                if (!AddWayPoint(i, j, 0, 1))
                                {
                                    findComplite = !move && moveCrystals.Count == 0;
                                    return;
                                }
                            }
                            else
                            {
                                if (i > 0)
                                {
                                    if (cells[i - 1, j].crystal == null && cells[i - 1, j + 1].crystal == null && !cells[i - 1, j + 1].isBarrier && !cells[i - 1, j].isCellGenerate)
                                    {
                                        move = true;
                                        if (!AddWayPoint(i, j, -1, 1))
                                        {
                                            findComplite = !move && moveCrystals.Count == 0;
                                            return;
                                        }
                                    }
                                    else
                                    {
                                        if (i < size - 1)
                                        {
                                            if (cells[i + 1, j].crystal == null && cells[i + 1, j + 1].crystal == null && !cells[i + 1, j + 1].isBarrier && !cells[i + 1, j].isCellGenerate)
                                            {
                                                move = true;
                                                if (!AddWayPoint(i, j, 1, 1))
                                                {
                                                    findComplite = !move && moveCrystals.Count == 0;
                                                    return;
                                                }
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    if (i < size - 1)
                                    {
                                        if (cells[i + 1, j].crystal == null && cells[i + 1, j + 1].crystal == null && !cells[i + 1, j + 1].isBarrier && !cells[i + 1, j].isCellGenerate)
                                        {
                                            move = true;
                                            if (!AddWayPoint(i, j, 1, 1))
                                            {
                                                findComplite = !move && moveCrystals.Count == 0;
                                                return;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        if (!AddWayPoint(i, j, 0, 0))
                        {
                            findComplite = !move && moveCrystals.Count == 0;
                            return;
                        }
                    }
                }
            }
        }

        findComplite = !move && moveCrystals.Count == 0;

        if (!move)
        {
            moveComplite = false;
            if (moveCrystals.Count == 0)
            {
                moveComplite = true;
                return;
            }
            for (int i = 0; i < moveCrystals.Count; i++)
            {
                if (moveCrystals[i].moveWayPoints.Count == 0)
                {
                    moveCrystals.RemoveAt(i);
                    break;
                }
                moveCrystals[i].MoveOnWay();
            }
        }
    }