Пример #1
0
    public void Click()
    {
        Transform transform = canvas.transform;

        foreach (Transform child in transform)
        {
            child.gameObject.SetActive(false);
        }

        instructionTextObject.SetActive(true);
        resultTextObject.SetActive(true);

        player.GetComponent <Player1> ().top1   = false;
        player.GetComponent <Player1> ().top2   = false;
        player.GetComponent <Player1> ().right2 = false;

        Top1.SetActive(true);
        Top1.GetComponent <M1Top1> ().collide = false;
        Top2.SetActive(true);
        Top2.GetComponent <M1Top2> ().collide = false;
        Right2.SetActive(true);
        Right2.GetComponent <M1Right2> ().collide = false;

        instructionText.text = "Please use direction keys to orient the yellow" +
                               "square on the top view and make it access the orange one.\n" +
                               "Falling leads to game over.";
        resultText.text = "";

        player.SetActive(true);
        player.transform.position = new Vector3(1.0f, 2.04f, 0.5f);

        isoCamera.SetActive(false);

        model.GetComponent <Model1> ().InitializeLog();
    }
Пример #2
0
        public void rotates_waypoint_right(int angle, int expectedNorth, int expectedEast)
        {
            var command = new Right2(angle);

            var result = command.Move(StartingPositions);

            result.Ship.North.Should().Be(0);
            result.Ship.East.Should().Be(0);
            result.Waypoint.North.Should().Be(expectedNorth);
            result.Waypoint.East.Should().Be(expectedEast);
        }
