Example #1
0
    public override void Tick(float deltaTime)
    {
        for (int i = 0; i < filters.Length; i++)
        {
            // cache variables
            Filter              filter        = filters[i];
            InventoryComponent  inventoryComp = filter.inventoryComponent;
            InputComponent      inputComp     = filter.inputComponent;
            InteractorComponent interactComp  = filter.interactorComponent;


            // ----- logic -----
            if (inputComp.GetKeyDown(KeyCode.E) || inputComp.GetButtonDown("Fire1"))
            {
                isGathering = true;
            }
            else if (inputComp.GetKeyUp(KeyCode.E) || inputComp.GetButtonUp("Fire1") || isGathering == false)
            {
                //stop gather
                interactedTime = 0f;
                isGathering    = false;
                player.uiComponent.gatheringPrompt.ProgressFill(0);
            }

            if (isGathering)
            {
                AttemptWorldInteract(interactComp, player.inventoryComponent, inputComp.worldInteractMask);
                interactComp.SetInteractMode(InteractMode.Object);
            }
        }
    }
Example #2
0
    public override void Tick(float deltaTime)
    {
        for (int i = 0; i < filters.Length; i++)
        {
            // cache variables
            Filter              filter        = filters[i];
            InventoryComponent  inventoryComp = filter.inventoryComponent;
            InputComponent      inputComp     = filter.inputComponent;
            InteractorComponent interactComp  = filter.interactorComponent;
            CartComponent       cartComp      = filter.cartComponent;


            // ----- logic -----
            if (inputComp.GetKeyDown(KeyCode.E) || inputComp.GetButtonDown("Fire1"))
            {
                //if (invComp.treeResources > 0)
                //{
                //    //craftingSystem?.CraftPotion1();
                //    //craftGO.SetActive(!craftGO.activeSelf);
                //}
                AttemptWorldInteract(interactComp, player.inventoryComponent, inputComp.worldInteractMask);
                interactComp.SetInteractMode(InteractMode.Object);
            }
            if (inputComp.upDPad)
            {
                DropItem(0);
            }
            else if (inputComp.rightDPad)
            {
                DropItem(1);
            }
            else if (inputComp.downDPad)
            {
                DropItem(2);
            }
            else if (inputComp.leftDPad)
            {
                DropItem(3);
            }
        }
    }
Example #3
0
    public override void Tick(float deltaTime)
    {
        for (int i = 0; i < filters.Length; i++)
        {
            // cache variables
            Filter         filter    = filters[i];
            InputComponent inputComp = filter.inputComponent;

            // ----- logic -----
            if (inputComp.GetKeyDown(KeyCode.E) || inputComp.GetButtonDown("Fire1"))
            {
            }
            if (Input.GetButtonDown("Fire4"))
            {
                questlist.GetComponent <GroceryList>().isButtonDown = true;
            }
            if (Input.GetButtonUp("Fire4"))
            {
                questlist.GetComponent <GroceryList>().isButtonDown = false;
            }
        }
    }
