Beispiel #1
0
    void Start()
    {
        pf  = GetComponent <PathFollower>();
        gms = GameManagerScript.instance;
        bs  = GetComponent <BehaviourScript>();

        speed = gms.speed;
    }
Beispiel #2
0
        public static void Main(string[] args)
        {
            BehaviourScript script = new BehaviourScript();

            script.Parse(s);
            script.Interpreter.PreVisit();
            script.Interpreter.EnterBlockNode("Start");
        }
Beispiel #3
0
    private void Start()
    {
        UIManagerScript.instance.mainPlayerStats = GetComponent <Statistics>();

        bs    = GetComponent <BehaviourScript>();
        gms   = GameManagerScript.instance;
        pf    = GetComponent <PathFollower>();
        speed = gms.speed;
    }
Beispiel #4
0
        public void ConditionTest_1()
        {
            BehaviourScript script = new BehaviourScript();

            ScriptException ex = Assert.Throws <ScriptException>(() => script.Parse(script_5));

            Assert.That(ex.Message, Is.EqualTo("Parsing Error: Unexpected Token: ELSEIF at 12.18"));

            Assert.Pass();
        }
Beispiel #5
0
    void Start()
    {
        GameObject gm = GameObject.Find("GameManager");

        gameManager = gm.GetComponent <BehaviourScript>();
        GameObject sp = GameObject.Find("Path");

        span = sp.GetComponent <Spawn>();
        hp   = 200;
    }
Beispiel #6
0
        public void ConditionTest_2()
        {
            double d = 0;

            d = GetValueFromInput("10");
            Assert.True(d == 1);

            d = GetValueFromInput("5");
            Assert.True(d == 2);

            d = GetValueFromInput("20");
            Assert.True(d == 3);

            d = GetValueFromInput("41");
            Assert.True(d == 4);

            d = GetValueFromInput("40");
            Assert.True(d == 5);

            Assert.Pass();

            double GetValueFromInput(string input)
            {
                string script_6 = $@"
               
                double d = {input};

                [Start]
                    if(d == 10) then
                        d = 1;
                    elif(d < 10) then
                        d = 2;
                    elif(d == 20) then
                        d = 3;
                    elif(d > 40) then
                        d = 4;
                    else
                        d = 5;
                    end
                end
            ";

                BehaviourScript script = new BehaviourScript();

                script.Parse(script_6);
                script.Interpreter.PreVisit();
                script.Interpreter.EnterBlockNode("Start");
                return(((DoubleValue)script.Interpreter.Current["d"]).Value);
            }
        }
Beispiel #7
0
    // Shoot the Laser
    private void Fire()
    {
        // Get ARCamera Transform
        Transform cam = Camera.main.transform;

        // Define the time of the next fire
        mNextFire = Time.time + mFireRate;

        // Set the origin of the RayCast
        Vector3 rayOrigin = cam.position;

        // Set the origin position of the Laser Line
        // It will always 10 units down from the ARCamera
        // We adopted this logic for simplicity
        mLaserLine.SetPosition(0, transform.up * -10f);


        RaycastHit hit;

        // Checks if the RayCast hit something
        if (Physics.Raycast(rayOrigin, cam.forward, out hit, mFireRange))
        {
            // Set the end of the Laser Line to the object hit
            mLaserLine.SetPosition(1, hit.point);
            BehaviourScript cubeCtr = hit.collider.GetComponent <BehaviourScript>();
            if (cubeCtr != null)
            {
                if (hit.rigidbody != null)
                {
                    // apply force to the target
                    hit.rigidbody.AddForce(-hit.normal * mHitForce);
                    // apply damage the target
                    cubeCtr.Hit(mLaserDamage);
                }
            }
        }
        else
        {
            // Set the enfo of the laser line to be forward the camera
            // using the Laser range
            mLaserLine.SetPosition(1, cam.forward * mFireRange);
        }
        StartCoroutine(LaserFx());
    }
Beispiel #8
0
        public void Test2()
        {
            BehaviourScript script = new BehaviourScript();

            script.Parse(script_2);
            script.Interpreter.PreVisit();

            double d  = ((DoubleValue)script.Interpreter.Current["d"]).Value;
            double d1 = ((DoubleValue)script.Interpreter.Current["d1"]).Value;
            double d2 = ((DoubleValue)script.Interpreter.Current["d2"]).Value;
            double d3 = ((DoubleValue)script.Interpreter.Current["d3"]).Value;

            Assert.IsTrue(d == 103);
            Assert.IsTrue(d1 == 160);
            Assert.IsTrue(d2 == 400);
            Assert.IsTrue(d3 == 800);

            Assert.Pass();
        }
