Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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();
        }
Exemplo n.º 3
0
    private void Awake()
    {
        mScene = GetComponentInParent <SubScene>();

        if (mScene == null)
        {
            Debug.Log("Scene cannot be null");
            return;
        }

        mScene.GetServiceManager().RegisterService(ApplicationConstants.SERVICE_CAMERA_CONTROLLER, this);
    }
Exemplo n.º 4
0
        void SetConfigurationInBuilder(Level level)
        {
            //get builder from
            IBuilder builder = mScene.GetServiceManager().GetService <LocalLevelBuilder_v2>(ApplicationConstants.SERVICE_LOCAL_LEVEL_BUILDER);

            if (builder == null)
            {
                Debug.Log("Builder cannot be null");
                return;
            }

            Dictionary <string, TilePainter> configMap = new Dictionary <string, TilePainter>();

            foreach (ColorToTilePainter ctt in level.GetColorToTileMap())
            {
                configMap.Add(ColorUtility.ToHtmlStringRGB(ctt.GetColor()).ToLower(), ctt.GetTilePainter());
            }

            //set builder new configuration
            builder.SetColorToTileDataDictionaryConfig(configMap);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
    // 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);
        });
    }
Exemplo n.º 7
0
 private void OnDestroy()
 {
     mScene.GetServiceManager().UnRegisterService(ApplicationConstants.SERVICE_LOCAL_LEVEL_BUILDER, this);
 }