/// <summary>
  /// Performs initialization of Leap Interaction.
  /// </summary>
  public void Initialize () {
    clientUnitLengthInMillimeters = MM_PER_M / transform.localScale.x;
    ReferenceObject = GetComponent<HandController>();

    m_scene = new Scene ();
    Scene.ClientUnitLengthInMillimeters = clientUnitLengthInMillimeters;
    PositionCamera();

    m_scene.RunCollisionDetection = EnableInteractionCollisions;
    m_scene.ResolveCollisions = true; //EnableInteractionCollisions;
    m_scene.AlwaysRunCollisionForHandsVsHeldObjects = true;
    
    m_scene.HandDistanceMultiplier = 1.0f;
    m_scene.DestroyClustersWhileNotHolding = true;
    
    // Don't create update the hand from the interact dll
    m_scene.UseBodyCallbacks = ShowInteractionHands;
    m_scene.UseHoldingCallbacks = true;
    
    // Start internal visualizer
    if (ShowVisualizer) { m_scene.OpenVisualDebgger (); }

    m_scene.AllowPinchWithAnyFinger = AllowPinchWithAnyFinger;
    m_scene.DisableHoldingOnPointingIndexFinger = DisableHoldingOnPointingIndexFinger;

    m_unityUtil = new UnityUtil (m_scene);
    m_unityUtil.InitLeap ();

    UnityUtil.LayerForHands = LayerForHands;
    UnityUtil.LayerForHeldObjects = LayerForHeldObjects;
    UnityUtil.LayerForReleasedObjects = LayerForReleasedObjects;

    // Optional: Initializatio of holding callbacks.
    // m_scene.OnHoldingHoverOver += OnHoldingHovers;
    // m_scene.OnHoldingStarts += OnHoldingStarts;
    m_scene.OnHoldingUpdates += DisableHandCollisions;
    m_scene.OnHoldingEnds += EnableHandCollisions;
  }
예제 #2
0
 /// <summary>
 /// Register repositories
 /// </summary>
 /// <param name="container">The Unity container</param>
 private void RegisterRepositories(IUnityContainer container)
 {
     UnityUtil.RegisterType <IExportImportRepository, BusinessRepository.SourceCodeRepository <Models.SourceCode> >(container, "tusourcecode", new InjectionConstructor(typeof(Context)));
     UnityUtil.RegisterType(container, typeof(Interfaces.BusinessRepository.ISourceCodeEntity <Models.SourceCode>), typeof(BusinessRepository.SourceCodeRepository <Models.SourceCode>), UnityInjectionType.Default, new InjectionConstructor(typeof(Context)));
     UnityUtil.RegisterType(container, typeof(Interfaces.BusinessRepository.ISourceCodeEntity <Models.SourceCode>), typeof(BusinessRepository.SourceCodeRepository <Models.SourceCode>), UnityInjectionType.Session, new InjectionConstructor(typeof(Context), typeof(IBusinessEntitySession)));
 }
예제 #3
0
 public void OnQuitGame()
 {
     UnityUtil.Quit();
 }
예제 #4
0
 /// <summary>
 /// Register services
 /// </summary>
 /// <param name="container">The Unity container</param>
 private void RegisterService(IUnityContainer container)
 {
     UnityUtil.RegisterType <Interfaces.Services.ISourceCodeService <Models.SourceCode>, SourceCodeEntityService <Models.SourceCode> >(container);
 }
