public List <VillagerStats> getAllVillagerStatsInBounds(Vector3 firstCorner, Vector3 secondCorner)
    {
        List <GameObject>    villagers = getAllVillagerObjects();
        List <VillagerStats> stats     = new List <VillagerStats>();
        float topLine;
        float botLine;
        float leftLine;
        float rightLine;

        if (firstCorner.y < secondCorner.y)
        {
            topLine = secondCorner.y;
            botLine = firstCorner.y;
        }
        else
        {
            topLine = firstCorner.y;
            botLine = secondCorner.y;
        }

        if (firstCorner.x < secondCorner.x)
        {
            leftLine  = firstCorner.x;
            rightLine = secondCorner.x;
        }
        else
        {
            leftLine  = secondCorner.x;
            rightLine = firstCorner.x;
        }

        for (int i = 0; i < villagers.Count; i++)
        {
            Vector3 position = villagers[i].transform.position;
            if (position.x >= leftLine && position.x <= rightLine && position.y <= topLine && position.y >= botLine)
            {
                VillagerGather gather = villagers[i].GetComponent <VillagerGather>();
                if (!gather.isWorkerBusy())
                {
                    stats.Add(villagers[i].GetComponent <VillagerStats>());
                }
            }
        }

        return(stats);
    }
Ejemplo n.º 2
0
    // On Mouse Down

    private void OnMouseDown()
    {
        if (!gather.isWorkerBusy())
        {
            if (inputManager.inputMode == InputMode.PeopleControl)
            {
                villagerStats.toggleSelected();
            }
            else if (inputManager.inputMode == InputMode.BuidlingSelected)
            {
                selectionManager.unselectAllBuildings();
                villagerStats.toggleSelected();
                inputManager.setInputMode(InputMode.PeopleControl);
            }
            characterUiManager.characterSelected(villagerStats.id, villagerStats.selected);
        }
    }
    private void OnMouseDown()
    {
        GameObject     person = selectionManager.getCharacterById(id);
        VillagerGather gather = person.GetComponent <VillagerGather>();

        if (!gather.isWorkerBusy())
        {
            if (!selected)
            {
                setSelected(true);
                selectionManager.selectVillagerById(id);
            }
            else
            {
                setSelected(false);
                selectionManager.unselectVillagerById(id);
            }
        }
    }