コード例 #1
0
    private void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Debug.Log("Mouse Clicked");
            Ray        ray = camera.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit))
            {
                if (hit.transform.CompareTag(targetsTag))
                {
                    cam.SetTarget(hit.transform);
                    Debug.Log("You clicked a blob");
                }
                else
                {
                    Debug.Log("Targeting Mesh");
                    //NavMeshHit nHit;
                    //Ray ray1 = Camera.main.ScreenPointToRay(Input.mousePosition);

                    //bool hasHit = NavMesh.Raycast(this.transform.position, hit.point, out nHit, NavMesh.AllAreas);
                    Debug.Log("Mesh Targeted");
                    Debug.Log(hit.point);
                    //randomDestination(10);

                    //Debug.Log("Area ID: " + nHit.mask);
                    //targetPosition = hit.point;
                    //agent.destination = targetPosition;



                    cam.ResetTarget();
                }
            }
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            TargetingPlayer = !TargetingPlayer;
            TargetPlayer    = PlayerCanvas.canvas.PlayerObject;
            if (!TargetingPlayer)
            {
                cam.SetTarget(TargetPlayer.transform);
            }
            else if (TargetingPlayer)
            {
                cam.ResetTarget();
            }
        }
    }
コード例 #2
0
ファイル: TargetSelector.cs プロジェクト: Wingxvii/RTSGame
    private void Update()
    {
        if (Input.GetMouseButtonDown(0) && !Input.GetKey(KeyCode.LeftShift))
        {
            cam.ResetTarget();

            float timeDelta = Time.time - lastClickTime;

            if (timeDelta < doubleClickTime)
            {
                Ray        ray = camera.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit;
                if (Physics.Raycast(ray, out hit))
                {
                    bool foundTarget = false;
                    foreach (string target in targetsTag)
                    {
                        if (hit.transform.CompareTag(target))
                        {
                            cam.SetTarget(hit.transform);
                            foundTarget = true;
                        }
                    }
                }
                lastClickTime = 0;
            }
            else
            {
                lastClickTime = Time.time;
            }
        }
    }
コード例 #3
0
    private void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            // cant click through UI now
            if (EventSystem.current.IsPointerOverGameObject())
            {
                return;
            }

            Ray       ray = camera.ScreenPointToRay(Input.mousePosition);
            Transform tmp = null;

            RaycastHit hit;

            if (Physics.Raycast(ray, out hit))
            {
                tmp = FindParentWithTag2(hit.transform, targetsTag);
                if (tmp != null)
                {
                    cam.SetTarget(tmp);
                }
                else
                {
                    cam.ResetTarget();
                }
            }
        }
    }
コード例 #4
0
    //private bool changedToWedge = false;

    //private float wedgeDelay = 3f;

    #endregion

    // Approach, box, repel, go to exit, end


    // Start is called before the first frame update
    private void Start()
    {
        cam.SetTarget(policeUnit);
        //World.DefaultGameObjectInjectionWorld.GetOrCreateSystem<CrowdCountingSystem>().NoCrowdLeftEvent += RepelledRiotersResponse;

        PoliceUnitVoiceController[] voiceControllers = UnityEngine.Object.FindObjectsOfType <PoliceUnitVoiceController>();
        if (voiceControllers.Length > 0)
        {
            PoliceUnitVoiceController voiceController = voiceControllers[0]; // grab the voice controller if there is one
            voiceController.OnTo3SidedBoxVoiceCommand           += VoiceToBoxResponse;
            voiceController.OnToParallelTightCordonVoiceCommand += VoiceToCordonResponse;
        }

        World.DefaultGameObjectInjectionWorld.GetOrCreateSystem <PoliceUnitRemoveMovementSystem>().ConnectToPrototypeManager();

        UpdateDisplayText(approachTextBlocks);
    }
コード例 #5
0
    //Wedge, parallel loose cordon, box, tight cordon, rotate left, rotate right, first halt, move forward, second halt, end tutorial


    // Start is called before the first frame update
    private void Start()
    {
        cam.SetTarget(policeUnit);

        PoliceUnitVoiceController[] voiceControllers = Object.FindObjectsOfType <PoliceUnitVoiceController>();
        if (voiceControllers.Length > 0)
        {
            PoliceUnitVoiceController voiceController = voiceControllers[0]; // grab the voice controller if there is one
            voiceController.OnToWedgeVoiceCommand += VoiceToWedgeResponse;
            voiceController.OnToParallelLooseCordonVoiceCommand += VoiceToParaLooseCordonResponse;
            voiceController.OnTo3SidedBoxVoiceCommand           += VoiceToBoxResponse;
            voiceController.OnToParallelTightCordonVoiceCommand += VoiceToParaTightCordonResponse;
            voiceController.OnRotateCommand      += VoiceRotateResponse;
            voiceController.OnHaltCommand        += VoiceHaltResponse;
            voiceController.OnMoveForwardCommand += VoiceMoveForwardResponse;
        }
        UpdateDisplayText(rotateCameraTextBlocks);
    }
