示例#1
0
    void Update()
    {
        if (!GUIManager.instance.GuiOpen)
        {
            if (Input.GetButtonDown("Roll"))
            {
                ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                if (Physics.Raycast(ray, out hit, 100, layerMask))
                {
                    tempVector   = hit.point;
                    tempVector.y = 0;
                    buffer.AddToBuffer(1, (tempVector - transform.position));
                }
            }
            if (Input.GetButtonDown("BasicAttack"))
            {
                if (gear.GetEquipment(ItemType.WEAPON) != null)
                {
                    ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                    if (Physics.Raycast(ray, out hit, 100, layerMask))
                    {
                        tempVector   = hit.point;
                        tempVector.y = 0;
                        buffer.AddToBuffer(aManager.EquippedAbilities [0].ActionID, (tempVector - transform.position));
                    }
                }
            }
        }
        animator.SetFloat("h", Input.GetAxisRaw("Horizontal"));
        animator.SetFloat("v", Input.GetAxisRaw("Vertical"));


        if (Input.GetButtonDown("Consumable"))
        {
            inventory.UseConsumable();
        }
        if (Input.GetButtonDown("Inventory"))
        {
            GUIManager.instance.ToggleInventory();
        }
        if (Input.GetButtonDown("Interact"))
        {
            interactor.InteractFirst();
        }
    }
示例#2
0
    void Update()
    {
        if (player != null)
        {
            distanceFromPlayer = transform.position.CalculateDistance(player.position);
            timer += Time.deltaTime;


            switch (rangeState)
            {
            case RangeFromPlayer.OUTOFRANGE:
                if (agro && timer > 1f)
                {
                    unitPathFinding.MoveTo(player.position);
                    timer = 0;
                }
                if (distanceFromPlayer <= agroRange)
                {
                    rangeState = RangeFromPlayer.AGRORANGE;
                }
                break;

            case RangeFromPlayer.AGRORANGE:
                if (distanceFromPlayer <= stoppingRange)
                {
                    unitPathFinding.CancelPath();
                    rangeState = RangeFromPlayer.ATTACKRANGE;
                }
                else if (distanceFromPlayer > agroRange)
                {
                    AgroTimer(agroTime);
                    rangeState = RangeFromPlayer.OUTOFRANGE;
                }
                tempVector    = player.position - transform.position;
                tempVector.y  = 0.2f;
                ray.direction = tempVector;
                tempVector    = transform.position;
                tempVector.y  = 0.2f;
                ray.origin    = tempVector;
                if (Physics.Raycast(ray, out hit, (player.position - ray.origin).magnitude, UnWalkable))
                {
                    StartCoroutine(AgroTimer(agroTime));
                }
                else if (agro)
                {
                    StopCoroutine(AgroTimer(agroTime));
                }
                else
                {
                    agro = true;
                }
                if (agro && timer > 1f)
                {
                    unitPathFinding.MoveTo(player.position);
                    timer = 0;
                }
                break;

            case RangeFromPlayer.ATTACKRANGE:
                if (distanceFromPlayer > stoppingRange)
                {
                    rangeState = RangeFromPlayer.AGRORANGE;
                }
                buffer.AddToBuffer(aManager.EquippedAbilities [0].ActionID, (player.position - transform.position));
                break;
            }
        }
    }