void ClearScripts()
 {
     gameObjectSelected = null;
     platformRotation   = null;
     searchPlatform     = null;
     movePlatform       = null;
 }
Beispiel #2
0
 private void interactWithObjects()
 {
     for (int i = 0; i < gameobjectsToBeInteracted.Length; i++)
     {
         if (gameobjectsToBeInteracted[i].gameObject is DoorObject)
         {
             //Toggle the door object
             DoorObject puerta = gameobjectsToBeInteracted[i].gameObject.GetComponent <DoorObject>();
             puerta.setState(!puerta.getState());
         }
         else if (gameobjectsToBeInteracted[i].gameObject is MovePlatform)
         {
             //Activate the platform
             MovePlatform plataforma = gameobjectsToBeInteracted[i].gameObject.GetComponent <MovePlatform>();
             if (gameobjectsToBeInteracted[i].gameObject.active)
             {
                 gameobjectsToBeInteracted[i].gameObject.SetActive(false);
             }
             else
             {
                 gameobjectsToBeInteracted[i].gameObject.SetActive(true);
             }
         }
         else if (gameobjectsToBeInteracted[i].gameObject.gameObject is foco)
         {
             //Switch off/on the spotlight
             foco spotlight = gameobjectsToBeInteracted[i].gameObject.GetComponent <foco>();
             //Logica a seguir para los focos
         }
     }
 }
Beispiel #3
0
    // Use this for initialization
    void Start()
    {
        theSpriteRenderer        = GetComponent <SpriteRenderer> ();
        theSpriteRenderer.sprite = leverInactive;

        myMovingPlatform = GetComponentInParent <MovePlatform> ();
    }
 void SetScripts()
 {
     Debug.Log(this + "SetScripts, gameObjectSelected: " + gameObjectSelected.name);
     searchPlatform   = gameObjectSelected.GetComponent <SearchPlatform>();
     platformRotation = gameObjectSelected.GetComponent <PlatformRotation>();
     movePlatform     = gameObjectSelected.GetComponent <MovePlatform>();
     movePlatform.SetLastPosition(gameObjectSelected.transform.position);
     movePlatform.SetCamera(gameplayCamera);
 }
Beispiel #5
0
    private IEnumerator MoveWithPlatform(Transform platform)
    {
        yield return(new WaitForFixedUpdate());

        MovePlatform mp    = platform.parent.GetComponent <MovePlatform>();
        float        speed = mp.GetSpeed / 4;

        transform.position += (mp.NextPosition - transform.position).normalized * speed * Time.deltaTime;
    }
Beispiel #6
0
 void SetScripts()
 {
     searchPlatform   = gameObjectSelected.GetComponent <SearchPlatform>();
     platformRotation = gameObjectSelected.GetComponent <PlatformRotation>();
     movePlatform     = gameObjectSelected.GetComponent <MovePlatform>();
     changeColor      = gameObjectSelected.GetComponent <ChangeColor>();
     movePlatform.SetLastPosition(gameObjectSelected.transform.position);
     movePlatform.SetCamera(gameplayCamera);
 }
Beispiel #7
0
    // Use this for initialization
    void Start()
    {
        spRenderer = GetComponent <SpriteRenderer> ();

        if (movePlatform == null)
        {
            Debug.Log("moveplatform not found");
            movePlatform = FindObjectOfType <MovePlatform> ();
        }
    }
    void ChangePositions()
    {
        searchPlatform.SetFind(false);
        MovePlatformToPosition(movePlatform, searchPlatform.GetNextPosition(), gameObjectSelected.transform.position);

        GameObject   otherPlatform     = searchPlatform.GetOtherPlatform();
        MovePlatform otherMovePlatform = otherPlatform.GetComponent <MovePlatform>();

        MovePlatformToPosition(otherMovePlatform, movePlatform.GetLastPosition(), otherPlatform.transform.position);
    }
Beispiel #9
0
    void CreateNewPlatform(Vector3 newPosition)
    {
        score++;

        GameObject platform = Instantiate(platformPrefab);

        newPosition.y += platform.transform.localScale.y;

        MovePlatform mover = platform.GetComponent <MovePlatform>();

        mover.platformStops += ChangeLocalScale;
        mover.platformStops += CreateNewPlatform;

        int randomStart = Random.Range(0, 4);

        switch (randomStart)
        {
        case 0:
            mover.end   = SpawnPositiontData.leftFather;
            mover.start = SpawnPositiontData.rightCloser;
            break;

        case 1:
            mover.end   = SpawnPositiontData.rightFather;
            mover.start = SpawnPositiontData.leftCloser;
            break;

        case 2:
            mover.end   = SpawnPositiontData.leftCloser;
            mover.start = SpawnPositiontData.rightFather;
            break;

        case 3:
            mover.end   = SpawnPositiontData.rightCloser;
            mover.start = SpawnPositiontData.leftFather;
            break;
        }
        mover.end.y   = newPosition.y;
        mover.start.y = newPosition.y;

        platform.transform.position = mover.start;

        if (currentPlatform != null)
        {
            lastPlatform = currentPlatform;
        }
        currentPlatform = mover;

        platform.transform.localScale = new Vector3(lastPlatform.transform.localScale.x, platformPrefab.transform.localScale.y, lastPlatform.transform.localScale.z);
    }
    // Start is called before the first frame update
    void Start()
    {
        platforms = GameObject.FindGameObjectsWithTag("Platform");

        mp = FindObjectOfType <MovePlatform>();
        for (int i = 0; i < 3; i++)
        {
            buttons[i].GetComponent <Button>().interactable = false;
        }
        moving_platforms.gameObject.SetActive(false);
        nextgamebtn.gameObject.SetActive(false);
        time = 0.1f;
        src  = gameObject.AddComponent <AudioSource>();

        //----------------------Data mining-------------
        OLDrecords = new Records();
        records    = new Records();
        string path = "/PlayerRecords.json";

        OLDrecords = JsonUtility.FromJson <Records>(File.ReadAllText(Application.persistentDataPath + path));
        Debug.Log("Total OLDfalse = " + OLDrecords.TotalFalse);
        Debug.Log("Total OLDtrue = " + OLDrecords.TotalTrue);
        Debug.Log("Total OLDAvgReactTime = " + OLDrecords.AvgReactTime);
        Debug.Log("Total OLDSumOfAns = " + OLDrecords.SumOfAns);
        Debug.Log("OLDPlayerType = " + OLDrecords.PlayerType);
        Debug.Log("OLDRecordScore = " + OLDrecords.RecordScore);

        OLDrecords.Detect_Type(OLDrecords);

        if (OLDrecords.result == 1)
        {
            temp      = 10;
            timestart = 60f;
        }
        if (OLDrecords.result == 2)
        {
            temp      = 12;
            timestart = 55f;
        }
        if (OLDrecords.result == 3)
        {
            temp      = 14;
            timestart = 50f;
        }
        //----------------------------
    }
