Example #1
0
        private void DrawScenery(int x, int y, int height, SceneryType sceneryType)
        {
            var ay = y - (height + 1) * Constants.BlockHeight - (Constants.ScenerySpriteHeight - Constants.TileSpriteHeight);

            if (x > Constants.ScenerySpriteWidth && ay > Constants.ScreenBufferHeight)
            {
                return;
            }

            _spriteBatch.Draw(_scenery,
                              new Vector2(x, ay),
                              new Rectangle((int)sceneryType * Constants.ScenerySpriteWidth, 0, Constants.ScenerySpriteWidth, Constants.ScenerySpriteHeight),
                              GetColor(null, height), 0, Vector2.Zero, Vector2.One, SpriteEffects.None, _depth);

            _depth += Constants.DepthIncrement;
        }
Example #2
0
 public AreaHeader(
     StartTime startTime,
     StartYPosition startYPosition,
     BackgroundType backgroundType,
     MiscPlatformType objectMode,
     SceneryType sceneryType,
     TerrainMode terrainMode)
     : this()
 {
     StartTime      = startTime;
     StartYPosition = startYPosition;
     BackgroundType = backgroundType;
     ObjectMode     = objectMode;
     SceneryType    = sceneryType;
     TerrainMode    = terrainMode;
 }
Example #3
0
    void Update()
    {
        if (canChange())
        {
            lastScenery = currentScenery;

            if (currentScenery == SceneryType.Field)
            {
                currentScenery = Random.Range(0, 2) == 0 ? SceneryType.Bleacher : SceneryType.Cloakromm;
            }
            else
            {
                currentScenery = SceneryType.Field;
            }

            onChangeSceneryEvent();

            resetTime();
        }
    }
