Beispiel #1
0
    private void SetResourceUsed(ResourcesInfos resourceToUseInfos, Need need)
    {
        ResourceInStock resourceInStock = GetResourceInStock(resourceToUseInfos.resourceType);

        print("set resource used");
        PlayerInput.Instance.needSelected.ResourceUsed = resourceInStock;
    }
Beispiel #2
0
    public void DrawVisualTile()
    {
        if (transform.childCount != 0)
        {
            DestroyImmediate(transform.GetChild(0).gameObject);
        }

        GetComponent <MeshRenderer>().materials[0].shader = Shader.Find("Unlit/Color");
        GetComponent <MeshRenderer>().materials[0].color  = Color.white;
        GetComponent <MeshRenderer>().materials[1].shader = Shader.Find("Unlit/Color");
        switch (tileType)
        {
        case TypeOfTile.None:
            GetComponent <MeshRenderer>().materials[1].color = (Resources.Load("MaterialTiles/None", typeof(Material)) as Material).color;
            resourcesInfos = null;
            break;

        case TypeOfTile.Blocker:
            GetComponent <MeshRenderer>().materials[1].color = (Resources.Load("MaterialTiles/Blocker", typeof(Material)) as Material).color;
            visualResource = Instantiate(Resources.Load("VisualResources/Mountain", typeof(GameObject)) as GameObject, transform.position + (Vector3.up * 0.2f), Quaternion.identity, transform);
            resourcesInfos = null;
            break;

        case TypeOfTile.Mouflu:
            GetComponent <MeshRenderer>().materials[1].color = (Resources.Load("MaterialTiles/Floor", typeof(Material)) as Material).color;
            resourcesInfos = Resources.Load("ResourcesInfos/Mouflu", typeof(ResourcesInfos)) as ResourcesInfos;
            visualResource = Instantiate(Resources.Load("VisualResources/Mouflu", typeof(GameObject)) as GameObject, transform.position + (Vector3.up * 0.2f), Quaternion.identity, transform);
            break;

        case TypeOfTile.Rock:
            GetComponent <MeshRenderer>().materials[1].color = (Resources.Load("MaterialTiles/Floor", typeof(Material)) as Material).color;
            resourcesInfos = Resources.Load("ResourcesInfos/Rock", typeof(ResourcesInfos)) as ResourcesInfos;
            visualResource = Instantiate(Resources.Load("VisualResources/Rock", typeof(GameObject)) as GameObject, transform.position + (Vector3.up * 0.2f), Quaternion.identity, transform);
            break;

        case TypeOfTile.Wood:
            GetComponent <MeshRenderer>().materials[1].color = (Resources.Load("MaterialTiles/Floor", typeof(Material)) as Material).color;
            resourcesInfos = Resources.Load("ResourcesInfos/Wood", typeof(ResourcesInfos)) as ResourcesInfos;
            visualResource = Instantiate(Resources.Load("VisualResources/Wood", typeof(GameObject)) as GameObject, transform.position + (Vector3.up * 0.2f), Quaternion.identity, transform);
            break;

        case TypeOfTile.Berry:
            GetComponent <MeshRenderer>().materials[1].color = (Resources.Load("MaterialTiles/Floor", typeof(Material)) as Material).color;
            resourcesInfos = Resources.Load("ResourcesInfos/Berry", typeof(ResourcesInfos)) as ResourcesInfos;
            visualResource = Instantiate(Resources.Load("VisualResources/Berry", typeof(GameObject)) as GameObject, transform.position + (Vector3.up * 0.2f), Quaternion.identity, transform);
            break;

        case TypeOfTile.Water:
            GetComponent <MeshRenderer>().materials[1].color = (Resources.Load("MaterialTiles/Water", typeof(Material)) as Material).color;
            resourcesInfos = null;
            break;
        }
    }
