Inheritance: MonoBehaviour
Exemplo n.º 1
0
        public async Task ChangePointDisplayAsync(ulong discordID, PointDisplay pointDisplay)
        {
            using (var context = new GuildContext())
            {
                await context.Database.EnsureCreatedAsync();

                var guild = await context.Guilds
                            .AsQueryable()
                            .SingleOrDefaultAsync(x => x.DBDiscordID == Context.Guild.Id.ToString());

                if (guild is null)
                {
                    await ReplyAsync("Guild was not found in the database");

                    return;
                }
                var user = await context.Users
                           .AsQueryable()
                           .SingleOrDefaultAsync(x => x.DBDiscordID == discordID.ToString() && x.Guild == guild);

                if (user is null)
                {
                    await ReplyAsync("User not found in the database");

                    return;
                }

                user.PointDisplay = pointDisplay;
                await context.SaveChangesAsync();
            }

            await ReplyAsync("Value changed");
        }
Exemplo n.º 2
0
    void OnCollisionEnter(Collision col)
    {
        //get points if any
        Car carScript = col.gameObject.GetComponent("Car") as Car;

        if (carScript != null)        //this is a car - get the points
        {
            carScore = carScript.CarScore;
        }
        else
        {
            carScore = 0;
        }

        //display points popup if any
        //PointScript = gameObject.GetComponent("PointDisplay") as PointDisplay;
        PointScript = col.gameObject.AddComponent <PointDisplay>() as PointDisplay;
        if (PointScript != null)
        {
            PointScript.DisplayPoints(carScore * gamestate.Instance.getActiveLevel(), this.gameObject.transform.position);
        }

        //destroy balloon object
        Destroy(this.gameObject);

        //make balloon pop sound
        SoundEffectsHelper.Instance.MakeBallonPopSound();

        //instead of lives we are actually tracking balloons
        gamestate.Instance.SetLives(gamestate.Instance.getLives() - 1);
    }
Exemplo n.º 3
0
        public void InitializeGameState()
        {
            GameRunning.gameTimer = new Stopwatch();
            GameRunning.gameTimer.Start();


            backGroundImage = new Entity(new StationaryShape(new Vec2F(0.0f, 0.0f),
                                                             new Vec2F(1.0f, 1.0f)),
                                         new Image(Path.Combine("Assets", "Images", "SpaceBackground.png"))
                                         );
            levelCreator = new LevelCreator();
            level        = levelCreator.CreateLevel(GameRunning.map);
            player       = new Player();
            player.SpawnPos(levelCreator.playerpos);
            CustomerList      = new List <Customer>();
            CustomersPickedUp = new List <Customer>();
            foreach (var customer in levelCreator.Customer)
            {
                Customer customer1 = new Customer(customer);
                CustomerList.Add(customer1);
            }
            points = new PointDisplay();
        }
Exemplo n.º 4
0
    private void Start()
    {
        pointDisplay = pointObject.GetComponent <PointDisplay>();

        time = PlayerPrefs.GetString(KEY_TIME, "");
        if (time == "")
        {
            timeTextObject.SetActive(false);
            pointText.SetActive(true);
            adIsReady            = true;
            adsButtonImage.color = new Color(255, 255, 255, 1f);
        }
        else
        {
            long temp = Convert.ToInt64(time);
            lastDateTime = DateTime.FromBinary(temp);
        }

        timeSpan = DateTime.UtcNow - lastDateTime;
        if (timeSpan < TimeSpan.FromSeconds(Respawn_Time))
        {
            adIsReady = false;
            pointText.SetActive(false);
            timeTextObject.SetActive(true);
            adsButtonImage.color = new Color(255, 255, 255, 0.5f);
        }

        //ゲームIDをAndroidとそれ以外(iOS)で分ける
#if UNITY_ANDROID
        string gameID = "3747065";
#else
        string gameID = "3395905";
#endif

        //広告の初期化
        Advertisement.Initialize(gameID, testMode: true);
    }
Exemplo n.º 5
0
        public async Task ChangePointDisplayAsync(IGuildUser guildUser, PointDisplay pointDisplay)
        {
            _ = guildUser ?? throw new NullReferenceException("ChangePointDisplayAsync - guildUser");

            await ChangePointDisplayAsync(guildUser.Id, pointDisplay);
        }
Exemplo n.º 6
0
        public async Task TransferAsync(ulong guildID)
        {
            try
            {
                string[] lines = System.IO.File.ReadAllLines($"{AppDomain.CurrentDomain.BaseDirectory}Data/TransferData.txt");
                using (var context = new GuildContext())
                {
                    await context.Database.EnsureCreatedAsync();

                    /*var guild = await context.Guilds
                     *  .Include(x => x.Ranks)
                     *  .Include(x => x.Users)
                     *  .ThenInclude(x => x.Rank)
                     *  .SingleOrDefaultAsync(x => x.DBDiscordID == guildID.ToString());*/

                    var query =
                        from entry in context.Guilds.AsQueryable()
                        where entry.DBDiscordID == guildID.ToString()
                        select entry;
                    var guild = await query.ToAsyncEnumerable().SingleOrDefaultAsync();

                    foreach (string line in lines)
                    {
                        string[] values = line.Split(';');
                        string   id     = values[0];
                        if (!int.TryParse(values[1], out int totalPoints))
                        {
                            Console.WriteLine("Failed to parse totalPoints");
                        }
                        if (!int.TryParse(values[2], out int monthPoints))
                        {
                            Console.WriteLine("Failed to parse monthPoints");
                        }
                        if (!DateTime.TryParse(values[3], out DateTime lastUpdate))
                        {
                            lastUpdate = DateTime.UtcNow;
                        }
                        PointDisplay pointDisplay = (PointDisplay)Enum.Parse(typeof(PointDisplay), values[4]);

                        var user = new User()
                        {
                            DiscordID    = ulong.Parse(id),
                            TotalPoints  = totalPoints,
                            MonthPoints  = monthPoints,
                            LastUpdate   = lastUpdate,
                            PointDisplay = pointDisplay,
                            Privileges   = Privileges.None,
                            Rank         = guild.GetRank(totalPoints),
                            Guild        = guild
                        };
                        await context.Users.AddAsync(user);
                    }
                    await context.SaveChangesAsync();
                }
                await ReplyAsync("Transfer completed");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.InnerException.Message);
                await ReplyAsync("Transfer failed");
            }
        }