コード例 #1
0
    /// <summary>
    /// Finds all the UI game objects and assigns them to a variable
    /// </summary>
    void FindAllGameObjects()
    {
        //We need to make refernces to various buttons/text game objects, but using GameObject.Find is inefficient if we do it every update.
        //Therefore, we assign variables to them and only use GameObject.Find once for each object in startup.
        navigationPanel  = AuxFunctions.FindObject(gameObject, "NavigationPanel");
        selectionPanel   = AuxFunctions.FindObject(gameObject, "SelectionPanel"); //The Mode Selection Tab GUI Objects
        defaultSimulator = AuxFunctions.FindObject(gameObject, "DefaultSimulator");
        mixAndMatchMode  = AuxFunctions.FindObject(gameObject, "MixAndMatchMode");
        simLoadField     = AuxFunctions.FindObject(gameObject, "SimLoadField");
        simLoadRobot     = AuxFunctions.FindObject(gameObject, "SimLoadRobot");
        simLoadReplay    = AuxFunctions.FindObject(gameObject, "SimLoadReplay");
        splashScreen     = AuxFunctions.FindObject(gameObject, "LoadSplash");
        errorScreen      = AuxFunctions.FindObject(gameObject, "ErrorScreen");

        graphics = AuxFunctions.FindObject(gameObject, "Graphics");
        input    = AuxFunctions.FindObject(gameObject, "Input");

        settingsMode = AuxFunctions.FindObject(gameObject, "SettingsMode");
        errorText    = AuxFunctions.FindObject(errorScreen, "ErrorText").GetComponent <Text>();

        simFieldSelectText = AuxFunctions.FindObject(defaultSimulator, "SimFieldSelectText");
        simRobotSelectText = AuxFunctions.FindObject(defaultSimulator, "SimRobotSelectText");

        AuxFunctions.FindObject(gameObject, "QualitySettingsText").GetComponent <Text>().text = QualitySettings.names[QualitySettings.GetQualityLevel()];

        mixAndMatchModeScript = AuxFunctions.FindObject(gameObject, "MixAndMatchModeScript");
        Debug.Log(mixAndMatchModeScript.ToString());
    }
コード例 #2
0
ファイル: CreateButton.cs プロジェクト: solomondg/synthesis
 /// <summary>
 /// Updates Tank Drive Slider from MainMenu to the active Scene.
 /// </summary>
 public void OnEnable()
 {
     tankDriveSwitch = AuxFunctions.FindObject("TankDriveSwitch");
     tankDriveSwitch.GetComponent <Slider>().value = InputControl.mPlayerList[InputControl.activePlayerIndex].isTankDrive ? 1 : 0;
     unitConversionSwitch = AuxFunctions.FindObject("UnitConversionSwitch");
     unitConversionSwitch.GetComponent <Slider>().value = PlayerPrefs.GetString("Measure").Equals("Metric") ? 1 : 0;
 }
コード例 #3
0
    public override float ReturnOutput()
    {
        //Raycasting begins, draw a ray from emitter to the receiver
        Ray ray = new Ray(Emitter.transform.position, Emitter.transform.forward);

        BulletSharp.Math.Vector3 fromUltra  = ray.origin.ToBullet();
        BulletSharp.Math.Vector3 toCollider = ray.GetPoint(10).ToBullet();

        Vector3 toColliderUnity = toCollider.ToUnity();

        //Callback returns all hit point results in order to avoid non colliders interfere with the ray test
        AllHitsRayResultCallback raysCallback = new AllHitsRayResultCallback(fromUltra, toCollider);

        //Retrieves bullet physics world and does a ray test with the given coordinates and updates the callback object
        BPhysicsWorld world = BPhysicsWorld.Get();

        world.world.RayTest(fromUltra, toCollider, raysCallback);
        List <BulletSharp.Math.Vector3> colliderPositions = raysCallback.HitPointWorld;

        BulletSharp.Math.Vector3 colliderPosition = BulletSharp.Math.Vector3.Zero;

        float distanceToCollider = 0;

        //Set the initial distance as the distance between emitter and receiver
        if (main != null && main.IsMetric)
        {
            distanceToCollider = sensorOffset;
        }
        else
        {
            distanceToCollider = AuxFunctions.ToFeet(sensorOffset);
        }

        //Loop through all hitpoints (exclude the origin), if there is at least one hitpoint less than the distance between two sensors,
        //something should block the beam between emitter and receiver
        foreach (BulletSharp.Math.Vector3 pos in colliderPositions)
        {
            if ((pos - fromUltra).Length < distanceToCollider && !pos.Equals(BulletSharp.Math.Vector3.Zero))
            {
                distanceToCollider = (pos - fromUltra).Length;
                colliderPosition   = pos;
            }
        }
        //Again if the line connects to the middle of the field nothing is blocking the beam
        Debug.DrawLine(fromUltra.ToUnity(), colliderPosition.ToUnity(), Color.blue);

        if (distanceToCollider < sensorOffset)
        {
            //Something is there
            state = "Broken";
            return(1);
        }
        else
        {
            //Nothing in between
            state = "Unbroken";
            return(0);
        }
    }
