Ejemplo n.º 1
0
 protected void SetTarget(MarkupPoint ignore = null)
 {
     TargetPoints.Clear();
     foreach (var enter in Tool.Markup.Enters)
     {
         TargetPoints.AddRange(GetTarget(enter, ignore));
     }
 }
Ejemplo n.º 2
0
        private void SetEnterTarget(Enter enter, MarkupPoint ignore)
        {
            if (ignore == null || ignore.Enter != enter)
            {
                TargetPoints.AddRange(enter.Points.Cast <MarkupPoint>());
                return;
            }

            var allow     = enter.Points.Select(i => 1).ToArray();
            var ignoreIdx = ignore.Num - 1;
            var leftIdx   = ignoreIdx;
            var rightIdx  = ignoreIdx;

            foreach (var line in enter.Markup.Lines.Where(l => l.Type == MarkupLine.LineType.Stop && l.Start.Enter == enter))
            {
                var from = Math.Min(line.Start.Num, line.End.Num) - 1;
                var to   = Math.Max(line.Start.Num, line.End.Num) - 1;
                if (from < ignore.Num - 1 && ignore.Num - 1 < to)
                {
                    return;
                }
                allow[from] = 2;
                allow[to]   = 2;

                for (var i = from + 1; i <= to - 1; i += 1)
                {
                    allow[i] = 0;
                }

                if (line.ContainsPoint(ignore))
                {
                    var otherIdx = line.PointPair.GetOther(ignore).Num - 1;
                    if (otherIdx < ignoreIdx)
                    {
                        leftIdx = otherIdx;
                    }
                    else if (otherIdx > ignoreIdx)
                    {
                        rightIdx = otherIdx;
                    }
                }
            }

            SetNotAllow(allow, leftIdx == ignoreIdx ? Find(allow, ignoreIdx, -1) : leftIdx, -1);
            SetNotAllow(allow, rightIdx == ignoreIdx ? Find(allow, ignoreIdx, 1) : rightIdx, 1);
            allow[ignoreIdx] = 0;

            foreach (var point in enter.Points)
            {
                if (allow[point.Num - 1] != 0)
                {
                    TargetPoints.Add(point);
                }
            }
        }
Ejemplo n.º 3
0
 void SwitchTarget()
 {
     //Initialise/Switch between targets
     if (currentTarget == TargetPoints.Point1)
     {
         currentTarget = TargetPoints.Point2;
     }
     else
     {
         currentTarget = TargetPoints.Point1;
     }
 }
Ejemplo n.º 4
0
        private void SetTarget(MarkupPoint.PointType pointType = MarkupPoint.PointType.Enter, MarkupPoint ignore = null)
        {
            TargetPoints.Clear();
            foreach (var enter in EditMarkup.Enters)
            {
                if ((pointType & MarkupPoint.PointType.Enter) == MarkupPoint.PointType.Enter)
                {
                    SetEnterTarget(enter, ignore);
                }

                if ((pointType & MarkupPoint.PointType.Crosswalk) == MarkupPoint.PointType.Crosswalk)
                {
                    SetCrosswalkTarget(enter, ignore);
                }
            }
        }
