Esempio n. 1
0
    public void Initialize(Tile t_originTile, City t_city)
    {
        m_cityOwner        = t_city;
        transform.position = t_originTile.transform.position;
        transform.SetParent(t_originTile.transform);

        m_resourceTile = t_originTile.GetResourceTile();
        GetComponent <SpriteRenderer>().sprite = m_buildingSprites[(int)m_resourceTile.GetResourceType()];
    }
Esempio n. 2
0
    public IEnumerator CheckResourceTileSetup()
    {
        m_tile.SetTileType(TileType.Land);

        GameObject resourcePrefab = Resources.Load <GameObject>("Prefabs/ResourceTile");

        GameObject resourceObject = GameObject.Instantiate(resourcePrefab);

        ResourceTile resource = resourceObject.GetComponent <ResourceTile>();

        resource.Setup(m_tile, ResourceType.Wheat);

        Assert.True(m_tile.transform.position == resource.transform.position);
        Assert.True(resource.transform.parent == m_tile.transform);
        Assert.True(resource.GetResourceType() == ResourceType.Wheat);
        Assert.True(m_tile.GetProduction() == 0);
        Assert.True(m_tile.GetFood() == 3);

        yield return(null);
    }
    void VillagerCollect()
    {
        if (targetObject == null)
        {
            isWorking     = false;
            agent.enabled = true;
            currentState  = CHARACTER_STATE.CHARACTER_WANDER;
        }

        if (isWorking && targetObject != null)
        {
            timer += Time.deltaTime;

            if (timer >= workTimer)
            {
                switch (workingResource.GetResourceType())
                {
                case 0:
                    workingResource.MineResource((int)taskSkills.mining * 10);
                    break;

                case 1:
                    workingResource.MineResource((int)taskSkills.woodcutting * 10);
                    break;

                case 2:
                    workingResource.MineResource((int)taskSkills.farming * 10);
                    break;
                }
                timer = 0;
            }
        }
        else if (!isWorking && targetObject != null)
        {
            isWorking     = true;
            agent.enabled = false;
            workTimer     = wanderTimer;
        }
    }
Esempio n. 4
0
 public void ProduceResource()
 {
     m_cityOwner.RecieveResource(m_resourceTile.GetResourceType(), m_resourceTile.m_resourceValue);
 }