Пример #1
0
        /// <summary>
        /// Draws a set of vector 3s
        /// </summary>
        /// <param name="spriteBatch">SpriteBatch object used to draw the vectors</param>
        /// <param name="max">Max position to draw</param>
        /// <param name="min">Min position to draw</param>
        /// <param name="debugColour">Colour to draw the Vectors in</param>
        /// <param name="lineTexture">Texture2D used for drawing the vectors</param>
        /// <param name="positionOffset">Offset to render the object at</param>
        public static void drawVector3s(SpriteBatch spriteBatch, Vector3 max, Vector3 min, Color debugColour, Texture2D lineTexture,
                                        Vector2 positionOffset)
        {
            Line2DParams parms = new Line2DParams();

            parms.Texture     = lineTexture;
            parms.LightColour = debugColour;
            //left
            parms.Position    = new Vector2(min.X, min.Y);
            parms.EndPosition = new Vector2(min.X, max.Y);
            Line2D left = new Line2D(parms);

            //top
            parms.Position    = new Vector2(min.X, min.Y);
            parms.EndPosition = new Vector2(max.X, min.Y);
            Line2D top = new Line2D(parms);

            //right
            parms.Position    = new Vector2(max.X, min.Y);
            parms.EndPosition = new Vector2(max.X, max.Y);
            Line2D right = new Line2D(parms);

            //bottom
            parms.Position    = new Vector2(min.X, max.Y);
            parms.EndPosition = new Vector2(max.X, max.Y);
            Line2D bottom = new Line2D(parms);

            left.render(spriteBatch, positionOffset);
            top.render(spriteBatch, positionOffset);
            right.render(spriteBatch, positionOffset);
            bottom.render(spriteBatch, positionOffset);
        }
Пример #2
0
        /// <summary>
        /// Actual building of the line
        /// </summary>
        /// <param name="parms">Line2DParams object containing the data required to build the line</param>
        public Line2D(Line2DParams parms)
            : base(parms)
        {
            base.position    = parms.Position;
            this.endPosition = parms.EndPosition;
            this.texture     = parms.Texture;

            recalculateRotation();
            recalculateScale();
        }
Пример #3
0
        private ClosestSeeable getMobsFieldOfView(Mob mob)
        {
            ClosestSeeable closestSeeable = null;

            foreach (var ghost in allGhosts)
            {
                ClosestSeeable candidate = canCharacterSeeCharacter(mob, ghost);

                if (candidate != null)
                {
#if DEBUG
                    // 1 Add it to the FOV list
                    Line2DParams parms = new Line2DParams()
                    {
                        Position    = candidate.Target.Position,
                        EndPosition = candidate.Source.Position,
                        LightColour = Color.Purple,
                        Texture     = Debug.debugChip
                    };
                    linesOfSight.Add(new Line2D(parms));
#endif
                    // are we the first candidate?
                    if (closestSeeable != null)
                    {
                        //2 Figure out if it is closer than previous candidates
                        if (candidate.Distance < closestSeeable.Distance)
                        {
                            closestSeeable = candidate;
                        }
                    }
                    else
                    {
                        closestSeeable = candidate;
                    }
                }
            }
#if DEBUG
            if (closestSeeable != null)
            {
                Line2DParams parms = new Line2DParams()
                {
                    Position    = closestSeeable.Target.Position,
                    EndPosition = closestSeeable.Source.Position,
                    LightColour = Color.Yellow,
                    Texture     = Debug.debugChip
                };
                closestsGhosts.Add(new Line2D(parms));
            }
#endif
            return(closestSeeable);
        }
