Ejemplo n.º 1
0
    void OnTileTypeChanged(RailType newType)
    {
        //Instantiation
        //If the new type is None, simply destroy our existing model if any
        if (newType == RailType.None)
        {
            if (instancedRail != null)
            {
                Destroy(instancedRail.gameObject);
            }
            return;
        }

        if (currentType.IsStraight() && instancedRail != null)
        {
            if (newType.IsTurn())
            {
                InstantiateModel(newType);
            }
        }
        else if (currentType.IsTurn() && instancedRail != null)
        {
            if (newType.IsStraight())
            {
                InstantiateModel(newType);
            }
        }
        //No existing model
        else
        {
            InstantiateModel(newType);
        }

        RotateRailModel(newType);
    }