Esempio n. 1
0
    void OnSelect(ClickableUnit unit)
    {
        if (unit != _building)
        {
            _rallyParticles.Stop();
            _rallyParticles.Clear();
            return;
        }

        _isSelected = true;

        _rallyParticles.Play();
    }
Esempio n. 2
0
    public static void MouseOverClickableObject(Transform script, ClickableObject co)
    {
        bool leftClick  = Input.GetMouseButtonDown(0);
        bool rightClick = Input.GetMouseButtonDown(1);

        // only register clicks if not over ui
        if (!EventSystem.current.IsPointerOverGameObject())
        {
            if (rightClick && !RightClickHandled)
            {
                RightClickHandled = true;

                /* TODO: handle building */

                /* TODO: handle  */

                Instance.TargetSelectedPeopleTo(script);
            }

            // check if not a person is behind object
            if (leftClick && !LeftClickHandled)
            {
                RaycastHit hit;
                Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);

                if (Physics.Raycast(ray, out hit, 200f, Instance.onlyPeople))
                {
                    Transform objectHit = hit.transform;

                    ClickableUnit hitCo = objectHit.GetComponentInChildren <ClickableUnit>();
                    if (hitCo)
                    {
                        MouseOverClickableUnit(hitCo.ScriptedParent(), hitCo);
                        LeftClickHandled = true;
                    }
                }
            }

            // Handle UI Hover and Click stuff
            if (leftClick && !LeftClickHandled && co.clickable)
            {
                uiManager.OnShowObjectInfo(script);
                LeftClickHandled = true;
                co.UpdateSelectionCircleMaterial();
            }
            else if (co.showSmallInfo)
            {
                uiManager.OnShowSmallObjectInfo(script);
            }
        }
    }
Esempio n. 3
0
    public static void MouseOverClickableUnit(Transform script, ClickableUnit cu)
    {
        bool leftClick = Input.GetMouseButtonDown(0);

        //bool rightClick = Input.GetMouseButtonDown(1);

        // Handle UI Hover and Click stuff
        if (leftClick && !LeftClickHandled && cu.clickable)
        {
            PersonScript ps = script.GetComponent <PersonScript>();
            if (ps)
            {
                ps.OnClick();
            }
            LeftClickHandled = true;
        }
    }
    IEnumerator UnitProduceRoutine()
    {
        //first, asses the front of the queue
        UnitData unit = _productionQueue[0];

        OnStartProduceUnit?.Invoke(unit);


        //TODO ui timer, simulate UnitProductionRoutine
        yield return(new WaitForSeconds(unit.Time));

        ClickableUnit unitObject = Instantiate(unit._unit.gameObject, _spawnPoint.position, _spawnPoint.rotation).GetComponent <ClickableUnit>(); //instantiate & asign

        Vector3 rayStart = _rallyPoint.RallyPoint + (Vector3.up * 10);                                                                            //to re-create the Auto-Move, we're hijacking the PlayerInput algorithm

        RaycastHit hit;

        if (Physics.Raycast(rayStart, Vector3.down, out hit, 10f))
        {
            if (hit.transform.gameObject != gameObject) //if rall is null, or is this, do not send a move command
            {
                unitObject.Identify(hit);               //else, make the spawned unit move
            }
        }

        _productionQueue.RemoveAt(0); //now it is safe to dequeue
        //ui event invoke unit produced

        if (_productionQueue.Count > 0)
        {
            _unitProduceRoutine = StartCoroutine(UnitProduceRoutine());
        }
        else
        {
            _unitProduceRoutine = null;
        }

        OnUpdateQueue?.Invoke(_productionQueue);
    }
Esempio n. 5
0
 private void Awake()
 {
     _controller = GetComponent <ClickableUnit>();
     _agent      = GetComponent <NavMeshAgent>();
 }
Esempio n. 6
0
 private void Awake()
 {
     _building    = GetComponent <ClickableUnit>();
     _gameManager = GameObject.Find("GameManager").GetComponent <PlayerInput>();
 }
Esempio n. 7
0
 public static void MouseExitClickableUnit(Transform script, ClickableUnit cu)
 {
     uiManager.ShowPersonInfo(false);
 }