Esempio n. 1
0
    public void Emit()
    {
        if (intensity <= 0.0f)
        {
            onParticles.Stop();
            pointLight.SetActive(false);
            if (laserRay != null)
            {
                /*foreach (Transform child in laserRay.transform)
                 *  Destroy(child.gameObject);*/
                Destroy(laserRay.gameObject);
                laserRay = null;
            }
            return;
        }

        onParticles.Play();
        pointLight.SetActive(true);

        if (laserRay == null)
        {
            laserRay = LaserManager.Instance.CastLaser(transform.position, transform.right, transform);
        }

        foreach (Transform child in laserRay.transform)
        {
            Destroy(child.gameObject);
        }

        laserRay.Cast(transform.position, transform.right, laserRay.transform);
    }
Esempio n. 2
0
        public override void TakeLaserDamage(Fraction source, LaserRay ray, float dmg)
        {
            if (dmg > 0f)
            {
                if (Fraction.IsNeutral && !source.IsNeutral)
                {
                    CannonHealth.Set(1);
                    SetFraction(source);
                }
                else if (!Fraction.IsNeutral && source != Fraction)
                {
                    CannonHealth.Set(0);
                    SetFraction(Fraction.GetNeutral());
                }
            }

            if (!source.IsNeutral && !Fraction.IsNeutral)
            {
                if (dmg > 0)
                {
                    counterAttackingLasersEnemy++;
                }
                _attackingRaysCollector.Add(ray);
            }
        }
Esempio n. 3
0
    public LaserRay CastLaser(Vector3 from, Vector3 direction)
    {
        LaserRay laser = Instantiate(laserRayPrefab, laserParent);

        laser.Cast(from, direction, laserParent);
        return(laser);
    }
Esempio n. 4
0
    public override void Initialize(GameWorld gameWorld, Agent agent, WeaponOrder weaponOrder)
    {
        base.Initialize(gameWorld, agent, weaponOrder);

        _laserRay = ((LaserRay)GetNode("LaserRay"));
        _laserRay.Initialize(gameWorld, Agent, _team);
    }
Esempio n. 5
0
    //Handles Collision with laser
    public void HandleLaserCollision(LaserRay ray)
    {
        //Change material and indicate hit to targetmaster
        Material mat = rend.material;

        mat.color  = targetHit;
        hit        = true;
        lastHitRay = ray;
    }
Esempio n. 6
0
 public GunLaser(MainAsteroidsScene scene, SpaceShip actor, float reloadTime, float rayTime) : base(actor)
 {
     this.scene = scene;
     ReloadTime = reloadTime;
     RayTime    = rayTime;
     LaserRay   = new LaserRay(scene, actor);
     AddSubObject(LaserRay);
     LaserRay.SetActive(false);
 }
Esempio n. 7
0
        public virtual void TakeLaserDamage(Fraction source, LaserRay ray, float dmg)
        {
#if DEBUG
            if (DebugSettings.Get("ImmortalCannons"))
            {
                _attackingRaysCollector.Add(ray); return;
            }
#endif

            if (source.IsNeutral)
            {
                if (dmg > 0f)
                {
                    ResetChargeAndBooster();
                }
            }
            else if (Fraction.IsNeutral)
            {
                if (dmg > 0f)
                {
                    counterAttackingLasersFriends++;

                    _attackingRaysCollector.Add(ray);

                    SetFraction(source);
                    CannonHealth.Set(dmg / Scale);
                    CannonHealth.Limit(0f, 1f);
                }
            }
            else
            {
                if (dmg > 0)
                {
                    counterAttackingLasersEnemy++;
                }

                _attackingRaysCollector.Add(ray);

                CannonHealth.Dec(dmg / Scale);

                if (FloatMath.IsZero(CannonHealth.TargetValue))
                {
                    // Never tell me the odds

                    SetFraction(Fraction.GetNeutral());
                }
                else if (CannonHealth.TargetValue < 0)
                {
                    SetFraction(source);
                    CannonHealth.Set(FloatMath.Abs(CannonHealth.TargetValue));
                }

                CannonHealth.Limit(0f, 1f);
            }
        }
Esempio n. 8
0
    public LaserRay CastLaser(Vector3 from, Vector3 direction, Transform parent)
    {
        if (parent == null)
        {
            parent = laserParent;
        }

        LaserRay laser = Instantiate(laserRayPrefab, parent);

        laser.Cast(from, direction, laser.transform);
        return(laser);
    }
Esempio n. 9
0
    public void HandleLaserCollision(LaserRay laserHit)
    {
        Transform parentTransform = laserHit.transform.parent;

        if (laserHit.HitNormal.z > 0)
        {
            pr = Instantiate(ray, transform.position, Quaternion.LookRotation(tr));
            pr.transform.parent = parentTransform;
            pr1 = Instantiate(ray, transform.position, Quaternion.LookRotation(tr1));
            pr1.transform.parent = parentTransform;
            pr2 = Instantiate(ray, transform.position, Quaternion.LookRotation(tr2));
            pr2.transform.parent = parentTransform;
        }
    }
Esempio n. 10
0
    public void HandleLaserCollision(LaserRay laserHit)
    {
        //reflektera map. laserns riktningsvektor samt ytans normal
        Vector3    direction       = Vector3.Reflect(laserHit.transform.forward, laserHit.HitNormal);
        Transform  parentTransform = laserHit.transform.parent;
        GameObject prev            = Instantiate(ray, laserHit.HitPoint, Quaternion.LookRotation(direction));

        prev.transform.parent = parentTransform;
        LaserRay newLaser = prev.GetComponent <LaserRay>();

        //sätt färg och minska bouncevalue
        newLaser.BounceValue = laserHit.BounceValue - bounceValue;
        newLaser.Color       = laserHit.Color;
    }
Esempio n. 11
0
 public LaserCollisionEventArgs(object @this, object other, Vector2f position, Vector2f normal, LaserRay ray) :
     base(@this, other, position, normal)
 {
     Ray = ray;
 }
Esempio n. 12
0
 // Called when the node enters the scene tree for the first time.
 public override void _Ready()
 {
     base._Ready();
     laserRay = ((LaserRay)GetNode("LaserRay"));
 }