Exemplo n.º 1
0
    private void Start()
    {
        target = GameObject.FindGameObjectWithTag("Player");

        Invoke("SelfDestruct", chaseTimer);

        PF_AlgorithmManager.RequestPath(transform.position, target.transform.position, OnPathFound);

        //DECISION MAKING
        attackManagerScript = GameObject.FindGameObjectWithTag("BossManager").GetComponent <AttackManager>();
    }
    private void Update()
    {
        clickCooldown -= Time.deltaTime;

        RefreshUI();

        ManaUpdate();

        newPathCooldownRemaining -= Time.deltaTime;

        if (clickCooldownRemaining <= 0f)
        {
            if (Input.GetMouseButtonDown(1))
            {
                Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                Debug.DrawRay(ray.origin, ray.direction * 1000, Color.yellow, 2f);

                RaycastHit hit;

                // Make sure the click was somewhere on the map.
                if (Physics.Raycast(ray, out hit, 1000f, 1 << LayerMask.NameToLayer("Grass")))
                {
                    targetPosition = hit.point;

                    targetIndicator.transform.position = targetPosition;
                    targetIndicator.SetActive(true);

                    PF_AlgorithmManager.RequestPath(transform.position, targetPosition, OnPathFound);

                    targetSet     = true;
                    targetReached = false;
                }

                clickCooldownRemaining = clickCooldown;
            }
        }

        if (newPathCooldownRemaining <= 0f)
        {
            if (targetSet && !targetReached)
            {
                PF_AlgorithmManager.RequestPath(transform.position, targetPosition, OnPathFound);

                newPathCooldownRemaining = newPathCooldown;
            }
        }

        if (currentHealth <= 0)
        {
            startMenuScript.changeScreenDeath();
        }
    }
Exemplo n.º 3
0
    private void Update()
    {
        if (newPathCooldown > 0f)
        {
            newPathCooldownRemaining -= Time.deltaTime;
        }

        // Update the path. (Dynamic)
        if (newPathCooldownRemaining <= 0f)
        {
            PF_AlgorithmManager.RequestPath(transform.position, target.transform.position, OnPathFound);

            newPathCooldownRemaining = newPathCooldown;
        }
    }
Exemplo n.º 4
0
 private void Awake()
 {
     instance    = this;
     pathfinding = GetComponent <PF_Algorithm>();
 }
Exemplo n.º 5
0
 private void Awake()
 {
     requestManager = GetComponent <PF_AlgorithmManager>();
     grid           = GetComponent <PF_Grid>();
 }