Пример #4
0
        /// <summary>
        /// Building of a coloured button
        /// </summary>
        /// <param name="parms"></param>
        public ColouredButton(ColouredButtonParams parms)
        {
            this.regularColour      = parms.RegularColour;
            this.mouseOverColour    = parms.MouseOverColour;
            this.renderingRectangle = new Rectangle(parms.StartX, parms.StartY, parms.Width, parms.Height);
            this.ID = parms.ID;

            // create our lines
            this.lines = new Line2D[4];
            Line2DParams lineParams = new Line2DParams();

            lineParams.Texture     = parms.LinesTexture;
            lineParams.LightColour = this.regularColour;

            lineParams.Position    = new Vector2(parms.StartX, parms.StartY);
            lineParams.EndPosition = new Vector2(parms.StartX + parms.Width, parms.StartY);
            this.lines[0]          = new Line2D(lineParams);

            lineParams.Position    = new Vector2(parms.StartX + parms.Width, parms.StartY);
            lineParams.EndPosition = new Vector2(parms.StartX + parms.Width, parms.StartY + parms.Height);
            this.lines[1]          = new Line2D(lineParams);

            lineParams.Position    = new Vector2(parms.StartX + parms.Width, parms.StartY + parms.Height);
            lineParams.EndPosition = new Vector2(parms.StartX, parms.StartY + parms.Height);
            this.lines[2]          = new Line2D(lineParams);

            lineParams.Position    = new Vector2(parms.StartX, parms.StartY + parms.Height);
            lineParams.EndPosition = new Vector2(parms.StartX, parms.StartY);
            this.lines[3]          = new Line2D(lineParams);

            // create the text
            Text2DParams textParams = new Text2DParams();

            textParams.Font        = parms.Font;
            textParams.LightColour = this.regularColour;
            textParams.Position    = parms.TextsPosition;
            textParams.WrittenText = parms.Text;
            this.text = new Text2D(textParams);
        }
