Ejemplo n.º 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();
        }
Ejemplo n.º 2
0
    public void OptionsResetButtonAction()
    {
        GameDatas.BankAccount    = 0;
        GameDatas.CollectedCoins = 0;

        GameDatas.ResetAbilities();
    }
Ejemplo n.º 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");
     }
 }
Ejemplo n.º 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));
    }
Ejemplo n.º 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);
    }
Ejemplo n.º 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();
    }
Ejemplo n.º 7
0
    private void Start()
    {
        coinsCollected = 0;
        stash          = GameDatas.GetStash();

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

        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex - 1);
    }
Ejemplo n.º 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();
     }
 }
Ejemplo n.º 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();
 }
Ejemplo n.º 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);
        }
    }
Ejemplo n.º 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();
        }
    }
Ejemplo n.º 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();
    }
Ejemplo n.º 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();
    }
Ejemplo n.º 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);
        }
    }
Ejemplo n.º 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++;
    }
Ejemplo n.º 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.");
                }
            });
        }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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();
        }
    }
Ejemplo n.º 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();
        }
Ejemplo n.º 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);
        }
    }
Ejemplo n.º 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;
        }
    }
Ejemplo n.º 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();
    }
Ejemplo n.º 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();
        }
Ejemplo n.º 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);
            }
Ejemplo n.º 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;
    }
Ejemplo n.º 27
0
 void AddFarePrice(FareColor color)
 {
     CollectCoin(GameDatas.GetFarePrice());
 }
Ejemplo n.º 28
0
 public void QuitButtonAction()
 {
     GameDatas.SaveData();
     Application.Quit();
 }
Ejemplo n.º 29
0
    public void PlayGameButtonAction()
    {
        GameDatas.SaveData();

        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
    }
Ejemplo n.º 30
0
 private void Awake()
 {
     GameDatas.LoadData();
 }