예제 #1
0
 public void CheckDisplayRange(Vector3Int playerTarget)
 {
     if (enemyCellPosition == playerTarget && !player.GetComponent <AbilityController>().laserState&& !shotIncoming && !abilityController.abilityActive)
     {
         mapManager.ShowFlats(thisEnemyName, enemyCellPosition, gameObject);
     }
 }
예제 #2
0
    void Update()
    {
        if (Input.GetMouseButtonDown(0) && !uiControler.IsPaused) //This operation is initiated by the player clicking the fire button.
        //if (Input.touchCount>0&&!uiControler.IsPaused) //This operation is initiated by the player clicking the fire button.
        {
            touch         = Input.GetTouch(0);
            touchPosition = Camera.main.ScreenToWorldPoint(touch.position);
            //clickPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);

            GameObject[] enemies = GameObject.FindGameObjectsWithTag("Enemy");
            foreach (GameObject enemy in enemies)
            {
                if (enemy.GetComponent <EnemyShipControl>().HighlightEnabled&& enemy.GetComponent <EnemyShipControl>().enemyCellPosition != gridLayout.WorldToCell(touchPosition))
                //if (enemy.GetComponent<EnemyShipControl>().HighlightEnabled && enemy.GetComponent<EnemyShipControl>().enemyCellPosition != gridLayout.WorldToCell(ClickPosition))
                {
                    mapManager.ShowFlats(enemy.GetComponent <EnemyShipControl>().thisEnemyName, enemy.GetComponent <EnemyShipControl>().enemyCellPosition, enemy, false);
                }
            }

            //Debug.Log(Input.mousePosition);
            //Debug.Log(touch.position);
            //Debug.Log("Screen height " + Screen.height + " Screen width " + Screen.width);
            //Debug.Log("% Screen height " + touch.position.y/Screen.height + " % Screen width " + touch.position.x / Screen.width);

            //float percentageScreenHeight = Input.mousePosition.y / Screen.height;
            float percentageScreenHeight = touch.position.y / Screen.height;
            //Debug.Log(percentageScreenHeight);
            if (percentageScreenHeight > 0.1 && percentageScreenHeight < 0.9)
            {
                if (!touchEnded)
                {
                    touchRegistered = false;
                    movementController.TouchRegistered = touchRegistered;
                }

                //mouseClicked = true;
                if (touch.phase == TouchPhase.Began)
                {
                    //Debug.Log("Click Manager hears the touch");
                    touchRegistered = true;
                    touchEnded      = false;
                    movementController.TouchRegistered = touchRegistered;
                }
                if (touch.phase == TouchPhase.Moved)
                {
                    touchRegistered = false;
                    movementController.TouchRegistered = touchRegistered;
                }
                if (touch.phase == TouchPhase.Ended)
                {
                    touchEnded      = true;
                    touchRegistered = false;
                    movementController.TouchRegistered = touchRegistered;
                }
                if (TouchRegistered)
                {
                    foreach (GameObject enemy in enemies)
                    {
                        if (!enemy.GetComponent <EnemyShipControl>().CheckShotRunning)
                        {
                            enemy.GetComponent <EnemyShipControl>().CheckDisplayRange(gridLayout.WorldToCell(touchPosition));
                            //enemy.GetComponent<EnemyShipControl>().CheckDisplayRange(gridLayout.WorldToCell(ClickPosition));
                        }
                    }
                }
            }
            else
            {
                //mouseClicked = false;
                touchRegistered = false;
                movementController.TouchRegistered = touchRegistered;
            }
        }
        else
        {
            //mouseClicked = false;
            touchRegistered = false;
            movementController.TouchRegistered = touchRegistered;
        }

        if (timer > 0)
        {
            timer -= Time.deltaTime;
        }
        else
        {
            waitForQuarterSec = false;
        }
    }