Esempio n. 1
0
    void CheckMouse()
    {
        if (Input.GetMouseButtonUp(0))
        {
            if (!EventSystem.current.IsPointerOverGameObject())
            {
                Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit;
                if (Physics.Raycast(ray, out hit))
                {
                    //Work out if a TacticsMovement has been selected.
                    if (hit.collider.GetComponent <TacticsMovement>() != null)
                    {
                        TacticsMovement UnitClickedOn = hit.collider.GetComponent <TacticsMovement>();

                        if (canFocusSwitch)
                        {
                            if (RangeFinder.LineOfSight(this, UnitClickedOn) == true)
                            {
                                SetFocus(UnitClickedOn);
                                remainingActions = 0;
                                remainingMove    = 0;
                                Initiative.queuedActions++;
                                StartCoroutine(Initiative.CheckForTurnEnd());
                            }
                        }
                        else if (remainingActions > 0)
                        {
                            foreach (Weapon.Target target in mainWeapon.targets)
                            {
                                if (target.unitTargeted == UnitClickedOn)
                                {
                                    Initiative.queuedActions += mainWeapon.weaponData.actionsPerAttack;
                                    mainWeapon.StartCoroutine("Attack", target);
                                    return;
                                }
                            }
                        }
                    }
                    else if (hit.collider.tag == "Tile Select")
                    {
                        Tile t = hit.collider.transform.parent.GetComponent <Tile>();
                        if (t.selectable)
                        {
                            Initiative.queuedActions++;
                            MoveToTile(t);
                            return;
                        }
                    }
                }
            }
        }
    }