示例#1
0
    private void Update()
    {
        if (!hasTarget)
        {
            Destroy(gameObject);
            return;
        }

        if (target != null)
        {
            //Destroy(gameObject);

            Transform centerOfTarget       = target.GetComponentInChildren <MeshRenderer>().gameObject.transform;
            float     centerToEdgeDistance = target.GetComponentInChildren <Renderer>().bounds.size.x;
            transform.LookAt(target.transform);
            //transform.localPosition += Vector3.forward * Time.deltaTime * 10f;

            if (Vector3.Distance(transform.position, centerOfTarget.position) > centerToEdgeDistance && target != null)
            {
                transform.position = Vector3.MoveTowards(transform.position, centerOfTarget.position, projectileSpeed);
            }

            else if (Vector3.Distance(transform.position, centerOfTarget.position) <= centerToEdgeDistance)
            {
                if (isTroop)
                {
                    //Debug.Log(damage);
                    target.TakeHit(damage, transform.localEulerAngles, "physical", 0f);
                    //target.TakeHit(damage, transform.position);
                    Destroy(gameObject);
                }

                //else if (isBuilding)
                //{
                //    target.GetComponent<BuildingsManager>().TakeDamage(damage);
                //    Destroy(gameObject);
                //
                //}
            }
        }

        else
        {
            Destroy(gameObject);
        }
    }
示例#2
0
    IEnumerator AttackTarget(LivingEntityManager target)
    {
        //float time = 0;

        if (target != null)
        {
            //time += Time.deltaTime;
            //if (Input.GetKeyDown(KeyCode.Space))
            //{
            //    //Debug.Log(target.name);
            //    target.CallStun(1f);
            //}

            float attackPerSecond = ((100 + agility + attackSpeed) * 0.01f) / 1.7f;
            float attackTime      = 1 / attackPerSecond;

            if (Time.time >= nextShotTime)
            {
                nextShotTime = Time.time + attackTime;

                //Debug.Log(baseDamage);

                target.TakeHit(baseDamage, transform.localEulerAngles, "physical", 0f);

                if (gameObject.GetComponent <CleaveDamage>())
                {
                    gameObject.GetComponent <CleaveDamage>().PerformCleaveAttack();
                    gameObject.GetComponent <CleaveDamage>().damage = baseDamage;
                }
                //time = 0;
            }

            //yield return new WaitForSeconds(attackTime);
        }
        yield return(null);
    }
示例#3
0
    IEnumerator ShowIndication()
    {
        LivingEntityManager hero;

        while (!Input.GetMouseButtonUp(0))
        {
            if (currentSelection != null)
            {
                currentSelection.GetComponentInChildren <MeshRenderer>().material = defaultMat;
                currentSelection = null;
            }

            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            RaycastHit hit;

            if (Physics.Raycast(ray, out hit, 100, heroMask))
            {
                //Material temp;

                if (hit.collider.GetComponent <LivingEntityManager>())
                {
                    hero = hit.collider.GetComponent <LivingEntityManager>();
                    //temp = hero.GetComponentInChildren<MeshRenderer>().material;

                    if (hero != this.GetComponent <LivingEntityManager>())
                    {
                        hero.GetComponentInChildren <MeshRenderer>().material = highlightMat;

                        currentSelection = hero;
                    }
                    //if (Input.GetMouseButtonUp(0))
                    //{
                    //    //Debug.Log("click");
                    //    hero.GetComponentInChildren<MeshRenderer>().material = wrongHighlighMat;
                    //
                    //    //Deploy GOO
                    //}
                }
            }
            yield return(null);
        }

        if (currentSelection != null)
        {
            currentSelection.GetComponentInChildren <MeshRenderer>().material = defaultMat;

            while (Vector3.Distance(transform.position, currentSelection.transform.position) > 8f)
            {
                yield return(null);
            }

            StartCoroutine(CoolDownStart());
            GetComponent <LivingEntityManager>().ChangeMana(-manaConsuption);

            //else
            //    gameObject.GetComponent<BristleFuryPassive>().StackDebuff();


            GameObject laser = Instantiate(laserPrefab, transform) as GameObject;
            //goo.transform.position = gooSpawnPoint.position;

            laser.GetComponent <LaserBeam>().myPos  = spawnPos;
            laser.GetComponent <LaserBeam>().target = currentSelection.transform;
            //
            //laser.GetComponent<LineRenderer>().SetPosition(0, spawnPos.position);
            //laser.GetComponent<LineRenderer>().SetPosition(1, currentSelection.gameObject.GetComponentInChildren<MeshRenderer>().transform.position);

            yield return(new WaitForSeconds(0.25f));

            currentSelection.TakeHit(450f, transform.localEulerAngles, "magical", GetComponent <LivingEntityManager>().spellDamageAmpli);

            Destroy(laser, 0.5f);
        }

        else if (currentSelection == null)
        {
            //if (transform.GetComponentInChildren<LaserBeam>())
            //    transform.GetComponentInChildren<LaserBeam>().hasTarget = false;
        }
    }