示例#1
0
        /*
         * Set the docked status of the ship
         */
        public void SetDocked(bool docked)
        {
            if (!this.docked && docked)
            {
                this.energyLevel = 100;
                ComsChatter("Commander Scot reports reports, 'Docking is complete, Captain.'");
            }

            if (this.docked && !docked)
            {
                ComsChatter("Lt Sulu reports, 'We're clear for maneuvering, Captain.'");
            }

            DamageControl.Docked(docked);
            Impulse.Docked(docked);
            LRS.Docked(docked);
            Phasers.Docked(docked);
            Probes.Docked(docked);
            Shields.Docked(docked);
            SRS.Docked(docked);
            Torpedoes.Docked(docked);
            Warp.Docked(docked);

            this.docked = docked;
        }
    // Use this for initialization
    void Start()
    {
        playerName   = GameObject.Find("PlayerName").GetComponent <InputField>();
        playerEmail  = GameObject.Find("PlayerEmail").GetComponent <InputField>();
        submitButton = GameObject.Find("SubmitButton").GetComponent <Button>();

        lrsScript = FindObjectOfType <LRS>();

        if (!submittedPlayerInfo)
        {
            Cursor.lockState = CursorLockMode.None;
            Cursor.visible   = true;
        }
    }
示例#3
0
文件: Validation.cs 项目: jakedw7/iAM
        /// <summary>
        /// Validates Linear Reference System Objects (against NETWORK_DEFINITION)
        /// </summary>
        /// <param name="lrsObject">Object to validate</param>
        /// <param name="strError">If Error is found, returns error</param>
        /// <returns>True if valid object.  False if error found.</returns>
        public static bool ValidateLinear(LRSObject lrsObject, out String strError)
        {
            strError = "";
            if (m_listLRS == null)
            {
                LoadLRS();
            }

            LRSObject lrsFind = LRS.Find(delegate(LRSObject lrs) { return(lrs.Route == lrsObject.Route && lrs.Direction == lrsObject.Direction); });

            if (lrsFind == null)
            {
                strError = "\tWarning:" + lrsObject.Route + " " + lrsObject.BeginStation.ToString() + "-" + lrsObject.EndStation.ToString() + "(" + lrsObject.Direction + ") ROUTE/DIRECTION not defined in NETWORK_DEFINITION.  This data row will be ignored at Rollup.";
                return(false);
            }

            //Check if BEGIN_STATION less that END_STATION
            if (lrsObject.BeginStation > lrsObject.EndStation)
            {
                strError = strError = "\tWarning:" + lrsObject.Route + " " + lrsObject.BeginStation.ToString() + "-" + lrsObject.EndStation.ToString() + "(" + lrsObject.Direction + ") END_STATION is greater than BEGIN_STATION.  This data row will be ignored at Rollup.";
                return(false);
            }


            if (lrsFind.EndStation < lrsObject.BeginStation)
            {
                strError = strError = "\tWarning:" + lrsObject.Route + " " + lrsObject.BeginStation.ToString() + "-" + lrsObject.EndStation.ToString() + "(" + lrsObject.Direction + ") ROUTES END_STATION is less than data BEGIN_STATION.  This data row will be ignored at Rollup.";
                return(false);
            }

            if (lrsFind.BeginStation > lrsObject.BeginStation)
            {
                strError = strError = "\tWarning:" + lrsObject.Route + " " + lrsObject.BeginStation.ToString() + "-" + lrsObject.EndStation.ToString() + "(" + lrsObject.Direction + ") ROUTES BEGIN_STATION is greater than data BEGIN_STATION.  Some data from this row may be ignored at Rollup.";
                return(false);
            }

            if (lrsFind.EndStation < lrsObject.BeginStation)
            {
                strError = strError = "\tWarning:" + lrsObject.Route + " " + lrsObject.BeginStation.ToString() + "-" + lrsObject.EndStation.ToString() + "(" + lrsObject.Direction + ") ROUTES END_STATION is less than data BEGIN_STATION.  This data row will be ignored at Rollup.";
                return(false);
            }

            if (lrsFind.EndStation < lrsObject.EndStation)
            {
                strError = strError = "\tWarning:" + lrsObject.Route + " " + lrsObject.BeginStation.ToString() + "-" + lrsObject.EndStation.ToString() + "(" + lrsObject.Direction + ") ROUTES END_STATION is less than data END_STATION.  Some data from this row may be ignored at Rollup.";
                return(false);
            }

            return(true);//Valid LRS object
        }