コード例 #4
0
ファイル: UltraSensor.cs プロジェクト: j143-zz/synthesis
 /// <summary>
 /// Change the sensor range
 /// </summary>
 /// <param name="distance"></param>
 /// <param name="isEditing"></param>
 public override void SetSensorRange(float distance, bool isEditing)
 {
     if (isEditing && !main.IsMetric)
     {
         distance = AuxFunctions.ToMeter(distance);
     }
     MaxRange = distance;
 }
コード例 #5
0
 // Use this for initialization
 void Start()
 {
     stateMachine  = GameObject.Find("StateMachine");
     canvas        = GameObject.Find("Canvas");
     cameraToolTip = GameObject.Find("TooltipText (9)");
     orientWindow  = AuxFunctions.FindObject(canvas, "OrientWindow");
     resetDropdown = GameObject.Find("Reset Robot Dropdown");
     isOrienting   = false;
 }
コード例 #6
0
 /// <summary>
 /// Toggles between meter and feet measurements
 /// </summary>
 public void ToggleUnitConversion()
 {
     if (canvas != null)
     {
         unitConversionSwitch = AuxFunctions.FindObject(canvas, "UnitConversionSwitch");
         int i = (int)unitConversionSwitch.GetComponent <Slider>().value;
         main.IsMetric = (i == 1 ? true : false);
     }
 }
コード例 #7
0
ファイル: MaMSimUI.cs プロジェクト: j143-zz/synthesis
    /// <summary>
    /// Finds all the necessary UI elements that need to be updated/modified
    /// </summary>
    private void FindElements()
    {
        canvas = GameObject.Find("Canvas");

        mixAndMatchPanel = AuxFunctions.FindObject(canvas, "MixAndMatchPanel");
        multiplayerPanel = AuxFunctions.FindObject(canvas, "MultiplayerPanel");

        simUI = StateMachine.Instance.gameObject.GetComponent <SimUI>();
    }
コード例 #8
0
 // Use this for initialization
 void Start()
 {
     if (isInverted)
     {
         this.gameObject.SendMessage("MakePixelPerfect");
         this.transform.localScale       = new Vector3(-this.transform.localScale.x, this.transform.localScale.y, this.transform.localScale.z);
         GetComponent <UIWidget>().pivot = AuxFunctions.GetInversedPivot(GetComponent <UIWidget>().pivot);
     }
 }
コード例 #9
0
ファイル: PlayerHealth.cs プロジェクト: Yisas/Viaje
    public void TakeDamage(Transform enemy)
    {
        AuxFunctions.HitDirection hitDirection = AuxFunctions.ReturnDirection(enemy, transform);

        if (!playerControl.isInvulnerable)
        {
            anim.SetTrigger("angryHeadbob");

            // Make sure the player can't jump.
            playerControl.jump = false;

            // Create a vector that's from the enemy to the player with an upwards boost.
            Vector3 hurtVectorVertical = transform.position - enemy.position + Vector3.up * 5f;

            Vector3 hurtVectorHorizontal;
            if (hitDirection == AuxFunctions.HitDirection.Left)
            {
                hurtVectorHorizontal = transform.position - enemy.position + Vector3.right * 5f;
            }
            else
            {
                hurtVectorHorizontal = transform.position - enemy.position + Vector3.left * 5f;
            }

            // Cancel prior velocities
            GetComponent <Rigidbody2D> ().velocity = new Vector3(0, 0, 0);

            if (playerControl.isGrounded == true)                                       // Add a force to the player in the direction of the vector and multiply by the hurtForce.
            {
                GetComponent <Rigidbody2D> ().AddForce(hurtVectorVertical * hurtForceGrounded);
                GetComponent <Rigidbody2D> ().AddForce(hurtVectorHorizontal * hurtForceGrounded);
            }
            else
            {
                GetComponent <Rigidbody2D> ().AddForce(hurtVectorVertical * hurtForceAirborne);
                GetComponent <Rigidbody2D> ().AddForce(hurtVectorHorizontal * hurtForceAirborne);
            }

            // Reduce the player's health by 10.
            health -= damageAmount;

            if (health <= startingHealth / 2 && !isHurt)
            {
                isHurt = true;
                foreach (SpriteSwitch ss in GetComponents <SpriteSwitch>())
                {
                    ss.Switch();
                }
            }

            lifeBar.UpdateHealthBar(health, true, isHurt);

            // Play random hurt clip
            PlayRandomSound(hurtSounds);
        }
    }
