Ejemplo n.º 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;
        }
Ejemplo n.º 2
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        DamageControl damageCtrl = other.GetComponent <DamageControl>();

        if (damageCtrl != null)
        {
            damageCtrl.ChangeHealth(damage);
        }
    }
Ejemplo n.º 3
0
    private void OnCollisionEnter2D(Collision2D other)
    {
        DamageControl damageCtrl = other.collider.GetComponent <DamageControl>();

        if (damageCtrl != null)
        {
            damageCtrl.ChangeHealth(damage);
            Destroy(gameObject);
        }
    }
Ejemplo n.º 4
0
        private void DamageControlMenu(IShip playerShip)
        {
            this.Strings(DamageControl.CONTROL_PANEL);
            this.WithNoEndCR("Enter Damage Control Command: ");

            //todo: readline needs to be done using an event
            var damageControlCommand = Console.ReadLine().Trim().ToLower();

            DamageControl.For(playerShip).Controls(damageControlCommand);
        }
Ejemplo n.º 5
0
        /*
         *
         */
        public MainWindow()
        {
            InitializeComponent();

            // start of custom code
            WriteToLog.write("---- System Start ----", string.Empty, true);
            debug = Config.ReadElement("Debug", "False", true).Equals("true", StringComparison.OrdinalIgnoreCase);

            // initialize the sub classes
            GameBoard     = new GameBoard(this);
            GameMap       = new GameMap(this);
            SRS           = new SRSController(this);
            LRS           = new LRSController(this);
            Warp          = new WarpController(this);
            Torpedoes     = new TorpedoController(this);
            Phasers       = new PhaserController(this);
            Shields       = new ShieldController(this);
            Impulse       = new ImpulseController(this);
            GameObjects   = new GameObjects(this);
            DamageControl = new DamageControl(this);
            StarBases     = new StarBaseController(this);
            Probes        = new ProbeController(this);

            // set up a new board and start the timer
            NewGame(8);
            CreateTimer();

            WriteToLog.write("Debug = " + debug.ToString());
            WriteToLog.ClearOldLogs();

            // set up the hotkeys
            rcImpulse.InputGestures.Add(new KeyGesture(Key.I, ModifierKeys.Control));
            CommandBindings.Add(new CommandBinding(rcImpulse, ImpulseCommand));

            rcWarp.InputGestures.Add(new KeyGesture(Key.W, ModifierKeys.Control));
            CommandBindings.Add(new CommandBinding(rcWarp, WarpCommand));

            rcTorpedoes.InputGestures.Add(new KeyGesture(Key.T, ModifierKeys.Control));
            CommandBindings.Add(new CommandBinding(rcTorpedoes, TorpedoCommand));

            rcPhasers.InputGestures.Add(new KeyGesture(Key.P, ModifierKeys.Control));
            CommandBindings.Add(new CommandBinding(rcPhasers, PhaserCommand));

            rcShields.InputGestures.Add(new KeyGesture(Key.S, ModifierKeys.Control));
            CommandBindings.Add(new CommandBinding(rcShields, ShieldCommand));
        }
Ejemplo n.º 6
0
        // Update is called once per frame
        void Update()
        {
            if (!IsInit)
            {
                return;
            }

            DamageControl.Update(Time.deltaTime);

            //if (LifeSupport.Status.GetCondition(eSystemState.OFFLINE) || LifeSupport.Status.GetCondition(eSystemState.INVALID))
            //{
            //    Controls.attack = false;
            //    Controls.special = false;
            //}

            //TacticalComputer.SetInput(Controls.attack, Controls.special, null);
        }
Ejemplo n.º 7
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();
        }