示例#4
0
        /*
         * Routine to set everything up for a new game
         */
        public void NewGame(int gridSize)
        {
            WriteToLog.write("---- Game Start ----");

            // initialize the other classes
            GameBoard.NewGame(gridSize);
            GameMap.NewGame();
            SRS.NewGame();
            LRS.NewGame();
            Warp.NewGame();
            Torpedoes.NewGame();
            Phasers.NewGame();
            Shields.NewGame();
            Impulse.NewGame();
            DamageControl.NewGame();
            StarBases.NewGame();
            Probes.NewGame();

            ComsClear();

            // Register starbases
            for (int i = 0; i < GameBoard.GetSize() * GameBoard.GetSize(); i++)
            {
                if (GameBoard.GetGameBoard(i) > 99)
                {
                    // Register this starbase
                    StarBases.AddStarbase(i);
                    WriteToLog.write("Added starbase to loc " + i.ToString());
                }
            }

            // locate the enterprise and play the game
            GameBoard.RandomEnterpriseLocation();
            WriteToLog.write("Enteprise is in sector " + GameBoard.GetLocation());

            SRS.Execute();
            SetCondition();
        }
示例#5
0
        private void SetConditionExecute()
        {
            WriteToLog.write("SetCondition - starDate=" + GameBoard.CurrentStarDate() + "  energy=" + this.energyLevel);

            // set the alert level
            if (GameBoard.GetGameBoard() % 100 / 10 > 0)
            {
                this.alertLevel = REDALERT;
            }
            else
            {
                //energy <15% or or shields up is yellow alert
                if (this.energyLevel < 15 || Shields.AreUp())
                {
                    this.alertLevel = YELLOWALERT;
                }
                else
                {
                    this.alertLevel = GREENALERT;
                }
            }

            Debug("Alert Level = " + alertLevel);

            // update the form
            this.Dispatcher.BeginInvoke((Action)(() =>
            {
                Debug("Updating Status");

                switch (this.alertLevel)
                {
                case REDALERT:
                    lblAlert.Content = "RED";
                    break;

                case YELLOWALERT:
                    this.lblAlert.Content = "YELLOW";
                    break;

                default:
                    this.lblAlert.Content = "GREEN";
                    break;
                }

                // update labels - the updatecontent method sends
                // the info to the log file when in debug mode
                UpdateContent(lblStarDate, String.Format("{0:0.0} ({1:0.0})", this.GameBoard.CurrentStarDate(), GameBoard.TimeLeft()));
                UpdateContent(lblEnergy, String.Format("{0:0.0}%", this.energyLevel));
                UpdateContent(lblKlingons, GameBoard.getKlingonCount().ToString());

                lblImpulse.Content = Impulse.HealthPercent() + "%";
                lblWarp.Content = Warp.HealthPercent() + "%";
                lblPhasers.Content = Phasers.HealthPercent() + "%";
                lblTorpedoes.Content = Torpedoes.HealthPercent() + "%";
                lblTorpedoCount.Content = "(" + Torpedoes.getCurrentCount() + " Remaining)";
                lblShields.Content = Shields.HealthPercent() + "%";
                lblLRS.Content = LRS.HealthPercent() + "%";
                lblShieldPowerRemaining.Content = Shields.levelPercent() + "%";

                string[] loc = GameBoard.GetLocationInfo();
                lblQuadrant.Content = loc[0];
                lblSector.Content = loc[1];
            }));


            // set button colors
            Debug("Set buttons");
            this.Dispatcher.BeginInvoke((Action)(() =>
            {
                // update button background
                btnImpulse.Background = ((Impulse.IsHealthy() ? LTGREEN : REDISH));
                btnWarp.Background = ((Warp.IsHealthy() ? LTGREEN : REDISH));
                btnTorpedoes.Background = ((Torpedoes.IsHealthy() ? (Torpedoes.getCurrentCount() > 2 ? LTGREEN : LTYELLOW) : REDISH));
                btnPhasers.Background = ((Phasers.IsHealthy() ? LTGREEN : REDISH));
                btnLRS.Background = ((LRS.IsHealthy() ? GREENISH : REDISH));
                btnRepairs.Background = (DamageControl.HealthPercent() > 50 ? GREENISH : (DamageControl.IsHealthy() ? LTYELLOW : REDISH));
                btnDivert.Background = (Shields.levelPercent() > 80 ? GREENISH : (Shields.levelPercent() < 40 ? REDISH : LTYELLOW));

                btnDivert.IsEnabled = !IsDocked();
                btnShields.IsEnabled = !IsDocked();

                if (this.alertLevel == REDALERT)
                {
                    if (Shields.HealthPercent() > 60)
                    {
                        btnShields.Background = (Shields.AreUp() ? GREENISH : REDISH);
                    }
                    else
                    {
                        btnShields.Background = ((Shields.IsHealthy() && Shields.AreUp() ? LTYELLOW : REDISH));
                    }
                }
                else
                {
                    if (Shields.HealthPercent() > 30)
                    {
                        btnShields.Background = (Shields.AreUp() ? GREENISH : LTGREEN);
                    }
                    else
                    {
                        btnShields.Background = ((Shields.IsHealthy() ? (Shields.AreUp() ? LTGREEN : LTYELLOW) : REDISH));
                    }
                }
            }));


            // are we docked?
            Debug("Docked");
            SetDocked(SRS.AreWeDocked());

            // look for starbase updates
            Debug("Starbases");
            StarBases.Execute();

            // execute damage control and LRS updates
            Debug("DC");
            DamageControl.Execute();

            // update the Long range sensors
            Debug("LRS");
            LRS.Execute();

            Debug("Exiting setcondition");
        }