コード例 #10
0
ファイル: UltraSensor.cs プロジェクト: Ronoman/synthesis
    //Step #2
    public override float ReturnOutput()
    {
        //Raycasting begins
        Ray ray = new Ray(gameObject.transform.position, transform.forward);

        BulletSharp.Math.Vector3 fromUltra  = ray.origin.ToBullet();
        BulletSharp.Math.Vector3 toCollider = ray.GetPoint(MaxRange).ToBullet();

        Vector3 toColliderUnity = toCollider.ToUnity();

        //Callback returns all hit point results in order to avoid non colliders interfere with the ray test
        AllHitsRayResultCallback raysCallback = new AllHitsRayResultCallback(fromUltra, toCollider);

        //Retrieves bullet physics world and does a ray test with the given coordinates and updates the callback object
        BPhysicsWorld world = BPhysicsWorld.Get();

        world.world.RayTest(fromUltra, toCollider, raysCallback);

        //Gets the position of all hit points of the ray test
        List <BulletSharp.Math.Vector3> colliderPositions = raysCallback.HitPointWorld;

        BulletSharp.Math.Vector3 colliderPosition = BulletSharp.Math.Vector3.Zero;

        float distanceToCollider = MaxRange;

        //Loop through all hit points and get the shortest distance, exclude the origin since it is also counted as a hit point
        foreach (BulletSharp.Math.Vector3 pos in colliderPositions)
        {
            if ((pos - fromUltra).Length <= MaxRange && (pos - fromUltra).Length < distanceToCollider && !pos.Equals(BulletSharp.Math.Vector3.Zero))
            {
                distanceToCollider = (pos - fromUltra).Length;
                colliderPosition   = pos;
            }
        }

        //Draw a line to view the ray action
        //When the ray links to the middle of the field, it means the sensor is out of range
        Debug.DrawLine(fromUltra.ToUnity(), colliderPosition.ToUnity(), Color.green, 5f);


        //setting shortest distance of a collider to the maxRange, then if any colliders are closer to the sensor,
        //their distanceToCollider value becomes the new shortest distance
        float shortestDistance = MaxRange;

        if (!isMetric)
        {
            distanceToCollider = AuxFunctions.ToFeet(distanceToCollider);
        }
        //A check that might be useful in the future if use a bundle of rays instead of a single ray
        if (distanceToCollider < shortestDistance)
        {
            shortestDistance = distanceToCollider;
        }

        return(shortestDistance);
    }
