Inheritance: MonoBehaviour
Ejemplo n.º 1
0
        public override void DrawItem(Radar radar, Graphics g)
        {
            double[] a = {D, GetAngle(b1), GetAngle(b2) };
            AddPolygon(g, a);

            // Draw link if required
            base.DrawItem(radar, g);
        }
Ejemplo n.º 2
0
    public void Initialize(Game mmoGame, Item actorItem, string name, Radar worldRadar)
    {
        this.item = actorItem;
        this.name = name;

        transform.position = new Vector3(this.item.Position.X, transform.position.y, this.item.Position.Y) * RunBehaviour.WorldToUnityFactor;

        ShowActor(false);
    }
Ejemplo n.º 3
0
	public void StartRadar() {
		parent = gameObject.transform.parent.gameObject;
		radar = Instantiate (radar, parent.transform.position, radar.transform.rotation) as Radar;

		Physics2D.IgnoreCollision (radar.collider2D, parent.collider2D);
		((CircleCollider2D)radar.collider2D).radius = range;

		radar.range = range;
		radar.parent = parent;

		radarExists = true;
	}
Ejemplo n.º 4
0
        public override void DrawItem(Radar radar, Graphics g)
        {
            RectangleF r = new RectangleF(new PointF(X - R/2, Y - R/2), new SizeF(R, R));

            if (H)
                g.DrawEllipse(new Pen(C, radar.PenWidth), r);
            else
                g.FillEllipse(new SolidBrush(C), r);

            // Draw link if required
            base.DrawItem(radar, g);
        }
Ejemplo n.º 5
0
    public void OnRadarExit( Collider other, Radar sender )
    {
        Obstacle obstacle;

        if( ( 1 << other.gameObject.layer & ObstacleLayer ) > 0 )
        {
            obstacle = SphericalObstacle.GetObstacle( other.gameObject );
            if( obstacle != null )
            {
                Wanderer.Obstacles.Remove( obstacle );
            }
        }
    }
Ejemplo n.º 6
0
    public void OnRadarExit( Collider other, Radar sender )
    {
        BoidBehaviour boidBehaviour;
        Obstacle obstacle;

        if( ( 1 << other.gameObject.layer & ObstacleLayer ) > 0 )
        {
            obstacle = SphericalObstacle.GetObstacle( other.gameObject );
            if( obstacle != null )
            {
                boid.Obstacles.Remove( obstacle );
            }
        }
        else
        {
            boidBehaviour = other.GetComponent( typeof( BoidBehaviour ) ) as BoidBehaviour;
            if( boidBehaviour != null )
            {
                boid.Neighbors.Remove( boidBehaviour.Vehicle );
            }
        }
    }
 void Start()
 {
     radar = gameObject.GetComponent <Radar>();
 }
 public void OnRadarEnter( Collider other, Radar sender )
 {
     HandleVisibility(other, true);
 }
Ejemplo n.º 9
0
 // Start is called before the first frame update
 void Start()
 {
     rigidbodyPlayer = GetComponent <Rigidbody>();
     //animator = GetComponent<Animator>();
     _playerRadar = GetComponent <Radar>();
 }
Ejemplo n.º 10
0
 // Use this for initialization
 private void Start()
 {
     Radar.RegisterRadarObject(gameObject, Image);
 }
Ejemplo n.º 11
0
 void Awake()
 {
     instance = this;
 }
Ejemplo n.º 12
0
    void HandleDetection(Radar radar)
    {
        /*
         * Neighbors are cached on radar detection.
         *
         * This means that IsInNeighborhood is evaluated when
         * detected, not every time that the behavior is going to
         * calculate its forces.
         *
         * This helps in lowering the processing load, but could
         * lead to a case where a vehicle is beyond the set parameters
         * but still considered a neighbor.
         *
         * If this is a concern, make sure that vehicles are detected
         * as often as the vehicle updates is forces.
         *
         */

        _neighbors.Clear();
        // I'd prefer an iterator, but trying to cut down on allocations
        for (int i = 0; i < radar.Vehicles.Count; i++)
        {
            var other = radar.Vehicles[i];
            if (Vehicle.IsInNeighborhood(other, MinRadius, MaxRadius, AngleCos))
            {
                _neighbors.Add(other);
            }
        }
    }
Ejemplo n.º 13
0
        public override void Apply(CrtSequence crtSequence)
        {
            if (!(crtSequence.ChartType is Radar))
            {
                throw new Exception("Invalid chart type");
            }

            Radar radar = crtSequence.ChartType as Radar;

            // c:radarChart
            _writer.WriteStartElement(Dml.Chart.Prefix, Dml.Chart.ElRadarChart, Dml.Chart.Ns);
            {
                // c:radarStyle
                writeValueElement(Dml.Chart.ElRadarStyle, mapRadarStyle(crtSequence.SsSequence));

                // c:varyColors: This setting needs to be ignored if the chart has
                //writeValueElement(Dml.Chart.ElVaryColors, crtSequence.ChartFormat.fVaried ? "1" : "0");

                // Radar Chart Series (CT_RadarSer)
                foreach (SeriesFormatSequence seriesFormatSequence in this.ChartFormatsSequence.SeriesFormatSequences)
                {
                    if (seriesFormatSequence.SerToCrt != null && seriesFormatSequence.SerToCrt.id == crtSequence.ChartFormat.idx)
                    {
                        // c:ser
                        _writer.WriteStartElement(Dml.Chart.Prefix, Dml.Chart.ElSer, Dml.Chart.Ns);

                        // EG_SerShared
                        seriesFormatSequence.Convert(new SeriesMapping(this.WorkbookContext, this.ChartContext));

                        // c:marker

                        // c:dPt (Data Points)
                        for (int i = 1; i < seriesFormatSequence.SsSequence.Count; i++)
                        {
                            // write a dPt for each SsSequence
                            SsSequence sss = seriesFormatSequence.SsSequence[i];
                            sss.Convert(new DataPointMapping(this.WorkbookContext, this.ChartContext, i - 1));
                        }

                        // c:dLbls (Data Labels)
                        this.ChartFormatsSequence.Convert(new DataLabelMapping(this.WorkbookContext, this.ChartContext, seriesFormatSequence));

                        // c:cat (Category Axis Data)
                        seriesFormatSequence.Convert(new CatMapping(this.WorkbookContext, this.ChartContext, Dml.Chart.ElCat));

                        // c:val
                        seriesFormatSequence.Convert(new ValMapping(this.WorkbookContext, this.ChartContext, Dml.Chart.ElVal));

                        _writer.WriteEndElement(); // c:ser
                    }
                }

                // Data Labels


                // Axis Ids
                foreach (int axisId in crtSequence.ChartFormat.AxisIds)
                {
                    writeValueElement(Dml.Chart.ElAxId, axisId.ToString());
                }
            }
            _writer.WriteEndElement();
        }
Ejemplo n.º 14
0
 // Use this for initialization
 void Start()
 {
     damage = 5;
     fitness = 0;
     moveSpeed = 15.0f;
     rotateSpeed = 100.0f;
     alive = true;
     animSelector = GetComponentsInChildren<LizardAnimationSelector>();
     player = GameObject.Find ("Warrior");
     hp = player.GetComponent<Experience>().enemyHealth;
     inputs = new List<double>();
     outputs = new List<double>();
     net = GetComponent<NeuralNet>();
     rays = GetComponent<Sensors>();
     radar = GetComponent<Radar>();
     catWrath = GameObject.FindGameObjectWithTag ("catslider");
     transform.Translate (Vector3.up);
 }
Ejemplo n.º 15
0
 public Corvette(MainHull hull, FtlDrive ftlDrive, CombatComputer combatComputer, Thruster thruster, Radar radar)
 {
     this.hull           = hull;
     this.ftlDrive       = ftlDrive;
     this.combatComputer = combatComputer;
     this.thruster       = thruster;
     this.radar          = radar;
 }