Ejemplo n.º 5
0
 private void Reset()
 {
     EditMarkup   = null;
     HoverNodeId  = 0;
     SelectNodeId = 0;
     HoverPoint   = null;
     SelectPoint  = null;
     TargetPoints.Clear();
     DragPoint = null;
     FillerPoints.Clear();
     FillerPointsSelector      = null;
     ToolMode                  = Mode.Node;
     cursorInfoLabel.isVisible = false;
     cursorInfoLabel.text      = string.Empty;
     Panel?.EndPanelAction();
     Panel?.Hide();
 }
    // Below Coroutine used to simulate burst fire
    IEnumerator BurstFire()
    {
        for (int i = 0; i < 3; i++)
        {
            nextFireBurst = Time.time + fireRateBurst;
            StartCoroutine(ShotEffect()); // Call our Shot Effect Coroutine
            ammoCount--;                  // Iterate ammoCount by one down each shot
            // Spawn Point for ray, always centered to center of camera, this takes a position relative to the camera and converts it to a world point
            Vector3    rayOrigin = fpsCam.ViewportToWorldPoint(new Vector3(0.5F, 0.5F, 0.0F));
            RaycastHit hit; // Holds the information returned from our array if it hits a gameObject with a collider attached

            // Determine start and end positions for our raycast line when the player fires, first we need to specficy two points for lineRenderer to draw between
            laserLine.SetPosition(0, bulletSpawn.position); // Our Start Point for our raycast to be shot out of the gun

            if (Physics.Raycast(rayOrigin, fpsCam.transform.forward, out hit, weaponRange))
            {
                laserLine.SetPosition(1, hit.point);                                    // index position 1 of Hit array, set to the world space position of object colliding with array.

                TargetPoints targetHealth = hit.collider.GetComponent <TargetPoints>(); // Using hit, store scripting reference of TargetPoints in targetHealth

                if (targetHealth != null)                                               // If the target hit did have TargetPoints attached then...
                {
                    // Call healthCalculator function of TargetPoints and pass in this gun's Damage as a parameter
                    targetHealth.healthCalculator(gunDamage);
                }

                if (hit.rigidbody != null) // If the target hit did have a rigidbody attached then...
                {
                    // AddForce to target in the direction negative to its normals and with hitForce as a multiplier
                    hit.rigidbody.AddForce(-hit.normal * hitForce);
                }
            }
            else
            {
                laserLine.SetPosition(1, rayOrigin + (fpsCam.transform.forward * weaponRange)); // index position 1 of Hit array, set to the world space position of object colliding with array
            }
            Instantiate(casing, casingSpawn.position, casingSpawn.rotation);                    // -- Test code for ejecting casings -- This is the only one that works because of Game Object Reference not working
            Debug.Log("Burst Shot Fired");
            yield return(new WaitForSeconds(0.1F));
        }
    }
Ejemplo n.º 7
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add ToolNewDisplacement.OnMouseDown implementation
            object       Miss    = Type.Missing;
            IMapControl2 pMapCtr = (((IToolbarControl)m_hookHelper.Hook).Buddy) as IMapControl2;

            if (pMapCtr != null)
            {
                //IGeoReference pGR = pRasterLayer as IGeoReference;
                IPoint mapPoint = pMapCtr.ToMapPoint(X, Y);
                m_NewLineFeedback.Display = pMapCtr.ActiveView.ScreenDisplay;
                if (bFlag == true)//起始点
                {
                    //IPointCollection pPCFrom;
                    //IPointCollection pPCTo = new MultipointClass();
                    //pPCTo.AddPoint(mapPoint, ref Miss, ref Miss);
                    //pPCFrom = pGR.PointsTransform(pPCTo, false);


                    // OriginPoints.AddPoint(mapPoint);
                    //IPoint pt = pPCFrom.get_Point(0);
                    m_NewLineFeedback.Start(mapPoint);
                    OriginPoints.AddPoint(mapPoint);
                    bFlag = false;
                }
                else//目标点
                {
                    TargetPoints.AddPoint(mapPoint);
                    bFlag = true;
                    IPolyline pPline = m_NewLineFeedback.Stop();

                    m_FrmVectorLinkTable.RefreshDataTable();
                    //RefreshLayer();
                }
            }
        }
Ejemplo n.º 8
0
        private void SetCrosswalkTarget(Enter enter, MarkupPoint ignore)
        {
            if (ignore != null && ignore.Enter != enter)
            {
                return;
            }

            var allow  = enter.Crosswalks.Select(i => 1).ToArray();
            var bridge = new Dictionary <MarkupPoint, int>();

            foreach (var crosswalk in enter.Crosswalks)
            {
                bridge.Add(crosswalk, bridge.Count);
            }

            var isIgnore  = ignore?.Enter == enter;
            var ignoreIdx = isIgnore ? bridge[ignore] : 0;

            var leftIdx  = ignoreIdx;
            var rightIdx = ignoreIdx;

            foreach (var line in enter.Markup.Lines.Where(l => l.Type == MarkupLine.LineType.Crosswalk && l.Start.Enter == enter))
            {
                var from = Math.Min(bridge[line.Start], bridge[line.End]);
                var to   = Math.Max(bridge[line.Start], bridge[line.End]);
                allow[from] = 2;
                allow[to]   = 2;
                for (var i = from + 1; i <= to - 1; i += 1)
                {
                    allow[i] = 0;
                }

                if (isIgnore && line.ContainsPoint(ignore))
                {
                    var otherIdx = bridge[line.PointPair.GetOther(ignore)];
                    if (otherIdx < ignoreIdx)
                    {
                        leftIdx = otherIdx;
                    }
                    else if (otherIdx > ignoreIdx)
                    {
                        rightIdx = otherIdx;
                    }
                }
            }

            if (isIgnore)
            {
                SetNotAllow(allow, leftIdx == ignoreIdx ? Find(allow, ignoreIdx, -1) : leftIdx, -1);
                SetNotAllow(allow, rightIdx == ignoreIdx ? Find(allow, ignoreIdx, 1) : rightIdx, 1);
                allow[ignoreIdx] = 0;
            }

            foreach (var point in bridge)
            {
                if (allow[point.Value] != 0)
                {
                    TargetPoints.Add(point.Key);
                }
            }
        }
