Ejemplo n.º 1
0
    private Carriage CreateCarriage(CarriageDefinition def)
    {
        Carriage carriage = Instantiate(m_carriagePrefab, Vector3.zero, Quaternion.identity);

        carriage.Init(def);
        return(carriage);
    }
Ejemplo n.º 2
0
    public void AddCarriage(Color carriageColor)
    {
        if (CarriageCount >= GameConstants.MAX_CARRIAGE_CAPACITY)
        {
            Debug.LogWarning(string.Format("Beetle {0} carriage count is maxed out", this.name));
            return;
        }

        Debug.Log(string.Format("Beetle {0} added carriage color {1}", this.name, carriageColor));

        CarriageDefinition newDef      = new CarriageDefinition(carriageColor, CarriageDefinition.Ability.None);
        Carriage           newCarriage = Instantiate(carriagePrefab, Vector3.zero, Quaternion.identity);

        newCarriage.transform.SetParent(m_layoutGroup.transform, false);
        newCarriage.Init(newDef, Carriage.State.Attached);
        m_carriageList.Add(newCarriage);

        Color color = GetDominantColor();

        Debug.Log("dominant color: " + color);

        Transform beetleImage = null;

        foreach (Transform child in transform)
        {
            if (child.name == "Beetle" + m_playerNumber)
            {
                beetleImage = child;
                break;
            }
        }

        foreach (Transform child in beetleImage)
        {
            if (child.name == color.ToString())
            {
                child.gameObject.SetActive(true);
            }
            else
            {
                child.gameObject.SetActive(false);
            }
        }
    }