Example #4
0
    public override void Tick(float deltaTime)
    {
        for (int i = 0; i < filters.Length; i++)
        {
            // cache variables
            Filter filter = filters[i];

            TorchComponent     torchC     = filter.torchComponent;
            InputComponent     inputC     = filter.inputComponent;
            InventoryComponent inventoryC = filter.inventoryComponent;

            if (inputC.GetKeyDown(KeyCode.T))
            {
                torchC.torchLight.enabled = !torchC.torchLight.enabled;
                inputC.avoidPlayer        = !inputC.avoidPlayer;
            }

            // ----- logic -----

            // activate/deactivate torch?
            // torch run out
        }
    }
    public override void Tick(float deltaTime)
    {
        for (int i = 0; i < filters.Length; i++)
        {
            // cache variables
            Filter filter = filters[i];

            InventoryComponent  invComp        = filter.inventoryComponent;
            InputComponent      inputComp      = filter.inputComponent;
            InteractorComponent interactorComp = filter.interactorComponent;
            MovementComponent   movComp        = filter.movementComponent;

            // ----- logic -----
            CheckDistanceToInteractable(filter);
            FindVisibleTargets();

            // no longer used---------------------------
            InteractMode previous = interactorComp.interactMode;
            if (inputComp.GetKeyDown(KeyCode.Alpha1))
            {
                // move set none if previous was new to SetInteractMode
                interactorComp.SetInteractMode(InteractMode.PlacingPlanks);
                if (previous == InteractMode.PlacingPlanks)
                {
                    interactorComp.SetInteractMode(InteractMode.None);
                }
            }
            else if (inputComp.GetKeyDown(KeyCode.Alpha2))
            {
                interactorComp.SetInteractMode(InteractMode.Combat);
                if (previous == InteractMode.Combat)
                {
                    interactorComp.SetInteractMode(InteractMode.None);
                }
            }
            //--------------------------------------------------

            if (inputComp.GetKeyDown(KeyCode.E) || inputComp.GetButtonDown("Fire1"))
            {
                //AttemptWorldInteract(interactorComp, player.inventoryComponent, inputComp.worldInteractMask);
                //interactorComp.SetInteractMode(InteractMode.Object);
            }
            else if (inputComp.GetKeyDown(KeyCode.Escape))
            {
                interactorComp.interactMode = InteractMode.None;
                CartComponent tc = (CartComponent)interactorComp.currentInteractable;
                if (tc)
                {
                    tc.isTraveling = true;
                }
            }

            if (Vector3.Distance(filter.gameObject.transform.position, transportableComponent.transform.position) < 6f ||
                Vector3.Distance(filter.gameObject.transform.position, travelComponent.transform.position) < 6f && lightComponent.IsLightEnabled())
            {
                goapSystem?.SetLightState(true);
            }
            else
            {
                goapSystem?.SetLightState(false);
            }

            if (Vector3.Distance(filter.gameObject.transform.position, transportableComponent.transform.position) < 3f)
            {
                if (inputComp.GetKeyDown(KeyCode.B) || inputComp.GetButtonDown("Fire3"))
                {
                    //bookGO.SetActive(!bookGO.activeSelf);
                    movComp.alive = false;
                }
                else
                {
                    movComp.alive = true;
                }

                if (inputComp.GetKeyDown(KeyCode.M) || inputComp.GetButtonDown("Fire2"))
                {
                    //mapGO.SetActive(!mapGO.activeSelf);
                }

                if (inputComp.GetKeyDown(KeyCode.E) || inputComp.GetButtonDown("Fire1"))
                {
                    //if (invComp.treeResources > 0)
                    //{
                    //    //craftingSystem?.CraftPotion1();
                    //    //craftGO.SetActive(!craftGO.activeSelf);
                    //}
                }
            }
            else
            {
                /*toggleMapGO.SetActive(false);
                 * toggleBookGO.SetActive(false);
                 * craftGO.SetActive(false);*/
            }

            isCombat      = interactorComp.interactMode == InteractMode.Combat;
            actorLocation = interactorComp.gameObject.transform.position;
            if (interactorComp.interactMode == InteractMode.PlacingPlanks)
            {
                isPlacingPlanks = true;
                if (isPlacingPlanks)
                {
                    // Don't LogWarning this unity I'm sure you have your reasons but I don't like them.
                }
                // TODO remaing at last possible location if impossible position
                plankPlaceLocation   = inputComp.GetMouseHoverTransformPosition(inputComp.objectPlaceMask);
                plankPlaceLocation.y = 0f;

                //if (inputComp.GetMouseButtonDown(0))
                //{
                //    PlacePlank(invComp);
                //}
            }
            else
            {
                isPlacingPlanks = false;
                if (inputComp.GetMouseButtonDown(0))
                {
                    inputComp.GetMouseWorldLocation(out RaycastHit hit);
                }
            }
        }
        if (Vector3.Distance(lightComponent.transform.position, transportableComponent.transform.position) < 7 && !lightComponent.IsLightEnabled()) //Magic number. Remove this
        {
            //lightComponent.currentFuel = lightComponent.maxFuel;
        }
    }