// Update is called once per frame
    void Update()
    {
        //for testing to ensure survivors are added to list
        if (Input.GetKeyDown(KeyCode.K))
        {
            foreach (GameObject go in listOfSurvivors)
            {
                Debug.Log(go.name);
            }
        }



        //MouseClick For selecting Survivor
        if (Input.GetMouseButtonDown(0))
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit, 1000))
            {
                if (hit.collider.tag == "Survivor")
                {
                    selectedSurvivor = hit.transform.gameObject; // gets the hit Gameobject and sets as selected
                    selectedMotor    = selectedSurvivor.GetComponent <SurvivorMovement>();
                    SurvivorDetails  = selectedSurvivor.GetComponent <Survivor>();

                    selectedSurvivor.GetComponent <SurvivorMovement>().isSelected = true;
                    Debug.Log("select");
                    UpdateUIInfo();
                }
            }
        }


        if (selectedSurvivor != null)
        {
            selectedMotor.movementDirection = Input.GetAxis("Horizontal") * screenMovementRight
                                              + Input.GetAxis("Vertical") * screenMovementForward;


            minimapCamera.transform.position =
                new Vector3(selectedSurvivor.transform.position.x,
                            100,
                            selectedSurvivor.transform.position.z);

            //if (Input.GetAxis(Axis_X) != 0 || Input.GetAxis(Axis_Y) != 0)
            //{
            //    anim.SetBool("IsWalking", true);
            //}
            //else
            //{
            //    anim.SetBool("IsWalking", false);

            //}
        }
    }
Пример #2
0
 // Use this for initialization
 void Awake()
 {
     foreach (GameObject item in GameObject.FindGameObjectsWithTag("Survivor"))
     {
         AddSurvivor(item);
         if (selectedSurvivor == null)
         {
             selectedSurvivor = item;
             selectedMotor    = selectedSurvivor.GetComponent <SurvivorMovement>();
         }
     }
     ;
 }
    void Start()
    {
        gOver = gameObject.GetComponent <GameOverScript>();

        anim = GetComponent <Animator>();

        // will rotate in relation to the camera's y axis, used to rotate player
        screenMovementSpace = Quaternion.Euler(0, Camera.main.transform.eulerAngles.y, 0);

        //Moving forwards or backwards on the z axis

        screenMovementForward = screenMovementSpace * Vector3.forward;


        //moving left or right on the x axis
        screenMovementRight = screenMovementSpace * Vector3.right;



        //sets minimap Camera
        minimapCamera = GameObject.FindGameObjectWithTag("MinimapCamera").GetComponent <Camera>();


        selectSurvivorName     = GameObject.Find("SurvivorName").GetComponent <Text>();
        selectSurvivorHealth   = GameObject.Find("SurvivorHealth").GetComponent <Text>();
        selectSurvivorStaminia = GameObject.Find("SurvivorStamina").GetComponent <Text>();
        selectSurvivorAccuracy = GameObject.Find("SurvivorAccuracy").GetComponent <Text>();

        foreach (GameObject item in GameObject.FindGameObjectsWithTag("Survivor"))
        {
            AddSurvivor(item);
            if (selectedSurvivor == null)
            {
                selectedSurvivor = item;

                selectedMotor   = selectedSurvivor.GetComponent <SurvivorMovement>();
                SurvivorDetails = selectedSurvivor.GetComponent <Survivor>();
                selectedSurvivor.GetComponent <SurvivorMovement>().isSelected = true;
                Debug.Log("select");
                UpdateUIInfo();
            }
        }
    }