Пример #3
0
        /// <summary>
        /// Initializes the AutoHandler.
        /// </summary>
        protected override void Init()
        {
            // Instantiates AutoHandler.
            AutoHandler = new Handler();

            //Sets the CAN Talons to rely off of the encoders for movement.
            AutoFunctions.ConfigureTalon(Right1, ConfigureType.Position, new EncoderParameters
            {
                AllowedError   = 0,
                Device         = CANTalon.FeedbackDevice.CtreMagEncoderRelative,
                NominalVoltage = 0.0f,
                PeakVoltage    = 12.0f,
                PIDFValues     = new PIDF
                {
                    kP = 0.151,
                    kI = 0,
                    kD = 0,
                    kF = 0
                },
                ReverseSensor = false
            });
            AutoFunctions.ConfigureTalon(Left1, ConfigureType.Position, new EncoderParameters
            {
                AllowedError   = 0,
                Device         = CANTalon.FeedbackDevice.CtreMagEncoderRelative,
                NominalVoltage = 0.0f,
                PeakVoltage    = 12.0f, //3.4f
                PIDFValues     = new PIDF
                {
                    kP = 0.151,
                    kI = 0,
                    kD = 0,
                    kF = 0
                },
                ReverseSensor = true
            });

            Right1.SetEncoderPostition(0); // Reset the encoder position to 0.
            Right1.ReverseOutput(true);    // Reverse the direction of the motor.
            Right2.MotorControlMode = WPILib.Interfaces.ControlMode.Follower;
            Right2.Set(Right1.DeviceId);   // Configure the second right talon to be a follower of the other right talon.

            Left1.SetEncoderPostition(0);  // Reset the eoncoder position to 0.
            Left1.ReverseOutput(false);    // Reverse the direction of the motor.
            Left1.ReverseSensor(true);
            Left2.MotorControlMode = WPILib.Interfaces.ControlMode.Follower;
            Left2.Set(Left1.DeviceId); // Configure the second left talon to be a follower of the other left talon.

            NavX.Reset();              // Reset the NavX's yaw value to zero.
        }
    // Update is called once per frame
    void Update()
    {
        if (Carl == null)
        {
            Carl = Instruction.GetComponent <RandomInstruction>();
        }

        if (SHealth <= 0)
        {
            Gameplay.SetActive(false);
            MrPersonGameObject.SetActive(false);
            MrPersonMusic.SetActive(false);
            GameOverScreen.SetActive(true);
            GameOverMusic.SetActive(true);
            if (UFB == true)
            {
                SHealth          = 1000;
                ShipHealth.text  = SHealth.ToString();
                EHealth          = 1200;
                EnemyHealth.text = EHealth.ToString();
            }
            else if (BabyMode == true)
            {
                SHealth          = 1000;
                ShipHealth.text  = SHealth.ToString();
                EHealth          = 200;
                EnemyHealth.text = EHealth.ToString();
            }
            else
            {
                SHealth          = 1000;
                ShipHealth.text  = SHealth.ToString();
                EHealth          = 1000;
                EnemyHealth.text = EHealth.ToString();
            }
        }

        if (EHealth <= 0)
        {
            if (BabyMode == true)
            {
                if (AreYouMrDark == true)
                {
                    Gameplay.SetActive(false);
                    MrPersonGameObject.SetActive(false);
                    MrPersonMusic.SetActive(false);
                    Dvic1.SetActive(true);
                    VictoryMusic.SetActive(true);
                    SHealth          = 1000;
                    ShipHealth.text  = SHealth.ToString();
                    EHealth          = 200;
                    EnemyHealth.text = EHealth.ToString();
                }
                else if (AreYouMrDark == false)
                {
                    Gameplay.SetActive(false);
                    MrPersonGameObject.SetActive(false);
                    MrPersonMusic.SetActive(false);
                    Lvic1.SetActive(true);
                    VictoryMusic.SetActive(true);
                    SHealth          = 1000;
                    ShipHealth.text  = SHealth.ToString();
                    EHealth          = 200;
                    EnemyHealth.text = EHealth.ToString();
                }
            }
            else if (Easy == true)
            {
                if (AreYouMrDark == true)
                {
                    Gameplay.SetActive(false);
                    MrPersonGameObject.SetActive(false);
                    MrPersonMusic.SetActive(false);
                    Dvic2.SetActive(true);
                    VictoryMusic.SetActive(true);
                    SHealth          = 1000;
                    ShipHealth.text  = SHealth.ToString();
                    EHealth          = 1000;
                    EnemyHealth.text = EHealth.ToString();
                }
                else if (AreYouMrDark == false)
                {
                    Gameplay.SetActive(false);
                    MrPersonGameObject.SetActive(false);
                    MrPersonMusic.SetActive(false);
                    Lvic2.SetActive(true);
                    VictoryMusic.SetActive(true);
                    SHealth          = 1000;
                    ShipHealth.text  = SHealth.ToString();
                    EHealth          = 1000;
                    EnemyHealth.text = EHealth.ToString();
                }
            }
            else if (Medium == true)
            {
                if (AreYouMrDark == true)
                {
                    Gameplay.SetActive(false);
                    MrPersonGameObject.SetActive(false);
                    MrPersonMusic.SetActive(false);
                    Dvic3.SetActive(true);
                    VictoryMusic.SetActive(true);
                    SHealth          = 1000;
                    ShipHealth.text  = SHealth.ToString();
                    EHealth          = 1000;
                    EnemyHealth.text = EHealth.ToString();
                }
                else if (AreYouMrDark == false)
                {
                    Gameplay.SetActive(false);
                    MrPersonGameObject.SetActive(false);
                    MrPersonMusic.SetActive(false);
                    Lvic3.SetActive(true);
                    VictoryMusic.SetActive(true);
                    SHealth          = 1000;
                    ShipHealth.text  = SHealth.ToString();
                    EHealth          = 1000;
                    EnemyHealth.text = EHealth.ToString();
                }
            }
            else if (Excruciatinglyhard == true)
            {
                if (AreYouMrDark == true)
                {
                    Gameplay.SetActive(false);
                    MrPersonGameObject.SetActive(false);
                    MrPersonMusic.SetActive(false);
                    Dvic4.SetActive(true);
                    VictoryMusic.SetActive(true);
                    SHealth          = 1000;
                    ShipHealth.text  = SHealth.ToString();
                    EHealth          = 1000;
                    EnemyHealth.text = EHealth.ToString();
                }
                else if (AreYouMrDark == false)
                {
                    Gameplay.SetActive(false);
                    MrPersonGameObject.SetActive(false);
                    MrPersonMusic.SetActive(false);
                    Lvic4.SetActive(true);
                    VictoryMusic.SetActive(true);
                    SHealth          = 1000;
                    ShipHealth.text  = SHealth.ToString();
                    EHealth          = 1000;
                    EnemyHealth.text = EHealth.ToString();
                }
            }
            else if (UFB == true)
            {
                if (AreYouMrDark == true)
                {
                    Debug.Log("made it here dark");
                    Gameplay.SetActive(false);
                    MrPersonGameObject.SetActive(false);
                    MrPersonMusic.SetActive(false);
                    UltEndingDark.SetActive(true);
                    UltEndingMusic.SetActive(true);
                    SHealth          = 1000;
                    ShipHealth.text  = SHealth.ToString();
                    EHealth          = 1200;
                    EnemyHealth.text = EHealth.ToString();
                }
                else if (AreYouMrDark == false)
                {
                    Debug.Log("made it here light");
                    Gameplay.SetActive(false);
                    MrPersonGameObject.SetActive(false);
                    MrPersonMusic.SetActive(false);
                    UltEndingLight.SetActive(true);
                    UltEndingMusic.SetActive(true);
                    SHealth          = 1000;
                    ShipHealth.text  = SHealth.ToString();
                    EHealth          = 1200;
                    EnemyHealth.text = EHealth.ToString();
                }
            }
        }


        if (Input.GetKeyDown(KeyCode.W)) //Attack
        {
            PressedButton = true;
            MrPerson.SetActive(false);
            LeftButtonPress.SetActive(false);
            RightButtonPress.SetActive(false);
            Left1.SetActive(false);
            Left2.SetActive(true);
            Left3.SetActive(false);
            Right1.SetActive(false);
            Right2.SetActive(false);
            Right3.SetActive(false);

            if (Carl.InstructionBoolArray[3] == true)
            {
                EHealth         -= Damage;
                EnemyHealth.text = EHealth.ToString();
            }
            else
            {
                if (Shields == true)
                {
                    Shields           = false;
                    ShieldStatus.text = "OFF";
                }
                else
                {
                    SHealth        -= Damage;
                    ShipHealth.text = SHealth.ToString();
                }
            }
        }

        if (Input.GetKeyDown(KeyCode.A)) //Move Left
        {
            PressedButton = true;
            MrPerson.SetActive(false);
            LeftButtonPress.SetActive(true);
            RightButtonPress.SetActive(false);
            Left1.SetActive(false);
            Left2.SetActive(false);
            Left3.SetActive(false);
            Right1.SetActive(false);
            Right2.SetActive(false);
            Right3.SetActive(false);

            if (Carl.InstructionBoolArray[0] == false)
            {
                if (Shields == true)
                {
                    Shields           = false;
                    ShieldStatus.text = "OFF";
                }
                else
                {
                    SHealth        -= MinorDamage;
                    ShipHealth.text = SHealth.ToString();
                }
            }
        }

        if (Input.GetKeyDown(KeyCode.S)) //Shields
        {
            PressedButton = true;
            MrPerson.SetActive(false);
            LeftButtonPress.SetActive(false);
            RightButtonPress.SetActive(false);
            Left1.SetActive(false);
            Left2.SetActive(false);
            Left3.SetActive(false);
            Right1.SetActive(false);
            Right2.SetActive(true);
            Right3.SetActive(false);

            if (Carl.InstructionBoolArray[6] == true)
            {
                Shields           = true;
                ShieldStatus.text = "ON";
            }
            else
            {
                if (Shields == true)
                {
                    Shields = false;
                }
                else
                {
                    SHealth        -= MinorDamage;
                    ShipHealth.text = SHealth.ToString();
                }
            }
        }

        if (Input.GetKeyDown(KeyCode.D)) //MoveRight
        {
            PressedButton = true;
            MrPerson.SetActive(false);
            LeftButtonPress.SetActive(false);
            RightButtonPress.SetActive(true);
            Left1.SetActive(false);
            Left2.SetActive(false);
            Left3.SetActive(false);
            Right1.SetActive(false);
            Right2.SetActive(false);
            Right3.SetActive(false);

            if (Carl.InstructionBoolArray[1] == false)
            {
                if (Shields == true)
                {
                    Shields           = false;
                    ShieldStatus.text = "OFF";
                }
                else
                {
                    SHealth        -= MinorDamage;
                    ShipHealth.text = SHealth.ToString();
                }
            }
            else
            {
                ShipHealth.text = SHealth.ToString();
            }
        }

        if (Input.GetKeyDown(KeyCode.Space)) //Restore Health
        {
            PressedButton = true;
            MrPerson.SetActive(false);
            LeftButtonPress.SetActive(false);
            RightButtonPress.SetActive(false);
            Left1.SetActive(false);
            Left2.SetActive(false);
            Left3.SetActive(true);
            Right1.SetActive(false);
            Right2.SetActive(false);
            Right3.SetActive(false);

            if (Carl.InstructionBoolArray[4] == true)
            {
                if (SHealth + 8 < 1000)
                {
                    SHealth        += 8;
                    ShipHealth.text = SHealth.ToString();
                }
                else
                {
                    SHealth         = 1000;
                    ShipHealth.text = SHealth.ToString();
                }
            }
            else
            {
                if (Shields == true)
                {
                    Shields           = false;
                    ShieldStatus.text = "OFF";
                }
                else
                {
                    SHealth        -= MinorDamage;
                    ShipHealth.text = SHealth.ToString();
                }
            }
        }

        if (Input.GetKeyDown(KeyCode.Q)) //Recharge Oxygen
        {
            PressedButton = true;
            MrPerson.SetActive(false);
            LeftButtonPress.SetActive(false);
            RightButtonPress.SetActive(false);
            Left1.SetActive(false);
            Left2.SetActive(false);
            Left3.SetActive(false);
            Right1.SetActive(true);
            Right2.SetActive(false);
            Right3.SetActive(false);

            if (Carl.InstructionBoolArray[5] == true)
            {
                if (SHealth + 4 < 1000)
                {
                    SHealth        += 4;
                    ShipHealth.text = SHealth.ToString();
                }
                else
                {
                    SHealth         = 1000;
                    ShipHealth.text = SHealth.ToString();
                }
            }
            else
            {
                if (Shields == true)
                {
                    Shields           = false;
                    ShieldStatus.text = "OFF";
                }
                else
                {
                    SHealth        -= MinorDamage;
                    ShipHealth.text = SHealth.ToString();
                }
            }
        }

        if (Input.GetKeyDown(KeyCode.E)) //Hyperspace Jump
        {
            PressedButton = true;
            MrPerson.SetActive(false);
            LeftButtonPress.SetActive(false);
            RightButtonPress.SetActive(false);
            Left1.SetActive(false);
            Left2.SetActive(false);
            Left3.SetActive(false);
            Right1.SetActive(false);
            Right2.SetActive(false);
            Right3.SetActive(true);

            if (Carl.InstructionBoolArray[7] == false)
            {
                if (Shields == true)
                {
                    Shields           = false;
                    ShieldStatus.text = "OFF";
                }
                else
                {
                    SHealth        -= MinorDamage;
                    ShipHealth.text = SHealth.ToString();
                }
            }
        }

        if (Input.GetKeyDown(KeyCode.R)) //Big Red Button
        {
            PressedButton = true;
            MrPerson.SetActive(false);
            LeftButtonPress.SetActive(false);
            RightButtonPress.SetActive(false);
            Left1.SetActive(true);
            Left2.SetActive(false);
            Left3.SetActive(false);
            Right1.SetActive(false);
            Right2.SetActive(false);
            Right3.SetActive(false);

            if (Carl.InstructionBoolArray[2] == true)
            {
                EHealth         -= Damage * 2;
                EnemyHealth.text = EHealth.ToString();
            }
            else
            {
                if (Shields == true)
                {
                    Shields           = false;
                    ShieldStatus.text = "OFF";
                }
                else
                {
                    SHealth        -= Damage * 2;
                    ShipHealth.text = SHealth.ToString();
                }
            }
        }
    }