상속: MonoBehaviour
예제 #1
0
	// Use this for initialization
	void Start () {
		sr = this.GetComponent<SpriteRenderer>();
        fluteArray.Add(flute1);
        fluteArray.Add(flute2);
        fluteArray.Add(flute3);
        fluteArray.Add(flute4);
        fluteArray.Add(flute5);

        //Randomizing the flute array to make a randomized solution out of
        for (int i = 4; i >= 0; i--){
			randStart = Random.Range (0, i);
			temp = fluteArray[randStart];
			fluteArray[randStart] = fluteArray[i];
			fluteArray[i] = temp;
			if(i < 3){
				solution[i] = fluteArray[i];
			}
		}
		//mixing our three colors together
		for(int j = 0; j < solution.Length; j++){
			solutionColor += solution[j].fluteCol;
		}
		solutionColor = solutionColor/3;
		sr.color = solutionColor;
       
    }
예제 #2
0
        public void XmlSerialization()
        {
            var flute = new Flute()
            {
                InstrumentName = "The flute of the golden king", InstrumentValue = 2000
            };

            try
            {
                using (MemoryStream stream = new MemoryStream())
                {
                    using (XmlTextWriter xml = new XmlTextWriter(stream, new UTF8Encoding(false)))
                    {
                        XmlSerializer xs = new XmlSerializer(typeof(Flute));
                        xs.Serialize(xml, flute);
                        string xmlData = Encoding.UTF8.GetString(((MemoryStream)xml.BaseStream).ToArray());
                        Assert.True(true);
                    }
                }
            }
            catch (Exception ex)
            {
                Assert.False(true);
            }
        }
예제 #3
0
    // Use this for initialization
    void Start()
    {
        sr = this.GetComponent <SpriteRenderer>();
        fluteArray.Add(flute1);
        fluteArray.Add(flute2);
        fluteArray.Add(flute3);
        fluteArray.Add(flute4);
        fluteArray.Add(flute5);

        //Randomizing the flute array to make a randomized solution out of
        for (int i = 4; i >= 0; i--)
        {
            randStart             = Random.Range(0, i);
            temp                  = fluteArray[randStart];
            fluteArray[randStart] = fluteArray[i];
            fluteArray[i]         = temp;
            if (i < 3)
            {
                solution[i] = fluteArray[i];
            }
        }
        //mixing our three colors together
        for (int j = 0; j < solution.Length; j++)
        {
            solutionColor += solution[j].fluteCol;
        }
        solutionColor = solutionColor / 3;
        sr.color      = solutionColor;
    }
예제 #4
0
        static void Main(string[] args)
        {
            Console.WriteLine("=== GREAT OPERA CONCERT ===");

            Director director = new Director(
                "Roberto", "Ajolfi",
                40, true, "Conservatorio di Milano");

            Person composer = new Person(
                "Ludwig", "Van Beethoven", 68, false);

            //OperaConcertEvent concert = new OperaConcertEvent(
            //    director,
            //    composer);

            ArrayList strumenti    = new ArrayList();
            Piano     piano        = new Piano("Steinway & Sons", Piano.PianoType.Grand);
            Flute     flute        = new Flute("Miyazawa Flutes", Flute.FluteType.SideBlow);
            Violin    firstViolin  = new Violin("Stradivari", 280);
            Violin    secondViolin = new Violin("Stentor", 30);

            strumenti.Add(piano);
            strumenti.Add(flute);
            strumenti.Add(firstViolin);
            strumenti.Add(secondViolin);

            OperaConcertEvent concert = new OperaConcertEvent(
                director,
                composer,
                strumenti);

            //concert.Instruments.Add(piano);
            //concert.Instruments.Add(flute);
            //concert.Instruments.Add(firstViolin);
            //concert.Instruments.Add(secondViolin);

            // PROVE GENERALI
            Console.WriteLine("--- PROVE GENERALI ---");
            foreach (Instrument instrument in concert.Instruments)
            {
                Console.WriteLine(instrument.ToString());
                instrument.Tune();
            }
            Console.WriteLine("--- FINE PROVE GENERALI ---");
            Console.WriteLine();

            // CONCERTONE !!
            Console.WriteLine("--- CONCERTONE ---");
            Console.WriteLine($"Opera di {concert.Composer.LastName}");
            Console.WriteLine($"--- Dirige: {concert.Director.LastName}");
            Console.WriteLine("------------------");
            foreach (Instrument instrument in concert.Instruments)
            {
                instrument.Play();
            }
            Console.WriteLine("--- FINE CONCERTONE ---");
        }
예제 #5
0
        public void XmlDeSerialization()
        {
            string xmlFluteData = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Flute xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><FluteBrand>JUPITER</FluteBrand><Material>STEEL</Material><FluteType>CLASSIC</FluteType><InstrumentName>The flute of the golden king</InstrumentName><IsAntiquity>false</IsAntiquity><InstrumentGroup>WOODWINDS</InstrumentGroup><InstrumentValue>2000</InstrumentValue></Flute>";

            using (MemoryStream stream = new MemoryStream(new UTF8Encoding().GetBytes(xmlFluteData)))
            {
                using (new XmlTextWriter(stream, new UTF8Encoding(false)))
                {
                    Flute fl = (Flute) new XmlSerializer(typeof(Flute)).Deserialize(stream);
                    Assert.Equal <int>(fl.CompareTo(new Flute()
                    {
                        InstrumentName = "The flute of the golden king", InstrumentValue = 2000
                    }), 0);
                }
            }
        }
예제 #6
0
    static void Main()
    {
        Instrument[] instruments = new Instrument[10];

        Random rand = new Random();

        for (int i = 0; i < 10; i++)
        {
            int randomNum = rand.Next((3 - 1) + 1) + 1;

            if (randomNum == 1)
            {
                instruments[i] = new Piano();
            }
            else if (randomNum == 2)
            {
                instruments[i] = new Flute();
            }
            else if (randomNum == 3)
            {
                instruments[i] = new Guitar();
            }
            instruments[i].play();
        }
        Console.WriteLine();
        for (int i = 0; i < 10; i++)
        {
            if (instruments[i].GetType() == typeof(Piano))
            {
                Console.WriteLine("Piano is stored at index : " + i);
            }
            else if (instruments[i].GetType() == typeof(Flute))
            {
                Console.WriteLine("Flute is stored at index : " + i);
            }
            else if (instruments[i].GetType() == typeof(Guitar))
            {
                Console.WriteLine("Guitar is stored at index : " + i);
            }
        }
        Console.ReadKey();
    }
예제 #7
0
        public static Stream BackgroundExtractIfCompressed(Stream input, ArchiveEntry entry)
        {
            if (!entry.IsCompressed)
            {
                return(input);
            }

            int uncompressedSize = (int)entry.UncompressedSize;

            if (uncompressedSize == 0)
            {
                return(new MemoryStream(0));
            }

            Stream writer, reader;

            Flute.CreatePipe(uncompressedSize, out writer, out reader);

            //if (!ThreadPool.QueueUserWorkItem((o) => ZLibHelper.UncompressAndDisposeStreams(input, writer, uncompressedSize, CancellationToken.None)))
            ThreadHelper.StartBackground("UncompressAndDisposeSourceAsync", () => ZLibHelper.UncompressAndDisposeStreams(input, writer, uncompressedSize, CancellationToken.None));
            return(reader);
        }