示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Resources"/> class.
        /// </summary>
        internal static void Initialize()
        {
            Resources.Logger = LogManager.GetCurrentClassLogger(typeof(Resources));

            Factory.Initialize();
            CSV.Initialize();
            Home.Initialize();
            Fingerprint.Initialize();
            GameDatas.Initialize();

            Resources.Gametools = new GameTools();

            Resources.Redis = new Redis();

            Resources.Players = new Players();
            Resources.Clans   = new Clans();
            Resources.Battles = new Battles();
            Resources.Random  = new XorShift();

            Resources.TCPGateway = new TCPServer();
            Resources.UDPGateway = new UDPServer();

            Resources.Started = true;

            Parser.Initialize();
            EventsHandler.Initialize();
        }
示例#2
0
    public void OptionsResetButtonAction()
    {
        GameDatas.BankAccount    = 0;
        GameDatas.CollectedCoins = 0;

        GameDatas.ResetAbilities();
    }
示例#3
0
 void SetBorderColor()
 {
     //Unlocked
     if (!locked)
     {
         border.color = unlockedColor;
     }
     //Selected
     else if (selected)
     {
         border.color = selectedColor;
     }
     //Has enought money, parent unlocked, not selected
     else if (!selected && ability.cost <= GameDatas.BankAccount && GameDatas.HasAbility(ability.parentAbility))
     {
         border.color = lockedColor;
     }
     //no money OR no parent unlocked AND not selected
     else if (!selected && (ability.cost > GameDatas.BankAccount || !GameDatas.HasAbility(ability.parentAbility)))
     {
         border.color = disabledColor;
     }
     else
     {
         Debug.Log("Something is not covered");
     }
 }
示例#4
0
    //makes next level configurations
    public void ContinueToNextLevel(BallManager ballManager, GameDatas gameDatas)
    {
        //makes enable level passed element
        levelPassedScreen.SetActive(true);

        //doesn't allow the collider of the last ring's slices collide
        ballManager.canCollide = false;

        //pauses the game
        Time.timeScale = 0f;

        //save level count
        gameDatas.LevelCount += 1;
        SaveLoad.gameDatas    = gameDatas;
        SaveLoad.Save();

        //save platform count
        if (gameDatas.PlatformCount < maxPlatformCount)
        {
            gameDatas.PlatformCount += 1;
            SaveLoad.gameDatas       = gameDatas;
            SaveLoad.Save();
        }

        StartCoroutine(DissapearLevelPassedScreen(ballManager));
    }
示例#5
0
    public void SetSelectedAbilityData(AbilitySO ability)
    {
        abilitiesTabCost.text  = "cost: " + ability.cost.ToString();
        abilitiesTabTitle.text = ability.title;

        selectedAbility = ability;

        if (GameDatas.HasAbility(ability.parentAbility))
        {
            if (GameDatas.BankAccount >= ability.cost)
            {
                abilitiesTabDescription.text = ability.description;
            }
            else
            {
                abilitiesTabDescription.text = "You don't have enough money for this.";
            }
        }
        else
        {
            abilitiesTabDescription.text = "You should unlock the parent ability first.";
        }

        OnAbilitySelected?.Invoke(ability);
    }
示例#6
0
    // Start is called before the first frame update
    void Start()
    {
        menuController = FindObjectOfType <MenuController>();
        menuController.AddListenerOnAbilitySelectedEvent(OtherIconSelected);
        menuController.AddListenerOnAbilityUnlockEvent(AbilityUnlocked);

        locked   = !GameDatas.HasAbility(ability.type);
        selected = false;

        Image[] images = GetComponentsInChildren <Image>();

        foreach (Image iconPart in images)
        {
            if (iconPart.tag == "IconBorder")
            {
                border = iconPart;
            }
            else if (iconPart.tag == "IconBackground")
            {
                background = iconPart;
            }
            else if (iconPart.tag == "IconImage")
            {
                icon = iconPart;
            }
        }

        SetBorderColor();
        SetIconImage();
    }