Ejemplo n.º 9
0
        public void RefreshLayer()
        {
            if (pGraphicsLayer != null)
            {
                IGraphicsContainer pGC = pGraphicsLayer as IGraphicsContainer;
                int nCount             = OriginPoints.PointCount;

                pGC.DeleteAllElements();
                for (int i = 0; i < nCount; i++)
                {
                    IPolyline ppl = new PolylineClass();
                    ppl.FromPoint = OriginPoints.get_Point(i);
                    ppl.ToPoint   = TargetPoints.get_Point(i);

                    IRgbColor pColor = new RgbColorClass();


                    ICartographicLineSymbol pCartoLineSymbol = new CartographicLineSymbolClass();
                    pCartoLineSymbol.Cap = esriLineCapStyle.esriLCSRound;

                    ILineProperties pLineProp = pCartoLineSymbol as ILineProperties;
                    pLineProp.DecorationOnTop = true;

                    ILineDecoration pLineDecoration = new LineDecorationClass();
                    ISimpleLineDecorationElement pSimpleLineDecoElem = new SimpleLineDecorationElementClass();
                    pSimpleLineDecoElem.AddPosition(1);
                    IArrowMarkerSymbol pArrowMarkerSym = new ArrowMarkerSymbolClass();
                    pArrowMarkerSym.Size             = 8;
                    pArrowMarkerSym.Color            = pColor;
                    pSimpleLineDecoElem.MarkerSymbol = pArrowMarkerSym as IMarkerSymbol;
                    pLineDecoration.AddElement(pSimpleLineDecoElem as ILineDecorationElement);
                    pLineProp.LineDecoration = pLineDecoration;

                    ILineSymbol pLineSymbol = pCartoLineSymbol as ILineSymbol;

                    pLineSymbol.Color = pColor;
                    pLineSymbol.Width = 1;

                    ILineElement pLineElem = new LineElementClass();
                    pLineElem.Symbol = pLineSymbol;
                    IElement pElem = pLineElem as IElement;
                    pElem.Geometry = ppl;

                    pGC.AddElement(pElem, 0);

                    // IGraphicsContainerSelect pGCS = pGC as IGraphicsContainerSelect;
                    // pGCS.SelectAllElements();
                    //bool bbb =   pGCS.ElementSelected(pElement);
                    //pGC.UpdateElement(pElement);

                    // IGraphicsContainerSelect pGCS = pGC as IGraphicsContainerSelect;
                    // pGCS.SelectAllElements();
                    //bool bbb =   pGCS.ElementSelected(pElement);
                    //pGC.UpdateElement(pElement);

                    //pElement = new MarkerElementClass();
                    //pElement.Geometry = m_OriginPoints.get_Point(i);
                    //ISimpleMarkerSymbol sms = new SimpleMarkerSymbolClass();
                    //sms.Style = esriSimpleMarkerStyle.esriSMSSquare;
                    //sms.Size = 9;
                    //IMarkerElement im = pElement as IMarkerElement;
                    //im.Symbol = sms ;
                    //    IGraphicsContainer pGraphicsContainer = m_pMapCtr.Map.BasicGraphicsLayer as IGraphicsContainer;
                    //  pGraphicsContainer.AddElement(pElement, 0);
                    //pGC.AddElement(pElement,0);
                    //pGC.UpdateElement(pElement);



                    //IMarkerElement pMarkerEle = new MarkerElementClass();
                    //IPictureMarkerSymbol pPictureMarkerSymbol = new PictureMarkerSymbol();
                    ////pPictureMarkerSymbol.Color = sitecolor as IColor;
                    //pPictureMarkerSymbol.Size = 10;
                    //pPictureMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap,
                    //    GetParentPathofExe() + @"Resource\Globe.bmp");
                    //IElement pEle = pMarkerEle as IElement;
                    //pEle.Geometry = ppl.FromPoint;
                    //pMarkerEle.Symbol = pPictureMarkerSymbol;
                    //IGraphicsContainer pGraphicsContainer = m_pMapCtr.Map.BasicGraphicsLayer as IGraphicsContainer;
                    ////site.pEle = pEle;
                    //pGraphicsContainer.AddElement(pEle, 0);
                }

                IMapControl2 pMapCtr = (((IToolbarControl)m_hookHelper.Hook).Buddy) as IMapControl2;
                if (pMapCtr != null)
                {
                    if (OriginPoints.PointCount == 0)
                    {
                        pMapCtr.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewAll, null, null);
                    }
                    else
                    {
                        pMapCtr.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
                    }
                }
            }
        }
    // Update is called once per frame
    void Update()
    {
        ammoCountText.text = ammoCount.ToString() + " / " + "Infinite"; // Display text of ammoCount

        // Semi-Automatic
        if (Input.GetButtonDown("Fire1") && Time.time > nextFireSingle && indexFireMode == 1 && hasAmmo == true)
        {
            nextFireSingle = Time.time + fireRateSingle; // Incriment nextFire so that the player must wait to fire again
            StartCoroutine(ShotEffect());                // Call our Shot Effect Coroutine

            // Spawn Point for ray, always centered to center of camera, this takes a position relative to the camera and converts it to a world point
            Vector3    rayOrigin = fpsCam.ViewportToWorldPoint(new Vector3(0.5F, 0.5F, 0.0F));
            RaycastHit hit; // Holds the information returned from our array if it hits a gameObject with a collider attached

            // Determine start and end positions for our raycast line when the player fires, first we need to specficy two points for lineRenderer to draw between
            laserLine.SetPosition(0, bulletSpawn.position); // Our Start Point for our raycast to be shot out of the gun

            if (Physics.Raycast(rayOrigin, fpsCam.transform.forward, out hit, weaponRange))
            {
                laserLine.SetPosition(1, hit.point);                                    // index position 1 of Hit array, set to the world space position of object colliding with array.

                TargetPoints targetHealth = hit.collider.GetComponent <TargetPoints>(); // Using hit, store scripting reference of TargetPoints in targetHealth

                if (targetHealth != null)                                               // If the target hit did have TargetPoints attached then...
                {
                    // Call healthCalculator function of TargetPoints and pass in this gun's Damage as a parameter
                    targetHealth.healthCalculator(gunDamage);
                }

                if (hit.rigidbody != null) // If the target hit did have a rigidbody attached then...
                {
                    // AddForce to target in the direction negative to its normals and with hitForce as a multiplier
                    hit.rigidbody.AddForce(-hit.normal * hitForce);
                }
            }
            else
            {
                laserLine.SetPosition(1, rayOrigin + (fpsCam.transform.forward * weaponRange)); // index position 1 of Hit array, set to the world space position of object colliding with array
            }
            ammoCount--;                                                                        // Iterate ammoCount by one down each shot
            Instantiate(casing, casingSpawn.position, casingSpawn.rotation);                    // -- Test code for ejecting casings -- This is the only one that works because of Game Object Reference not working
            Debug.Log("Single Shot Fired");
        }
        // Burst
        if (Input.GetButtonDown("Fire1") && Time.time > nextFireBurst && indexFireMode == 2 && hasAmmo == true)
        {
            StartCoroutine(BurstFire());
        }

        // Automatic
        if (Input.GetButton("Fire1") && Time.time > nextFireAutomatic && indexFireMode == 3 && hasAmmo == true)
        {
            nextFireAutomatic = Time.time + fireRateAutomatic;
            StartCoroutine(ShotEffect()); // Call our Shot Effect Coroutine

            // Spawn Point for ray, always centered to center of camera, this takes a position relative to the camera and converts it to a world point
            Vector3    rayOrigin = fpsCam.ViewportToWorldPoint(new Vector3(0.5F, 0.5F, 0.0F));
            RaycastHit hit; // Holds the information returned from our array if it hits a gameObject with a collider attached

            // Determine start and end positions for our raycast line when the player fires, first we need to specficy two points for lineRenderer to draw between
            laserLine.SetPosition(0, bulletSpawn.position); // Our Start Point for our raycast to be shot out of the gun

            if (Physics.Raycast(rayOrigin, fpsCam.transform.forward, out hit, weaponRange))
            {
                laserLine.SetPosition(1, hit.point);                                    // index position 1 of Hit array, set to the world space position of object colliding with array.

                TargetPoints targetHealth = hit.collider.GetComponent <TargetPoints>(); // Using hit, store scripting reference of TargetPoints in targetHealth

                if (targetHealth != null)                                               // If the target hit did have TargetPoints attached then...
                {
                    // Call healthCalculator function of TargetPoints and pass in this gun's Damage as a parameter
                    targetHealth.healthCalculator(gunDamage);
                }

                if (hit.rigidbody != null) // If the target hit did have a rigidbody attached then...
                {
                    // AddForce to target in the direction negative to its normals and with hitForce as a multiplier
                    hit.rigidbody.AddForce(-hit.normal * hitForce);
                }
            }
            else
            {
                laserLine.SetPosition(1, rayOrigin + (fpsCam.transform.forward * weaponRange)); // index position 1 of Hit array, set to the world space position of object colliding with array
            }

            ammoCount--;                                                     // Iterate ammoCount by one down each shot
            Instantiate(casing, casingSpawn.position, casingSpawn.rotation); // -- Test code for ejecting casings -- This is the only one that works because of Game Object Reference not working
            Debug.Log("Automatic Shot Fired");
        }
        // Fire Modes
        if (indexFireMode == 0 && consoleTextDisplayed == false)
        {
            // Console Alert: FireMode set to safe
            Debug.Log("Safe");
            // Play FireMode Switch Sound Effect
            //aud.PlayOneShot(FireModeSoundEffect);
            consoleTextDisplayed = true; // FireMode has been changed so, Console has displayed text
        }
        if (indexFireMode == 1 && consoleTextDisplayed == false)
        {
            // Console Alert: FireMode set to single
            Debug.Log("Single");
            // Play FireMode Switch Sound Effect
            //aud.PlayOneShot(FireModeSoundEffect);
            consoleTextDisplayed = true; // FireMode has been changed so, Console has displayed text
        }

        if (indexFireMode == 2 && consoleTextDisplayed == false)
        {
            // Console Alert: FireMode set to burst
            Debug.Log("Burst");
            // Play FireMode Switch Sound Effect
            //aud.PlayOneShot(FireModeSoundEffect);
            consoleTextDisplayed = true; // FireMode has been changed so, Console has displayed text
        }

        if (indexFireMode == 3 && consoleTextDisplayed == false)
        {
            // Console Alert: FireMode set to automatic
            Debug.Log("Automatic");
            // Play FireMode Switch Sound Effect
            //aud.PlayOneShot(FireModeSoundEffect);
            consoleTextDisplayed = true; // FireMode has been changed so, Console has displayed text
        }

        if (indexFireMode > 3 && consoleTextDisplayed == false)
        {
            // Console Alert: FireMode Reset
            Debug.Log("Switch FireMode Reset");
            indexFireMode        = 1;     // FireMode set back to one
            consoleTextDisplayed = false; // FireMode has been changed so, Console has displayed text
        }

        // Below If Statement checks to see if FireMode is presed
        if (Input.GetButtonDown("FireMode"))
        {
            // Console Alert: Switch Station Button Pressed
            Debug.Log("Switch FireMode Button Pressed");
            //aud.Stop(); // Stop Playing the Previous Track
            indexFireMode++;              // Then Incriment indexStation to change station track played
            consoleTextDisplayed = false; // Radio station has been changed so, Console has displayed text
        }

        // Ammo Management and Reload
        if (Input.GetButtonDown("Reload"))
        {
            aud.PlayOneShot(gunEquipReload, 1.0F); // Play Reload Sound Effect
            ammoCount = 30;
            hasAmmo   = true;
            if (ammoCount <= 0)
            {
                Instantiate(magEmpty, magEmptySpawn.position, magEmptySpawn.rotation); // Spawn empty mag if ammoCount is 0
            }
            if (ammoCount > 0)
            {
                ammoCount = 30 + 1;
                Instantiate(magFull, magFullSpawn.position, magFullSpawn.rotation); // Spawn full mag if ammoCount is greater than 0
            }
        }
        if (ammoCount <= 0)
        {
            hasAmmo = false;
        }
    }