Example #4
0
        public void Paint(int trackPos, RoadBrush road, AboveBrush above, SceneryBrush left, SceneryBrush right)
        {
            switch (road)
            {
                case RoadBrush.Road:
                    Offset = new Vector3(0f, 0f, 0f);
                    Size = new Vector2(1f, 0.05f);
                    TextureName = "road-normal";
                    TrackSurface = SurfaceType.Road;
                    if (trackPos % 2 == 0) Tint = Color.DarkGray.ToVector3();
                    else Tint = Color.White.ToVector3();
                    break;
                case RoadBrush.Wood:
                    Offset = new Vector3(0f, 0f, 0f);
                    Size = new Vector2(1f, 0.05f);
                    TextureName = "road-wood";
                    TrackSurface = SurfaceType.Road;
                    if (trackPos % 2 == 0) Tint = Color.DarkGray.ToVector3();
                    else Tint = Color.White.ToVector3();
                    break;
                case RoadBrush.Crossroad:
                    Offset = new Vector3(0f, 0f, 0f);
                    Size = new Vector2(1f, 0.05f);
                    TextureName = "crossroad";
                    TrackSurface = SurfaceType.Road;
                    //if (trackPos % 2 == 0) Tint = Color.DarkGray.ToVector3();
                    Tint = Color.White.ToVector3();
                    break;

            }

            Vector3 leftV = Vector3.Cross(Normal, Vector3.Up);
            Vector3 rightV = -Vector3.Cross(Normal, Vector3.Up);

            switch (above)
            {
                case AboveBrush.Tunnel:
                    AboveOffset = new Vector3(0f,0.45f,0f);
                    AboveSize = new Vector2(3f, 1f);
                    AboveTextureName = "tunnel";
                    if (trackPos % 4 == 0) AboveTint = Color.DarkGray.ToVector3();
                    else AboveTint = Color.White.ToVector3();
                    break;
                case AboveBrush.TunnelUpper:
                    AboveOffset = new Vector3(0f, 1.25f, 0f);
                    AboveSize = new Vector2(1f, 0.5f);
                    AboveTextureName = "tunnel-upper";
                    if (trackPos % 4 == 0) AboveTint = Color.DarkGray.ToVector3();
                    else AboveTint = Color.White.ToVector3();
                    break;
                case AboveBrush.StartGrid:
                    if (trackPos % 10 == 0)
                    {
                        AboveOffset = new Vector3(0f, 0.45f, 0f);
                        AboveSize = new Vector2(1.5f, 1f);
                        AboveTextureName = "start";
                        AboveTint = Color.White.ToVector3();
                    }
                    break;
                case AboveBrush.Erase:
                    AboveTextureName = "";
                    break;

            }

            switch (left)
            {
                case SceneryBrush.Trees:
                    if (trackPos % 10 == 0)
                    {
                        LeftOffset = (leftV * 1f) + (leftV * new Vector3(((float)randomNumber.NextDouble()*3f), 0f, 0f)) + new Vector3(0f, (-Position.Y) +0.4f, 0f);
                        LeftSize = new Vector2(0.5f, 1f);
                        LeftTextureName = "tree";
                        LeftScenery = SceneryType.Offroad;
                        LeftTint = Color.White.ToVector3();
                    }
                    break;
                case SceneryBrush.LampPost:
                    if (trackPos % 10 == 0)
                    {
                        LeftOffset = (leftV * 1f) + new Vector3(0f, (-Position.Y) + 0.4f, 0f);
                        LeftSize = new Vector2(0.5f, 1f);
                        LeftTextureName = "lamppost-left";
                        LeftScenery = SceneryType.Offroad;
                        LeftTint = Color.White.ToVector3();
                    }
                    break;
                case SceneryBrush.SignLeft:
                case SceneryBrush.SignRight:
                    if (trackPos % 20 == 0)
                    {
                        LeftOffset = (leftV * 1f) + new Vector3(0f, (-Position.Y) + 0.4f, 0f);
                        LeftSize = new Vector2(0.5f, 1f);
                        LeftTextureName = left==SceneryBrush.SignLeft?"sign-left":"sign-right";
                        LeftScenery = SceneryType.Wall;
                        LeftTint = Color.White.ToVector3();
                    }
                    break;
                case SceneryBrush.Girders:
                    if (trackPos % 20 == 0)
                    {
                        LeftSize = new Vector2(0.25f, Position.Y + 1f);
                        LeftOffset = (leftV * 0.625f) + new Vector3(0f, (-Position.Y) + ((LeftSize.Y / 2)-0.1f), 0f);
                        LeftTextureName = "girder";
                        LeftScenery = SceneryType.Wall;
                        LeftTint = Color.White.ToVector3();
                    }
                    break;
                case SceneryBrush.UpperWall:
                    LeftOffset = (leftV * 1f) + new Vector3(0f, 0f, 0f);
                    LeftSize = new Vector2(1f, 3f);
                    LeftTextureName = "wall";
                    LeftScenery = SceneryType.Wall;
                    if (trackPos % 4 == 0) LeftTint = Color.DarkGray.ToVector3();
                    else LeftTint = Color.White.ToVector3();
                    break;
                case SceneryBrush.LowerWall:
                    LeftOffset = new Vector3(0f, -0.8f, 0f);
                    LeftSize = new Vector2(1.1f, 1.5f);
                    LeftTextureName = "wall";
                    LeftScenery = SceneryType.Wall;
                    if (trackPos % 4 == 0) LeftTint = Color.DarkGray.ToVector3();
                    else LeftTint = Color.White.ToVector3();
                    break;
                case SceneryBrush.Ground:
                    LeftOffset = (leftV * 4f) + new Vector3(0f, (-Position.Y) -3f, 0f);
                    LeftSize = new Vector2(5f, 6f);
                    LeftTextureName = "ground";
                    LeftScenery = SceneryType.Offroad;
                    LeftTint = Color.White.ToVector3();
                    break;
                case SceneryBrush.Building:
                    if (trackPos % 15 == 0)
                    {
                        LeftOffset = (leftV * 1f) + new Vector3(0f, (-Position.Y) + 1.2f, 0f);
                        LeftSize = new Vector2(2.5f, 2.5f);
                        LeftTextureName = "building";
                        LeftScenery = SceneryType.Offroad;
                        LeftTint = Color.White.ToVector3();
                    }
                    break;
                case SceneryBrush.BuildingCorner:
                    if (trackPos % 1 == 0)
                    {
                        LeftOffset = (leftV * 2f) + new Vector3(0f, (-Position.Y) + 1.2f, 0f);
                        LeftSize = new Vector2(2f, 2.5f);
                        LeftTextureName = "buildingcorner";
                        LeftScenery = SceneryType.Offroad;
                        LeftTint = Color.White.ToVector3();
                    }
                    break;
                case SceneryBrush.Crossroad:
                    LeftOffset = (leftV * 3f) + new Vector3(0f, 0f, 0f);
                    LeftSize = new Vector2(5f, 0.05f);
                    LeftTextureName = "crossroad";
                    LeftScenery = SceneryType.Offroad;
                    if (trackPos % 20 == 0) LeftTint = Color.Red.ToVector3();
                    else LeftTint = Color.White.ToVector3();
                    break;
                case SceneryBrush.Erase:
                    LeftTextureName = "";
                    break;
            }
            switch (right)
            {
                case SceneryBrush.Trees:
                    if (trackPos % 10 == 0)
                    {
                        RightOffset = (rightV * 1f) + (rightV * new Vector3(((float)randomNumber.NextDouble() * 3f), 0f, 0f)) + new Vector3(0f, (-Position.Y) +0.4f, 0f);
                        RightSize = new Vector2(0.5f, 1f);
                        RightTextureName = "tree";
                        RightScenery = SceneryType.Offroad;
                        RightTint = Color.White.ToVector3();
                    }
                    break;
                case SceneryBrush.LampPost:
                    if (trackPos % 10 == 0)
                    {
                        RightOffset = (rightV * 1f) + new Vector3(0f, (-Position.Y) + 0.4f, 0f);
                        RightSize = new Vector2(0.5f, 1f);
                        RightTextureName = "lamppost-right";
                        RightScenery = SceneryType.Offroad;
                        RightTint = Color.White.ToVector3();
                    }
                    break;
                case SceneryBrush.SignLeft:
                case SceneryBrush.SignRight:
                    if (trackPos % 20 == 0)
                    {
                        RightOffset = (rightV * 1f) + new Vector3(0f, (-Position.Y) + 0.4f, 0f);
                        RightSize = new Vector2(0.5f, 1f);
                        RightTextureName = right == SceneryBrush.SignLeft ? "sign-left" : "sign-right";
                        RightScenery = SceneryType.Wall;
                        RightTint = Color.White.ToVector3();
                    }
                    break;
                case SceneryBrush.Girders:
                    if (trackPos % 20 == 0)
                    {
                        RightSize = new Vector2(0.25f, Position.Y+1f);
                        RightOffset = (rightV * 0.625f) + new Vector3(0f, (-Position.Y) + ((RightSize.Y / 2)-0.1f), 0f);
                        RightTextureName = "girder";
                        RightScenery = SceneryType.Wall;
                        RightTint = Color.White.ToVector3();
                    }
                    break;
                case SceneryBrush.UpperWall:
                    RightOffset = (rightV * 1f) + new Vector3(0f, 0f, 0f);
                    RightSize = new Vector2(1f, 3f);
                    RightTextureName = "wall";
                    RightScenery = SceneryType.Wall;
                    if (trackPos % 4 == 0) RightTint = Color.DarkGray.ToVector3();
                    else RightTint = Color.White.ToVector3();
                    break;
                case SceneryBrush.LowerWall:
                    RightOffset = new Vector3(0f, -0.8f, 0f);
                    RightSize = new Vector2(1.1f, 1.5f);
                    RightTextureName = "wall";
                    RightScenery = SceneryType.Wall;
                    if (trackPos % 4 == 0) RightTint = Color.DarkGray.ToVector3();
                    else RightTint = Color.White.ToVector3();
                    break;
                case SceneryBrush.Ground:
                    RightOffset = (rightV * 4f) + new Vector3(0f, (-Position.Y) -3f, 0f);
                    RightSize = new Vector2(4f, 6f);
                    RightTextureName = "ground";
                    RightScenery = SceneryType.Offroad;
                    RightTint = Color.White.ToVector3();
                    break;
                case SceneryBrush.Building:
                    if (trackPos % 20 == 0)
                    {
                        RightOffset = (rightV * 1f) + new Vector3(0f, (-Position.Y) + 1.2f, 0f);
                        RightSize = new Vector2(2.5f, 2.5f);
                        RightTextureName = "building";
                        RightScenery = SceneryType.Offroad;
                        RightTint = Color.White.ToVector3();
                    }
                    break;
                case SceneryBrush.BuildingCorner:
                    if (trackPos % 1 == 0)
                    {
                        RightOffset = (rightV * 2f) + new Vector3(0f, (-Position.Y) + 1.2f, 0f);
                        RightSize = new Vector2(2f, 2.5f);
                        RightTextureName = "buildingcorner";
                        RightScenery = SceneryType.Offroad;
                        RightTint = Color.White.ToVector3();
                    }
                    break;
                case SceneryBrush.Crossroad:
                    RightOffset = (rightV * 3f) + new Vector3(0f, 0f, 0f);
                    RightSize = new Vector2(5f, 0.05f);
                    RightTextureName = "crossroad";
                    RightScenery = SceneryType.Offroad;
                    if (trackPos % 20 == 0) RightTint = Color.Red.ToVector3();
                    else RightTint = Color.White.ToVector3();
                    break;
                case SceneryBrush.Erase:
                    RightTextureName = "";
                    break;
            }
        }
Example #5
0
    private void onStartTransactionScenery()
    {
        locked = true;

        ownSceneryType = SceneryController.CurrentScenery;
    }
Example #6
0
    void Start()
    {
        ownSceneryType = SceneryType.Field;

        resetCount();
    }
Example #7
0
    void Start()
    {
        currentScenery = SceneryType.Field;

        resetTime();
    }
Example #8
0
    // Return the closest scenery element, of the given type, relative to the given position
    // Only checks for resources, nothing else. May return null if no valid resources
    public SceneryManager_Scenery GetClosestScenery(Vector2 Source, SceneryType Type)
    {
        // Find the closest element
        SceneryManager_Scenery Closest = null;
        float Distance = float.MaxValue;

        // For each element, if type matches and has minerals left and distance to source is smaller, save as closest
        foreach(SceneryManager_Scenery Scenery in SceneryList)
        {
            if(Scenery.Type == Type && Scenery.Minerals > 0)
            {
                float SceneryDistance = (Scenery.ScenerySprite.GetPosition() - Source).magnitude;
                if(SceneryDistance < Distance)
                {
                    // Removed to supress warning:
                    //Distance = Distance;
                    Closest = Scenery;
                }
            }
        }

        // Done: return the closest (if any)
        return Closest;
    }