示例#7
0
    private void Start()
    {
        coinsCollected = 0;
        stash          = GameDatas.GetStash();

        FindObjectOfType <CarController>().AddListenerOnTransferFareEvent(AddFarePrice);
    }
示例#8
0
    public void EndGame(int collectedCoins, string endString)
    {
        GameDatas.AddCollectedCoinsToBank(collectedCoins);
        GameDatas.EndGameMessage = endString;
        GameDatas.SaveData();

        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex - 1);
    }
示例#9
0
 public static void Load()
 {
     if (HasSave())
     {
         FileStream file = File.Open(Application.persistentDataPath + "/ColorWarrior.save", FileMode.Open);
         Game = (GameDatas)(new BinaryFormatter().Deserialize(file));
         file.Close();
     }
 }
示例#10
0
 private void InitOther()
 {
     gGameData      = new GameDatas();
     gMsgDispatcher = new MsgDispatcher();
     gSystemMgr     = new SystemMgr();
     gResMgr        = new ResEditorMgr();
     gUiMgr         = new UiMgr();
     gGameCtrl      = new GameCtrl();
     gTimerMgr      = new TimerMgr();
     gGameAdapter   = new GameAdapterUtils();
 }
示例#11
0
    public void UnlockButtonAction()
    {
        if (GameDatas.HasAbility(selectedAbility.parentAbility) && GameDatas.BankAccount >= selectedAbility.cost)
        {
            GameDatas.SetAbility(selectedAbility.type, true);
            GameDatas.SpendMoney(selectedAbility.cost);

            UpdateAccounts();
            OnAbilityUnlock?.Invoke(selectedAbility.type);
        }
    }
示例#12
0
    public static void Load()
    {
        if (File.Exists(Application.persistentDataPath + "/datasInfo.gd"))
        {
            BinaryFormatter bf       = new BinaryFormatter();
            FileStream      dataFile = File.Open(Application.persistentDataPath + "/datasInfo.gd", FileMode.Open);

            gameDatas = (GameDatas)bf.Deserialize(dataFile);
            dataFile.Close();
        }
    }
示例#13
0
    private void Start()
    {
        //gets instances
        ui         = gameObject.AddComponent <Ui>() as Ui;
        mainCanvas = FindObjectOfType(typeof(Canvas)) as Canvas;

        //get datas saved
        SaveLoad.Load();
        gameDatas = SaveLoad.gameDatas;

        InitialProgressBarSettings();
        SpecifyFirstAndLastColorsOfProgressBar();
        PrintBestScore();
    }
示例#14
0
    // Start is called before the first frame update
    void Start()
    {
        coinCollector = FindObjectOfType <CoinCollector>();
        coinCollector.AddListenerOnCoinCollectedEvent(ChangeCoinText);

        carController = FindObjectOfType <CarController>();
        carController.AddListenerOnPickUpFareEvent(ChangeFareImageColor);
        carController.AddListenerOnTransferFareEvent(ChangeFareImageColor);

        stash = GameDatas.GetStash();
        ChangeCoinText(0);

        SetFareImages();
    }
示例#15
0
    public override void Going(float carSpeed)
    {
        Vector3 speed = carController.transform.forward * carSpeed * GameDatas.GetCarSpeedMultiplier();

        speed -= carController.transform.right * laneShiftingSpeed;

        carController.SetCarVelocity(speed);

        float goalLanePos = GetLanePosition();

        if (Mathf.Abs(carController.transform.position.x - goalLanePos) < laneTolerance)
        {
            carController.TransitionState(carController.straightState);
        }
    }
示例#16
0
    void SpawnLevelPart()
    {
        Vector3 position = new Vector3(-1.5f * tileSize, 0, levelPartCount * tileSize);

        Instantiate(levelPartPrefab, position, Quaternion.identity, this.transform);

        if (levelPartCount >= 8)
        {
            SpawnItemOnGround();
        }

        if (GameDatas.HasAbility(AbilityType.FARE_BLUE))
        {
            SpawnFare(position);
        }

        levelPartCount++;
    }
