protected override void InInit() { EventMan.AddPlayerLivesChangeListener(SetLives); EventMan.AddLevelChnageCallback(SetLevel); btnNextLevel.onClick.AddListener(NextClick); }
public void ReduceLives() { currLives--; // Debug.Log("lives left " + currLives); EventMan.OnPlayerLivesChange(currLives); }
void SetGameState(GameStates state) { if (currGameState != state) { currGameState = state; EventMan.OnGameStateChange(currGameState); } }
void SubscribeToEvents() { EventMan.AddBallDieListener(BallDied); EventMan.AddBlockHitListener(BlockHit); // EventMan.AddBlockDieListener(BlockDie); EventMan.AddBonusDieListener(BonusDie); EventMan.AddBonusCatchListener(BonusCatch); }
public void StartLevel() { PrepareInitialObjects(); currLevel = -1; EventMan.OnGameStart(); MoveToNextLevel(); }
void LevelComplete() { if (GameMan.instance.GetMapParser().isLastLevel(currLevel)) { EventMan.OnGameEnded(); } else { MoveToNextLevel(); } }
private void Update() { if (Input.GetKeyDown(KeyCode.P)) { EventMan.RaiseOnReset(); // Function call to invoke event } else if (Input.GetKeyDown(KeyCode.L)) { EventMan.RaiseOnReStart(); // Function call to invoke event } }
void OnTriggerEnter2D(Collider2D col) { if (col.tag == ReusableObject.tgFloor) { EventMan.OnBonusDie(this); return; } if (col.tag == ReusableObject.tgStick) { EventMan.OnBonusCatch(this); return; } }
// static float m_Scale; // public static float GetScale(){ // return m_Scale; // } public void Init() { EventMan.AddGameStateChangeListener(GameStateChange); InitWindows(); // Debug.Log("Screen " + Screen.width + " . " + Screen.height); // Debug.Log("RTrs " + m_RectTransform.sizeDelta.x + " / " + m_RectTransform.sizeDelta.y); // Debug.Log("scale " + m_RectTransform.localScale); // m_Scale = m_RectTransform.localScale.x; OpenWindow(WinViewBase.WinType.Menu); }
void Start() { instance = this; itemMan = new ItemMan(); dataLoader = new DataLoader(); player = new Player(); EventMan.AddGameStartListener(GameStarted); EventMan.AddGameEndedListener(GameEnded); onDataLoaded(); guiMan.Init(); }
void BallDied(BallVis vis) { var player = GameMan.instance.GetPlayer(); player.ReduceLives(); if (player.isAlive()) { ContinueLevel(); } else { EventMan.OnGameEnded(); } }
void InteractRay() { Ray ray = Camera.main.ViewportPointToRay(new Vector3(0.5F, 0.5F, 0)); RaycastHit hit; GameObject intPass; if (Physics.Raycast(ray, out hit)) { print("I'm looking at " + hit.transform.name); } else { print("I'm looking at nothing!"); } intPass = hit.collider.gameObject; EventMan.hasInteracted(intPass); }
// Collisions // Should I make one step back upon collision? void OnTriggerEnter2D(Collider2D col) { // Debug.Log(col.name); // on floor if (col.tag == ReusableObject.tgFloor) { EventMan.OnBallDie(this); return; } // platform if (col.tag == ReusableObject.tgStick) { moveDir.y *= -1; return; } if (col.tag == ReusableObject.tgWall) { Bounce(col); return; } //block if (col.tag == ReusableObject.tgBlock) { if (!hitBlock) { hitBlock = true; // to allow only 1 block hit per frame Bounce(col); } EventMan.OnBlockHit(col); return; } }
void Awake() { Instance = this; }