private void OnCollectedFreeze(string arg1, ActionParams arg2) { m_Scene.GetEventManager().RemoveListenerFromEvent(ApplicationConstants.EVENT_PLAYER_COLLECTED_FREEZE, OnCollectedFreeze); m_Scene.GetEventManager().ListenToEvent(ApplicationConstants.EVENT_FREEZE_OVER, OnFreezeOver); SetWorldSpeed(0); }
void Start() { m_Scene = gameObject.GetComponentInParent <SubScene>(); m_Scene.SetScore(this); mPowerUpIcon.gameObject.SetActive(false); m_Scene.GetEventManager().ListenToEvent(ApplicationConstants.EVENT_PLAYER_COLLECTED_BOOSTER, IncreaseBoosterByAmount); m_Scene.GetEventManager().ListenToEvent(ApplicationConstants.EVENT_PLAYER_COLLECTED_COIN, IncreaseCoinsByAmount); }
public void SwipeDetectorHandle(SwipeData data) { //text.text = "SwipeDetector_OnSwipe"; int selectedSubScene = GetSelectedScene(data.StartPosition); SubScene subscene = GameManager.GetInstance().GetSubScene(selectedSubScene); if (subscene == null) { Debug.Log("subscene not found, check your selectedSubScene index"); return; } SceneEventManager eventManager = subscene.GetEventManager(); if (eventManager == null) { Debug.Log("eventManager not found in scene"); return; } if (data.Direction.Equals(SwipeDirection.Down)) { //eventManager.SwipeDownEvent(); eventManager.CallEvent(ApplicationConstants.EVENT_IO_SWIPE_DOWN, ActionParams.EmptyParams); } if (data.Direction.Equals(SwipeDirection.Tap)) { //eventManager.SwipeUpEvent(); eventManager.CallEvent(ApplicationConstants.EVENT_IO_TAP, ActionParams.EmptyParams); //eventManager.SwipeUpEvent(); //eventManager.CallEvent("onSwipeUpEvent"); } }
private void Start() { //TODO move this to global //-- Load all Rule Tiles into an array, at this point it is only raw data UnityEngine.Object[] RuleTiles = Resources.LoadAll("RuleTile/", typeof(RuleTile)); //-- Insert them into a dictionary foreach (UnityEngine.Object ruleTile in RuleTiles) { if (!ruleTile || !(ruleTile is RuleTile)) { throw new System.Exception("Resource loading has failed!"); } ruleTiles.Add(ruleTile.name, (RuleTile)ruleTile); } mScene = GetComponentInParent <SubScene>(); if (mScene == null) { Debug.Log("Scene cannot be null"); return; } mScene.SetLocalLevelBuilder(this); mScene.GetServiceManager().RegisterService(ApplicationConstants.SERVICE_LOCAL_LEVEL_BUILDER, this); //ActionParams actionParams = new ActionParams(); //actionParams.Put("ref", this); mScene.GetEventManager().CallEvent(ApplicationConstants.BUILDER_IS_INITIALIZED, ActionParams.EmptyParams); mIsLoaded = true; //mDependencyLoader.Run(); }
private void Start() { Debug.unityLogger.Log(TAG, "Start()"); mScene = GetComponentInParent <SubScene>(); if (mScene == null) { Debug.Log("Scene cannot be null"); return; } //mScene.SetLocalLevelBuilder(this); //ActionParams actionParams = new ActionParams(); //actionParams.Put("ref", this); mScene.GetEventManager().CallEvent(ApplicationConstants.BUILDER_IS_INITIALIZED, ActionParams.EmptyParams); mPlayer = mScene.GetPlayer(); mScene.GetServiceManager().RegisterService(ApplicationConstants.SERVICE_LOCAL_LEVEL_BUILDER, this); }
void Init() { mSubScene.GetEventManager().ListenToEvent(ApplicationConstants.EVENT_PLAYER_COLLECTED_MAGNET, ActivateMagnet); mSubScene.GetEventManager().ListenToEvent(ApplicationConstants.EVENT_PLAYER_COLLECTED_FREEZE, ActivateFreeze); mSubScene.GetEventManager().ListenToEvent(ApplicationConstants.EVENT_PLAYER_COLLECTED_SPEED, ActivateSpeed); mSubScene.GetEventManager().ListenToEvent(ApplicationConstants.EVENT_PLAYER_COLLECTED_DOUBLECASH, ActivateDoubleCash); mSubScene.GetEventManager().ListenToEvent(ApplicationConstants.EVENT_PLAYER_COLLECTED_SHIELD, ActivateShield); mSubScene.GetEventManager().ListenToEvent(ApplicationConstants.EVENT_PLAYER_COLLECTED_HEALTH, ActivateHealth); }
public virtual void Init() { m_Scene = gameObject.GetComponentInParent(typeof(SubScene)) as SubScene; if (m_Scene == null) { throw new System.Exception("Object must be attached to a specific scene!"); } float speed = m_Scene.GetWorldSpeed(); SetWorldSpeed(speed); worldIndex = m_Scene.GetIndex(); LocalPowerUpManager localPowerUpManager = m_Scene.GetLocalPowerUpManager(); PowerUpManager.PowerUpEffect effect = m_Scene.GetLocalPowerUpManager().GetActivatedPowerUp(); ActionParams actionParams = localPowerUpManager.GetActionParams(); if (effect.Equals(PowerUpManager.PowerUpEffect.Speed)) { OnCollectedSpeed("", actionParams); } else if (effect.Equals(PowerUpManager.PowerUpEffect.Freeze)) { //Nothing is supposed to be created during freeze but just in case OnCollectedFreeze("", actionParams); } //mPowerUpHandler = PowerUpHandlerBase.powerUpDefaultHandler; //Listen to events m_Scene.GetEventManager().ListenToEvent(ApplicationConstants.EVENT_PLAYER_DIE_BY_HIT, OnGameOver); m_Scene.GetEventManager().ListenToEvent(ApplicationConstants.EVENT_PLAYER_COLLECTED_SPEED, OnCollectedSpeed); m_Scene.GetEventManager().ListenToEvent(ApplicationConstants.EVENT_PLAYER_COLLECTED_FREEZE, OnCollectedFreeze); }
//private GroundObject mForeground; private void Start() { //--Register as game cinematics in scene subScene = GetComponentInParent <SubScene>(); subScene.SetGameCinematics(this); mPlayerTransform = player.transform; //mForeground = foreground.GetComponent<GroundObject>(); DOTween.Init(); PlayStartCinematics(); //--Listen to events subScene.GetEventManager().ListenToEvent(ApplicationConstants.EVENT_PLAYER_DIE_BY_HIT, PlayDeathByHitCinematics); }
public void PlayDeathByHitCinematics(string eventName, ActionParams actionParams) { Debug.Log("game over cinematics"); subScene.GetEventManager().RemoveListenerFromEvent(ApplicationConstants.EVENT_PLAYER_DIE_BY_HIT, PlayDeathByHitCinematics); camera.DOMoveX(-10, 4) .SetEase(Ease.OutCubic) .OnComplete(() => { GameEventManager.Instance.CallEvent(ApplicationConstants.EVENT_CINEMATIC_DEATH_BY_HIT_OVER, ActionParams.EmptyParams); //CommonRequests.RequestGameOver(); }); wolf_1.DOMoveX(-17.5f, 2); wolf_2.DOMoveX(-12.1f, 2f).OnComplete(() => wolf_2.localScale = new Vector3(-1, 1, 0)); }
private void Start() { //reset current level mCurrentLevel = 0; //get scene mScene = GetComponentInParent <SubScene>(); //get current level from data Level currentLevel = mLevels[mCurrentLevel]; //spawn a background for the game mCurrentBackground = ObjectPoolManager.Instance.Spawn(currentLevel.GetBackground().name, mScene.transform.position + new Vector3(0, 0, 10)); //set it to be a child of scene mCurrentBackground.transform.parent = mScene.transform; //spawn a foreground for the game mCurrentForeground = ObjectPoolManager.Instance.Spawn(currentLevel.GetForeground().name, mScene.transform.position + new Vector3(0, -15.68f, 5), mScene.transform); //set it to be a child of scene mCurrentForeground.transform.parent = mScene.transform; mScene.GetServiceManager().CallActionWhenServiceIsLive(ApplicationConstants.SERVICE_LOCAL_LEVEL_BUILDER, () => { SetConfigurationInBuilder(currentLevel); }); //mScene.GetEventManager().ListenToEvent(ApplicationConstants.BUILDER_IS_INITIALIZED, (string arg1, ActionParams arg2) => { // SetConfigurationInBuilder(currentLevel); //}); //mScene.GetEventManager(). mScene.GetEventManager().ListenToEvent(ApplicationConstants.EVENT_CHANGE_TO_NEXT_WORLD, ChangeToNextLevel); }
// Start is called before the first frame update void Start() { _stateMachine = new StateMachine(); mStandCollider = transform.Find("Stand Collider").gameObject; mSlideCollider = transform.Find("Slide Collider").gameObject; mPlatformCollider = transform.Find("Platform Collider").gameObject; //ColliderBridge cb = mPlatformCollider.AddComponent<ColliderBridge>(); //cb.Initialize(this); //This supposed to fix the raycast issue Physics2D.queriesStartInColliders = false; collider = GetComponent <Collider2D>(); run = new RunningState(this, _stateMachine); //charge = new ChargingState(this, _stateMachine); jump = new JumpingState(this, _stateMachine); descend = new DescendingState(this, _stateMachine); ultraJump = new UltraJumpState(this, _stateMachine); powerDescend = new PowerDescendState(this, _stateMachine); slide = new SlideState(this, _stateMachine); die = new DyingState(this, _stateMachine); mRigidBody2D = GetComponent <Rigidbody2D>(); //AudioManager.instance.PlayMusicInLoop("footsteps"); worldIndex = m_Scene.GetIndex(); mScore = m_Scene.GetScore(); isShieldActive = false; mIsDead = false; //PlayerMovementManager.SetInstance(worldIndex, this); mPlayerSprite = gameObject.GetComponentInChildren <PlayerSprite>(); mAnimator = GetComponentInChildren <Animator>(); //DontDestroyOnLoad(mAnimator); mAnimator.SetInteger("State", (int)PlayerAnimation.PlayerRunning); _stateMachine.Initialize(run); //--Sign as a listener to swipe down event m_Scene.GetEventManager().ListenToEvent(ApplicationConstants.EVENT_IO_SWIPE_DOWN, Instance_onSwipeDownEvent); m_Scene.GetEventManager().ListenToEvent(ApplicationConstants.EVENT_IO_TAP, Instance_onSwipeUpEvent); m_Scene.GetEventManager().ListenToEvent(ApplicationConstants.EVENT_PLAYER_COLLECTED_FREEZE, OnCollectedFreeze); m_Scene.GetEventManager().ListenToEvent(ApplicationConstants.EVENT_PLAYER_COLLECTED_SHIELD, OnCollectedShield); m_Scene.GetServiceManager().CallActionWhenServiceIsLive(ApplicationConstants.SERVICE_LOCAL_LEVEL_BUILDER, () => { mLocalLevelBuilder = m_Scene.GetServiceManager().GetService <LocalLevelBuilder_v2>(ApplicationConstants.SERVICE_LOCAL_LEVEL_BUILDER); }); }