예제 #1
0
    public void generateWheel()
    {
        List <Transform> children = new List <Transform>();

        foreach (Transform child in transform)
        {
            children.Add(child);
        }

        foreach (Transform child in children)
        {
            DestroyImmediate(child.gameObject, true);
        }

        // create Names
        WheelOption[] wheelOptions = createNameArray();
        if (wheelOptions.Length == 0)
        {
            wheelOptions = BlankOptions();
        }

        int i = 0;

        foreach (WheelOption option in wheelOptions)
        {
            var          segment = Instantiate(wheelSegment, transform.position, Quaternion.identity);
            WheelSegment ws      = segment.gameObject.GetComponent <WheelSegment>();
            ws.AddName(option.name);
            ws.SetColour(option.colour);
            segment.transform.rotation = Quaternion.Euler(0, 0, 60 * i);
            segment.transform.parent   = gameObject.transform;
            segment.transform.name     = $"{option.name} ({i})";
            i++;
        }
    }
예제 #2
0
    private WheelSegment CreatSegment()
    {
        temperaryWheelSegment = Instantiate(wheelSegment, transform);
        temperaryWheelSegment.transform.eulerAngles = segmentRotation;
        segmentRotation.z += 360f / segmentsCount;

        return(temperaryWheelSegment);
    }
예제 #3
0
 private void OnTriggerExit2D(Collider2D other)
 {
     currentTickObject = null;
 }
예제 #4
0
 private void OnTriggerStay2D(Collider2D other)
 {
     currentTickObject = other.gameObject.GetComponent <WheelSegment>();
 }
        public async Task <Result <bool> > InsertSpin(string userId, double playedAmount, WheelSegment segment)
        {
            var user = await context.Users.FindAsync(Guid.Parse(userId));

            if (user == null)
            {
                return(Result <bool> .CreateFailed(
                           HttpStatusCode.NotFound, "Αδυναμία ανάκτησης υπολοιίου"));
            }
            var spin = new Spin();

            spin.PlayedAmount = playedAmount;
            spin.TimeStamp    = DateTime.Now;
            spin.Win          = segment.Win;
            spin.TotalAmount  = playedAmount * segment.Multiplier;
            spin.User         = user;
            try
            {
                await context.Spins.AddAsync(spin);

                await context.SaveChangesAsync();
            }
            catch (Exception)
            {
                return(Result <bool> .CreateFailed(
                           HttpStatusCode.NotFound, "Αδυναμία ανάκτησης υπολοιίου"));
            }
            return(Result <bool> .CreateSuccessful(true));
        }
예제 #6
0
        public static void Initialize(Context context, UserManager <User> userManager)
        {
            context.Database.EnsureCreated();


            // Look for any users or wheel settings
            if (context.Users.Any() || context.WheelSettings.Any())
            {
                return;   // DB has been seeded
            }

            var ws = new WheelSetting();

            ws.SettingJSONString = GetDefaultSettingsJSONString();
            context.WheelSettings.Add(ws);
            context.SaveChanges();

            List <WheelSegment> segments = new List <WheelSegment>();

            for (int i = 0; i < 3; i++)
            {
                var segment1 = new WheelSegment();
                segment1.ResultText = "You win!";
                segment1.Value      = "win x" + (1.5 + i);
                segment1.Win        = true;
                segment1.Multiplier = (i + 1.5);
                segment1.Type       = "string";
                segments.Add(segment1);

                var segment2 = new WheelSegment();
                segment2.ResultText = "You lose!";
                segment2.Value      = "lose x" + (1.5 + i);
                segment2.Win        = false;
                segment2.Multiplier = -(i + 1.5);
                segment2.Type       = "string";
                segments.Add(segment2);
            }
            context.AddRange(segments);

            context.SaveChanges();

            //users seed
            for (int i = 0; i < 10; i++)
            {
                User u  = new User();
                var  ui = new UserInfo();
                ui.RegistrationDate = DateTime.Now;

                u.Email     = "user" + i + "@gmail.com";
                u.UserName  = u.Email;
                u.Balance   = 100;
                u.FirstName = "User" + i;
                u.LastName  = "Userovic" + i;

                List <Transaction> tl = new List <Transaction>();
                for (int j = 0; j < 10; j++)
                {
                    Transaction t = new Transaction();
                    t.Amount = i * 10;
                    t.Source = j % 2 == 0 ? TransactionSource.Bank : TransactionSource.DepositCode;
                    t.Type   = j % 2 == 0 ? TransactionType.Deposit : TransactionType.Withdrow;
                    t.Date   = DateTime.Now;
                    t.User   = u;
                    tl.Add(t);
                }
                List <DepositCode> dkl = new List <DepositCode>();
                for (int k = 0; k < 2; k++)
                {
                    DepositCode dk = new DepositCode();
                    dk.User      = u;
                    dk.IsUsed    = false;
                    dk.Amount    = ((k + 2) * 10);
                    dk.UsingCode = Guid.NewGuid().ToString().Substring(0, 8);
                    dkl.Add(dk);
                }
                u.DepositCodes = dkl;
                u.Transactions = tl;
                //context.Transactions.AddRange(tl);

                ui.User = u;
                context.UserInfo.Add(ui);
                var result = userManager.CreateAsync(u, "123456");
            }
            System.Threading.Thread.Sleep(5000);
            context.SaveChanges();
            //wheel settings seed
        }