コード例 #11
0
    /// <summary>
    /// Find ALL the GUI stuff needed for the sensor GUI to work
    /// </summary>
    private void FindElements()
    {
        canvas        = GameObject.Find("Canvas");
        simUI         = gameObject.GetComponent <SimUI>();
        sensorManager = GameObject.Find("SensorManager").GetComponent <SensorManager>();
        dynamicCamera = GameObject.Find("Main Camera").GetComponent <DynamicCamera>();
        toolkit       = GameObject.Find("StateMachine").GetComponent <Toolkit>();

        sensorOptionPanel     = AuxFunctions.FindObject(canvas, "SensorOptionPanel");
        sensorTypePanel       = AuxFunctions.FindObject(canvas, "SensorTypePanel");
        configureSensorButton = AuxFunctions.FindObject(canvas, "ConfigureSensorButton");

        //For sensor option panel
        addSensorButton      = AuxFunctions.FindObject(sensorOptionPanel, "AddNewSensor");
        selectExistingButton = AuxFunctions.FindObject(sensorOptionPanel, "ConfigureExistingSensor");
        cancelOptionButton   = AuxFunctions.FindObject(sensorOptionPanel, "CancelButton");
        sensorOptionToolTip  = AuxFunctions.FindObject(sensorOptionPanel, "ToolTipPanel");

        //For choosing sensor type
        addUltrasonicButton  = AuxFunctions.FindObject(sensorTypePanel, "AddUltrasonic");
        addBeamBreakerButton = AuxFunctions.FindObject(sensorTypePanel, "AddBeamBreaker");
        addGyroButton        = AuxFunctions.FindObject(sensorTypePanel, "AddGyro");
        cancelTypeButton     = AuxFunctions.FindObject(sensorTypePanel, "CancelButton");

        //For Sensor position and attachment configuration
        configureSensorPanel          = AuxFunctions.FindObject(canvas, "SensorConfigurationPanel");
        changeSensorNodeButton        = AuxFunctions.FindObject(configureSensorPanel, "ChangeNodeButton");
        sensorConfigurationModeButton = AuxFunctions.FindObject(configureSensorPanel, "ConfigurationMode");
        sensorNodeText            = AuxFunctions.FindObject(configureSensorPanel, "NodeText").GetComponent <Text>();
        cancelNodeSelectionButton = AuxFunctions.FindObject(configureSensorPanel, "CancelNodeSelectionButton");
        deleteSensorButton        = AuxFunctions.FindObject(configureSensorPanel, "DeleteSensorButton");
        hideSensorButton          = AuxFunctions.FindObject(configureSensorPanel, "HideSensorButton");

        //For Sensor angle configuration
        sensorAnglePanel = AuxFunctions.FindObject(canvas, "SensorAnglePanel");
        xAngleEntry      = AuxFunctions.FindObject(sensorAnglePanel, "xAngleEntry");
        yAngleEntry      = AuxFunctions.FindObject(sensorAnglePanel, "yAngleEntry");
        zAngleEntry      = AuxFunctions.FindObject(sensorAnglePanel, "zAngleEntry");
        showAngleButton  = AuxFunctions.FindObject(configureSensorPanel, "ShowSensorAngleButton");
        editAngleButton  = AuxFunctions.FindObject(sensorAnglePanel, "EditButton");

        //For range configuration
        sensorRangePanel = AuxFunctions.FindObject(canvas, "SensorRangePanel");
        RangeEntry       = AuxFunctions.FindObject(sensorRangePanel, "RangeEntry");
        showRangeButton  = AuxFunctions.FindObject(configureSensorPanel, "ShowSensorRangeButton");
        editRangeButton  = AuxFunctions.FindObject(sensorRangePanel, "EditButton");
        rangeUnit        = AuxFunctions.FindObject(sensorRangePanel, "RangeUnit").GetComponent <Text>();

        lockPositionButton = AuxFunctions.FindObject(configureSensorPanel, "LockPositionButton");
        lockAngleButton    = AuxFunctions.FindObject(configureSensorPanel, "LockAngleButton");
        lockRangeButton    = AuxFunctions.FindObject(configureSensorPanel, "LockRangeButton");

        showSensorButton  = AuxFunctions.FindObject(canvas, "ShowOutputButton");
        sensorOutputPanel = AuxFunctions.FindObject(canvas, "SensorOutputBorder");
        robotCameraGUI    = GameObject.Find("StateMachine").GetComponent <RobotCameraGUI>();
    }
コード例 #12
0
ファイル: UltraSensor.cs プロジェクト: j143-zz/synthesis
    //Step #2
    public override float ReturnOutput()
    {
        //Raycasting begins
        Ray ray = new Ray(gameObject.transform.position, transform.forward);

        BulletSharp.Math.Vector3 fromUltra  = ray.origin.ToBullet();
        BulletSharp.Math.Vector3 toCollider = ray.GetPoint(MaxRange).ToBullet();

        Vector3 toColliderUnity = toCollider.ToUnity();

        //Callback returns all hit point results in order to avoid non colliders interfere with the ray test
        AllHitsRayResultCallback raysCallback = new AllHitsRayResultCallback(fromUltra, toCollider);

        //Retrieves bullet physics world and does a ray test with the given coordinates and updates the callback object
        BPhysicsWorld world = BPhysicsWorld.Get();

        world.world.RayTest(fromUltra, toCollider, raysCallback);

        //Gets the position of all hit points of the ray test
        List <BulletSharp.Math.Vector3> colliderPositions = raysCallback.HitPointWorld;

        BulletSharp.Math.Vector3 colliderPosition = BulletSharp.Math.Vector3.Zero;

        float distanceToCollider = MaxRange;

        if (main != null && main.IsMetric)
        {
            distanceToCollider = MaxRange;
            foreach (BulletSharp.Math.Vector3 pos in colliderPositions)
            {
                if ((pos - fromUltra).Length < MaxRange && !pos.Equals(BulletSharp.Math.Vector3.Zero))
                {
                    distanceToCollider = (pos - fromUltra).Length;
                    colliderPosition   = pos;
                }
            }
        }
        else
        {
            distanceToCollider = AuxFunctions.ToFeet(MaxRange);
            foreach (BulletSharp.Math.Vector3 pos in colliderPositions)
            {
                if (AuxFunctions.ToFeet((pos - fromUltra).Length) < distanceToCollider && !pos.Equals(BulletSharp.Math.Vector3.Zero))
                {
                    distanceToCollider = AuxFunctions.ToFeet((pos - fromUltra).Length);
                    colliderPosition   = pos;
                }
            }
        }

        //Draw a line to view the ray action
        //When the ray links to the middle of the field, it means the sensor is out of range
        Debug.DrawLine(fromUltra.ToUnity(), colliderPosition.ToUnity(), Color.green, 5f);

        return(distanceToCollider);
    }