Пример #5
0
        public BackGround(ContentManager content)
        {
            this.birdChirpSFX = LoadingUtils.load <SoundEffect>(content, "BirdChirp");
            Texture2D backGroundTexture             = LoadingUtils.load <Texture2D>(content, "BackGround");
            StaticDrawable2DParams backGroundParams = new StaticDrawable2DParams();

            backGroundParams.Texture = backGroundTexture;
            this.backGround          = new StaticDrawable2D(backGroundParams);
            this.sun   = new Sun(content);
            this.fence = new Fence(content);
            this.house = new House(content);

            // create the boards lines
            Texture2D    linesTexture = LoadingUtils.load <Texture2D>(content, "LineColour");
            Line2DParams lineParams   = new Line2DParams();

            lineParams.Texture       = linesTexture;
            lineParams.LightColour   = Color.White;
            lineParams.Scale         = new Vector2(5f, 5f);
            this.lines               = new Line2D[8];
            lineParams.StartPosition = new Vector2(350f, 525f);
            lineParams.EndPosition   = new Vector2(900f, 525f);
            this.lines[0]            = new Line2D(lineParams);
            lineParams.StartPosition = new Vector2(350f, 612f);
            lineParams.EndPosition   = new Vector2(900f, 612f);
            this.lines[1]            = new Line2D(lineParams);
            lineParams.StartPosition = new Vector2(515f, 450f);
            lineParams.EndPosition   = new Vector2(515f, 700f);
            this.lines[2]            = new Line2D(lineParams);
            lineParams.StartPosition = new Vector2(715f, 450f);
            lineParams.EndPosition   = new Vector2(715f, 700f);
            this.lines[3]            = new Line2D(lineParams);
            lineParams.StartPosition = new Vector2(350f, 450f);
            lineParams.EndPosition   = new Vector2(350f, 700f);
            this.lines[4]            = new Line2D(lineParams);
            lineParams.StartPosition = new Vector2(900f, 450f);
            lineParams.EndPosition   = new Vector2(900f, 700f);
            this.lines[5]            = new Line2D(lineParams);
            lineParams.StartPosition = new Vector2(350f, 450f);
            lineParams.EndPosition   = new Vector2(905f, 450f);
            this.lines[6]            = new Line2D(lineParams);
            lineParams.StartPosition = new Vector2(350f, 700f);
            lineParams.EndPosition   = new Vector2(900f, 700f);
            this.lines[7]            = new Line2D(lineParams);

            // create our clouds
            this.clouds = new Cloud[9];
            float layer1Y = 20f;
            float layer2Y = 70f;
            float layer3Y = 130f;

            this.clouds[0] = new Cloud(new Vector2(500f, layer1Y), ResourceManager.getInstance().CloudTexture2, SpriteEffects.FlipHorizontally);
            this.clouds[1] = new Cloud(new Vector2(1000f, layer1Y), ResourceManager.getInstance().CloudTexture1);
            this.clouds[2] = new Cloud(new Vector2(1400f, layer1Y), ResourceManager.getInstance().CloudTexture2);
            this.clouds[3] = new Cloud(new Vector2(200f, layer2Y), ResourceManager.getInstance().CloudTexture1);
            this.clouds[4] = new Cloud(new Vector2(700f, layer2Y), ResourceManager.getInstance().CloudTexture2);
            this.clouds[5] = new Cloud(new Vector2(1200f, layer2Y), ResourceManager.getInstance().CloudTexture2, SpriteEffects.FlipHorizontally);
            this.clouds[6] = new Cloud(new Vector2(10f, layer3Y), ResourceManager.getInstance().CloudTexture2);
            this.clouds[7] = new Cloud(new Vector2(900f, layer3Y), ResourceManager.getInstance().CloudTexture1, SpriteEffects.FlipHorizontally);
            this.clouds[8] = new Cloud(new Vector2(400f, layer3Y), ResourceManager.getInstance().CloudTexture1);

            // shrubs
            this.shrubs = new StaticDrawable2D[11];
            StaticDrawable2DParams shrubParams = new StaticDrawable2DParams();

            shrubParams.Origin  = new Vector2(48f, 48f);
            shrubParams.Scale   = new Vector2(1f, 1f);
            shrubParams.Texture = ResourceManager.getInstance().ShrubTexture;

            float x       = 300f;
            float y       = 400f;
            float xCutoff = 110f;
            float yCutoff = 96f;
            int   index   = 0;

            //shrubs across the top
            for (int i = 1; i <= 5; i++)
            {
                shrubParams.Position = new Vector2(x + (i * xCutoff), y);
                this.shrubs[index]   = new StaticDrawable2D(shrubParams);
                index += 1;
            }

            // shrubs down the left
            x = 324f;
            y = 365f;
            for (int i = 1; i <= 3; i++)
            {
                shrubParams.Position = new Vector2(x, y + (i * yCutoff));
                this.shrubs[index]   = new StaticDrawable2D(shrubParams);
                index += 1;
            }
            // shrubs down the right
            x = 918f;
            for (int i = 1; i <= 3; i++)
            {
                shrubParams.Position = new Vector2(x, y + (i * yCutoff));
                this.shrubs[index]   = new StaticDrawable2D(shrubParams);
                index += 1;
            }

            // create our rocks
            StaticDrawable2DParams rockParams = new StaticDrawable2DParams();

            rockParams.Scale = new Vector2(1.5f, 1.5f);

            rockParams.Position = new Vector2(59f, 527f);
            rockParams.Texture  = LoadingUtils.load <Texture2D>(content, "LeftRock");
            this.leftRock       = new StaticDrawable2D(rockParams);

            rockParams.Position = new Vector2(994f, 527);
            rockParams.Texture  = LoadingUtils.load <Texture2D>(content, "RightRock");
            this.rightRock      = new StaticDrawable2D(rockParams);
#if WINDOWS
#if DEBUG
            if (this.house != null)
            {
                ScriptManager.getInstance().registerObject(this.house, "house");
            }
            if (this.backGround != null)
            {
                ScriptManager.getInstance().registerObject(this.backGround, "backGround");
            }
            if (this.lines != null)
            {
                for (int i = 0; i < this.lines.Length; i++)
                {
                    ScriptManager.getInstance().registerObject(this.lines[i], "line" + i);
                }
            }
            if (this.shrubs != null)
            {
                for (int i = 0; i < this.shrubs.Length; i++)
                {
                    if (this.shrubs[i] != null)
                    {
                        ScriptManager.getInstance().registerObject(this.shrubs[i], "shrub" + i);
                    }
                }
            }
            if (this.leftRock != null)
            {
                ScriptManager.getInstance().registerObject(this.leftRock, "leftRock");
            }
            if (this.rightRock != null)
            {
                ScriptManager.getInstance().registerObject(this.rightRock, "rightRock");
            }
#endif
#endif
        }