예제 #1
0
    void Start()
    {
        // Firstly, stop the particles from playing before the fire button is pressed.
        bubbles.Stop();

        // Then calculate and position the rings based on the number of rings specified.
        if (numberOfRings > 0)
        {
            defRingPos  = defaultRingPosition.transform.position;
            nextRingPos = nextRingPosition.transform.position;

            Quaternion ringRotation = Quaternion.Euler(defaultRingRotation);
            string     name         = "Ring ";

            System.Random rand     = new System.Random();
            int           matIndex = rand.Next(0, 4);

            // Instantiate the first ring, then add it to the list.
            rings.Add(RingFactory.CreateRing(defRingPos, ringRotation,
                                             name, true, true, false, ringMaterials[matIndex]));

            // Add the specified number of rings to the list following the first one.
            for (int i = 1; i < numberOfRings; ++i)
            {
                matIndex = rand.Next(0, 4);

                if (i == numberOfRings - 1) // Check if we're on the last ring. Add it to the list as the last ring.
                {
                    rings.Add(RingFactory.CreateRing(nextRingPos, ringRotation,
                                                     name + i.ToString(), false, false, true, ringMaterials[matIndex]));
                }
                else // Otherwise instantiate it and add it to the list as a middle ring.
                {
                    rings.Add(RingFactory.CreateRing(nextRingPos, ringRotation,
                                                     name + i.ToString(), false, false, false, ringMaterials[matIndex]));
                    nextRingPos.y += posOffset;
                }
            }
        }
        else
        {
            Debug.LogWarning("Specify a nonzero, positive number of rings you would like to add.");
        }
    }
예제 #2
0
 private void Start()
 {
     instance = this;
 }
예제 #3
0
        public static void Demo()
        {
            List <Figure> figures = new List <Figure>();

            while (true)
            {
                Console.Clear();
                Console.WriteLine("Console graphical editor.");
                Console.WriteLine("Select option.");
                Console.WriteLine("1. Add Line.");
                Console.WriteLine("2. Add Circle.");
                Console.WriteLine("3. Add Rectangle.");
                Console.WriteLine("4. Add Round.");
                Console.WriteLine("5. Add Ring.");
                Console.WriteLine("6. Add Ring (aggregation).");
                Console.WriteLine("7. Show figures.");
                Console.WriteLine("0. Exit.");

                int select;
                while (!int.TryParse(Console.ReadLine(), out select))
                {
                    Console.WriteLine("Wrong input. Try again.");
                }

                switch (select)
                {
                case 1:
                    figures.Add(LineFactory.Create());
                    Console.Clear();
                    Console.WriteLine("Line added. Press enter to continue.");
                    Console.ReadLine();
                    break;

                case 2:
                    figures.Add(CircleFactory.Create());
                    Console.Clear();
                    Console.WriteLine("Circle added. Press enter to continue.");
                    Console.ReadLine();
                    break;

                case 3:
                    figures.Add(RectangleFactory.Create());
                    Console.Clear();
                    Console.WriteLine("Rectangle added. Press enter to continue.");
                    Console.ReadLine();
                    break;

                case 4:
                    figures.Add(RoundFactory.Create());
                    Console.Clear();
                    Console.WriteLine("Round added. Press enter to continue.");
                    Console.ReadLine();
                    break;

                case 5:
                    figures.Add(RingFactory.Create());
                    Console.Clear();
                    Console.WriteLine("Ring added. Press enter to continue.");
                    Console.ReadLine();
                    break;

                case 6:
                    figures.Add(RingAggregationFactory.Create());
                    Console.Clear();
                    Console.WriteLine("Ring (aggregation) added. Press enter to continue.");
                    Console.ReadLine();
                    break;

                case 7:
                    Console.Clear();
                    foreach (Figure figure in figures)
                    {
                        figure.ShowInfo();
                        Console.WriteLine();
                    }
                    Console.ReadLine();
                    break;

                case 0:
                    Console.WriteLine("Good luck!");
                    Console.ReadLine();
                    return;

                default:
                    Console.WriteLine("Wrong option. Try again.");
                    break;
                }
            }
        }