コード例 #13
0
ファイル: SensorBase.cs プロジェクト: Ronoman/synthesis
    /// <summary>
    /// Update the sensor output at the corresponding sensorOutputPanel
    /// </summary>
    public virtual void UpdateOutputDisplay()
    {
        GameObject outputPanel = GameObject.Find(gameObject.name + "_Panel");

        if (outputPanel != null)
        {
            GameObject inputField = AuxFunctions.FindObject(outputPanel, "Entry");
            inputField.GetComponent <InputField>().text = ReturnOutput().ToString();
        }
    }
コード例 #14
0
    public void InitializeLocalValues()
    {
        //Navigation Values

        Canal     = 0;
        Nivel     = 0;
        EmpresaID = -1;
        GranjaID  = -1;
        NucleoID  = -1;
        GalponID  = -1;
        SiloID    = -1;

        //Get Scripts

        ServerScript     = gameObject.GetComponent <ServerClass>();
        GridScript       = gameObject.GetComponent <GridClass>();
        ThemeScript      = gameObject.GetComponent <ThemeClass>();
        WinManagerScript = gameObject.GetComponent <WindowManager>();

        //Initialize Grids

        GridName     = "Grid";
        GridLocation = GameObject.Find("Grid");
        GridCanales  = GameObject.Find("GridCanales");
        GridLocation.SetActive(false);

        //Channels Buttons

        GameObject.Find("Temas").transform.Find("Fondo").GetComponent <Button>().onClick.AddListener(() => GoToChannel("temas"));
        GameObject.Find("Indicadores").transform.Find("Fondo").GetComponent <Button>().onClick.AddListener(() => GoToChannel("indicadores"));
        GameObject.Find("Resumen").transform.Find("Fondo").GetComponent <Button>().onClick.AddListener(() => GoToChannel("resumen"));
        GameObject.Find("Temperatura").transform.Find("Fondo").GetComponent <Button>().onClick.AddListener(() => GoToChannel("temperatura"));

        //Debugging and navigation

        backBtn = GameObject.Find("back-btn").GetComponent <Button>();
        backBtn.onClick.AddListener(() => JumpToComponent("menu"));
        empresaBtn       = GameObject.Find("empresas-btn").GetComponent <Button>();
        granjaBtn        = GameObject.Find("granjas-btn").GetComponent <Button>();
        nucleoBtn        = GameObject.Find("nucleos-btn").GetComponent <Button>();
        galponBtn        = GameObject.Find("galpones-btn").GetComponent <Button>();
        empresaImg       = GameObject.Find("empresas-btn").GetComponent <Image>();
        granjaImg        = GameObject.Find("granjas-btn").GetComponent <Image>();
        nucleoImg        = GameObject.Find("nucleos-btn").GetComponent <Image>();
        galponImg        = GameObject.Find("galpones-btn").GetComponent <Image>();
        enabledColor     = AuxFunctions.ConvertColorRGBA(107.0f, 171.0f, 129.0f, 1.0f);
        disabledColor    = AuxFunctions.ConvertColorRGBA(143.0f, 168.0f, 185.0f, 1.0f);
        empresaImg.color = disabledColor;
        granjaImg.color  = disabledColor;
        nucleoImg.color  = disabledColor;
        galponImg.color  = disabledColor;
        empresaBtn.onClick.AddListener(() => JumpToComponent("empresa"));
        granjaBtn.onClick.AddListener(() => JumpToComponent("granja"));
        nucleoBtn.onClick.AddListener(() => JumpToComponent("nucleo"));
    }