示例#17
0
        public override void LoadAssets()
        {
            Task.Factory.StartNew(() =>
            {
                if (!Directory.Exists(GAMEDATA_PATH))
                {
                    Logger.Get <GameContext>().LogCritical($"GameData not found, please provide GameData in directory {GAMEDATA_PATH} first.");
                }
                else
                {
                    var startTime       = Environment.TickCount;
                    GameDatas           = GameDatas.FromPath(GAMEDATA_PATH);
                    CompressedGameDatas = WPDUtil.ZipToBase64(GameDatas.SerializeBase64String());
                    var timeDiff        = Environment.TickCount - startTime;

                    Logger.Get <GameContext>().LogInformation($"GameData has been loaded in {timeDiff} ms.");
                }
            });
        }
示例#18
0
 public static float GetCarSpeedMultiplier()
 {
     if (GameDatas.HasAbility(AbilityType.SPEED_175))
     {
         return(1.75f);
     }
     else if (GameDatas.HasAbility(AbilityType.SPEED_150))
     {
         return(1.5f);
     }
     else if (GameDatas.HasAbility(AbilityType.SPEED_125))
     {
         return(1.25f);
     }
     else
     {
         return(1.0f);
     }
 }
示例#19
0
    // Start is called before the first frame update
    void Start()
    {
        levelPartCount = 0;
        xPosition      = 0;

        fareDistance = GameDatas.GetFareDistance();
        hasBlueFare  = false;
        hasRedFare   = false;
        hasGreenFare = false;

        DestroyerManager dm = FindObjectOfType <DestroyerManager>();

        dm.AddListenerOnGroundHitEvent(SpawnLevelPart);

        for (int i = 0; i < startPartCount; i++)
        {
            SpawnLevelPart();
        }
    }
示例#20
0
        public async Task Refresh()
        {
            await Task.Run(() => SteamAPI.Refresh());

            var games = SteamAPI.Games.Values
                        .Select(o => new GameData(o.Id)
            {
                IsInstalled = o.IsInstalled, Name = o.Name, SquareDraft = o.Banner.Value
            })
                        .OrderBy(o => o.IsInstalled ? 0 : 1)
                        .ThenBy(o => o.Name)
                        .Select(o => new GameDataViewModel(o, _tileCreator, SteamAPI))
                        .ToList();

            var oldSelection = SelectedGameData?.GameModel?.GameID;

            GameDatas.ReplaceAndResetCollection(games);

            SelectedGameData = GameDatas.Where(o => o.GameModel.GameID == oldSelection).FirstOrDefault();
        }
示例#21
0
    FareColor GetRandomColor()
    {
        int endRange  = GameDatas.HasAbility(AbilityType.FARE_GREEN) ? 3 : GameDatas.HasAbility(AbilityType.FARE_RED) ? 2 : 1;
        int randomInt = Random.Range(0, endRange);

        switch (randomInt)
        {
        case 0:
            return(FareColor.BLUE);

        case 1:
            return(FareColor.RED);

        case 2:
            return(FareColor.GREEN);

        default:
            return(FareColor.BLUE);
        }
    }
示例#22
0
    void SetFareImages()
    {
        blueFare.gameObject.SetActive(false);
        redFare.gameObject.SetActive(false);
        greenFare.gameObject.SetActive(false);

        if (GameDatas.HasAbility(AbilityType.FARE_BLUE))
        {
            blueFare.gameObject.SetActive(true);
            blueFare.sprite = grayFareSprite;
        }
        if (GameDatas.HasAbility(AbilityType.FARE_RED))
        {
            redFare.gameObject.SetActive(true);
            redFare.sprite = grayFareSprite;
        }
        if (GameDatas.HasAbility(AbilityType.FARE_GREEN))
        {
            greenFare.gameObject.SetActive(true);
            greenFare.sprite = grayFareSprite;
        }
    }
