Пример #1
0
        public Session()
        {
            UiInput            = new UiInput(this);
            HudUi              = new Hud(this);
            TargetUi           = new TargetUi(this);
            DsUtil             = new DSUtils(this);
            DsUtil2            = new DSUtils(this);
            StallReporter      = new StallReporter();
            InnerStallReporter = new StallReporter();
            Av                     = new RunAv(this);
            Api                    = new ApiBackend(this);
            ApiServer              = new ApiServer(this);
            Projectiles            = new Projectiles.Projectiles(this);
            AcqManager             = new AcquireManager(this);
            TerminalMon            = new TerminalMonitor(this);
            _cachedEwarPacket.Data = new List <EwarValues>(32);

            ProblemRep            = new ProblemReport(this);
            VisDirToleranceCosine = Math.Cos(MathHelper.ToRadians(VisDirToleranceAngle));
            AimDirToleranceCosine = Math.Cos(MathHelper.ToRadians(AimDirToleranceAngle));

            VoxelCaches[ulong.MaxValue] = new VoxelCache();

            HeatEmissives = CreateHeatEmissive();
            LoadVanillaData();

            for (int i = 0; i < AuthorSettings.Length; i++)
            {
                AuthorSettings[i] = -1;
            }
        }
    // Start is called before the first frame update
    void Start()
    {
        jobList     = new List <Job>();
        etaClock    = GameObject.Find("ETA Clock").GetComponentInChildren <TerminalMonitor>();
        ship        = GameObject.Find("Ship").GetComponent <Ship>();
        blackScreen = GameObject.Find("Black Screen").GetComponent <BlackScreen>();
        navTerm     = GameObject.Find("NAVCOM_Terminal").GetComponent <Terminal>();
        powerTerm   = GameObject.Find("Power_Terminal").GetComponent <Terminal>();
        engineTerm  = GameObject.Find("Engine_Terminal").GetComponent <Terminal>();
        coolingTerm = GameObject.Find("Cooling_Terminal").GetComponent <Terminal>();


        // boombot = GameObject.Find("BoomBot");
        //boombot.SetActive(false);

        jobID               = new List <int>();
        jobNames            = new List <string>();
        destinations        = new List <string>();
        cargoNames          = new List <string>();
        cargoTypes          = new List <string>();
        cargoValues         = new List <float>();
        targetDeliveryTimes = new List <float>();
        jobTiers            = new List <int>();
        alreadyListed       = new List <bool>();

        GenerateJobPool();
        GenerateAvailableJobs();
    }
    // Update is called once per frame
    void Update()
    {
        UpdateInternalShipTemp();

        //Sets text output and sends it to the ship's main monitor.
        textOutput  = "Barrow Freight Interplanetary";
        textOutput += "\nShip Power usage: " + currentShipPowerConsumption + "/" + currentShipPowerCapacity + "Gw";
        textOutput += "\nCurrent  Ship Speed " + previousFrameShipSpeed + "LSPS";
        textOutput += "\nCurrent Ship Temp: " + currentShipTemp.ToString("F1") + "C";
        textOutput += "\nCurrent  Ship Cooling Rate: " + currentShipCoolingRate + "";
        textOutput += "\nShip Com Range: " + maxShipComRange + "KM";
        textOutput += "\nHeat Generation: " + totalShipHeatGeneration;
        textOutput += "\nCurrency: " + currency;

        TerminalMonitor monitor = GameObject.Find("Mission Monitor").GetComponentInChildren <TerminalMonitor>();

        monitor.WriteToMonitor(textOutput);



        //Reset current power usage, so that it does not continue to increase every frame.
        currentShipPowerConsumption = 0;
        currentShipPowerCapacity    = baseShipPowerCapacity;
        previousFrameShipSpeed      = currentShipSpeed;
        currentShipSpeed            = 10;
        currentShipCoolingRate      = baseShipCoolingRate;
        maxShipComRange             = 0;
        consumedShipCargoCapacity   = 0;
        //currentShipTemp = baseShipTemp;
        totalShipHeatGeneration = 0;
    }
    // Start is called before the first frame update
    void Start()
    {
        Transform firePSTransform = this.transform.Find("Fire Particle System");

        if (firePSTransform)
        {
            fire = this.transform.Find("Fire Particle System").gameObject;
            ps   = fire.GetComponent <ParticleSystem>();
        }

        currentFailureRate = baseFailureRate;

        jobsManager   = GameObject.Find("Game Managers").GetComponent <Jobs>();
        terminalStore = GameObject.Find("Game Managers").GetComponent <TerminalStore>();
        monitor       = GetComponentInChildren <TerminalMonitor>();

        Renderer rend = GetComponent <Renderer>();

        if (rend == null)
        {
            return;
        }

        switch (terminalType)
        {
        case TerminalTypes.PowerGenerator:
            rend.material.color = Color.yellow;
            label                  = "Power Generator";
            powerCapacity          = 1000;
            heatGeneration         = 500;
            positiveAttributeLabel = "Power Generated:\n";
            positiveAttribute      = powerCapacity;
            positiveAttributeUnit  = "Gw";
            break;

        case TerminalTypes.CoolingUnit:
            rend.material.color = Color.blue;
            label                  = "Cooling Unit";
            powerConsumption       = 100;
            coolingRate            = 300;
            positiveAttributeLabel = "Heat Dissipated:\n";
            positiveAttribute      = coolingRate;
            positiveAttributeUnit  = "BTUs";
            break;

        case TerminalTypes.EngineControl:
            rend.material.color = Color.red;
            label                  = "Engine Control";
            powerConsumption       = 200;
            heatGeneration         = 500;
            engineSpeed            = 1;
            positiveAttributeLabel = "Engine Speed:\n";
            positiveAttribute      = engineSpeed;
            positiveAttributeUnit  = "LSPS";
            break;

        case TerminalTypes.NAVCOMComputer:
            label = "NAV/COM Computer";
            //rend.material.color = Color.green;
            powerConsumption       = 50;
            heatGeneration         = 50;
            comRangeBoost          = 100;
            positiveAttributeLabel = "Com Range:\n";
            positiveAttribute      = comRangeBoost;
            positiveAttributeUnit  = "KM";
            break;

        default:
            break;
        }
    }
    // Update is called once per frame
    void Update()
    {
        handPosition = new Vector3(Camera.main.transform.localPosition.x, Camera.main.transform.localPosition.y - 1f, Camera.main.transform.localPosition.z + 1f);

        if (Input.GetMouseButtonDown(1))
        {
            viewLocked = false;
            GetComponent <FirstPersonController>().enabled = true;
            terminalBeepsScript.resetTerminalStartupAndRunningSound();
            terminalBeepsScript.terminalOffSound.Play();
        }

        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit rhInfo;

            //If an object is clicked...
            if (Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out rhInfo, interactionRange, ignorePlayerMask))
            {
                //Debug.Log("clicked on " + rhInfo.collider.name + " with tag" + rhInfo.collider.gameObject.tag);
                //Debug.Log("holding? "+ isHoldingObject + " " );

                //..and if that object is a Terminal Monitor
                if (rhInfo.collider.gameObject.tag == "TerminalMonitor")
                {
                    //Debug.Log("rhInfo.collider.gameObject.tag == TerminalMonitor");
                    //Debug.Log("Monitor Clicked");
                    viewLocked     = true;
                    targetMonitor  = rhInfo.collider.gameObject.GetComponent <TerminalMonitor>();
                    targetTerminal = targetMonitor.GetComponentInParent <Terminal>();

                    initialPlayerPosition  = transform.position;
                    lockedCameraPosition   = targetTerminal.transform.TransformPoint(Vector3.left * 1.25f);
                    lockedCameraPosition.y = initialPlayerPosition.y;

                    terminalBeepsManager.transform.position = targetTerminal.transform.position;
                    terminalBeepsScript.playInitialBeep();
                    terminalBeepsScript.playDelayedBeeps();
                    terminalBeepsScript.playTerminalStartupAndRunningSound();

                    if (targetTerminal.terminalType == Terminal.TerminalTypes.JobSelection)
                    {
                        jobsManager.GenerateAvailableJobs();
                    }

                    if (targetTerminal.terminalType == Terminal.TerminalTypes.TerminalStore)
                    {
                        terminalStore.GenerateAvailableTerminals();
                    }
                    //..and if that object is a terminal bay and the player holds an object
                }
                else if (rhInfo.collider.gameObject.tag == "TerminalBay")
                {
                    if (isHoldingObject)
                    {
                        placeObject(rhInfo.collider.gameObject);
                    }
                    else
                    {
                        //...and if that terminal bay already has an object installed.
                        targetBay = rhInfo.collider.gameObject.GetComponent <TerminalBay>();
                        if (targetBay.IsModuleInstalled())
                        {
                            //GameObject installedObject = targetBay.GetInstalledObject();
                            //portableObject po = installedObject.GetComponent<portableObject>();
                            //po.DeactivateObject();
                        }
                    }
                }
                else if (rhInfo.collider.gameObject.tag == "TerminalPlacementCollider")
                {
                    Debug.Log("placement Collider clicked");
                    targetTerminal = rhInfo.collider.gameObject.GetComponentInParent <Terminal>();

                    portableObject po = heldObject.GetComponent <portableObject>();
                    po.PlaceTerminal(targetTerminal.transform.position);

                    //...and if the object is not interactable and the player holds an object.
                }
                else if (isHoldingObject)     //end of if isHoldingObject and target is TerminalBay.
                {
                    dropObject();
                    //...and if the object is a movable object
                }
                else if (rhInfo.collider.gameObject.tag == "MovableObject")     // wasn't yet isHoldingObject
                {
                    portableObject po = rhInfo.collider.gameObject.GetComponent <portableObject>();
                    if (!po.IsObjectInstalled())
                    {
                        pickUpObject(rhInfo.collider.gameObject);
                    }
                    else
                    {
                        po.ActivateObject();
                    }
                }
            } //end of if a raycast hits something
        }     // end of if mouse button 0 is pressed

        if (Input.GetKeyDown(KeyCode.E))
        {
            if (isHoldingObject)
            {
                portableObject po = heldObject.GetComponent <portableObject>();
                if (po.IsFireExtinguisher())
                {
                    po.ToggleIsSpraying();

                    source = po.GetComponent <AudioSource>();
                    source.Play();

                    RaycastHit rhInfo;

                    //If an object is clicked...
                    if (Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out rhInfo, fireExtinguisherRange, ignorePlayerMask))
                    {
                        //..and if that object is a Fire Collider
                        if (rhInfo.collider.gameObject.tag == "FireCollider")
                        {
                            Debug.Log("FC clicked");
                            targetTerminal = rhInfo.collider.gameObject.transform.parent.gameObject.GetComponent <Terminal>();
                            if (targetTerminal.isBurning)
                            {
                                targetTerminal.ToggleIsBurning();
                            }
                        }
                        //    if (targetTerminal.isBurning)
                        //{
                        //    targetTerminal.ToggleIsBurning();
                        //}
                    }
                }
            }
        }

        if (Input.GetKeyUp(KeyCode.E))
        {
            if (isHoldingObject)
            {
                portableObject po = heldObject.GetComponent <portableObject>();
                if (po.IsFireExtinguisher())
                {
                    po.ToggleIsSpraying();
                }
            }
        }

        if (isHoldingObject)
        {
            MoveObjectToHands();
        }

        if (viewLocked)
        {
            GetComponent <FirstPersonController>().enabled = false;
            mainCamera.transform.LookAt(targetMonitor.transform);
            transform.position = lockedCameraPosition;
        }
    } // end of Update()