コード例 #6
0
    private void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);

            if (hit.collider != null)
            {
                if (hit.transform.CompareTag(targetsTag))
                {
                    cam.SetTarget(hit.transform);
                }
                else
                {
                    cam.ResetTarget();
                }
            }
        }
    }
コード例 #7
0
 private void ClickOnObjects()
 {
     if (Input.GetMouseButtonDown(0))
     {
         Ray        ray = camera.ScreenPointToRay(Input.mousePosition);
         RaycastHit hit;
         if (Physics.Raycast(ray, out hit))
         {
             if (hit.transform.CompareTag(targetsTag))
             {
                 cam.SetTarget(hit.transform);
             }
             else
             {
                 cam.ResetTarget();
             }
         }
     }
 }
コード例 #8
0
    private void Update()
    {
        if (!Input.GetMouseButtonDown(0))
        {
            return;
        }
        var        ray = camera.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (!Physics.Raycast(ray, out hit))
        {
            return;
        }

        if (hit.transform.CompareTag(targetsTag))
        {
            cam.SetTarget(hit.transform);
        }
        else
        {
            cam.ResetTarget();
        }
    }
コード例 #9
0
 private void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         Ray        ray = camera.ScreenPointToRay(Input.mousePosition);
         RaycastHit hit;
         if (Physics.Raycast(ray, out hit))
         {
             bool foundTarget = false;
             foreach (string target in targetsTag)
             {
                 if (hit.transform.CompareTag(target))
                 {
                     cam.SetTarget(hit.transform);
                     foundTarget = true;
                 }
             }
             if (!foundTarget)
             {
                 cam.ResetTarget();
             }
         }
     }
 }
コード例 #10
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButton(1))
        {
            if (CameraCaster.Instance.SelectedDestination() != null)
            {
                characterAgent.MoveToLocation((Vector3)CameraCaster.Instance.SelectedDestination());
            }
        }
        if (Input.GetMouseButtonDown(0))
        {
            characterAgent.Execute();
        }
        if (Input.GetKeyDown(KeyCode.B) && currentCommand == 'I')
        {
            currentCommand = 'B';
        }
        if (Input.GetKeyDown(KeyCode.A) && currentCommand == 'I')
        {
            currentCommand = 'A';
            characterAgent.BasicAttackInitiate();
        }

        /* Future action implementation
         * if (Input.GetKeyDown(KeyCode.Q) && currentCommand == 'I'){
         *  currentCommand = 'Q';
         *  characterAgent.ActionEnable(currentCommand);
         * }
         * if (Input.GetKeyDown(KeyCode.W) && currentCommand == 'I'){
         *  currentCommand = 'W';
         *  characterAgent.ActionEnable(currentCommand);
         * }
         * if (Input.GetKeyDown(KeyCode.E) && currentCommand == 'I'){
         *  currentCommand = 'E';
         *  characterAgent.ActionEnable(currentCommand);
         * }
         * if (Input.GetKeyDown(KeyCode.R) && currentCommand == 'I'){
         *  currentCommand = 'R';
         *  characterAgent.ActionEnable(currentCommand);
         * }
         */
        //// Cancel ////
        if (Input.GetKeyDown(KeyCode.Escape) && currentCommand == 'I')
        {
            Application.Quit();
        }
        else if (Input.GetKeyDown(KeyCode.Escape) && currentCommand != 'B')
        {
            characterAgent.CancelCommand();
            currentCommand = 'I';
        }

        //// Build Command ////
        if (currentCommand == 'B')
        {
            GameController.Instance.Build();
        }

        //// Camera Control ////
        if (Input.GetKeyDown(KeyCode.Space))
        {
            rtscamera.SetTarget(selectedCharacter.transform);
        }
        if (Input.GetKeyUp(KeyCode.Space) || (cameraJump))
        {
            rtscamera.ResetTarget();
            cameraJump = false;
        }

        //// Character Selection ////
        if (Input.GetKeyDown(KeyCode.Alpha1) || Input.GetKeyDown(KeyCode.Keypad1))
        {
            rtscamera.SetTarget(character01.transform);
            selectedCharacter = character01;
            characterAgent    = character01.GetComponent <CharacterAgent>();
            cameraJump        = true;
        }
        if (Input.GetKeyDown(KeyCode.Alpha2) || Input.GetKeyDown(KeyCode.Keypad2))
        {
            rtscamera.SetTarget(character02.transform);
            selectedCharacter = character02;
            characterAgent    = character02.GetComponent <CharacterAgent>();
            cameraJump        = true;
        }
        if (Input.GetKeyDown(KeyCode.Alpha3) || Input.GetKeyDown(KeyCode.Keypad3))
        {
            rtscamera.SetTarget(character03.transform);
            selectedCharacter = character03;
            characterAgent    = character03.GetComponent <CharacterAgent>();
            cameraJump        = true;
        }
        if (Input.GetKeyDown(KeyCode.Alpha4) || Input.GetKeyDown(KeyCode.Keypad4))
        {
            rtscamera.SetTarget(character04.transform);
            selectedCharacter = character04;
            characterAgent    = character04.GetComponent <CharacterAgent>();
            cameraJump        = true;
        }
    }