Exemplo n.º 1
0
        public void InitShoot(Unit tUnit)
        {
            tgtUnit   = tUnit;
            tgtRadius = tgtUnit.GetRadius();
            targetPos = tgtUnit.GetTargetPoint();
            shot      = true;      hit = false; shootTime = Time.time;

            if (type == _Type.Projectile)
            {
                //estimate the time taken to reach the target (roughly) and calculate the effective elevation based on falloffRange
                float dist = Vector3.Distance(GetPos(), targetPos);
                eta          = dist / speed;
                effElevation = elevation * Mathf.Clamp((dist - (falloffRange * .5f)) / falloffRange, 0, 1);
            }
            else if (type == _Type.Beam)
            {
                if (shootPoint != null)
                {
                    thisT.parent = shootPoint;
                }
            }
            else if (type == _Type.Effect)
            {
                thisT.LookAt(targetPos);
            }

            /*
             * else if(type==_Type.Missile){
             *      float dist=Vector3.Distance(GetPos(), targetPos);
             *      eta=dist/speed;
             *
             *      if(shootPoint!=null) thisT.rotation=shootPoint.rotation;
             *
             *      float rotX=maxDeviation;//Random.Range(0, maxDeviation);
             *      float rotY=Random.value>.5f ? -maxDeviation : maxDeviation;	//Random.Range(-maxDeviation, maxDeviation);
             *      missileOffset=thisT.rotation*Quaternion.Euler(-rotX, rotY, 0)*Vector3.forward*dist*0.65f;
             * }
             */

            effectShoot.Spawn(GetPos(), GetRot());
            AudioManager.PlaySound(shootSound);
        }
Exemplo n.º 2
0
 public float GetDetectionRange(Unit tgtUnit)
 {
     return(GetAttackRange() + tgtUnit.GetRadius());
 }