void Start()
    {
        player            = GameObject.FindGameObjectWithTag("Player");
        timeManager       = GameObject.Find("TimeManager");
        gameControllerObj = GameObject.Find("GameController");

        if (player != null)
        {
            playerInfo = player.GetComponent <PlayerInformationScript>();
        }
        else
        {
            Debug.LogError("PLAYER NOT FOUND");
        }

        if (timeManager != null)
        {
            timeScript = timeManager.GetComponent <TimeCycleScript>();
        }
        else
        {
            Debug.LogError("Cant find time");
        }

        if (gameControllerObj != null)
        {
            gameController = gameControllerObj.GetComponent <GameControllerScript>();
        }
    }
示例#2
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Player")
        {
            Player = other.GetComponent <PlayerInformationScript>();
            if (other.name == RaceController.GetComponent <RaceController>().GetUIOwner().name)
            {
                UpdateUI = true;
            }


            if (Name == "StartFinishLine")
            {
                if (Player.Checkpoint4 == true) //has a lap been completed
                {
                    Player.CompletedLap();
                    if (UpdateUI)
                    {
                        RaceController.GetComponent <RaceController>().UpdateLapInfo();
                    }
                }
            }
            else
            {
                other.GetComponent <PlayerInformationScript>().SetCheckpointTimes(Name);
                if (UpdateUI)
                {
                    RaceController.GetComponent <RaceController>().SetCheckpointTimes(Name);
                }
            }
        }
    }
    void Start()
    {
        if (Application.loadedLevelName == "HomeScene")
        {
            homeInstructPanel = GameObject.Find("Instruction_Panel");
            playerObj         = GameObject.FindGameObjectWithTag("Player");
            timeManagerObj    = GameObject.Find("TimeManager");

            if (homeInstructPanel != null)
            {
                if (instructionPanelRead == false)
                {
                    homeInstructPanel.SetActive(true);
                }
                else
                {
                    homeInstructPanel.SetActive(false);
                }
            }
            else
            {
                Debug.LogError("Instruct panel not found");
            }
            if (playerObj != null)
            {
                playerInfo = playerObj.GetComponent <PlayerInformationScript>();

                playerName  = playerInfo.playerName;
                playerScore = playerInfo.score;
            }
            else
            {
                Debug.LogError(playerObj.name + " not found!!");
            }

            if (timeManagerObj != null)
            {
                timeScript = timeManagerObj.GetComponent <TimeCycleScript>();
            }
            else
            {
                Debug.LogError(timeManagerObj.name + " not found!!");
            }

            saveButton = GameObject.Find("SaveButton").GetComponent <Button>();
            loadButton = GameObject.Find("LoadButton").GetComponent <Button>();

            saveButton.onClick.AddListener(() => Save());
            loadButton.onClick.AddListener(() => LoadInGame());
        }
    }
示例#4
0
    // Use this for initialization
    void Start()
    {
        RaceStarted       = false;
        AIPath            = new Path();
        AIPath.TotalNodes = 0;
        AIPath.Index      = 0;
        AIPath.Nodes      = new List <GameObject>();
        GetComponent <UsePowerupScript>().Owner = gameObject;

        rb = GetComponent <Rigidbody>();

        Info = GetComponent <PlayerInformationScript>();

        int ChildNodes = PathObject.transform.childCount; // get the total amount of path nodes

        for (int i = 0; i < ChildNodes; i++)
        {
            AIPath.Nodes.Add(PathObject.transform.GetChild(i).gameObject);
            ++AIPath.TotalNodes;
        }

        agent.destination = AIPath.Nodes[AIPath.Index].transform.position;
    }