コード例 #15
0
 /// <summary>
 /// Set the offset between emitter & receiver
 /// </summary>
 /// <param name="distance"></param>
 /// <param name="isEditing"></param>
 public override void SetSensorRange(float distance, bool isEditing = false)
 {
     //Convert the distance pass in as meter so the position of emitter & transmitter will be set properly
     if (isEditing && !main.IsMetric)
     {
         distance = AuxFunctions.ToMeter(distance);
     }
     Emitter.transform.localPosition  = new Vector3(0, 0, -distance / 2);
     Receiver.transform.localPosition = new Vector3(0, 0, distance / 2);
     sensorOffset = distance;
 }
コード例 #16
0
ファイル: UltraSensor.cs プロジェクト: j143-zz/synthesis
 public override float GetSensorRange()
 {
     if (main.IsMetric)
     {
         return(MaxRange);
     }
     else
     {
         return(AuxFunctions.ToFeet(MaxRange));
     }
 }
コード例 #17
0
ファイル: BeamBreaker.cs プロジェクト: Ronoman/synthesis
    public override void UpdateOutputDisplay()
    {
        base.UpdateOutputDisplay();
        GameObject outputPanel = GameObject.Find(gameObject.name + "_Panel");

        if (outputPanel != null)
        {
            GameObject outputText = AuxFunctions.FindObject(outputPanel, "Text");
            outputText.GetComponent <Text>().text = gameObject.name + " Output (1 closed)";
        }
    }
コード例 #18
0
ファイル: SimUI.cs プロジェクト: j143-zz/synthesis
 /// <summary>
 /// Toggles between meter and feet measurements
 /// </summary>
 public void ToggleUnitConversion()
 {
     if (canvas != null)
     {
         unitConversionSwitch = AuxFunctions.FindObject(canvas, "UnitConversionSwitch");
         int i = (int)unitConversionSwitch.GetComponent <Slider>().value;
         main.IsMetric = (i == 1 ? true : false);
         PlayerPrefs.SetString("Measure", i == 1 ? "Metric" : "Imperial");
         //Debug.Log("Metric: " + main.IsMetric);
     }
 }
コード例 #19
0
 /// <summary>
 /// Disable the ruler
 /// </summary>
 private void DisableRuler()
 {
     ignoreClick = true;
     firstPoint  = BulletSharp.Math.Vector3.Zero;
     usingRuler  = false;
     rulerStartPoint.GetComponent <LineRenderer>().enabled = false;
     rulerStartPoint.SetActive(false);
     rulerEndPoint.SetActive(false);
     AuxFunctions.FindObject(canvas, "RulerStartButton").SetActive(true);
     AuxFunctions.FindObject(canvas, "RulerTooltipText").SetActive(false);
 }
コード例 #20
0
ファイル: SimulatorUI.cs プロジェクト: BraytonK/synthesis
 public void ShowControlPanel(bool show)
 {
     if (show)
     {
         AuxFunctions.FindObject(canvas, "InputManagerPanel").SetActive(true);
     }
     else
     {
         AuxFunctions.FindObject(canvas, "InputManagerPanel").SetActive(false);
     }
 }
コード例 #21
0
 public void UpdateTankText()
 {
     if (Controls.IsTankDrive)
     {
         enableTankDriveText      = AuxFunctions.FindObject(gameObject, "EnableTankDriveText").GetComponent <Text>();
         enableTankDriveText.text = "Switch Arcade Drive";
     }
     else
     {
         enableTankDriveText      = AuxFunctions.FindObject(gameObject, "EnableTankDriveText").GetComponent <Text>();
         enableTankDriveText.text = "Switch Tank Drive";
     }
 }
コード例 #22
0
    // Use this for initialization
    protected void Start()
    {
        // Setup references
        // Get all enemies in this formation
        foreach (GameObject enemy in AuxFunctions.FindChildrenWithTag(transform.FindChild("Ships").transform, "Enemy"))
        {
            enemies.Add(enemy);
        }

        // Setup variables
        numOfEnemies        = enemies.Count;
        initialNumOfEnemies = enemies.Count;
    }
コード例 #23
0
    public override void UpdateOutputDisplay()
    {
        GameObject outputPanel = GameObject.Find(gameObject.name + "_Panel");

        if (outputPanel != null)
        {
            GameObject inputField = AuxFunctions.FindObject(outputPanel, "Entry");
            inputField.GetComponent <InputField>().text = state;
            //Debug.Log(state);
            GameObject outputText = AuxFunctions.FindObject(outputPanel, "Text");
            outputText.GetComponent <Text>().text = gameObject.name + " Output";
        }
    }