Ejemplo n.º 16
0
    // Use this for initialization
    void Start()
    {
        string username = "******";

        if (!isLocalPlayer)
        {
            DisableComponents();
            AssignRemoteLayer();
        }
        else
        {
            // If we have a main camera and it has been marked as main
            //sceneCamera = Camera.main;
            if (sceneCamera != null)
            {
                //sceneCamera.gameObject.SetActive(false);
            }

            playerUIInstance      = Instantiate(playerUIPrefab);
            playerUIInstance.name = playerUIPrefab.name;

            PlayerUI playerUI = playerUIInstance.GetComponent <PlayerUI>();  // PlayerUI component of the PlayerUI instance

            EnergyScript energy = this.gameObject.GetComponent <EnergyScript>();
            energy.energyBarImage = playerUI.energyBar;
            energy.chargeBarImage = playerUI.chargeEnergyBar;

            Health health = this.gameObject.GetComponent <Health>();
            health.HealthImage = playerUI.healthBar;

            //     HealthBarManager healthBarManager = GameObject.FindObjectOfType<HealthBarManager>();


            ComboMeter combometer = this.gameObject.GetComponent <ComboMeter>();
            combometer.ComboCounterText = playerUI.comboCounterText;
            combometer.ComboTimerBar    = playerUI.comboCounterTimer;

            DragonAttack dragonAttack = this.gameObject.GetComponent <DragonAttack>();
            dragonAttack.raycaster = playerUIInstance.GetComponent <GraphicRaycaster>();

            Radar radar = this.gameObject.GetComponent <Radar>();
            radar = playerUI.radar;

            MoveJoystick joystick = playerUI.joystick.GetComponent <MoveJoystick>();
            this.gameObject.GetComponent <PlayerMovement>().SetJoystick(joystick);

            bStartTimeCheck = false;
        }

        RegisterPlayer();
        GetComponent <Player>().Setup();


        if (UserAccountManager.IsLoggedIn)
        {
            username = UserAccountManager.LoggedIn_Username;
        }
        else
        {
            username = transform.name;
        }

        CmdSetUsername(transform.name, username);
    }
 void Start()
 {
     m_vehicle = gameObject.GetComponent <Vehicle>();
     maxSpeed  = m_vehicle.maxSpeed;
     radar     = gameObject.GetComponent <Radar>();
 }