Beispiel #11
0
    /**
     * When the character gets on top of a platform it should add the platform speed to its own speed.
     */
    private Vector3 AddSpeedFromPlatform(Collider col)
    {
        Vector3      platformSpeed = Vector3.zero;
        MovePlatform mover         = col.gameObject.GetComponent <MovePlatform>();

        if (mover != null)
        {
            platformSpeed = mover.currDir;
        }
        else
        {
            Rigidbody colRb = col.gameObject.GetComponent <Rigidbody>();
            if (colRb != null)
            {
                platformSpeed = colRb.velocity;
            }
        }

        return(platformSpeed);
    }
Beispiel #12
0
    private MovePlatform movePlatform; // скрипт с реализацией движения и вращения


    void Start()
    {
        movePlatform = GetComponent <MovePlatform>();
    }
 private void Start()
 {
     movePlatform = FindObjectOfType <MovePlatform>();
 }
Beispiel #14
0
 // Start is called before the first frame update
 void Start()
 {
     lastPlatform = starterPlatform;
     CreateNewPlatform(platformPrefab.transform.position);
 }
 // Use this for initialization
 void Start()
 {
     m_move_script_         = GetComponent <MovePlatform>();
     m_move_script_.enabled = false;
 }
Beispiel #16
0
 void Awake()
 {
     movePlatformScript = GetComponent <MovePlatform>();
     tr = GetComponent <Transform>();
     rb = GetComponent <Rigidbody2D>();
 }
 void MovePlatformToPosition(MovePlatform moveTemp, Vector3 nextPosition, Vector3 currentPosition)
 {
     moveTemp.SetNextPosition(nextPosition);
     moveTemp.CalculateLinearTrajectory(currentPosition);
     moveTemp.StartMove();
 }
Beispiel #18
0
    void Update()
    {
        // Check if the player has pressed the fire button and if enough time has elapsed since they last fired
        if (Input.GetButtonDown("Fire1") && Time.time > nextFire)
        {
            // Update the time when our player can fire next
            nextFire = Time.time + fireRate;

            // Start our ShotEffect coroutine to turn our laser line on and off
            StartCoroutine(ShotEffect());

            // Create a vector at the center of our camera's viewport
            Vector3 rayOrigin = fpsCam.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 0.0f));

            // Declare a raycast hit to store information about what our raycast has hit
            RaycastHit hit;


            // Set the start position for our visual effect for our laser to the position of gunEnd
            laserLine.SetPosition(0, gunEnd.position);

            // Check if our raycast has hit anything
            if (Physics.Raycast(rayOrigin, fpsCam.transform.forward, out hit, weaponRange))
            {
                // if (Physics.SphereCast(rayOrigin, 100,fpsCam.transform.forward, out hit, weaponRange))

                // Set the end position for our laser line
                laserLine.SetPosition(1, hit.point);

                // Get a reference to a health script attached to the collider we hit
                ShootableBox     health = hit.collider.GetComponent <ShootableBox>();
                MovePlatform     mp     = hit.collider.GetComponent <MovePlatform>();
                MoveablePlatform mc     = hit.collider.GetComponent <MoveablePlatform>();
                MultiMove        mm     = hit.collider.GetComponent <MultiMove>();

                if (health != null)
                {
                    health.Damage(gunDamage);
                }

                if (mp != null)
                {
                    //use if MoveablePlatform is mine not prefab
                    mp.Frozen();
                }

                if (mm != null)
                {
                    //use if MoveablePlatform is mine not prefab
                    mm.Frize();
                }
                if (mc != null)
                {
                    //use if MoveablePlatform is mine not prefab
                    mc.Froze();
                }

                // Check if the object we hit has a rigidbody attached
                if (hit.rigidbody != null)
                {
                }
            }
            else
            {
                // If we did not hit anything, set the end of the line to a position directly in front of the camera at the distance of weaponRange
                laserLine.SetPosition(1, rayOrigin + (fpsCam.transform.forward * weaponRange));
            }
        }
    }