Ejemplo n.º 8
0
        IEnumerator FadeInit()
        {
            Debug.Log("Start system init");
            _init      = false;
            Subsustems = new List <Subsystems.Subsystem>();
            var subsystems = GetComponentsInChildren <Subsystems.Subsystem>();

            foreach (var subsystem in subsystems)
            {
                Subsustems.Add(subsystem);
                subsystem.Init();
                subsystem.Status.State = eSystemState.OFFLINE;
            }
            DamageControl.Init();
            foreach (var subsystem in subsystems)
            {
                subsystem.Status.State = eSystemState.ONLINE;
                yield return(new WaitForSeconds(0.25f));
            }
            Controls = new Controls();
            _init    = true;
            Debug.Log("End system init");
        }
Ejemplo n.º 9
0
    public int arraySize;                               // Serialized save data for the custom inspector to track how many elements(segment) exist in the healthSegmentArray

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //Called at start of scene before the first frame and whenever the object is re-enabled
    private void Awake()
    {
        //Iterate over all the segment for setting up any initial data
        for (int i = 0; i < segmentArray.Length; i++)
        {
            //Check if the segment will be starting with full or no health
            if (segmentArray[i].startActive)
            {
                segmentArray[i].currentHealth = segmentArray[i].maxHealth;
            }
            else
            {
                segmentArray[i].currentHealth = 0f;
            }

            //Make sure recharge timers start with the correct delay
            segmentArray[i].rechargeTimer = segmentArray[i].rechargeDelay;
        }

        //Initialize segment control classes
        healingControl  = new HealingControl(segmentArray, this);
        rechargeControl = new RechargeControl(segmentArray, this, healingControl, universalRecharge, universalDamageReset);
        damageControl   = new DamageControl(segmentArray, rechargeControl, this);
    }
Ejemplo n.º 10
0
 void Start()
 {
     dc = transform.Find("AttackCollision").GetComponent<DamageControl>();
 }
Ejemplo n.º 11
0
 // Start is called before the first frame update
 void Start()
 {
     playerPos     = GameObject.FindWithTag("Player").transform;
     HealthManager = GameObject.FindWithTag("Player").GetComponent <Health>();
     DamageControl = GameObject.FindWithTag("Player").GetComponent <DamageControl>();
 }
Ejemplo n.º 12
0
        /*
         * Button execution was broken out of the button handler so the
         * short cut keys can access it in a straight forward way
         */
        private void ButtonCommand(string btn)
        {
            bool executed = false;

            // prevent button hot keys during timer execution
            if (timerStep == 0)
            {
                Debug(btn + " pressed");

                switch (btn.ToUpper())
                {
                case "IMPL":
                    executed = Impulse.Execute();
                    break;

                case "WARP":
                    executed = Warp.Execute();

                    if (executed)
                    {
                        SRS.Execute();
                    }
                    break;

                case "SHLD":
                    Shields.Execute();
                    timerStep     = 4;
                    timer.Enabled = true;
                    //SetCondition();
                    break;

                case "POWER":
                    Shields.divertPower();
                    timerStep     = 4;
                    timer.Enabled = true;
                    //SetCondition();
                    break;

                case "TORP":
                    executed = Torpedoes.Execute();
                    break;

                case "PHAS":
                    executed = Phasers.Execute();
                    break;

                case "DMG":
                    DamageControl.FixAllDamage();
                    timerStep     = 4;
                    timer.Enabled = true;
                    //SetCondition();
                    break;
                }

                if (executed)
                {
                    // update status before animation starts
                    SetCondition();

                    if (IsUsingAnimation())
                    {
                        timerStep     = 1;
                        timer.Enabled = true;
                    }
                    else
                    {
                        Debug("No Animation Executing");
                        GameObjects.MoveWithNoAnimation();
                        GameObjects.TakingFire();
                        GameObjects.MoveWithNoAnimation();
                    }
                }
            }
        }
Ejemplo n.º 13
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");
        }
Ejemplo n.º 14
0
 void Start()
 {
     Time.timeScale = 1f;
     DamageControl  = GameObject.FindWithTag("Player").GetComponent <DamageControl>();
 }