Пример #1
0
 public void ChangePathType(PathTypeState newType)
 {
     lastSetType = newType.Type;
     if (_pathType != null)
     {
         _pathType.OnExitState();
     }
     _pathType = newType;
     _pathType.OnEnterState(this);
 }
Пример #2
0
    public void ChangePathType(PathType newType)
    {
        PathTypeState state = null;

        lastSetType = newType;
        switch (newType)
        {
        case PathType.city:
            state = new CityType();
            break;

        case PathType.desert:
            state = new DesertType();
            break;

        case PathType.field:
            state = new FieldType();
            break;

        case PathType.forest:
            state = new ForestType();
            break;

        case PathType.mountain:
            state = new MountainType();
            break;

        case PathType.road:
            state = new RoadType();
            break;

        case PathType.rocks:
            state = new RocksType();
            break;

        case PathType.swamp:
            state = new SwampType();
            break;

        case PathType.water:
            state = new WaterType();
            break;
        }

        if (_pathType != null)
        {
            _pathType.OnExitState();
        }
        _pathType = state;
        _pathType.OnEnterState(this);
    }