Exemplo n.º 1
0
        static void Main(string[] args)
        {
            //set initial variables
            string input_numberOfDiceSides = "6";
            string input_HowManyDice       = "";
            int    howManyDice             = 0;
            int    diceSides           = 6;
            int    howManyRolls        = 1;
            string input_NumberOfSides = "0";
            string input_HowManyRolls  = "";


            Console.WriteLine("Hello! Time to play the dice math game...");
            Console.WriteLine("Please enter how many dice you would like to roll.");
            input_HowManyDice = Console.ReadLine();
            howManyDice       = Convert.ToInt32(input_HowManyDice);
            diceResults diceResult = new diceResults();

            die[] diceCollection = new die[howManyDice];

            Console.WriteLine("Great! Now lets set how many sides you would like them to have.");

            for (int i = 0; i < howManyDice; i++)
            {
                Console.WriteLine("How many sides would you like dice {0} to have?", i + 1);
                input_NumberOfSides = Console.ReadLine();
                diceSides           = Convert.ToInt32(input_NumberOfSides);
                diceCollection[i]   = new die()
                {
                    numberOfSides = diceSides
                };
            }
            Console.WriteLine("Ok how many times do you want me to roll these dice?", input_numberOfDiceSides);
            input_HowManyRolls = Console.ReadLine();
            howManyRolls       = Convert.ToInt32(input_HowManyRolls);
            Console.WriteLine("When you are ready for me to roll your dice, press ENTER", diceSides, howManyRolls);
            Console.ReadKey();
            RollTheDie(diceCollection, howManyRolls, diceResult);
            AnalyzeResults(diceCollection, diceResult);
            var rawResultsList = diceResult.rawResults.Select(p => p.ToString()).ToList();

            Console.WriteLine("RESULTS!");
            Console.Write("Raw Roll Results: ");
            diceResult.rawResults.Sort();
            foreach (var item in diceResult.rawResults)
            {
                Console.Write("{0} ", item);
            }
            Console.Write("\n");
            Console.WriteLine("------------------------------------");
            Console.WriteLine("Results Average:            | {0}", Math.Round(diceResult.average, 2, MidpointRounding.AwayFromZero));
            Console.WriteLine("Results Median:             | {0}", diceResult.median);
            Console.WriteLine("Results Mode:               | {0}", diceResult.mode);
            Console.WriteLine("Results Standard Deviation: | {0}", Math.Round(diceResult.standardDeviation, 2, MidpointRounding.AwayFromZero));
            Console.WriteLine("Roll Total is               | {0}", diceResult.rollTotal);
            Console.WriteLine("------------------------------------");
            Console.WriteLine("Thanks For Playing!");
            Console.WriteLine("Press ENTER to exit");
            Console.ReadLine();
        }
Exemplo n.º 2
0
 //每帧检测
 void SetEffect(Frame f)
 {
     CheckEffect();
     if (iextplayer == null)
     {
         return;
     }
     foreach (var e in f.effectList)
     {
         Transform o = transform.Find(e.follow);
         if (e.lifeframe > 0)
         {
             if (o != null)
             {
                 die d = new die();
                 d.lifetime = e.lifeframe;
                 d.effid    = iextplayer.PlayEffectLooped(e.name, o, e.position, e.isFollow, dir);
                 livetimelist.Add(d);
             }
         }
         else
         {
             iextplayer.PlayEffect(e.name, o, e.position, e.isFollow, dir);
         }
     }
 }
Exemplo n.º 3
0
    void OnTriggerEnter2D(Collider2D coll)
    {
        die enemy = coll.GetComponent <die>();

        if (enemy != null)
        {
            enemy.takedamage(damage);
        }
        //   Instantiate(impacteffect, transform.position, transform.rotation);

        Destroy(gameObject);
        //  impacteffect.SetActive(false);
        //DestroyImmediate(impacteffect, true);
    }
Exemplo n.º 4
0
 //// Start is called before the first frame update
 void Start()
 {
     shot1  = GameObject.FindGameObjectWithTag("Shot");
     shot2  = GameObject.FindGameObjectWithTag("Shot2");
     shot3  = GameObject.FindGameObjectWithTag("Shot3");
     shot4  = GameObject.FindGameObjectWithTag("Shot4");
     shot5  = GameObject.FindGameObjectWithTag("Shot5");
     shot6  = GameObject.FindGameObjectWithTag("Shot6");
     shots1 = shot1.GetComponent <die>();
     shots2 = shot2.GetComponent <die>();
     shots3 = shot3.GetComponent <die>();
     shots4 = shot4.GetComponent <die>();
     shots5 = shot5.GetComponent <die>();
     shots6 = shot6.GetComponent <die>();
 }
Exemplo n.º 5
0
 //每帧检测
 void SetEffect(Frame f)
 {
     CheckEffect();
     foreach (var e in f.effectList)
     {
         Transform o = this.transform.Find(e.follow);
         if (e.lifeframe > 0)
         {
             if (o != null)
             {
                 die d = new die();
                 d.lifetime = e.lifeframe;
                 d.effid    = AniResource.PlayEffectLooped(e.name, e.position, dir, o);
                 livetimelist.Add(d);
             }
         }
         else
         {
             AniResource.PlayEffect(e.name, o, e.position, e.isFollow, dir);
         }
     }
 }