Пример #1
0
    //Spawning laserLine objects and assigning its position, rotation and parent transform.
    LaserLine spawnLaserBeam(Vector3 tiltAngle)
    {
        LaserLine spawn = Instantiate <LaserLine>(laserLinePrefab);

        spawn.transform.localPosition = transform.position;
        spawn.transform.localRotation = Quaternion.Euler(tiltAngle);
        spawn.transform.parent        = gameObject.transform;

        return(spawn);
    }
Пример #2
0
        void LaserBeam(Transform ee)
        {
            Vector3    rr  = ee.TransformDirection(Vector3.forward);
            Ray        ray = new Ray(ee.position, rr);
            RaycastHit nearHit;

            if (Physics.Raycast(ray, out nearHit))
            {
                string RootName = nearHit.transform.root.name;
                if (RootName == "MyRobot")
                {
                    return;
                }
                Instantiate(Effect, nearHit.point, Quaternion.identity);
                if ((nearHit.collider.tag == "Figure"))
                {
                    Transform j = nearHit.collider.transform;
                    while ((j.parent.tag == "Figure") && (j.parent.name != "Tower"))
                    {
                        j = j.parent;
                    }
                    Damaging(j.gameObject, 700, RootName);

                    if (Robo.ContainsKey(RootName))
                    {
                        if (Robo[RootName].Health <= 0)
                        {
                            nearHit.transform.root.gameObject.SetActive(false);
                            Robo[RootName].HealthCoroutine = null;
                            return;
                        }

                        //print(RootName + "=" + Robo[RootName].Health);

                        if (Robo[RootName].HealthCoroutine != null)
                        {
                            StopCoroutine(Robo[RootName].HealthCoroutine);
                            Robo[RootName].HealthCoroutine = null;
                        }
                        if (Robo[RootName].HealthCoroutine == null)
                        {
                            Robo[RootName].HealthCoroutine = StartCoroutine(HealthTimer(10, RootName));
                        }
                    }
                }
            }
            GameObject lr = new GameObject("LaserRay");
            GameObject Tm = new GameObject("Tm");

            lr.transform.parent        = ee;
            Tm.transform.parent        = ee;
            lr.transform.localPosition = new Vector3(0, 0, 1.4f);
            lr.AddComponent <LaserLine>();
            LaserLine ll = lr.GetComponent <LaserLine>();

            ll.width             = 0.7f;
            ll.innerFadeMaterial = Setup.innerFadeMaterial;
            ll.outerFadeMaterial = Setup.outerFadeMaterial;
            ll.SetPositions(new Vector3[] { lr.transform.position, nearHit.point });
            ll.Visible = true;
            Destroy(lr, 0.1f);
            Destroy(Tm, 0.2f);
            lr.AddComponent <AudioSource>();
            AudioSource audio = lr.GetComponent <AudioSource>();

            audio.clip = Beam;
            audio.Play();
        }
Пример #3
0
        internal void PlaceDotAtRandomPosition()
        {
            var random     = new Random(Guid.NewGuid().GetHashCode());
            int dotXCenter = random.Next(_settings.maxLeft + DotSize, _settings.maxRight - DotSize);
            int dotYCenter = random.Next(_settings.minHeight + DotSize, _settings.maxHeight - DotSize);

            BottomWallPosition = new LaserLine
            {
                FirstPosition = new LaserPositionAndColors
                {
                    X           = dotXCenter - DotSize,
                    Y           = dotYCenter - DotSize,
                    LaserColors = _laserPatternHelper.GetRandomLaserColors()
                },

                SecondPosition = new LaserPositionAndColors
                {
                    X           = dotXCenter + DotSize,
                    Y           = dotYCenter - DotSize,
                    LaserColors = _laserPatternHelper.GetRandomLaserColors()
                }
            };

            RightWallPosition = new LaserLine
            {
                FirstPosition = new LaserPositionAndColors
                {
                    X           = dotXCenter + DotSize,
                    Y           = dotYCenter - DotSize,
                    LaserColors = _laserPatternHelper.GetRandomLaserColors()
                },

                SecondPosition = new LaserPositionAndColors
                {
                    X           = dotXCenter + DotSize,
                    Y           = dotYCenter + DotSize,
                    LaserColors = _laserPatternHelper.GetRandomLaserColors()
                }
            };

            TopWallPosition = new LaserLine
            {
                FirstPosition = new LaserPositionAndColors
                {
                    X           = dotXCenter + DotSize,
                    Y           = dotYCenter + DotSize,
                    LaserColors = _laserPatternHelper.GetRandomLaserColors()
                },

                SecondPosition = new LaserPositionAndColors
                {
                    X           = dotXCenter - DotSize,
                    Y           = dotYCenter + DotSize,
                    LaserColors = _laserPatternHelper.GetRandomLaserColors()
                }
            };

            LeftWallPosition = new LaserLine
            {
                FirstPosition = new LaserPositionAndColors
                {
                    X           = dotXCenter - DotSize,
                    Y           = dotYCenter + DotSize,
                    LaserColors = _laserPatternHelper.GetRandomLaserColors()
                },

                SecondPosition = new LaserPositionAndColors
                {
                    X           = dotXCenter - DotSize,
                    Y           = dotYCenter - DotSize,
                    LaserColors = _laserPatternHelper.GetRandomLaserColors()
                }
            };
        }