Beispiel #3
0
    public void SetTypeOfTile()
    {
        if (transform.childCount > 0)
        {
            DestroyImmediate(transform.GetChild(0).gameObject);
        }
        switch (tileType)
        {
        case TypeOfTile.None:
            GetComponent <MeshRenderer>().sharedMaterials[1].color = (Resources.Load("MaterialTiles/None", typeof(Material)) as Material).color;
            resourcesInfos = null;
            break;

        case TypeOfTile.Blocker:
            GetComponent <MeshRenderer>().sharedMaterials[1].color = (Resources.Load("MaterialTiles/Blocker", typeof(Material)) as Material).color;
            resourcesInfos = null;
            break;

        case TypeOfTile.Mouflu:
            GetComponent <MeshRenderer>().sharedMaterials[1].color = (Resources.Load("MaterialTiles/Mouflu", typeof(Material)) as Material).color;
            resourcesInfos = Resources.Load("ResourcesInfos/Mouflu", typeof(ResourcesInfos)) as ResourcesInfos;
            visualResource = Instantiate(Resources.Load("VisualResources/Mouflu", typeof(GameObject)) as GameObject, transform.position, Quaternion.identity, transform);
            break;

        case TypeOfTile.Rock:
            GetComponent <MeshRenderer>().sharedMaterials[1].color = (Resources.Load("MaterialTiles/Rock", typeof(Material)) as Material).color;
            resourcesInfos = Resources.Load("ResourcesInfos/Rock", typeof(ResourcesInfos)) as ResourcesInfos;
            visualResource = Instantiate(Resources.Load("VisualResources/Rock", typeof(GameObject)) as GameObject, transform.position, Quaternion.identity, transform);
            break;

        case TypeOfTile.Wood:
            GetComponent <MeshRenderer>().sharedMaterials[1].color = (Resources.Load("MaterialTiles/Wood", typeof(Material)) as Material).color;
            resourcesInfos = Resources.Load("ResourcesInfos/Wood", typeof(ResourcesInfos)) as ResourcesInfos;
            visualResource = Instantiate(Resources.Load("VisualResources/Wood", typeof(GameObject)) as GameObject, transform.position, Quaternion.identity, transform);
            break;

        case TypeOfTile.Berry:
            GetComponent <MeshRenderer>().sharedMaterials[1].color = (Resources.Load("MaterialTiles/Berry", typeof(Material)) as Material).color;
            resourcesInfos = Resources.Load("ResourcesInfos/Berry", typeof(ResourcesInfos)) as ResourcesInfos;
            visualResource = Instantiate(Resources.Load("VisualResources/Berry", typeof(GameObject)) as GameObject, transform.position, Quaternion.identity, transform);
            break;
        }

        SetDirtyEditor();
    }
 public void SetImage(ResourcesInfos resourcesInfos)
 {
     image.sprite = resourcesInfos.sprite;
 }
 public void ChangeNeedSelectedResourceUse(ResourcesInfos resourceToSet)
 {
     print("change need selected resource use");
     needSelected.ResourceUsed = cityPlayer.GetResourceInStock(resourceToSet.resourceType);
 }
 public void ChangeNeedSelectedResourceUse(ResourcesInfos resourceToSet)
 {
     needSelected.ResourceUsed = cityPlayer.GetResourceInStock(resourceToSet.resourceType);
 }
Beispiel #7
0
    public void DrawInformationResourcesNeededAround(Need need)
    {
        for (int i = 0; i < resourcesNeededFolder.transform.childCount; i++)
        {
            Destroy(resourcesNeededFolder.transform.GetChild(i).gameObject);
        }

        for (int j = 0; j < PlayerInput.Instance.cityPlayer.needs.Length; j++)
        {
            if (PlayerInput.Instance.cityPlayer.needs[j].ResourceUsed == null)
            {
                return;
            }
        }
        CharaAvatar avatar = (CharaAvatar)GameObject.FindObjectOfType(typeof(CharaAvatar));

        List <CharaAvatar.ResourceConsume> rC = avatar.GetResourcesUsedPerRound();

        for (int i = 0; i < rC.Count; i++)
        {
            if (rC[i].resourceType == GameManager.ResourceType.Berry)
            {
                ResourcesInfos rI = (Resources.Load("ResourcesInfos/Berry", typeof(ResourcesInfos)) as ResourcesInfos);
                int            numberOfTileNeeded = (int)Mathf.Ceil(rC[i].amountPerRound / (rI.WonPerRound + DecretManager.Instance.totalDecreeInfos.collectQuantityBerry));
                if (numberOfTileNeeded > 0)
                {
                    GameObject uIResource = Instantiate(resourcesNeeded, resourcesNeededFolder.transform.position, resourcesNeededFolder.transform.rotation, resourcesNeededFolder.transform);
                    uIResource.GetComponent <Image>().sprite = (Resources.Load <Sprite>("UINeededResources/BerryIcon"));
                    uIResource.transform.GetChild(0).GetComponent <Text>().text = numberOfTileNeeded.ToString();
                }
            }

            if (rC[i].resourceType == GameManager.ResourceType.Wood)
            {
                ResourcesInfos rI = (Resources.Load("ResourcesInfos/Wood", typeof(ResourcesInfos)) as ResourcesInfos);
                int            numberOfTileNeeded = (int)Mathf.Ceil(rC[i].amountPerRound / (rI.WonPerRound + DecretManager.Instance.totalDecreeInfos.collectQuantityWood));
                if (numberOfTileNeeded > 0)
                {
                    GameObject uIResource = Instantiate(resourcesNeeded, resourcesNeededFolder.transform.position, resourcesNeededFolder.transform.rotation, resourcesNeededFolder.transform);
                    uIResource.GetComponent <Image>().sprite = (Resources.Load <Sprite>("UINeededResources/WoodIcon"));
                    uIResource.transform.GetChild(0).GetComponent <Text>().text = numberOfTileNeeded.ToString();
                }
            }

            if (rC[i].resourceType == GameManager.ResourceType.Rock)
            {
                GameObject uIResource = Instantiate(resourcesNeeded, resourcesNeededFolder.transform.position, resourcesNeededFolder.transform.rotation, resourcesNeededFolder.transform);
                uIResource.GetComponent <Image>().sprite = (Resources.Load <Sprite>("UINeededResources/RockIcon"));
                uIResource.transform.GetChild(0).GetComponent <Text>().text  = "X";
                uIResource.transform.GetChild(0).GetComponent <Text>().color = Color.red;
            }

            if (rC[i].resourceType == GameManager.ResourceType.Mouflu)
            {
                GameObject uIResource = Instantiate(resourcesNeeded, resourcesNeededFolder.transform.position, resourcesNeededFolder.transform.rotation, resourcesNeededFolder.transform);
                uIResource.GetComponent <Image>().sprite = (Resources.Load <Sprite>("UINeededResources/MoufluIcon"));
                uIResource.transform.GetChild(0).GetComponent <Text>().text  = "X";
                uIResource.transform.GetChild(0).GetComponent <Text>().color = Color.red;
            }
        }
    }