{"id":15388525,"url":"https://github.com/deebloo/unityflux","last_synced_at":"2026-01-30T07:11:26.527Z","repository":{"id":71870517,"uuid":"49902970","full_name":"deebloo/UnityFlux","owner":"deebloo","description":null,"archived":false,"fork":false,"pushed_at":"2023-12-15T05:23:08.000Z","size":6818,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-12T07:53:48.375Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"ASP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/deebloo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-01-18T20:24:40.000Z","updated_at":"2016-01-18T20:27:44.000Z","dependencies_parsed_at":"2023-12-15T06:42:41.948Z","dependency_job_id":null,"html_url":"https://github.com/deebloo/UnityFlux","commit_stats":{"total_commits":11,"total_committers":1,"mean_commits":11.0,"dds":0.0,"last_synced_commit":"bc52c78bb633dc576df3c17654d54c0905569b5b"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deebloo%2FUnityFlux","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deebloo%2FUnityFlux/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deebloo%2FUnityFlux/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deebloo%2FUnityFlux/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deebloo","download_url":"https://codeload.github.com/deebloo/UnityFlux/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247423492,"owners_count":20936622,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-01T14:57:06.197Z","updated_at":"2026-01-30T07:11:21.504Z","avatar_url":"https://github.com/deebloo.png","language":"ASP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# UnityFlux\n\nUse flux pattern with Unity from the RollABall tutorial level.\n\n### Actions\n```C#\npublic static class Actions {\n  // Create Score updated delegate and event\n  public delegate int ScoreUpdateAction();\n  public static event ScoreUpdateAction OnScoreUpdateAction;\n  \n  // Update the score\n  public static void UpdateScore() {\n  \tif(OnScoreUpdateAction != null) {\n  \t\t// Fire the OnScoreUpdateAction event\n  \t\tOnScoreUpdateAction ();\n  \t}\n  }\n}\n\n```\n\n### Store\n```C#\npublic static class ScoreStore {\n\t// private model\n\tprivate static int score;\n\t\n\t// This stores delegate and event\n\tpublic delegate void ScoreUpdated(int score);\n\tpublic static event ScoreUpdated OnScoreUpdated;\n\t\n\t// Set default score to 0 and add method to OnScoreUpDateAction event\n\tstatic ScoreStore () {\n\t\tscore = 0;\n\n\t\tActions.OnScoreUpdateAction += updateScore;\n\t}\n\n\t// increment the score by one and fire the OnScoreUpdated event.\n\tprivate static int updateScore() {\n\t\tscore++;\n\t\t\n\t\t// Fire the OnScoreUpdated event\n\t\tif(OnScoreUpdated != null) {\n\t\t\tOnScoreUpdated (score);\n\t\t}\n\n\t\treturn score;\n\t}\n\n\t// returns the score value;\n\tpublic static int getScore() {\n\t\treturn score;\n\t}\n}\n```\n\n### PlayerController\n```C#\n...\npublic class PlayerController : MonoBehaviour {\n  ...\n\t\n\t// update the score and desactivate collectables\n\tvoid OnTriggerEnter(Collider other) {\n\t\tif(other.gameObject.CompareTag(\"Pickup\")) {\n\t\t\tother.gameObject.SetActive (false);\n\t\t\t\n\t\t\tActions.UpdateScore();\n\t\t}\n\t}\n}\n```\n\n### ScoreBoardController\n```C#\n...\npublic class ScoreBoardController : MonoBehaviour {\n\tprivate Text scoreBoard;\n\n\t// Use this for initialization\n\tvoid Start () {\n\t\tscoreBoard = GetComponent\u003cText\u003e ();\n\t\tsetCountText (ScoreStore.getScore());\n\t}\n\n\tvoid OnEnable () {\n\t\tScoreStore.OnScoreUpdated += setCountText;\n\t}\n\n\tvoid OnDisable () {\n\t\tScoreStore.OnScoreUpdated -= setCountText;\n\t}\n\n  // Update text when score is updated\n\tvoid setCountText (int score) {\n\t\tscoreBoard.text = \"Score: \" + score.ToString();\n\n\t\tif(score \u003e= 5) {\n\t\t\tscoreBoard.text = \"You Win!\";\n\t\t}\n\t}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeebloo%2Funityflux","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeebloo%2Funityflux","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeebloo%2Funityflux/lists"}