Exemplo n.º 1
0
    public void Load()
    {
        if (File.Exists(Application.persistentDataPath + "/replayTest.dat"))
        {
            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Open(Application.persistentDataPath + "/replayTest.dat", FileMode.Open);
            rP = (ReplayPath)bf.Deserialize(file);
            file.Close();

            timeBetweenNodes        = rP.TimeBetweenNodes;
            this.transform.position = rP.GetNode();
            nextNode = rP.GetNode();
            moveRate = CalculateMoveRate();
        }
        else
        {
            print("File not found, destroying Ghost");
            Destroy(this.gameObject);
        }
    }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (timeSinceLastNode >= timeBetweenNodes)
        {
            ++i;
            timeSinceLastNode = 0f;
            if (i == rP.NodeCount())
            {
                Destroy(this.gameObject);
            }
            else
            {
                nextNode = rP.GetNode();
            }

            moveRate = CalculateMoveRate();
        }

        Vector3 dir = nextNode - this.transform.position;

        this.transform.Translate(dir.normalized * moveRate);
        timeSinceLastNode += Time.deltaTime;
    }