コード例 #1
0
        public static void LoadLevel(int world, int level)
        {
            for (int i = 0; i < ApplicationConstants.NumberOfScenes; i++)
            {
                //--Load texture file
                Texture2D texture = Utils.LoadTextureFile("World_" + world + "/Level_" + level + "/" + i);

                //--Get bounds
                int width  = texture.width;
                int height = texture.height;

                //--convert Texture to pixel data
                Color[] colors = RenderService.RenderTextureToPixel(texture);

                //--The lambda needs to access the correct index
                int j = i;

                //--Get the service manager from scene
                ServiceManager serviceManager = SubSceneMultiton.Instance.
                                                GetInstance(i).
                                                GetServiceManager();

                //--Call upon creation of service manager to init and create the level
                serviceManager.CallActionWhenServiceIsLive(ApplicationConstants.SERVICE_LOCAL_LEVEL_BUILDER, () =>
                {
                    LocalLevelBuilder_v2 localLevelBuilder = serviceManager.
                                                             GetService <LocalLevelBuilder_v2>(ApplicationConstants.SERVICE_LOCAL_LEVEL_BUILDER);
                    localLevelBuilder.Init(world);
                    localLevelBuilder.CreateLevel(colors, width, height);
                });
            }
        }
コード例 #2
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);
        });
    }