Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        if(txtOptic.activeSelf != opticControl)
        {
            txtOptic.SetActive(opticControl);
        }

        if (!opticControl)
        {

            if (gamemaster.curTurn == GameMaster.turns.player)
            {
                switch (state)
                {
                    case formState.idle:
                        idle();
                        break;
                    case formState.move:
                        move();
                        break;
                    default:
                        break;
                }
            }
            else
            {
                if (pointerLine.gameObject.activeSelf) pointerLine.gameObject.SetActive(false);
                if (pointerAPIndic.gameObject.activeSelf) pointerAPIndic.gameObject.SetActive(false);
                if (pointerAPLeftIndic.gameObject.activeSelf) pointerAPLeftIndic.gameObject.SetActive(false);
                if (pointer.gameObject.activeSelf) pointer.gameObject.SetActive(false);
            }

            if (CONTROLS_IS_ON)
            {
                if (Input.GetKeyDown(KeyCode.Alpha1))
                {
                    formBtnClicked(0);
                }
                if (Input.GetKeyDown(KeyCode.Alpha2))
                {
                    formBtnClicked(1);
                }
                if(Input.GetKeyDown(KeyCode.Tab))
                {
                    combineFormsBtnClicked();
                }
                if (gamemaster.opticFormIsAvailable && Input.GetKeyDown(KeyCode.Alpha3))
                {
                    opticControl = true;
                }
            }
            if (txtActionPoints.text != "Actionpoints: " + (actionPointsLeft + 1))
            {
                txtActionPoints.text = "Actionpoints: " + (actionPointsLeft + 1);
            }
        }
        else
        {

            CameraShaderManager csm = Camera.main.GetComponent<CameraShaderManager>();

            if (!csm.isOptic)
            {
                Debug.Log("OPTICCCCCCCCCCCCCCCCCCC");
                AudioManager.PlayClip(OpticCastSound);
            }
            csm.SetOptic();

            if (Input.GetMouseButtonUp(0) && CONTROLS_IS_ON)
            {
                RaycastHit hit;
                Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

                if (Physics.Raycast(ray, out hit))
                {
                    if (LayerMask.LayerToName(hit.transform.gameObject.layer) == "Walkable")
                    {
                        RaycastHit hitt;

                        Vector3 startPos = new Vector3(spawnedForms[0].transform.position.x, spawnedForms[0].transform.position.y+5, spawnedForms[0].transform.position.z);

                        Vector3 dir = (hit.point - startPos).normalized;

                        if (Physics.Raycast(startPos, dir, out hitt))
                        {
                            if (Vector3.Distance(hitt.point, hit.point) < 0.1f)
                            {
                                AudioManager.PlayClip(OpticCastedSound);
                                //Debug.Log("Can call the optic here! yay!");
                                if (spawnedOpticForm != null)
                                {
                                    if (opticFormScript != null)
                                    {
                                        opticFormScript.setNewPos(hit.point);
                                        Camera.main.GetComponent<CameraShaderManager>().RemoveOptic();

                                    }
                                }
                                else
                                {
                                    spawnedOpticForm = Instantiate(opticFormPrefab, spawnedForms[0].transform.position, Quaternion.identity) as GameObject;
                                    opticFormScript = spawnedOpticForm.GetComponent<OpticForm>();
                                    opticFormScript.setNewPos(hit.point);
                                    Camera.main.GetComponent<CameraShaderManager>().RemoveOptic();
                                }

                                opticControl = false;
                            }
                            else
                            {
                                //Debug.Log("cant see it");
                                //Debug.Log(hitt.point);
                                //Debug.Log(hit.point);
                            }
                        }
                        else
                        {
                            //Debug.Log("raycast no");
                        }
                    }
                    else
                    {
                        //Debug.Log("Can't call the optic here!");
                    }
                }
            }
        }
    }
Esempio n. 2
0
    // Use this for initialization
    void Start()
    {
        actionPointsLeft = maxActionPoints;
        textureHiderManager = GameObject.FindObjectOfType<TextureHiderManager>();
        gamemaster = GameObject.FindGameObjectWithTag("GameMaster").GetComponent<GameMaster>();
        layerMask = 1 << LayerMask.NameToLayer("Walkable");

        spawnedForms[0] = GameObject.FindGameObjectWithTag("Player");

        //ui
        gameUI = GameObject.FindGameObjectWithTag("gameUI").transform;

        txtActionPoints = gameUI.FindChild("txtActionPoints").GetComponent<Text>();
        btnForm0 = gameUI.FindChild("btnPhysical").GetComponent<Button>();
        btnForm1 = gameUI.FindChild("btnDigital").GetComponent<Button>();
        btnForm2 = gameUI.FindChild("btnOptic").GetComponent<Button>(); txtOptic = gameUI.FindChild("txtOpticControl").gameObject;
        btnCombine = gameUI.FindChild("btnCombine").GetComponent<Button>();

        btnForm2.gameObject.SetActive(gamemaster.opticFormIsAvailable);

        btnForm0.onClick.AddListener(() => formBtnClicked(0));
        btnForm1.onClick.AddListener(() => formBtnClicked(1));
        btnForm2.onClick.AddListener(() => opticControl = true);
        btnCombine.onClick.AddListener(() => combineFormsBtnClicked());

        GameObject physical = spawnedForms[0];
        spawnedForms = new GameObject[spawnableForms.Length];
        spawnedForms[0] = physical;
        //

        curAgent = spawnedForms[0].GetComponent<NavMeshAgent>();
        curAnimator = spawnedForms[0].GetComponent<Animator>();
        pointerLine.SetPosition(0, spawnedForms[0].transform.position);

        camFocus = Object.FindObjectOfType<CameraFocuser>();
        //camFocus.TargetToFollow = spawnedForms[0].transform;

        elapsed = 0f;
        path = new NavMeshPath();

        //Optic form
        if(spawnedOpticForm != null) opticFormScript = spawnedOpticForm.GetComponent<OpticForm>();
        //

        //unstucker
        curUnstuckWait = unstuckWait;
        // /unstucker

        pointerRenderer = pointer.GetComponent<MeshRenderer>();
    }