Ejemplo n.º 18
0
        private static string IndividualRadar(Radar radar, bool showTestAlert = false)
        {
            List <Alert> listAlertByRadar = null;

            if (radar != null)
            {
                listAlertByRadar = Alert.ListOfAlerts.Where(s => s.Radar != null && s.Radar.Name == radar.Name).ToList();
            }
            else
            {
                listAlertByRadar = Alert.ListOfAlerts.Where(w => w.TimeCreated > DateTime.Now.AddHours(-6)).ToList();
            }

            if (!showTestAlert)
            {
                listAlertByRadar = listAlertByRadar.Where(w => w.Icon != IconType.GoodNightAnnoucement).ToList();
            }

            StringBuilder strBuilder = new StringBuilder();

            strBuilder.Append(@"<link rel='icon' type='image/png' href='data:image/png;base64,AAABAAEAEBAQAAEABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAA
AAAAAAAoqwAAT09PAP///wApKSkAgoKCAB6AAAAdegAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAZmZmZmZmZmZlVVVVVVVVVmUAAAAAAABWZQAzMzMzAFZlADAGYAMAVmAAAAZg
AAAGYFUABmAAVQZgVQAGYABVBmAAAAZgAAAGYAIiJmIiIAZgAjEmYjEgBmACMyZiMyAGYAJCJmJC
IAZgAAAAAAAABmUAAAAAAABWZmZmZmZmZmYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' />");
            strBuilder.Append("<meta name=viewport content='width=device-width, initial-scale=1'>");
            if (!System.Globalization.CultureInfo.CurrentCulture.TextInfo.IsRightToLeft)
            {
                strBuilder.Append("<link rel='stylesheet' type='text/css' href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css'>");
            }
            else
            {
                strBuilder.Append("<link rel='stylesheet' type='text/css' href='https://cdnjs.cloudflare.com/ajax/libs/bootstrap-rtl/3.2.0-rc2/css/bootstrap-rtl.min.css'>");
            }

            strBuilder.Append("<title>Robot Bum </title>");
            strBuilder.Append("<meta http-equiv='refresh' content='30' >");
            strBuilder.Append("<h3><b>Robot Bum");
            if (radar != null)
            {
                strBuilder.Append(String.Format(" ({0})", radar.Name));
            }


            strBuilder.Append("</b></h3>");


            strBuilder.Append("<span class='visible-lg-inline visible-md-inline'><b>Online time: " + (DateTime.Now - OpenDateTime).ToString(@"dd\ hh\:mm\:ss") + "</b></span><hr/>");

            for (int i = listAlertByRadar.Count - 1; i >= 0; i--)
            {
                try
                {
                    if (listAlertByRadar[i].AlertType != PluginAlertType.NoAlert)
                    {
                        if (listAlertByRadar[i].AlertType == PluginAlertType.High)
                        {
                            strBuilder.Append("<font color=red>");
                        }
                        else if (listAlertByRadar[i].AlertType == PluginAlertType.Medium)
                        {
                            strBuilder.Append("<font color=darkorange>");
                        }
                        else if (listAlertByRadar[i].AlertType == PluginAlertType.Low)
                        {
                            strBuilder.Append("<font color=green>");
                        }
                        else if (listAlertByRadar[i].AlertType == PluginAlertType.Test)
                        {
                            strBuilder.Append("<font color=darkgray>");
                        }

                        if (radar != null)
                        {
                            strBuilder.Append("<span ><b class='visible-lg-inline visible-md-inline'>" + listAlertByRadar[i].TimeCreated.ToString() + "</b></span>");
                            //strBuilder.Append("<span><b>" + listAlertByRadar[i].TimeCreated.ToString("HH:mm") + "</b>");
                        }
                        else
                        {
                            strBuilder.Append("<span><b class='visible-lg-inline visible-md-inline'> " + Alert.ListOfAlerts[i].TimeCreated.ToString() + "</b></span>");
                            //strBuilder.Append("<span><b>" + listAlertByRadar[i].TimeCreated.ToString("HH:mm") + "</b> - ");
                            strBuilder.Append("<span><b><a href='main/" + listAlertByRadar[i].Radar.Name + "/index.html'>" + listAlertByRadar[i].Radar.Description + "</a></b></span>");
                        }

                        strBuilder.Append(" - ");
                        if (!String.IsNullOrEmpty(listAlertByRadar[i].Message))
                        {
                            var start = listAlertByRadar[i].Message.ToString().Split('#').ToList();
                            if (start.Count == 1)
                            {
                                strBuilder.Append(listAlertByRadar[i].Message.ToString());
                            }
                            else
                            {
                                strBuilder.Append("<span>" + start.FirstOrDefault() + "</span>");
                                strBuilder.Append("<span class='visible-lg-inline'>" + listAlertByRadar[i].Message.ToString().Replace(start.FirstOrDefault(), "") + "</span>");
                            }
                        }
                        strBuilder.Append("</font></span>");

                        strBuilder.Append("<span class='visible-lg-inline'><font color=lightgray> ");

                        strBuilder.Append("</font></span>");

                        strBuilder.Append("<br/>");
                    }
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
            strBuilder.Append("<hr/>");

            strBuilder.Append("<hr/>");
            strBuilder.Append("<h5>Robot Bum</h5>");



            return(strBuilder.ToString());
        }
Ejemplo n.º 19
0
    public void OnRadarEnter( Collider other, Radar sender )
    {
        VehicleBehaviour vehicleBehaviour;
        Obstacle obstacle;

        if( ( 1 << other.gameObject.layer & obstacleLayers ) > 0 )
        {
            obstacle = SphericalObstacle.GetObstacle( other.gameObject );
            if( obstacle != null )
            {
                vehicle.Obstacles.Add( obstacle );
            }
        }
        else
        {
            vehicleBehaviour = other.GetComponent( typeof( VehicleBehaviour ) ) as VehicleBehaviour;
            if( vehicleBehaviour != null )
            {
                vehicle.Neighbors.Add( vehicleBehaviour.Vehicle );
            }
        }
    }
Ejemplo n.º 20
0
 public static bool IsAirplaneInApproximation(AirplaneBasic airplane, Radar radar)
 {
     return(airplane.Altitude <= 28000);
 }
Ejemplo n.º 21
0
        public override IEnumerable <object> UpdateState()
        {
            //spawn some fish next to the player
            GameMain.GameScreen.BackgroundCreatureManager.SpawnSprites(2,
                                                                       Submarine.MainSub.Position + Character.Controlled.Position);

            foreach (Item item in Item.ItemList)
            {
                var wire = item.GetComponent <Wire>();
                if (wire != null && wire.Connections.Any(c => c != null))
                {
                    wire.Locked = true;
                }
            }

            yield return(new WaitForSeconds(4.0f));

            infoBox = CreateInfoFrame("Use WASD to move and the mouse to look around");

            yield return(new WaitForSeconds(5.0f));

            //-----------------------------------

            infoBox = CreateInfoFrame("Open the door at your right side by highlighting the button next to it with your cursor and pressing E");

            Door tutorialDoor = Item.ItemList.Find(i => i.HasTag("tutorialdoor")).GetComponent <Door>();

            while (!tutorialDoor.IsOpen && Character.Controlled.WorldPosition.X < tutorialDoor.Item.WorldPosition.X)
            {
                yield return(CoroutineStatus.Running);
            }

            yield return(new WaitForSeconds(2.0f));

            //-----------------------------------

            infoBox = CreateInfoFrame("Hold W or S to walk up or down stairs. Use shift to run.", true);

            while (infoBox != null)
            {
                yield return(CoroutineStatus.Running);
            }

            //-----------------------------------

            infoBox = CreateInfoFrame("At the moment the submarine has no power, which means that crucial systems such as the oxygen generator or the engine aren't running. Let's fix this: go to the upper left corner of the submarine, where you'll find a nuclear reactor.");

            Reactor reactor = Item.ItemList.Find(i => i.HasTag("tutorialreactor")).GetComponent <Reactor>();

            reactor.MeltDownTemp = 20000.0f;

            while (Vector2.Distance(Character.Controlled.Position, reactor.Item.Position) > 200.0f)
            {
                yield return(CoroutineStatus.Running);
            }

            infoBox = CreateInfoFrame("The reactor requires fuel rods to generate power. You can grab one from the steel cabinet by walking next to it and pressing E.");

            while (Character.Controlled.SelectedConstruction == null || Character.Controlled.SelectedConstruction.Name != "Steel Cabinet")
            {
                yield return(CoroutineStatus.Running);
            }

            infoBox = CreateInfoFrame("Pick up one of the fuel rods either by double-clicking or dragging and dropping it into your inventory.");

            while (!HasItem("Fuel Rod"))
            {
                yield return(CoroutineStatus.Running);
            }

            infoBox = CreateInfoFrame("Select the reactor by walking next to it and pressing E.");

            while (Character.Controlled.SelectedConstruction != reactor.Item)
            {
                yield return(CoroutineStatus.Running);
            }
            yield return(new WaitForSeconds(0.5f));

            infoBox = CreateInfoFrame("Load the fuel rod into the reactor by dropping it into any of the 5 slots.");

            while (reactor.AvailableFuel <= 0.0f)
            {
                yield return(CoroutineStatus.Running);
            }

            infoBox = CreateInfoFrame("The reactor is now fueled up. Try turning it on by increasing the fission rate.");

            while (reactor.FissionRate <= 0.0f)
            {
                yield return(CoroutineStatus.Running);
            }
            yield return(new WaitForSeconds(0.5f));

            infoBox = CreateInfoFrame("The reactor core has started generating heat, which in turn generates power for the submarine. The power generation is very low at the moment,"
                                      + " because the reactor is set to shut itself down when the temperature rises above 500 degrees Celsius. You can adjust the temperature limit by changing the \"Shutdown Temperature\" in the control panel.", true);

            while (infoBox != null)
            {
                reactor.ShutDownTemp = Math.Min(reactor.ShutDownTemp, 5000.0f);
                yield return(CoroutineStatus.Running);
            }
            yield return(new WaitForSeconds(0.5f));

            infoBox = CreateInfoFrame("The amount of power generated by the reactor should be kept close to the amount of power consumed by the devices in the submarine. "
                                      + "If there isn't enough power, devices won't function properly (or at all), and if there's too much power, some devices may be damaged."
                                      + " Try to raise the temperature of the reactor close to 3000 degrees by adjusting the fission and cooling rates.", true);

            while (Math.Abs(reactor.Temperature - 3000.0f) > 100.0f)
            {
                reactor.AutoTemp     = false;
                reactor.ShutDownTemp = Math.Min(reactor.ShutDownTemp, 5000.0f);
                yield return(CoroutineStatus.Running);
            }
            yield return(new WaitForSeconds(0.5f));

            infoBox = CreateInfoFrame("Looks like we're up and running! Now you should turn on the \"Automatic temperature control\", which will make the reactor "
                                      + "automatically adjust the temperature to a suitable level. Even though it's an easy way to keep the reactor up and running most of the time, "
                                      + "you should keep in mind that it changes the temperature very slowly and carefully, which may cause issues if there are sudden changes in grid load.");

            while (!reactor.AutoTemp)
            {
                yield return(CoroutineStatus.Running);
            }
            yield return(new WaitForSeconds(0.5f));

            infoBox = CreateInfoFrame("That's the basics of operating the reactor! Now that there's power available for the engines, it's time to get the submarine moving. "
                                      + "Deselect the reactor by pressing E and head to the command room at the right edge of the vessel.");

            Steering steering = Item.ItemList.Find(i => i.HasTag("tutorialsteering")).GetComponent <Steering>();
            Radar    radar    = steering.Item.GetComponent <Radar>();

            while (Vector2.Distance(Character.Controlled.Position, steering.Item.Position) > 150.0f)
            {
                yield return(CoroutineStatus.Running);
            }

            CoroutineManager.StartCoroutine(KeepReactorRunning(reactor));

            infoBox = CreateInfoFrame("Select the navigation terminal by walking next to it and pressing E.");

            while (Character.Controlled.SelectedConstruction != steering.Item)
            {
                yield return(CoroutineStatus.Running);
            }
            yield return(new WaitForSeconds(0.5f));

            infoBox = CreateInfoFrame("There seems to be something wrong with the navigation terminal." +
                                      " There's nothing on the monitor, so it's probably out of power. The reactor must still be"
                                      + " running or the lights would've gone out, so it's most likely a problem with the wiring."
                                      + " Deselect the terminal by pressing E to start checking the wiring.");

            while (Character.Controlled.SelectedConstruction == steering.Item)
            {
                yield return(CoroutineStatus.Running);
            }
            yield return(new WaitForSeconds(1.0f));

            infoBox = CreateInfoFrame("You need a screwdriver to check the wiring of the terminal."
                                      + " Equip a screwdriver by pulling it to either of the slots with a hand symbol, and then use it on the terminal by left clicking.");

            while (Character.Controlled.SelectedConstruction != steering.Item ||
                   Character.Controlled.SelectedItems.FirstOrDefault(i => i != null && i.Name == "Screwdriver") == null)
            {
                yield return(CoroutineStatus.Running);
            }


            infoBox = CreateInfoFrame("Here you can see all the wires connected to the terminal. Apparently there's no wire"
                                      + " going into the to the power connection - that's why the monitor isn't working."
                                      + " You should find a piece of wire to connect it. Try searching some of the cabinets scattered around the sub.");

            while (!HasItem("Wire"))
            {
                yield return(CoroutineStatus.Running);
            }

            infoBox = CreateInfoFrame("Head back to the navigation terminal to fix the wiring.");

            PowerTransfer junctionBox = Item.ItemList.Find(i => i != null && i.HasTag("tutorialjunctionbox")).GetComponent <PowerTransfer>();

            while ((Character.Controlled.SelectedConstruction != junctionBox.Item &&
                    Character.Controlled.SelectedConstruction != steering.Item) ||
                   Character.Controlled.SelectedItems.FirstOrDefault(i => i != null && i.Name == "Screwdriver") == null)
            {
                yield return(CoroutineStatus.Running);
            }

            if (Character.Controlled.SelectedItems.FirstOrDefault(i => i != null && i.GetComponent <Wire>() != null) == null)
            {
                infoBox = CreateInfoFrame("Equip the wire by dragging it to one of the slots with a hand symbol.");

                while (Character.Controlled.SelectedItems.FirstOrDefault(i => i != null && i.GetComponent <Wire>() != null) == null)
                {
                    yield return(CoroutineStatus.Running);
                }
            }

            infoBox = CreateInfoFrame("You can see the equipped wire at the middle of the connection panel. Drag it to the power connector.");

            var steeringConnection = steering.Item.Connections.Find(c => c.Name.Contains("power"));

            while (steeringConnection.Wires.FirstOrDefault(w => w != null) == null)
            {
                yield return(CoroutineStatus.Running);
            }

            infoBox = CreateInfoFrame("Now you have to connect the other end of the wire to a power source. "
                                      + "The junction box in the room just below the command room should do.");

            while (Character.Controlled.SelectedConstruction != null)
            {
                yield return(CoroutineStatus.Running);
            }

            yield return(new WaitForSeconds(2.0f));

            infoBox = CreateInfoFrame("You can now move the other end of the wire around, and attach it on the wall by left clicking or "
                                      + "remove the previous attachment by right clicking. Or if you don't care for neatly laid out wiring, you can just "
                                      + "run it straight to the junction box.");

            while (Character.Controlled.SelectedConstruction == null || Character.Controlled.SelectedConstruction.GetComponent <PowerTransfer>() == null)
            {
                yield return(CoroutineStatus.Running);
            }

            infoBox = CreateInfoFrame("Connect the wire to the junction box by pulling it to the power connection, the same way you did with the navigation terminal.");

            while (radar.Voltage < 0.1f)
            {
                yield return(CoroutineStatus.Running);
            }

            infoBox = CreateInfoFrame("Great! Now we should be able to get moving.");


            while (Character.Controlled.SelectedConstruction != steering.Item)
            {
                yield return(CoroutineStatus.Running);
            }

            infoBox = CreateInfoFrame("You can take a look at the area around the sub by selecting the \"Sonar\" checkbox.");

            while (!radar.IsActive)
            {
                yield return(CoroutineStatus.Running);
            }
            yield return(new WaitForSeconds(0.5f));

            infoBox = CreateInfoFrame("The green rectangle in the middle is the submarine, and the flickering shapes outside it are the walls of an underwater cavern. "
                                      + "Try moving the submarine by clicking somewhere on the monitor and dragging the pointer to the direction you want to go to.");

            while (steering.TargetVelocity == Vector2.Zero && steering.TargetVelocity.Length() < 50.0f)
            {
                yield return(CoroutineStatus.Running);
            }
            yield return(new WaitForSeconds(4.0f));

            infoBox = CreateInfoFrame("The submarine moves up and down by pumping water in and out of the two ballast tanks at the bottom of the submarine. "
                                      + "The engine at the back of the sub moves it forwards and backwards.", true);

            while (infoBox != null)
            {
                yield return(CoroutineStatus.Running);
            }

            infoBox = CreateInfoFrame("Steer the submarine downwards, heading further into the cavern.");

            while (Submarine.MainSub.WorldPosition.Y > 40000.0f)
            {
                yield return(CoroutineStatus.Running);
            }
            yield return(new WaitForSeconds(1.0f));

            var moloch = Character.Create(
                "Content/Characters/Moloch/moloch.xml",
                steering.Item.WorldPosition + new Vector2(3000.0f, -500.0f));

            moloch.PlaySound(CharacterSound.SoundType.Attack);

            yield return(new WaitForSeconds(1.0f));

            infoBox = CreateInfoFrame("Uh-oh... Something enormous just appeared on the radar.");

            List <Structure> windows = new List <Structure>();

            foreach (Structure s in Structure.WallList)
            {
                if (s.CastShadow || !s.HasBody)
                {
                    continue;
                }

                if (s.Rect.Right > steering.Item.CurrentHull.Rect.Right)
                {
                    windows.Add(s);
                }
            }

            float slowdownTimer = 1.0f;
            bool  broken        = false;

            do
            {
                steering.TargetVelocity = Vector2.Zero;

                slowdownTimer = Math.Max(0.0f, slowdownTimer - CoroutineManager.DeltaTime * 0.3f);
                Submarine.MainSub.Velocity *= slowdownTimer;

                moloch.AIController.SelectTarget(steering.Item.CurrentHull.AiTarget);
                Vector2 steeringDir = windows[0].WorldPosition - moloch.WorldPosition;
                if (steeringDir != Vector2.Zero)
                {
                    steeringDir = Vector2.Normalize(steeringDir);
                }

                moloch.AIController.SteeringManager.SteeringManual(CoroutineManager.DeltaTime, steeringDir * 100.0f);

                foreach (Structure window in windows)
                {
                    for (int i = 0; i < window.SectionCount; i++)
                    {
                        if (!window.SectionIsLeaking(i))
                        {
                            continue;
                        }
                        broken = true;
                        break;
                    }
                    if (broken)
                    {
                        break;
                    }
                }
                if (broken)
                {
                    break;
                }

                yield return(CoroutineStatus.Running);
            } while (!broken);

            //fix everything except the command windows
            foreach (Structure w in Structure.WallList)
            {
                bool isWindow = windows.Contains(w);

                for (int i = 0; i < w.SectionCount; i++)
                {
                    if (!w.SectionIsLeaking(i))
                    {
                        continue;
                    }

                    if (isWindow)
                    {
                        //decrease window damage to slow down the leaking
                        w.AddDamage(i, -w.SectionDamage(i) * 0.48f);
                    }
                    else
                    {
                        w.AddDamage(i, -100000.0f);
                    }
                }
            }

            Submarine.MainSub.GodMode = true;

            var capacitor1 = Item.ItemList.Find(i => i.HasTag("capacitor1")).GetComponent <PowerContainer>();
            var capacitor2 = Item.ItemList.Find(i => i.HasTag("capacitor1")).GetComponent <PowerContainer>();

            CoroutineManager.StartCoroutine(KeepEnemyAway(moloch, new PowerContainer[] { capacitor1, capacitor2 }));

            infoBox = CreateInfoFrame("The hull has been breached! Close all the doors to the command room to stop the water from flooding the entire sub!");

            Door commandDoor1 = Item.ItemList.Find(i => i.HasTag("commanddoor1")).GetComponent <Door>();
            Door commandDoor2 = Item.ItemList.Find(i => i.HasTag("commanddoor2")).GetComponent <Door>();
            Door commandDoor3 = Item.ItemList.Find(i => i.HasTag("commanddoor3")).GetComponent <Door>();

            //wait until the player is out of the room and the doors are closed
            while (Character.Controlled.WorldPosition.X > commandDoor1.Item.WorldPosition.X ||
                   (commandDoor1.IsOpen || (commandDoor2.IsOpen || commandDoor3.IsOpen)))
            {
                //prevent the hull from filling up completely and crushing the player
                steering.Item.CurrentHull.Volume = Math.Min(steering.Item.CurrentHull.Volume, steering.Item.CurrentHull.FullVolume * 0.9f);
                yield return(CoroutineStatus.Running);
            }


            infoBox = CreateInfoFrame("You should quickly find yourself a diving mask or a diving suit. " +
                                      "There are some in the room next to the airlock.");

            bool divingMaskSelected = false;

            while (!HasItem("Diving Mask") && !HasItem("Diving Suit"))
            {
                if (!divingMaskSelected &&
                    Character.Controlled.ClosestItem != null && Character.Controlled.ClosestItem.Name == "Diving Suit")
                {
                    infoBox = CreateInfoFrame("There can only be one item in each inventory slot, so you need to take off "
                                              + "the jumpsuit if you wish to wear a diving suit.");

                    divingMaskSelected = true;
                }

                yield return(CoroutineStatus.Running);
            }

            if (HasItem("Diving Mask"))
            {
                infoBox = CreateInfoFrame("The diving mask will let you breathe underwater, but it won't protect from the water pressure outside the sub. " +
                                          "It should be fine for the situation at hand, but you still need to find an oxygen tank and drag it into the same slot as the mask." +
                                          "You should grab one or two from one of the cabinets.");
            }
            else if (HasItem("Diving Suit"))
            {
                infoBox = CreateInfoFrame("In addition to letting you breathe underwater, the suit will protect you from the water pressure outside the sub " +
                                          "(unlike the diving mask). However, you still need to drag an oxygen tank into the same slot as the suit to supply oxygen. " +
                                          "You should grab one or two from one of the cabinets.");
            }

            while (!HasItem("Oxygen Tank"))
            {
                yield return(CoroutineStatus.Running);
            }

            yield return(new WaitForSeconds(5.0f));

            infoBox = CreateInfoFrame("Now you should stop the creature attacking the submarine before it does any more damage. Head to the railgun room at the upper right corner of the sub.");

            var railGun = Item.ItemList.Find(i => i.GetComponent <Turret>() != null);

            while (Vector2.Distance(Character.Controlled.Position, railGun.Position) > 500)
            {
                yield return(new WaitForSeconds(1.0f));
            }

            infoBox = CreateInfoFrame("The railgun requires a large power surge to fire. The reactor can't provide a surge large enough, so we need to use the "
                                      + " supercapacitors in the railgun room. The capacitors need to be charged first; select them and crank up the recharge rate.");

            while (capacitor1.RechargeSpeed < 0.5f && capacitor2.RechargeSpeed < 0.5f)
            {
                yield return(new WaitForSeconds(1.0f));
            }

            infoBox = CreateInfoFrame("The capacitors take some time to recharge, so now is a good " +
                                      "time to head to the room below and load some shells for the railgun.");


            var loader = Item.ItemList.Find(i => i.Name == "Railgun Loader").GetComponent <ItemContainer>();

            while (Math.Abs(Character.Controlled.Position.Y - loader.Item.Position.Y) > 80)
            {
                yield return(CoroutineStatus.Running);
            }

            infoBox = CreateInfoFrame("Grab one of the shells. You can load it by selecting the railgun loader and dragging the shell to. "
                                      + "one of the free slots. You need two hands to carry a shell, so make sure you don't have anything else in either hand.");

            while (loader.Item.ContainedItems.FirstOrDefault(i => i != null && i.Name == "Railgun Shell") == null)
            {
                moloch.Health = 50.0f;

                capacitor1.Charge += 5.0f;
                capacitor2.Charge += 5.0f;
                yield return(CoroutineStatus.Running);
            }

            infoBox = CreateInfoFrame("Now we're ready to shoot! Select the railgun controller.");

            while (Character.Controlled.SelectedConstruction == null || Character.Controlled.SelectedConstruction.Name != "Railgun Controller")
            {
                yield return(CoroutineStatus.Running);
            }

            moloch.AnimController.SetPosition(ConvertUnits.ToSimUnits(Character.Controlled.WorldPosition + Vector2.UnitY * 600.0f));

            infoBox = CreateInfoFrame("Use the right mouse button to aim and wait for the creature to come closer. When you're ready to shoot, "
                                      + "press the left mouse button.");

            while (!moloch.IsDead)
            {
                if (moloch.WorldPosition.Y > Character.Controlled.WorldPosition.Y + 600.0f)
                {
                    moloch.AIController.SteeringManager.SteeringManual(CoroutineManager.DeltaTime, Character.Controlled.WorldPosition - moloch.WorldPosition);
                }

                moloch.AIController.SelectTarget(Character.Controlled.AiTarget);
                yield return(CoroutineStatus.Running);
            }

            Submarine.MainSub.GodMode = false;

            infoBox = CreateInfoFrame("The creature has died. Now you should fix the damages in the control room: " +
                                      "Grab a welding tool from the closet in the railgun room.");

            while (!HasItem("Welding Tool"))
            {
                yield return(CoroutineStatus.Running);
            }

            infoBox = CreateInfoFrame("The welding tool requires fuel to work. Grab a welding fuel tank and attach it to the tool " +
                                      "by dragging it into the same slot.");

            do
            {
                var weldingTool = Character.Controlled.Inventory.Items.FirstOrDefault(i => i != null && i.Name == "Welding Tool");
                if (weldingTool != null &&
                    weldingTool.ContainedItems.FirstOrDefault(contained => contained != null && contained.Name == "Welding Fuel Tank") != null)
                {
                    break;
                }

                yield return(CoroutineStatus.Running);
            } while (true);


            infoBox = CreateInfoFrame("You can aim with the tool using the right mouse button and weld using the left button. " +
                                      "Head to the command room to fix the leaks there.");

            do
            {
                broken = false;
                foreach (Structure window in windows)
                {
                    for (int i = 0; i < window.SectionCount; i++)
                    {
                        if (!window.SectionIsLeaking(i))
                        {
                            continue;
                        }
                        broken = true;
                        break;
                    }
                    if (broken)
                    {
                        break;
                    }
                }

                yield return(new WaitForSeconds(1.0f));
            } while (broken);

            infoBox = CreateInfoFrame("The hull is fixed now, but there's still quite a bit of water inside the sub. It should be pumped out "
                                      + "using the bilge pump in the room at the bottom of the submarine.");

            Pump pump = Item.ItemList.Find(i => i.HasTag("tutorialpump")).GetComponent <Pump>();

            while (Vector2.Distance(Character.Controlled.Position, pump.Item.Position) > 100.0f)
            {
                yield return(CoroutineStatus.Running);
            }

            infoBox = CreateInfoFrame("The two pumps inside the ballast tanks "
                                      + "are connected straight to the navigation terminal and can't be manually controlled unless you mess with their wiring, " +
                                      "so you should only use the pump in the middle room to pump out the water. Select it, turn it on and adjust the pumping speed " +
                                      "to start pumping water out.", true);

            while (infoBox != null)
            {
                yield return(CoroutineStatus.Running);
            }


            bool brokenMsgShown = false;

            Item brokenBox = null;

            while (pump.FlowPercentage > 0.0f || pump.CurrFlow <= 0.0f || !pump.IsActive)
            {
                if (!brokenMsgShown && pump.Voltage < pump.MinVoltage && Character.Controlled.SelectedConstruction == pump.Item)
                {
                    brokenMsgShown = true;

                    infoBox = CreateInfoFrame("Looks like the pump isn't getting any power. The water must have short-circuited some of the junction "
                                              + "boxes. You can check which boxes are broken by selecting them.");

                    while (true)
                    {
                        if (Character.Controlled.SelectedConstruction != null &&
                            Character.Controlled.SelectedConstruction.GetComponent <PowerTransfer>() != null &&
                            Character.Controlled.SelectedConstruction.Condition == 0.0f)
                        {
                            brokenBox = Character.Controlled.SelectedConstruction;

                            infoBox = CreateInfoFrame("Here's our problem: this junction box is broken. Luckily engineers are adept at fixing electrical devices - "
                                                      + "you just need to find a spare wire and click the \"Fix\"-button to repair the box.");
                            break;
                        }

                        if (pump.Voltage > pump.MinVoltage)
                        {
                            break;
                        }

                        yield return(CoroutineStatus.Running);
                    }
                }

                if (brokenBox != null && brokenBox.Condition > 50.0f && pump.Voltage < pump.MinVoltage)
                {
                    yield return(new WaitForSeconds(1.0f));

                    if (pump.Voltage < pump.MinVoltage)
                    {
                        infoBox = CreateInfoFrame("The pump is still not running. Check if there are more broken junction boxes between the pump and the reactor.");
                    }
                    brokenBox = null;
                }

                yield return(CoroutineStatus.Running);
            }

            infoBox = CreateInfoFrame("The pump is up and running. Wait for the water to be drained out.");

            while (pump.Item.CurrentHull.Volume > 1000.0f)
            {
                yield return(CoroutineStatus.Running);
            }

            infoBox = CreateInfoFrame("That was all there is to this tutorial! Now you should be able to handle " +
                                      "most of the basic tasks on board the submarine.");

            yield return(new WaitForSeconds(4.0f));

            Character.Controlled = null;
            GameMain.GameScreen.Cam.TargetPos = Vector2.Zero;
            GameMain.LightManager.LosEnabled  = false;

            var cinematic = new TransitionCinematic(Submarine.MainSub, GameMain.GameScreen.Cam, 5.0f);

            while (cinematic.Running)
            {
                yield return(CoroutineStatus.Running);
            }

            Submarine.Unload();
            GameMain.MainMenuScreen.Select();

            yield return(CoroutineStatus.Success);
        }
Ejemplo n.º 22
0
 // Use this for initialization
 void Start()
 {
     radar = GetComponentInChildren <Radar>();
 }
Ejemplo n.º 23
0
        //Radar refresh ( 5 sec. )
        private void tmrRefresh_Tick(object sender, EventArgs e)
        {
            foreach (Plane plane in Planes)
            {
                plane.isWarned  = false;
                plane.isCircled = false;
            }

            List <Plane> PlanesToDelete = new List <Plane> ( );

            foreach (Plane plane in Planes)
            {
                #region Moving the dots of the plane
                plane.Dots [9] = plane.Dots [7];
                plane.Dots [8] = plane.Dots [6];
                plane.Dots [7] = plane.Dots [5];
                plane.Dots [6] = plane.Dots [4];
                plane.Dots [5] = plane.Dots [3];
                plane.Dots [4] = plane.Dots [2];
                plane.Dots [3] = plane.Dots [1];
                plane.Dots [2] = plane.Dots [0];
                plane.Dots [1] = plane.X;
                plane.Dots [0] = plane.Y;
                #endregion

                #region TCAS
                if (Planes.Count > 1)
                {
                    foreach (Plane plane2 in Planes)
                    {
                        if (plane != plane2)
                        {
                            double Distance = Math.Sqrt(Math.Pow(plane2.X - plane.X, 2) + Math.Pow(plane2.Y - plane.Y, 2));

                            if ((Math.Abs(plane.CurAlt - plane2.CurAlt) < 1000) && (plane.CurAlt >= 2000 && plane2.CurAlt >= 2000))
                            {
                                if (Distance < 90)
                                {
                                    plane.isCircled  = true;
                                    plane2.isCircled = true;

                                    if (Distance < 60)
                                    {
                                        plane.isWarned  = true;
                                        plane2.isWarned = true;

                                        if (!Dangerouses.Contains(plane.Callsign + plane2.Callsign))
                                        {
                                            msgBox("Separation error!\nPenalty: - 1000$");
                                            tcas.Play( );

                                            Statistics.Salary -= 1000;
                                            lblSalary.Text     = Statistics.Salary.ToString( ) + "$";

                                            Dangerouses.Add(plane.Callsign + plane2.Callsign);
                                        }

                                        if (Distance < 5 && (plane.CurAlt - plane2.CurAlt <= 100 || plane2.CurAlt - plane.CurAlt <= 100))
                                        {
                                            tmrHeading.Stop( );
                                            tmrNewPlane.Stop( );
                                            tmrRefresh.Stop( );
                                            ScoreCheck( );
                                            alert.Play( );

                                            frmLooser form = new frmLooser("Crash!\nInbound: " + Statistics.Landed.ToString( ) + "\nOutbound: " + Statistics.Outbound.ToString( ));
                                            form.ShowDialog( );
                                            form.Dispose( );
                                            ScoreCheck( );
                                            this.TopMost = true;
                                            MenuForm.Show( );
                                            tmrCloseWindow.Start( );
                                        }
                                    }
                                    else
                                    {
                                        if (Dangerouses.Contains(plane.Callsign + plane2.Callsign))
                                        {
                                            Dangerouses.Remove(plane.Callsign + plane2.Callsign);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                #endregion

                #region Speed
                if (Math.Abs(plane.SetSpd - plane.CurSpd) <= 4)
                {
                    plane.CurSpd = plane.SetSpd;
                }
                else
                {
                    int SpdIncrement = -2;

                    if (plane.SetSpd > plane.CurSpd)
                    {
                        SpdIncrement *= -1;
                    }

                    if (plane.CurAlt <= 5000)
                    {
                        SpdIncrement *= 2;
                    }

                    plane.CurSpd += SpdIncrement;
                }
                #endregion

                #region Altitude
                int AltIncrement = rnd.Next(250, 300);                          //If UP below FL100

                if (plane.SetAlt > plane.CurAlt)
                {
                    if (plane.CurAlt >= 10000)
                    {
                        AltIncrement = rnd.Next(100, 150);
                    }
                }
                else if (plane.SetAlt < plane.CurAlt)
                {
                    if (plane.CurAlt >= 10000)
                    {
                        AltIncrement *= -1;
                    }
                    else
                    {
                        AltIncrement = rnd.Next(70, 120) * -1;
                    }
                }


                if (Math.Abs(plane.SetAlt - plane.CurAlt) < 250)
                {
                    plane.CurAlt = plane.SetAlt;
                }
                else
                {
                    plane.CurAlt += AltIncrement;
                }
                #endregion

                #region Position
                plane.X = ( int )(plane.X + (plane.CurSpd / 20 * Math.Cos(( double )(plane.CurHdg - 90) / 180 * Math.PI)));
                plane.Y = ( int )(plane.Y + (plane.CurSpd / 20 * Math.Sin(( double )(plane.CurHdg - 90) / 180 * Math.PI)));
                #endregion

                #region Heading
                plane.CurHdg = plane.CalcHdg;
                #endregion

                #region Landing/Outbound/FlyOut

                #region Correction of approach
                if (plane.isClearedForApproach)
                {
                    if (plane.Y > Locations.Runway.locy - 15 && plane.Y < Locations.Runway.locy)
                    {
                        plane.SetHdg = 260;
                    }
                    else if (plane.Y < Locations.Runway.locy + 15 && plane.Y > Locations.Runway.locy)
                    {
                        plane.SetHdg = 280;
                    }

                    if (plane.Y > Locations.Runway.locy - 2 && plane.Y < Locations.Runway.locy + 2)
                    {
                        plane.SetHdg = 270;
                    }
                }
                #endregion

                #region Glide/Landing
                if (plane.Controller == "TWR" && !plane.isOutgoing)
                {
                    if (plane.X <= Locations.Runway.locx + 200)
                    {
                        plane.SetSpd = 160;
                        plane.SetAlt = 1000;
                    }

                    if (plane.X <= Locations.Runway.locx + 150)
                    {
                        plane.SetAlt = 0;
                        plane.SetSpd = 130;
                    }

                    if ((plane.X > Locations.Runway.locx + 25 && plane.X < Locations.Runway.locx + 50) || plane.CurAlt <= 200)
                    {
                        PlanesToDelete.Add(plane);

                        Statistics.Landed++;
                        lblLanded.Text = Statistics.Landed.ToString( );

                        Statistics.Salary += 2000;
                        lblSalary.Text     = Statistics.Salary.ToString( ) + "$";
                    }
                }
                #endregion

                #region Outbound
                if (plane.Controller == "CTR" && plane.isOutgoing)
                {
                    if (plane.X > Locations.Outbound.out1x && plane.Y > Locations.Outbound.out1y && plane.Y < Locations.Outbound.out1y + 100)
                    {
                        PlanesToDelete.Add(plane);

                        Statistics.Salary += 2000;
                        lblSalary.Text     = Statistics.Salary.ToString( ) + "$";

                        Statistics.Outbound++;
                        lblOutbound.Text = Statistics.Outbound.ToString( );
                    }
                }
                #endregion

                #region Fly out of sector
                if (plane.X < -20 || plane.X > Radar.Width + 20 || plane.Y < -20 || plane.Y > Radar.Height + 20)
                {
                    msgBox(plane.Callsign + " flyed out from your sector! Penalty: -2000$");

                    Statistics.Salary -= 1000;
                    lblSalary.Text     = Statistics.Salary.ToString( ) + "$";

                    PlanesToDelete.Add(plane);
                }
                #endregion

                #endregion

                #region Setting of borders
                plane.Border.Left   = plane.X;
                plane.Border.Right  = plane.X + 90;
                plane.Border.Top    = plane.Y - 40;
                plane.Border.Bottom = plane.Y - 10;
                #endregion
            }

            if (!VERA.isDetached && SelectedPlane != null && VERA.ConstX != null)
            {
                VERA.ConstX = SelectedPlane.X;
                VERA.ConstY = SelectedPlane.Y;
            }

            foreach (Plane plane in PlanesToDelete)
            {
                Planes.Remove(plane);
                if (SelectedPlane == plane)
                {
                    SelectedPlane = null;
                }
            }

            Menu_Refresh(SelectedPlane);
            Radar.Invalidate( );
        }
Ejemplo n.º 24
0
 public Radar Radar()
 {
     if(this.radar == null)
         radar = new Radar();
     return this.radar;
 }
Ejemplo n.º 25
0
        /// <summary>
        /// Startet den Roboter
        /// </summary>
        public void driveParcour(Robot robot)
        {
            int i = 0;

            numberOfObjects = 0;

            //Robot robot = new Robot();
            robot.Drive.Power = true;
            this.radar        = new Radar(Constants.IORadarSensor);

            // gerade aus fahren
            robot.Drive.RunLine(2.5f, 0.3f, 0.5f);
            while (!robot.Drive.Done)
            {
                // warten bis fertig gefahren
                Thread.Sleep(100);

                // start with measuring
                if (radar.Distance < 1 && i == 0)
                {
                    // begining Object
                    i = 1;  // set beginning of Object
                    robot.RobotConsole[Leds.Led1].LedEnabled = true;
                    robot.RobotConsole[Leds.Led3].LedEnabled = true;
                    robot.RobotConsole[Leds.Led2].LedEnabled = false;
                    robot.RobotConsole[Leds.Led4].LedEnabled = false;
                }

                if (radar.Distance > 1.5f && i == 1)
                {
                    numberOfObjects = numberOfObjects + 1; // increment number of Objects
                    i = 0;                                 // reset help variable for next Objects
                    robot.RobotConsole[Leds.Led1].LedEnabled = false;
                    robot.RobotConsole[Leds.Led3].LedEnabled = false;
                    robot.RobotConsole[Leds.Led2].LedEnabled = true;
                    robot.RobotConsole[Leds.Led4].LedEnabled = true;
                }
            }

            robot.Drive.RunTurn(-90.0f, 0.3f, 0.5f);
            while (!robot.Drive.Done)
            {
                // warten bis fertig gedreht
                Thread.Sleep(100);
            }

            // gerade aus fahren 1.5m
            robot.Drive.RunLine(1.5f, 0.3f, 0.5f);
            while (!robot.Drive.Done)
            {
                // warten bis fertig gefahren
                Thread.Sleep(100);
            }

            robot.Drive.RunTurn(-90.0f, 0.3f, 0.5f);
            while (!robot.Drive.Done)
            {
                // warten bis fertig gedreht
                Thread.Sleep(100);
            }

            // gerade aus fahren 1.5m
            robot.Drive.RunLine(1.5f, 0.3f, 0.5f);
            while (!robot.Drive.Done)
            {
                // warten bis fertig gefahren
                Thread.Sleep(100);
            }

            // Kreis fahren
            robot.Drive.RunArcRight(1.0f, 90.0f, 0.3f, 0.5f);
            while (!robot.Drive.Done)
            {
                // warten bis fertig gefahren
                Thread.Sleep(100);
            }

            // gerade aus fahren 1.5m
            robot.Drive.RunLine(0.2f, 0.3f, 0.5f);
            while (!robot.Drive.Done)
            {
                // warten bis fertig gefahren
                Thread.Sleep(100);
            }

            robot.Drive.RunTurn(-90.0f, 0.3f, 0.5f);
            while (!robot.Drive.Done)
            {
                // warten bis fertig gedreht
                Thread.Sleep(100);
            }

            // Roboter stoppen
            robot.Drive.Stop();
        }
Ejemplo n.º 26
0
        private void InitializeFixtures()
        {
            for (int i = 0; i <= marsWheels.Length - 1; i++)
            {
                Fixture item = new Fixture();
                this.marsWheels[i] = new Wheel();
                double z = i <= 2 ? -1 : 1;

                item.Lock(marsWheels[i], new Point3d(0, 0, z * -0.5));
                fixturesWheels.Add(item);
            }

            driveWheels[0] = marsWheels[2];
            driveWheels[1] = marsWheels[5];

            for (int i = 0; i <= 5; i++)
            {
                Fixture item = new Fixture();
                fixturesCorpse.Add(item);
            }

            fixturesWheels[0].SetPosition(-5, -5, 3);
            fixturesWheels[1].SetPosition(0, -5, 3);
            fixturesWheels[2].SetPosition(6, -5, 3);

            fixturesWheels[3].SetPosition(-5, -5, -3);
            fixturesWheels[4].SetPosition(0, -5, -3);
            fixturesWheels[5].SetPosition(6, -5, -3);

            fixturesCorpse[0].SetPosition(-5, -3.8, 2.6);
            fixturesCorpse[1].SetPosition(0, -4, 2.6);
            fixturesCorpse[2].SetPosition(6, -3.8, 2.6);
            fixturesCorpse[3].SetPosition(-5, -3.8, -2.6);
            fixturesCorpse[4].SetPosition(0, -4, -2.6);
            fixturesCorpse[5].SetPosition(6, -3.8, -2.6);

            for (int i = 0; i <= 1; i++)
            {
                Fixture mainFixture = new Fixture();
                mainFixture.Size = 2;
                fixturesMain.Add(mainFixture);
            }

            fixturesMain[0].SetPosition(2, -3, 2);
            fixturesMain[1].SetPosition(2, -3, -2);

            Block block = new Block(fixturesCorpse[2], fixturesMain[0]);
            fixturesMain[0].Lock(block);

            block = new Block(fixturesCorpse[5], fixturesMain[1]);
            fixturesMain[1].Lock(block);

            for (int i = 0; i <= 1; i++)
            {
                double z = i == 0 ? -1 : 1;
                Fixture item = new Fixture();
                item.Size = 1.5;
                item.SetPosition(-2, -3.6, z * -2.6);
                fixturesCorpse.Add(item);
            }

            block = new Block(fixturesCorpse[6], fixturesMain[0]);
            fixturesMain[0].Lock(block);

            block = new Block(fixturesCorpse[7], fixturesMain[1]);
            fixturesMain[1].Lock(block);

            for (int i = 0; i <= 5; i++)
            {
                block = new Block(marsWheels[i], fixturesCorpse[i]);
                fixturesCorpse[i].Lock(block);
                //fixturesWheels[i].Lock(block);
            }

            for (int i = 0; i <= 1; i++)
            {
                Fixture fixt = fixturesCorpse[i + 6];
                Fixture fcon = fixturesCorpse[i * 3];
                block = new Block(fcon, fixt);
                fixt.Lock(block);

                fcon = fixturesCorpse[i * 3 + 1];
                block = new Block(fcon, fixt);
                fixt.Lock(block);
            }

            Fixture radarBasement = new Fixture();
            radarBasement.Size = 2;
            radarBasement.SetPosition(-1, -1.5, 0);
            fixturesRadar.Add(radarBasement);

            Fixture r2 = new Fixture();
            r2.SetPosition(-1, 3, 0);
            fixturesRadar.Add(r2);

            mainRadar = new Radar();
            r2.Lock(mainRadar);

            block = new Block(r2, radarBasement);
            radarBasement.Lock(block);

            Fixture cameraBasement = new Fixture();
            cameraBasement.Size = 1.5;
            cameraBasement.SetPosition(6.5, -2, 0);
            fixturesCamera.Add(cameraBasement);

            Fixture c2 = new Fixture();
            c2.SetPosition(8.5, 0, 0);
            fixturesCamera.Add(c2);

            Fixture c3 = new Fixture();
            c3.SetPosition(12.5, -1, 0);
            fixturesCamera.Add(c3);

            block = new Block(c2, cameraBasement);
            cameraBasement.Lock(block);

            block = new Block(c3, c2);
            c2.Lock(obj: block, type: PositionType.Absolute);

            scaner = new Scaner();
            scaner.Size = 0.75;
            c2.Lock(obj: c3, type: PositionType.Absolute);
            c3.Lock(scaner);

            //cameraBasement.Lock(c2);
            //c2.Turn(new Point3d(0, 1, 0), 90);

            fixtures.AddRange(fixturesCamera);
            fixtures.AddRange(fixturesCorpse);
            fixtures.AddRange(fixturesMain);
            fixtures.AddRange(fixturesRadar);
            fixtures.AddRange(fixturesWheels);
        }
 /// <summary>
 /// A radar is only compatible (and thus can be assigned)
 /// to this system if it has the same type as the radars already
 /// assigned, or if the system is unclassified.
 /// </summary>
 /// <param name="radar"></param>
 /// <returns></returns>
 private bool IsRadarCompatible(Radar radar)
 {
     return(_assignedType == RadarType.NONE ||
            _assignedType == radar.type);
 }
Ejemplo n.º 28
0
 /// <summary>
 /// 保存雷达信息
 /// </summary>
 /// <param name="loader">雷达对象</param>
 /// <returns></returns>
 public int SaveRadar(Radar radar)
 {
     return(this.provider.ExecuteSql(this.GetRadarSqlString(radar)));
 }
Ejemplo n.º 29
0
 // Update is called once per frame
 private void OnDestroy()
 {
     Radar.RemoveRadarObject(gameObject);
 }
Ejemplo n.º 30
0
 public void OnRadarStay( Collider other, Radar sender )
 {
 }
 // Use this for initialization
 void Start()
 {
     neighbor = this.GetComponent <Radar>();
 }
Ejemplo n.º 32
0
        /// <summary>
        /// Search for enemies in range
        /// </summary>
        /// <returns></returns>
        private bool SearchForEnemy()
        {
            IEnumerable <Pawn> pawns = Radar.FindEnemyPawns(this.Position, radarDistance);

            return(pawns.Count() > 0);
        }
 public void OnRadarExit( Collider other, Radar sender )
 {
     HandleVisibility(other, false);
 }
Ejemplo n.º 34
0
 // Start is called before the first frame update
 void Start()
 {
     Radar.RegisterRadarObject(this.gameObject, image);
 }
Ejemplo n.º 35
0
 // Use this for initialization
 void Start()
 {
     //simply invoke to register with radar
     Radar.RegisterRadarObject(gameObject, image);
 }
Ejemplo n.º 36
0
 public Radar(Radar s) : base(s)
 {
 }
Ejemplo n.º 37
0
        public SurvivalGameScene(Game game, GraphicsDeviceManager graphic, ContentManager content, GraphicsDevice GraphicsDevice, SpriteBatch spriteBatch, Vector2 pausePosition, Rectangle pauseRect, Texture2D actionTexture, CutSceneDialog cutSceneDialog, Radar radar, Texture2D stunnedTexture)
            : base(game)
        {
            graphics = graphic;
            Content = content;
            GraphicDevice = GraphicsDevice;
            this.spriteBatch = spriteBatch;
            this.pausePosition = pausePosition;
            this.pauseRect = pauseRect;
            this.actionTexture = actionTexture;
            this.game = game;
            this.radar = radar;
            this.stunnedIconTexture = stunnedTexture;
            roundTime = TimeSpan.FromSeconds(2592000);
            random = new Random();

            gameCamera = new Camera(GameMode.SurvivalMode);
            boundingSphere = new GameObject();
            hydroBot = new HydroBot(GameConstants.MainGameMaxRangeX, GameConstants.MainGameMaxRangeZ, GameConstants.MainGameFloatHeight, GameMode.SurvivalMode);

            if (File.Exists("SurvivalMode"))
            {
                ObjectsToSerialize objectsToSerialize = new ObjectsToSerialize();
                Serializer serializer = new Serializer();
                string SavedFile = "SurvivalMode";
                objectsToSerialize = serializer.DeSerializeObjects(SavedFile);
                hydroBot = objectsToSerialize.hydrobot;
            }

            //stop spinning the bar
            IngamePresentation.StopSpinning();

            HydroBot.gamePlusLevel = 0;
            HydroBot.gameMode = GameMode.SurvivalMode;
            for (int index = 0; index < GameConstants.numberOfSkills; index++)
            {
                HydroBot.skills[index] = true;
            }

            skillTextures = new Texture2D[GameConstants.numberOfSkills];
            bulletTypeTextures = new Texture2D[GameConstants.numBulletTypes];

            // for the mouse or touch
            cursor = new Cursor(game, spriteBatch);
            //Components.Add(cursor);

            bubbles = new List<Bubble>();
            points = new List<Point>();

            //loading winning, losing textures
            winningTexture = IngamePresentation.winningTexture;
            losingTexture = IngamePresentation.losingTexture;
            scaredIconTexture = IngamePresentation.scaredIconTexture;

            isAncientKilled = false;

            // Instantiate the factory Button
            float buttonScale = 1.0f;
            if (game.Window.ClientBounds.Width <= 900)
            {
                buttonScale = 0.8f; // scale the factory panel icons a bit smaller in small window mode
            }
            factoryButtonPanel = new ButtonPanel(4, buttonScale);

            this.Load();

            gameBoundary = new GameBoundary();
            gameBoundary.LoadGraphicsContent(GraphicDevice);
        }
Ejemplo n.º 38
0
 // Called when object is destroyed
 void OnDestroy()
 {
     //remove from radar
     Radar.RemoveRadarObject(gameObject);
 }
Ejemplo n.º 39
0
 void OnDestroy()
 {
     Radar.RemoveRadarObject(this.gameObject);
 }
Ejemplo n.º 40
0
    /// <summary>
    /// The initialize.
    /// </summary>
    /// <param name="mmoGame">
    /// The game.
    /// </param>
    /// <param name="mmoItem">
    /// The item.
    /// </param>
    /// <param name="worldRadar">
    /// the radar
    /// </param>
    public void Initialize(Game mmoGame, Item mmoItem, Radar worldRadar)
    {
        const int Layer = 1;
        this.radar = worldRadar;
        this.game = mmoGame;
        this.item = mmoItem;

        this.name = "Item" + this.item.Id;
        
        if (this.game.WorldData.Height > this.game.WorldData.Width)
        {
            this.actorHeight = this.game.WorldData.Height / 5f;
        }
        else
        {
            this.actorHeight = this.game.WorldData.Width / 5f;
        }

        this.transform.localScale = new Vector3(this.game.WorldData.Width / 200f, this.actorHeight, this.game.WorldData.Height / 200f);
        this.transform.position = new Vector3(0f, this.actorHeight / 2f, 0f);
        this.gameObject.layer = Layer;
      
        this.actorView = GameObject.CreatePrimitive(PrimitiveType.Cube);
        this.actorView.name = "ActorView" + this.item.Id;
        this.actorView.layer = Layer;

        this.actorText = (GameObject)Instantiate(Resources.Load("ActorName"));
        this.actorText.name = "ActorText" + this.item.Id;
        this.actorText.transform.localScale = new Vector3(this.actorHeight / 8f, this.actorHeight / 8f, this.actorHeight / 8f);
        this.actorText.transform.renderer.material.color = new Color(0, 0, 0);
        this.actorText.layer = Layer;
        this.mainCamera = GameObject.Find("Main Camera");

        this.transform.position = new Vector3(this.item.Position[0], this.transform.position.y, this.item.Position[1]);
        //Debug.Log(this.transform.position);
        this.actorText.transform.position = new Vector3(this.item.Position[0], this.actorText.transform.position.y, this.item.Position[1]);
        this.actorView.transform.position = new Vector3(this.item.Position[0], this.actorView.transform.position.y, this.item.Position[1]);

        this.ShowActor(false);
    }
Ejemplo n.º 41
0
    private float m_timer;      //actual timer for enemy spawn

    private void Start()
    {
        m_timer    = m_spawnTimer;  //set spawn time
        m_setTimer = m_spawnTimer;
        m_radar    = GetComponent <Radar>();
    }
Ejemplo n.º 42
0
    protected override void Awake()
    {
        base.Awake();
        GameObject = gameObject;
        Rigidbody = GetComponent<Rigidbody>();
        var allSteerings = GetComponents<Steering>();
        Steerings = allSteerings.Where( x => !x.IsPostProcess ).ToArray();
        SteeringPostprocessors = allSteerings.Where( x => x.IsPostProcess ).ToArray();

        if (_movementPriority == 0)
        {
            _movementPriority = gameObject.GetInstanceID();
        }
        _radar = this.GetComponent<Radar>();
        Speedometer = this.GetComponent<Speedometer>();
    }
 // Use this for initialization
 void Start()
 {
     display = GetComponent <Text>();
     r       = GameObject.FindGameObjectWithTag("Radar").GetComponent <Radar>();
 }
Ejemplo n.º 44
0
 //Focusing on picRadar
 private void lbl1_Click(object sender, EventArgs e)
 {
     Radar.Focus( );
 }
Ejemplo n.º 45
0
 private void OnDisable()
 {
     Radar.RemoveRadarObject(gameObject);
 }
Ejemplo n.º 46
0
 private void OnEnable()
 {
     Radar.RegisterRadarObject(gameObject, _ico);
 }
Ejemplo n.º 47
0
 // Inicializo el Radar a falso consiguiendo el script que dibuja el radar
 void Start()
 {
     MiRadar = this.gameObject.GetComponent<Radar>();
     MiRadar.enabled = false;
 }
Ejemplo n.º 48
0
 // Use this for initialization
 void Start()
 {
     BF = FindObjectOfType<BodyFlow>();
     R = FindObjectOfType<Radar>();
 }