示例#6
0
        internal override object run()
        {
            //check if multiple cameras are active
            //This variable checks for cameras in the scene if it is aready set then there is multiple cameras in the scene if
            //at the end of this is still -1 then there aren't any both cases we would return an error

            int camera = -1;

            for (int x = 0; x < URS.Count; x++)
            {
                if (URS[x] is FCamera)
                {
                    if (((FCamera)URS[x]).active)
                    {
                        if (camera == -1)
                        {
                            camera = x;
                            Fuzzy3D.activeCamera = (FCamera)URS[camera];
                        }
                        else
                        {
                            //Throwing an error that I found in an example of how to use throw as I am rather new to it
                            throw new IndexOutOfRangeException();
                        }
                    }
                }
            }
            if (camera == -1)
            {
                throw new IndexOutOfRangeException();
            }

            Vector3 cam    = ((FCamera)URS[camera]).position;
            double  camRot = ((FCamera)URS[camera]).Rotation;

            //Looping through the URS to set to the LRS
            //Console.WriteLine("Before Translation: " + URS.Count);
            List <FSceneMember> MRS = new List <FSceneMember>();

            for (int y = 0; y < URS.Count; y++)
            {
                if (URS[y] is FPolygon)
                {
                    Vector3[] prev = ((FPolygon)URS[y]).verticies;
                    Vector3[] next = { Vector3.Subtract(prev[0], cam), Vector3.Subtract(prev[1], cam), Vector3.Subtract(prev[2], cam) };

                    MRS.Add(new FPolygon(next, ((FPolygon)URS[y]).color, ((FPolygon)URS[y]).surfaceNormal));
                    continue;
                }
                if (URS[y] is FCamera)
                {
                    //Console.WriteLine("WHat the f**k!");

                    Vector3 prev = ((FCamera)URS[y]).position;
                    MRS.Add(new FCamera(Vector3.Subtract(prev, cam), ((FCamera)URS[y]).FOV));
                    continue;
                }

                throw new Exception("Transformer does not currently handle Lightsources!");
            }

            // Do the same but for rotation.
            // Note that this must occur after translation; It is dependent on it.

            for (int y = 0; y < MRS.Count; y++)
            {
                if (MRS[y] is FPolygon)
                {
                    Vector3[] prev = ((FPolygon)MRS[y]).verticies;
                    Vector3[] next = { Rotate2D(prev[0], camRot), Rotate2D(prev[1], camRot), Rotate2D(prev[2], camRot) };


                    // Now we check about surface normal
                    if (((FPolygon)MRS[y]).surfaceNormal == new Vector3(0, 0, 0))
                    {
                        LRS.Add(new FPolygon(next, ((FPolygon)MRS[y]).color));
                    }
                    else
                    {
                        FPolygon poly = new FPolygon(next, ((FPolygon)MRS[y]).color, ((FPolygon)MRS[y]).surfaceNormal);

                        Console.WriteLine("Y: " + y + " Vector: " + poly.surfaceNormal.X + ", " + poly.surfaceNormal.Y + ", " + poly.surfaceNormal.Z + " Angle: " + Math.Abs(Math.Acos(poly.surfaceNormal.X)));
                        if (Math.Abs(Math.Acos(poly.surfaceNormal.X)) > Math.PI / 2 & !Double.IsNaN(Math.Abs(Math.Acos(poly.surfaceNormal.X))))
                        {
                            LRS.Add(poly);
                        }
                    }


                    continue;
                }
                if (MRS[y] is FCamera)
                {
                    Vector3 prev = ((FCamera)MRS[y]).position;

                    LRS.Add(new FCamera(Rotate2D(prev, camRot), ((FCamera)MRS[y]).FOV));

                    continue;
                }

                throw new Exception("Transformer does not currently handle: " + URS[y].GetType());
            }
            //Console.WriteLine("After Rotation: " + LRS.Count);
            return(base.run());
        }