コード例 #24
0
 /// <summary>
 /// Initiate ruler
 /// </summary>
 public void StartRuler()
 {
     usingRuler = true;
     rulerStartPoint.SetActive(true);
     AuxFunctions.FindObject(canvas, "RulerStartButton").SetActive(false);
     AuxFunctions.FindObject(canvas, "RulerTooltipText").SetActive(true);
     if (SimUI.changeAnalytics)
     {
         Analytics.CustomEvent("Used Ruler", new Dictionary <string, object> //for analytics tracking
         {
         });
     }
 }
コード例 #25
0
    /// <summary>
    /// FInds all the gameobjects and stores them in variables for efficiency
    /// </summary>
    void Start()
    {
        canvas            = GameObject.Find("Canvas");
        multiplayerWindow = AuxFunctions.FindObject(canvas, "MultiplayerPanel");
        addRobotWindow    = AuxFunctions.FindObject(canvas, "AddRobotPanel");

        for (int i = 0; i < robotButtons.Length; i++)
        {
            robotButtons[i] = AuxFunctions.FindObject(canvas, "Robot" + (i + 1) + "Button");
        }

        simUI     = StateMachine.Instance.gameObject.GetComponent <SimUI>();
        highlight = AuxFunctions.FindObject(canvas, "HighlightActiveRobot");
    }
コード例 #26
0
ファイル: ServerClass.cs プロジェクト: pesanchezbr/SimpleFarm
    private void ParseFavorites()
    {
        string[] items;
        items = FavoritesFromBD.Split(';');
        int itemsLength = items.Length - 1;

        for (int i = 1; i < itemsLength; i++)
        {
            EmpresaFavFromBD = int.Parse(AuxFunctions.GetDataValue(items[i], "idempresa:"));
            GranjaFavFromBD  = int.Parse(AuxFunctions.GetDataValue(items[i], "idgranja:"));
            NucleoFavFromBD  = int.Parse(AuxFunctions.GetDataValue(items[i], "idnucleo:"));
            GalponFavFromBD  = int.Parse(AuxFunctions.GetDataValue(items[i], "idgalpon:"));
            SiloFavFromBD    = int.Parse(AuxFunctions.GetDataValue(items[i], "idsilo:"));
        }
    }
コード例 #27
0
    /// <summary>
    /// Clickeds the inside window.
    /// </summary>
    /// <returns><c>true</c>, if inside window was clickeded, <c>false</c> otherwise.</returns>
    public bool ClickedInsideWindow()
    {
        float mouseX = Input.mousePosition.x;
        float mouseY = Screen.height - Input.mousePosition.y;         // Convert mouse coordinates to unity window positions coordinates

        foreach (OverlayWindow win in windows)
        {
            if ((win.Active && AuxFunctions.MouseInWindow(win.GetWindowRect())) || (mouseX < sidebarWidth && mouseY < GUI_SIDEBAR_PADDING_Y + sidebarHeight))
            {
                return(true);
            }
        }

        return(false);
    }
コード例 #28
0
    public void StartGamepieceSpawn(int index)
    {
        if (definingRelease || definingIntake || addingGamepiece)
        {
            Debug.Log("User Error");                                                       //Message Manager already dispatches error message to user
        }
        else if (settingSpawn == 0)
        {
            if (GameObject.Find(gamepieceNames[index]) != null)
            {
                if (spawnIndicator != null)
                {
                    Destroy(spawnIndicator);
                }
                if (spawnIndicator == null)
                {
                    spawnIndicator      = Instantiate(AuxFunctions.FindObject(gamepieceNames[index]).GetComponentInParent <BRigidBody>().gameObject, new UnityEngine.Vector3(0, 3, 0), UnityEngine.Quaternion.identity);
                    spawnIndicator.name = "SpawnIndicator";
                    Destroy(spawnIndicator.GetComponent <BRigidBody>());
                    if (spawnIndicator.transform.GetChild(0) != null)
                    {
                        spawnIndicator.transform.GetChild(0).name = "SpawnIndicatorMesh";
                    }
                    Renderer render = spawnIndicator.GetComponentInChildren <Renderer>();
                    render.material.shader = Shader.Find("Transparent/Diffuse");
                    Color newColor = render.material.color;
                    newColor.a            = 0.6f;
                    render.material.color = newColor;
                }
                spawnIndicator.transform.position = gamepieceSpawn[index];
                settingSpawn = index + 1;

                DynamicCamera dynamicCamera = Camera.main.transform.GetComponent <DynamicCamera>();
                lastCameraState = dynamicCamera.cameraState;
                dynamicCamera.SwitchCameraState(new DynamicCamera.SateliteState(dynamicCamera));

                //MainState.ControlsDisabled = true;
            }
            else
            {
                UserMessageManager.Dispatch("You must define the gamepiece first!", 5f);
            }
        }
        else
        {
            FinishGamepieceSpawn();  //if already setting spawn, end editing process
        }
    }
