예제 #1
0
    public override void OnContext(System.Object context)
    {
        base.OnContext(context);

        collisionProcessor = new CollisionProcessor();

        GameObject voxelCharacter = GameObject.Instantiate(ResourceManager.Instance.LoadAsset <UnityEngine.Object> ("Characters/VoxelGirl/MainCharacter")) as GameObject;

        if (voxelCharacter == null)
        {
            QLogger.LogErrorAndThrowException("VoxelGirl is not instantiated");
        }

        // Main.Instance.uIManager = uiManagerGo.GetComponent<UIManager>();
        // if ( Main.Instance.uIManager == null ) QLogger.LogErrorAndThrowException ( "UiManager script was not instantiated");

        player = new iPlayer();
        CharacterController controller = new CharacterController();

        controller.Init(voxelCharacter, player);
        WeaponController weaponController = new WeaponController();

        player.Init(controller, weaponController);

        CollisionListener playerCollisionListener = voxelCharacter.GetComponentInChildren <CollisionListener>();

        Core.QLogger.Assert(playerCollisionListener != null);
        playerCollisionListener.Init(collisionProcessor.ProcessCollision, player);


        cameraScript = GameObject.Find("ThirdPersonCamera").GetComponent <ThirdPersonCamera>();
        cameraScript.SetCharacterToFollow(voxelCharacter.transform);


        player.EquipWeapon(eInventoryItem.Pistol);

        Core.Updater.Instance.FixedUpdater += FixedUpdate;
        Core.Updater.Instance.LateUpdater  += LateUpdate;
    }