예제 #1
0
    //taken from PlayerScript - sets position of the clone
    public void setLocation(CloneLocation cloneLocation)
    {
        if (!cloneLocation.Equals(TrackMovement.DESTROY_CLONE))
        {
            transform.position = cloneLocation.getLocation();

            Vector3 currRotation = cloneLocation.getRotation();

            transform.rotation = Quaternion.Euler(new Vector3(currRotation.x, currRotation.y - 90, currRotation.z));
            currDirection      = transform.rotation.eulerAngles;

            if (cloneLocation.getDidSword())
            {
                Debug.Log("STABBY STAB STAB");
                sword.drawn = true;
            }
            else if (cloneLocation.getDidShoot())
            {
                Debug.Log("One two three four five six seven--");
            }
        }
        else
        {
            this.kill();
        }
    }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        PlayerScript        PlayerScript        = GetComponent <PlayerScript>();
        TimeTravelIndicator TimeTravelIndicator = GetComponent <TimeTravelIndicator>();

        if (frameNum % framerate == 0) //every big frame, record the player's actions
        {
            bool didSword = PlayerScript.didSword;
            bool didShoot = PlayerScript.didShoot;

            CloneLocation toAdd = new CloneLocation(transform.position,
                                                    playerRotation.transform.rotation.eulerAngles, didSword, didShoot);

            if (didShoot)
            {
                PlayerScript.didShoot = false;
            }
            if (didSword)
            {
                PlayerScript.didSword = false;
            }

            locations.Add(key, toAdd); //Add the player's current location to the locations map
            key++;                     //The location's number
        }

        frameNum++;

        int charge = PlayerScript.getCharges();

        if (charge >= currLevelCharges())                                   //go back in time
        {
            newClone = Instantiate(clone);                                  //create the clone

            PlayerScript.resetCharges();                                    //set charges to 0

            TimeTravelIndicator.setFlash("white");                          //flashes the screen white

            Resetter resetter = nonPlayerObjects.GetComponent <Resetter>(); //resets the location of everything
            resetter.reset = true;
            bucket.GetComponent <BucketScript>().reset();                   //resets the bucket's status

            timer.GetComponent <Timer>().reset();                           //resets the timer

            locations.Add(key, DESTROY_CLONE);                              //Adds a marker - the past self should be destroyed here
            key++;
        }

        if ((newClone != null) && (frameNum % framerate == 0)) //every big frame, update the clone
        {
            CloneLocation toSet       = (CloneLocation)locations[key2];
            CloneScript   cloneScript = newClone.GetComponent <CloneScript>();
            if (!PlayerScript.getPause())       //Pauses the clone
            {
                cloneScript.setLocation(toSet); //set the clone's location
                key2++;
            }
        }
    }