Beispiel #9
0
 // Use this for initialization
 void Start()
 {
     gameManager = GameObject.Find("GameManager").GetComponent <BehaviourScript>();
     build       = GetComponent <AudioSource>();
 }
Beispiel #10
0
    // Update is called once per frame
    void Update()
    {
        Vector2 direction  = mPointO.transform.position - transform.position;
        Vector2 direction1 = mPoint1.transform.position - transform.position;
        Vector2 direction2 = mPoint2.transform.position - transform.position;
        Vector2 direction3 = mPoint3.transform.position - transform.position;
        Vector2 direction4 = mPoint4.transform.position - transform.position;
        Vector2 direction5 = mPoint5.transform.position - transform.position;
        Vector2 Design     = TwoWay.position - transform.position;
        Vector2 SD1        = SecP1.position - transform.position;
        Vector2 SD2        = SecP2.position - transform.position;

        if (turn1 == false)
        {
            transform.Translate(direction.normalized * EWalkSpeed * Time.deltaTime);
        }
        if (turn1 == true && turn2 == false)
        {
            transform.Translate(direction1.normalized * EWalkSpeed * Time.deltaTime);
        }



        if (turn1 == true && turn2 == true && DeTT == false)
        {
            transform.Translate(Design.normalized * EWalkSpeed * Time.deltaTime);
        }

        if (Design.magnitude <= 0.1f)
        {
            decision = Random.Range(0.0f, 1.0f);
            if (decision <= 0.5f)
            {
                SecWay = true;
                DeTT   = true;
            }
            else
            {
                SecWay = false;
                DeTT   = true;
            }
        }

        if (turn1 == true && turn2 == true && DeTT == true && SecWay == true && SecT1 == false)
        {
            transform.Translate(SD1.normalized * EWalkSpeed * Time.deltaTime);
        }

        if (turn1 == true && turn2 == true && DeTT == true && SecWay == true && SecT1 == true && SecT2 == false)
        {
            transform.Translate(SD2.normalized * EWalkSpeed * Time.deltaTime);
        }
        if (turn1 == true && turn2 == true && DeTT == true && SecWay == true && SecT1 == true && SecT2 == true)
        {
            transform.Translate(direction5.normalized * EWalkSpeed * Time.deltaTime);
        }

        if (turn1 == true && turn2 == true && DeTT == true && SecWay == false && turn3 == false)
        {
            transform.Translate(direction2.normalized * EWalkSpeed * Time.deltaTime);
        }

        if (turn1 == true && turn2 == true && DeTT == true && SecWay == false && turn3 == true && turn4 == false)
        {
            transform.Translate(direction3.normalized * EWalkSpeed * Time.deltaTime);
        }
        if (turn1 == true && turn2 == true && DeTT == true && SecWay == false && turn3 == true && turn4 == true && turn5 == false)
        {
            transform.Translate(direction4.normalized * EWalkSpeed * Time.deltaTime);
        }
        if (turn1 == true && turn2 == true && DeTT == true && SecWay == false && turn3 == true && turn4 == true && turn5 == true)
        {
            transform.Translate(direction5.normalized * EWalkSpeed * Time.deltaTime);
        }
        if (direction.magnitude <= 0.1f)
        {
            turn1 = true;
        }
        if (direction1.magnitude <= 0.1f)
        {
            turn2 = true;
        }

        if (SD1.magnitude <= 0.1f)
        {
            SecT1 = true;
        }

        if (SD2.magnitude <= 0.1f)
        {
            SecT2 = true;
        }
        if (direction2.magnitude <= 0.1f)
        {
            turn3 = true;
        }
        if (direction3.magnitude <= 0.1f)
        {
            turn4 = true;
        }
        if (direction4.magnitude <= 0.1f)
        {
            turn5 = true;
        }

        if (direction5.magnitude <= 0.1f)
        {
            final = true;
        }

        if (final == true)
        {
            Destroy(gameObject);
            BehaviourScript gameManager =
                GameObject.Find("GameManager").GetComponent <BehaviourScript>();
            gameManager.Health -= 1;
        }
    }
 // Use this for initialization
 void Start()
 {
     startLogging = false;
     ang = compass.GetComponent<ANG> ();
     behaviour = gameObject.GetComponent<BehaviourScript>();
     foundLayer = 8;
     enableCompass = false;
     randomPlacement (12f, 12f, 250f, 250f, 0, 3);
     randomPlacement (255f, 12f, 485f, 250f, 3, 6);
     randomPlacement (12f, 255f, 250f, 485f, 6, 9);
     randomPlacement (255f, 255f, 485f, 485f, 9, 12);
     componentCameraCB = gameObject.GetComponentsInChildren<CB> ();
 }