예제 #5
0
    private void Update()
    {
        float             b = 0.2f;
        AnimatorStateInfo currentAnimatorStateInfo  = this.playerAnimator.GetCurrentAnimatorStateInfo(1);
        AnimatorStateInfo currentAnimatorStateInfo2 = this.playerAnimator.GetCurrentAnimatorStateInfo(2);

        if (currentAnimatorStateInfo.shortNameHash == this.toIdleHash)
        {
            if (!this.netPrefab)
            {
                LocalPlayer.Animator.SetLayerWeightReflected(3, 0f);
            }
            if (currentAnimatorStateInfo.normalizedTime > 0.5f)
            {
                b = 7f;
            }
            if (!this.netPrefab)
            {
                if (LocalPlayer.Stats.Fuel.CurrentFuel > 0f)
                {
                    this.chainSawAnimator.CrossFade("Base Layer.toIdle", 0f, 0, currentAnimatorStateInfo.normalizedTime);
                }
            }
            else if (this.playerAnimator.GetFloat("fuel") > 0.1f)
            {
                this.chainSawAnimator.CrossFade("Base Layer.toIdle", 0f, 0, currentAnimatorStateInfo.normalizedTime);
            }
            if (!this.netPrefab)
            {
                this.playerAnimator.SetBool("cancelCheckArms", true);
                this.playerAnimator.SetBool("checkArms", false);
            }
            this.syncIdle = true;
        }
        else
        {
            this.syncIdle = false;
            if (!this.netPrefab)
            {
                this.playerAnimator.SetBool("cancelCheckArms", false);
            }
        }
        if (this.active)
        {
            if (currentAnimatorStateInfo2.shortNameHash == this.sawTreeHash || currentAnimatorStateInfo.shortNameHash == this.sawAttackHash)
            {
                if (Time.time > this.attackTimer && !this.netPrefab)
                {
                    if (this.sawCollider.enabled)
                    {
                        this.sawCollider.enabled = false;
                        if (this.mainCollider)
                        {
                            this.mainCollider.enabled = true;
                        }
                    }
                    else
                    {
                        this.sawCollider.enabled = true;
                        if (this.mainCollider)
                        {
                            this.mainCollider.enabled = false;
                        }
                    }
                    if (currentAnimatorStateInfo.shortNameHash == this.sawAttackHash)
                    {
                        this.attackTimer = Time.time + 0.25f;
                    }
                    else
                    {
                        this.attackTimer = Time.time + 0.05f;
                    }
                }
                b = 7f;
            }
            else
            {
                if (!this.netPrefab)
                {
                    this.sawCollider.enabled = false;
                }
                if (this.mainCollider)
                {
                    this.mainCollider.enabled = false;
                }
            }
            if (currentAnimatorStateInfo.shortNameHash == this.idleHash || currentAnimatorStateInfo.shortNameHash == this.toIdleHash)
            {
                if (this.netPrefab && this.netActive)
                {
                    this.AffirmEventStarted();
                }
                else if (!this.netPrefab)
                {
                    this.AffirmEventStarted();
                }
            }
            if (this.eventInstance != null)
            {
                if (currentAnimatorStateInfo2.shortNameHash == this.sawTreeHash || currentAnimatorStateInfo2.shortNameHash == this.toSawTreeHash || currentAnimatorStateInfo.shortNameHash == this.sawAttackHash || currentAnimatorStateInfo.shortNameHash == this.toSawAttackHash)
                {
                    if (!this.cuttingObject)
                    {
                        this.SetCuttingParameter(0.5f);
                    }
                    if (this.cuttingObject)
                    {
                        this.SetCuttingParameter(0.8f);
                        this.setCuttingTreeParameter(0.5f);
                        if (this.cuttingFlesh)
                        {
                            this.setCuttingTreeParameter(0f);
                            this.setCuttingFleshParameter(0.5f);
                        }
                    }
                }
                else
                {
                    this.cuttingObject = false;
                    this.cuttingFlesh  = false;
                    this.cuttingTree   = false;
                    this.SetCuttingParameter(0f);
                    this.setCuttingFleshParameter(0f);
                    this.setCuttingTreeParameter(0f);
                }
                if (!this.netPrefab && TheForest.Utils.Input.GetButton("AltFire"))
                {
                    b = 8f;
                    this.SetCuttingParameter(0.8f);
                }
                UnityUtil.ERRCHECK(this.eventInstance.set3DAttributes(base.transform.to3DAttributes()));
            }
        }
        if (!this.netPrefab)
        {
            bool flag = LocalPlayer.Inventory.CurrentView == PlayerInventory.PlayerViews.World;
            if (LocalPlayer.Stats.Fuel.CurrentFuel <= 0f)
            {
                this.chainSawAnimator.SetBool("empty", true);
                b = 0f;
                if (this.active)
                {
                    this.active = false;
                    this.StopEvent();
                    this.sawCollider.enabled = false;
                    this.playerAnimator.SetFloatReflected("fuel", 0f);
                    this.playerAnimator.SetBool("attack", false);
                    this.playerAnimator.SetBool("sawAttack", false);
                    if (this.smokeGo)
                    {
                        this.smokeGo.SetActive(false);
                    }
                }
                LocalPlayer.Inventory.SetReloadDelay(1f);
                if (Scene.HudGui.FuelReserveEmpty.activeSelf != flag)
                {
                    Scene.HudGui.FuelReserveEmpty.SetActive(flag);
                }
                Scene.HudGui.FuelReserve.fillAmount = 0f;
                Mood.StopConstantVibratation();
            }
            else
            {
                if (!this.active)
                {
                    this.active = true;
                }
                this.chainSawAnimator.SetBool("empty", false);
                LocalPlayer.Inventory.CancelReloadDelay();
                if (!this.netPrefab)
                {
                    this.playerAnimator.SetFloatReflected("fuel", 1f);
                }
                if (this.smokeGo)
                {
                    this.smokeGo.SetActive(true);
                }
                if (this.mainCollider.enabled)
                {
                    LocalPlayer.Stats.Fuel.CurrentFuel -= Time.deltaTime * 3f;
                    Mood.BeginConstantVibratation(this.VibrateForceAttack, this.VibrateForceAttack);
                }
                else
                {
                    Mood.BeginConstantVibratation(this.VibrateForceIdle, this.VibrateForceIdle);
                }
                Scene.HudGui.FuelReserve.fillAmount = LocalPlayer.Stats.Fuel.CurrentFuel / LocalPlayer.Stats.Fuel.MaxFuelCapacity;
                if (Scene.HudGui.FuelReserveEmpty.activeSelf)
                {
                    Scene.HudGui.FuelReserveEmpty.SetActive(false);
                }
            }
            if (Scene.HudGui.FuelReserve.gameObject.activeSelf != flag)
            {
                Scene.HudGui.FuelReserve.gameObject.SetActive(flag);
            }
        }
        if (this.netPrefab)
        {
            if (this.playerAnimator.GetFloat("fuel") <= 0.1f)
            {
                this.chainSawAnimator.SetBool("empty", true);
                b = 0f;
                if (this.netActive)
                {
                    this.StopEvent();
                    if (this.smokeGo)
                    {
                        this.smokeGo.SetActive(false);
                    }
                    this.netActive = false;
                }
            }
            else if (!this.netActive)
            {
                if (this.smokeGo)
                {
                    this.smokeGo.SetActive(true);
                }
                this.chainSawAnimator.SetBool("empty", false);
                this.netActive = true;
            }
        }
        this.chainSpeed = Mathf.Lerp(this.chainSpeed, b, Time.deltaTime * 2f);
        this.chainSawAnimator.SetFloatReflected("chainSpeed", this.chainSpeed);
    }