コード例 #29
0
    private void ParseFavoritesFromBD()
    {
        string[] items;
        items = favoritesFromBD.Split(';');
        int itemsLength = items.Length - 2;

        for (int i = 0; i <= itemsLength; i++)
        {
            IdEmpresaFav = int.Parse(AuxFunctions.GetDataValue(items[i], "idempresa:"));
            IdGranjaFav  = int.Parse(AuxFunctions.GetDataValue(items[i], "idgranja:"));
            IdNucleoFav  = int.Parse(AuxFunctions.GetDataValue(items[i], "idnucleo:"));
            IdGalponFav  = int.Parse(AuxFunctions.GetDataValue(items[i], "idgalpon:"));
            IdSiloFav    = int.Parse(AuxFunctions.GetDataValue(items[i], "idsilo:"));
            print(IdEmpresaFav + "/" + IdGranjaFav + "/" + IdNucleoFav + "/" + IdGalponFav + "/" + IdSiloFav);
        }
    }
コード例 #30
0
ファイル: RobotCameraGUI.cs プロジェクト: j143-zz/synthesis
    /// <summary>
    /// Find all robot camera related GUI elements in the canvas
    /// </summary>
    public void FindGUIElements()
    {
        canvas           = GameObject.Find("Canvas");
        sensorManagerGUI = GameObject.Find("StateMachine").GetComponent <SensorManagerGUI>();

        //For robot camera view window
        robotCameraView       = Resources.Load("Images/RobotCameraView") as RenderTexture;
        robotCameraViewWindow = AuxFunctions.FindObject(canvas, "RobotCameraPanelBorder");

        //For robot camera manager
        robotCameraListObject = GameObject.Find("RobotCameraList");
        robotCameraManager    = robotCameraListObject.GetComponent <RobotCameraManager>();

        //For camera indicator
        if (CameraIndicator == null)
        {
            CameraIndicator = AuxFunctions.FindObject(robotCameraListObject, "CameraIndicator");
        }
        showCameraButton = AuxFunctions.FindObject(canvas, "ShowCameraButton");

        //For camera position and attachment configuration
        configureCameraPanel          = AuxFunctions.FindObject(canvas, "CameraConfigurationPanel");
        configureRobotCameraButton    = AuxFunctions.FindObject(canvas, "CameraConfigurationButton");
        changeCameraNodeButton        = AuxFunctions.FindObject(configureCameraPanel, "ChangeNodeButton");
        cameraConfigurationModeButton = AuxFunctions.FindObject(configureCameraPanel, "ConfigurationMode");
        cameraNodeText            = AuxFunctions.FindObject(configureCameraPanel, "NodeText").GetComponent <Text>();
        cancelNodeSelectionButton = AuxFunctions.FindObject(configureCameraPanel, "CancelNodeSelectionButton");

        //For camera angle configuration
        cameraAnglePanel = AuxFunctions.FindObject(canvas, "CameraAnglePanel");
        xAngleEntry      = AuxFunctions.FindObject(cameraAnglePanel, "xAngleEntry");
        yAngleEntry      = AuxFunctions.FindObject(cameraAnglePanel, "yAngleEntry");
        zAngleEntry      = AuxFunctions.FindObject(cameraAnglePanel, "zAngleEntry");
        showAngleButton  = AuxFunctions.FindObject(configureCameraPanel, "ShowCameraAngleButton");
        editAngleButton  = AuxFunctions.FindObject(cameraAnglePanel, "EditButton");

        //For field of view configuration
        cameraFOVPanel = AuxFunctions.FindObject(canvas, "CameraFOVPanel");
        FOVEntry       = AuxFunctions.FindObject(cameraFOVPanel, "FOVEntry");
        showFOVButton  = AuxFunctions.FindObject(configureCameraPanel, "ShowCameraFOVButton");
        editFOVButton  = AuxFunctions.FindObject(cameraFOVPanel, "EditButton");

        lockPositionButton = AuxFunctions.FindObject(configureCameraPanel, "LockPositionButton");
        lockAngleButton    = AuxFunctions.FindObject(configureCameraPanel, "LockAngleButton");
        lockFOVButton      = AuxFunctions.FindObject(configureCameraPanel, "LockFOVButton");
    }