示例#23
0
    private void Start()
    {
        //gets instances
        gameEnvironmentSetUp = gameObject.AddComponent <GameEnvironmentSetUp>() as GameEnvironmentSetUp;
        touchControlManager  = TouchControlManager.Instance;

        //gets datas saved
        SaveLoad.Load();
        gameDatas = SaveLoad.gameDatas;

        WholePlatform = new GameObject("wholePlatform");

        PlatformCount = gameDatas.PlatformCount;

        //get harder point settings
        firstGetHarderPoint  = (PlatformCount * 25) / 100;
        secondGetHarderPoint = (PlatformCount * 50) / 100;
        thirdGetHarderPoint  = (PlatformCount * 75) / 100;

        PlatformSetUp();
        MakeControlPointForARing();
    }
示例#24
0
        public async Task Refresh()
        {
            GameDatas.SuspendCollectionChanged = true;
            var games = Task.Run <IEnumerable <GameData> >(() =>
            {
                return(AllOwnedGames.GetGames(UserData.SteamCommunityId)
                       .Select(o => new GameData(o))
                       .OrderBy(o => o.Installed ? 0 : 1)
                       .ThenBy(o => o.Name)
                       .ToList());
            });

            GameDatas.Clear();

            foreach (var game in (await games))
            {
                GameDatas.Add(game);
                game.SaveToCache();
            }
            GameDatas.SuspendCollectionChanged = false;
            GameDatas.RefreshBinding();
        }
示例#25
0
            public DB MakeDB()
            {
                try { System.IO.Directory.Delete(DBAddress, true); } catch { }

                MakeDB(ref SimpleDatas, "KeyValueDatas", (c) => c.Name);

                MakeDB(ref Groups, "Groups", (c) => c.Name);
                (Groups.Relation((c) => c.GroupParents, (c) => c.IsUpdateAble = ISUpdateAble),
                 Groups.Relation((c) => c.GroupChilds, (c) => c.IsUpdateAble = ISUpdateAble)).Join();

                MakeDB(ref Products, "Products", (c) => c.ProductName);
                (Products.Relation((c) => c.GroupParents, (c) => c.IsUpdateAble = ISUpdateAble),
                 Groups.Relation((c) => c.ProductChilds, (c) => c.IsUpdateAble = ISUpdateAble)).Join();

                MakeDB(ref GameDatas, "GameDatas", (c) => (string)c.Product.Key);
                (GameDatas.Relation((c) => c.Product, (c) => c.IsChild = true),
                 Products.Relation((c) => c.Game, (c) => c.IsUpdateAble = ISUpdateAble)).Join();

                MakeDB(ref GameImages, "GameImages", (c) => (string)c.Product.Key);
                (GameImages.Relation((c) => c.Product, (c) => c.IsChild = true),
                 Products.Relation((c) => c.Image, (c) => c.IsUpdateAble = ISUpdateAble)).Join();

                return(this);
            }
示例#26
0
    private void Start()
    {
        //gets instances
        uiManager            = UiManager.Instance;
        gameManager          = GameManager.Instance;
        gameEnvironmentSetUp = gameObject.AddComponent <GameEnvironmentSetUp>() as GameEnvironmentSetUp;
        touchControlManager  = TouchControlManager.Instance;
        levelSettings        = gameObject.AddComponent <LevelSettings>();
        gameDatas            = new GameDatas();

        //get datas that is saved
        SaveLoad.Load();
        BestScore     = SaveLoad.gameDatas.BestScore;
        LevelCount    = SaveLoad.gameDatas.LevelCount;
        platformCount = SaveLoad.gameDatas.PlatformCount;

        targetForCamera = GameObject.FindWithTag("targetForCamera");
        mainCanvas      = FindObjectOfType(typeof(Canvas)) as Canvas;

        //calculates initial distance between ball and targetForCamera object
        targetOffset = targetForCamera.transform.position - transform.position;

        bestScoreObject = mainCanvas.transform.Find("bestScore").gameObject;
    }
示例#27
0
 void AddFarePrice(FareColor color)
 {
     CollectCoin(GameDatas.GetFarePrice());
 }
示例#28
0
 public void QuitButtonAction()
 {
     GameDatas.SaveData();
     Application.Quit();
 }
示例#29
0
    public void PlayGameButtonAction()
    {
        GameDatas.SaveData();

        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
    }
示例#30
0
 private void Awake()
 {
     GameDatas.LoadData();
 }