Example #1
1
            public ControlNode(Vector2i pos, float[,] map, Vector2 position, float size)
                : base(position)
            {
                Active = map[pos.x, pos.y];

                if (pos.x == map.GetLength(0))
                {
                    Right = new Node(position + Vector2.right * size * 0.5f);
                }
                else
                {
                    Right = new Node(position + Vector2.right * size * 0.5f);
                }

                if (pos.y == map.GetLength(1))
                {
                    Up = new Node(position + Vector2.up * size * 0.5f);
                }
                else
                {
                    Up = new Node(position + Vector2.up * size * 0.5f);
                }

                //float right = pos.x <  ? map[pos.x + 1, pos.y] : Active;
                //float up = map[pos.x, pos.y + 1];
            }
Example #2
0
        public override bool Update(Vector2i mouseS, IMapManager currentMap)
        {
            if (currentMap == null) return false;

            spriteToDraw = GetDirectionalSprite(pManager.CurrentBaseSpriteKey);

            mouseScreen = mouseS;
            mouseWorld = CluwneLib.ScreenToWorld(mouseScreen);

            var bounds = spriteToDraw.GetLocalBounds();
            var spriteSize = CluwneLib.PixelToTile(new Vector2f(bounds.Width, bounds.Height));
            var spriteRectWorld = new FloatRect(mouseWorld.X - (spriteSize.X / 2f),
                                                 mouseWorld.Y - (spriteSize.Y / 2f),
                                                 spriteSize.X, spriteSize.Y);

            if (pManager.CurrentPermission.IsTile)
                return false;

            if (pManager.CollisionManager.IsColliding(spriteRectWorld))
                return false;

            //if (currentMap.IsSolidTile(mouseWorld)) return false;

            var rangeSquared = pManager.CurrentPermission.Range * pManager.CurrentPermission.Range;
            if (rangeSquared > 0)
                if (
                    (pManager.PlayerManager.ControlledEntity.GetComponent<TransformComponent>(ComponentFamily.Transform)
                         .Position - mouseWorld).LengthSquared() > rangeSquared) return false;

            currentTile = currentMap.GetTileRef(mouseWorld);

            return true;
        }
Example #3
0
    public override void OnBlockChanged(Vector2i block, VoxelTypes newValue)
    {
        //If we can't plant a seed here anymore, the job should be cancelled.
        if (!WorldVoxels.CanPlantOn(WorldVoxels.GetVoxelAt(PlantPos.LessY)) ||
            !WorldVoxels.CanPlantIn(WorldVoxels.GetVoxelAt(PlantPos)))
        {
            if (elveMovement != null)
            {
                StopJob(false, "Can't plant seed anymore");
            }
            else
            {
                Cancel("Can't plant seed anymore");
            }
            return;
        }

        //If there is an Elve doing this job, and his path was affected, recalculate pathing.
        System.Func<VoxelNode, bool> isAffected = (n) =>
        {
            return Mathf.Abs(block.x - n.WorldPos.x) <= 1 &&
                   Mathf.Abs(block.y - n.WorldPos.y) <= 1;
        };
        if (elveMovement != null && elveMovement.Path.Any(isAffected))
        {
            if (!elveMovement.StartPath(PlantPos))
            {
                StopJob(true, "Path became blocked");
                return;
            }
        }
    }
Example #4
0
        public Ladder(Vector2i pos) : base(pos)
        {
            CurrentTex = "ladderbottom";
            Movable = true;

            DrawOnTop = true;
        }
Example #5
0
    private static Vector2i? GetActualPosition(Vector2 position)
    {
        NavigationField navigationField = NavigationField.Instance;
        Vector2i pos = Vector2i.FromVector2Round(position);
        if (!navigationField.fieldSize.ContainsAsSize(pos))
        {
            return null;
        }

        if (!float.IsPositiveInfinity(navigationField.Costs[pos.x, pos.y]))
        {
            return pos;
        }

        // Try to find a nice neighbour...
        for (int y = -1; y <= 1; y++)
        {
            for (int x = -1; x <= 1; x++)
            {
                Vector2i test = new Vector2i(pos.x + x, pos.y + y);
                if (!float.IsPositiveInfinity(navigationField.GetCost(test)))
                {
                    return test;
                }
            }
        }

        return null;
    }
Example #6
0
        // TODO: get rid of ComputeProjectionMatrix()

        public Camera( Vector3f position, Vector3f forward, Vector3f up,
            float fovYDegrees,
            int screenWidth, int screenHeight )
        {
            FieldOfView = Arithmetic.DegreesToRadians( fovYDegrees );

            // interpolationKeyFrames = new KeyFrameInterpolator
            Frame = new ManipulatedCameraFrame();
            
            SceneRadius = 1.0f;
            orthoCoeff = ( float ) ( Math.Tan( FieldOfView / 2.0 ) );
            SceneCenter = Vector3f.Zero;

            CameraType = CameraType.PERSPECTIVE;

            ZNearCoefficient = 0.005f;
            ZClippingCoefficient = ( float ) ( Math.Sqrt( 3.0 ) );

            // dummy values
            screenSize = new Vector2i( screenWidth, screenHeight );

            Position = position;
            UpVector = up;
            ViewDirection = forward;

            ComputeViewMatrix();
            ComputeProjectionMatrix();
        }
Example #7
0
        public static bool OnMouseButton(Controls.Control hoveredControl, int x, int y, bool down)
        {
            if (!down)
            {
                m_LastPressedControl = null;

                // Not carrying anything, allow normal actions
                if (CurrentPackage == null)
                    return false;

                // We were carrying something, drop it.
                onDrop(x, y);
                return true;
            }

            if (hoveredControl == null)
                return false;
            if (!hoveredControl.DragAndDrop_Draggable())
                return false;

            // Store the last clicked on control. Don't do anything yet,
            // we'll check it in OnMouseMoved, and if it moves further than
            // x pixels with the mouse down, we'll start to drag.
            m_LastPressedPos = new Vector2i(x, y);
            m_LastPressedControl = hoveredControl;

            return false;
        }
    public void TappedOnTile(Vector2i mapPos)
    {
        while (!(mMap.IsGround(mapPos.x, mapPos.y)))
            --mapPos.y;

        MoveTo(new Vector2i(mapPos.x, mapPos.y + 1));
    }
Example #9
0
        public Cannon(Direction2D direction, Vector2i index)
        {
            _direction = direction;
            _worldIndex = index;

            _readOnlyBullets = new ReadOnlyCollection<Bullet>(_bullets);
        }
Example #10
0
        public InputManager(GameEngine engine)
        {
            KeyboardState = new Dictionary<Keyboard.Key,bool>();
            PreviousKeyboardState = new Dictionary<Keyboard.Key,bool>();

            MouseState = new Dictionary<Mouse.Button,bool>();
            PreviousMouseState = new Dictionary<Mouse.Button,bool>();

            MousePosition = new Vector2i(0,0);
            PreviousMousePosition = new Vector2i(0,0);

            //game.Window.MouseWheelMoved += Window_MouseWheelMoved;

            foreach (Keyboard.Key key in keysEnum)
            {
                KeyboardState.Add(key,false);
                PreviousKeyboardState.Add(key, false);
            }

            foreach (Mouse.Button mouseButton in buttonsEnum)
            {
                MouseState.Add(mouseButton, false);
                PreviousMouseState.Add(mouseButton, false);
            }
        }
Example #11
0
 public override void SetField(Vector2i vect, char value)
 {
     if (IsEntryPointInTheSize(vect))
     {
         VarField[vect.X, vect.Y] = value;
     }
 }
        protected override BlockType GenerateBlock(Vector2i worldPosition, Vector2i turbulence, Vector3 normal, ZoneRatio influence)
        {
            if (Vector3.Angle(Vector3.up, normal) > 65)
                return BlockType.Rock;

            return base.GenerateBlock(worldPosition, turbulence, normal, influence);
        }
Example #13
0
 public static Vector2i Next(this Random random, Vector2i min, Vector2i max)
 {
     return new Vector2i(
         random.Next(min.X, max.X + 1),
         random.Next(min.Y, max.Y + 1)
     );
 }
        public ScrollableContainer(string uniqueName, Vector2i size, IResourceManager resourceManager)
        {
            _resourceManager = resourceManager;

            Size = size;

            //if (RenderTargetCache.Targets.Contains(uniqueName))
            //    //Now this is an ugly hack to work around duplicate RenderImages. Have to fix this later.
            //    uniqueName = uniqueName + Guid.NewGuid();

            clippingRI = new RenderImage(uniqueName,(uint)Size.X,(uint) Size.Y);

            //clippingRI.SourceBlend = AlphaBlendOperation.SourceAlpha;
            //clippingRI.DestinationBlend = AlphaBlendOperation.InverseSourceAlpha;
            //clippingRI.SourceBlendAlpha = AlphaBlendOperation.SourceAlpha;
            //clippingRI.DestinationBlendAlpha = AlphaBlendOperation.InverseSourceAlpha;
            clippingRI.BlendSettings.ColorSrcFactor = BlendMode.Factor.SrcAlpha;
            clippingRI.BlendSettings.ColorDstFactor = BlendMode.Factor.OneMinusSrcAlpha;
            clippingRI.BlendSettings.AlphaSrcFactor = BlendMode.Factor.SrcAlpha;
            clippingRI.BlendSettings.AlphaDstFactor = BlendMode.Factor.OneMinusSrcAlpha;

            scrollbarH = new Scrollbar(true, _resourceManager);
            scrollbarV = new Scrollbar(false, _resourceManager);
            scrollbarV.size = Size.Y;

            scrollbarH.Update(0);
            scrollbarV.Update(0);

            Update(0);
        }
Example #15
0
 public void SendVector(Vector2i vect)
 {
     if (!(Player is Player.NetworkPlayer))
     {
         client.Send(string.Format("UniTTT!Vector:{0}", vect.ToString()));
     }
 }
Example #16
0
        private void UpdatePos(ref Piece[,] board, int x, int y)
        {
            board[Position.X, Position.Y] = null;

            Sprite.Position = new Vector2f(x* 65, y * 65);
            Position = new Vector2i(x, y);
        }
Example #17
0
 public Sprite(SpriteSheet spriteSheet, string name, Vector2i size, Box2 coordinates)
 {
     SpriteSheet = spriteSheet;
     Name = name;
     Size = size;
     Coordinates = coordinates;
 }
Example #18
0
        public MenuScreen(Screen parentScreen, ContentManager m, string title, Vector2i pos, bool centeredX, bool centeredY, bool bordered, bool hasBackground, Color backgroundColor)
        {
            this.ParentScreen = parentScreen;

            this.ButtonColor = Color.Black;
            this.BackGroudColor = backgroundColor;
            this.TitleFont = m.Media.loadFont("Content/fonts/sweetness.ttf");
            this.ButtonFont = m.Media.loadFont("Content/fonts/sweetness.ttf");
            this.TitleSize = 90;
            this.ButtonSize = 55;
            this.buttons = new List<MenuButton>();

            this.Title = new Text(title, TitleFont, TitleSize);
            Title.Origin = new Vector2f(Title.GetLocalBounds().Left, Title.GetLocalBounds().Top);
            this.bounds = new Rectangle(pos.X, pos.Y, 0,0);

            this.isBordered = bordered;
            this.isCenteredX = centeredX;
            this.isCenteredY = centeredY;
            this.IsDrawn = true;
            this.IsUpdated = true;

            this.hasBackground = hasBackground;
            this.BackGroudColor = backgroundColor;

            setButtons();
        }
Example #19
0
 public Tile this[Vector2i vec]
 {
     get
     {
         return this.Tiles[vec.X, vec.Y];
     }
 }
 public static BHEntity RoundSmall(BHGame mGame, Vector2i mPosition = default(Vector2i), float mAngle = 0, int mSpeed = 0)
 {
     BHEntity result = BHPresetBase.Bullet(mGame, mPosition, mAngle, mSpeed, 5.ToUnits());
     result.Sprite = new Sprite(Assets.GetTexture("b_circlesmall"));
     result.IsSpriteFixed = true;
     return result;
 }
Example #21
0
    /// <summary>
    /// Immediately starts pathing towards the given target position.
    /// Replaces any previous pathing commands.
    /// Returns "false" if no path could be found, or "true" otherwise.
    /// </summary>
    public bool StartPath(Vector2i targetWorldPos)
    {
        OnPathCompleted = null;

        targetPos = targetWorldPos;
        Assert.IsTrue(targetPos.x >= 0 && targetPos.y >= 0 &&
                       targetPos.x < WorldVoxels.Instance.Voxels.GetLength(0) &&
                       targetPos.y < WorldVoxels.Instance.Voxels.GetLength(1),
                      "Invalid target position " + targetPos);

        UpdatePos();

        PathFinder<VoxelNode> pather = new PathFinder<VoxelNode>(VoxelGraph.Instance,
                                                                 VoxelEdge.MakeEdge);
        pather.Start = new VoxelNode(currentPos);
        pather.End = new VoxelNode(targetPos);
        bool foundPath = pather.FindPath();
        if (!foundPath)
        {
            Path.Clear();
            return false;
        }

        Path = pather.CurrentPath.ToList();
        Path.Reverse();

        //Start the path.
        Assert.IsTrue(Path[Path.Count - 1].WorldPos == currentPos,
                      "Current pos is " + currentPos + " but first node of path is " +
                        Path[Path.Count - 1].WorldPos);
        targetPos = currentPos;
        OnStateFinished(null);

        return true;
    }
Example #22
0
 public BlockInfo(Vector2i position, BlockType type, float height, Vector3 normal)
 {
     Position = position;
     Type = type;
     Height = height;
     Normal = normal;
 }
Example #23
0
        public double DistanceEstimate(Vector2i a, Vector2i b)
        {
            if (UseManhattanMetric)
                return Math.Abs(b.X - a.X) + Math.Abs(b.Y - a.Y);

            return Utils.Distance(new Vector2f(a.X, a.Y), new Vector2f(b.X, b.Y));
        }
 public void Setup(RL.Map _map, int[] _dir)
 {
     map = _map;
     directions = _dir;
     lineRenderers = new GameObject[directions.Length];
     for (int i = 0; i < directions.Length; i++) {
         lineRenderers [i] = new GameObject ();
         lineRenderers [i].transform.parent = transform;
         lineRenderers [i].transform.position = transform.position;
         LineRenderer lr = lineRenderers [i].AddComponent<LineRenderer> ();
         lr.renderer.sortingOrder = 2;
         lr.renderer.sortingLayerName = "Default";
         lr.SetColors(new Color(74/255f,63/255f,148/255f, 0.5f), new Color(113/255f,138/255f,145/255f, 0.5f));
         lr.SetWidth (0.05f, 0.05f);
         lr.material = (Material)Resources.Load ("trapParticle");
         lr.useWorldSpace = false;
         // move out on the direction until we hit a wall, this is our endpoint
         Vector2i ndir = new Vector2i (RL.Map.nDir[directions[i],0], RL.Map.nDir[directions[i],1]);
         Vector2i np = GetComponent<RLCharacter>().positionI;
         int distanceCount = 1;
         np += ndir;
         while (map.IsOpenTile (np.x, np.y)) {
             np += ndir;
         }
     //			np -= ndir*0.5f;
         lr.SetPosition (0, Vector3.zero);
         lr.SetPosition (1, new Vector3(np.x-ndir.x*0.5f, np.y-ndir.y*0.5f, 0)-transform.position);
     }
 }
Example #25
0
 public Exit(Vector2i _pos)
     : base(_pos)
 {
     CurrentTex = "exit";
     Movable = false;
     Open = false;
 }
 public static void Stop(BHEntity mEntity, Vector2i mDirection, Rectangle mBounds, int mBoundsOffset)
 {
     if (mDirection.X == -1) mEntity.Position = new Vector2i(mBounds.X + mBoundsOffset, mEntity.Position.Y);
     if (mDirection.X == 1) mEntity.Position = new Vector2i(mBounds.X + mBounds.Width - mBoundsOffset, mEntity.Position.Y);
     if (mDirection.Y == -1) mEntity.Position = new Vector2i(mEntity.Position.X, mBounds.Y + mBoundsOffset);
     if (mDirection.Y == 1) mEntity.Position = new Vector2i(mEntity.Position.X, mBounds.Y - mBoundsOffset + mBounds.Height);
 }
Example #27
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FreezingArcher.Core.Window"/> class.
        /// </summary>
        /// <param name="size">Windowed size.</param>
        /// <param name="resolution">Resolution of the framebuffer.</param>
        /// <param name="title">Title.</param>
        public Window (Vector2i size, Vector2i resolution, string title)
        {
            Logger.Log.AddLogEntry (LogLevel.Info, ClassName, "Creating new window '{0}'", title);
	    MSize = size;
	    MResolution = resolution;
	    MTitle = title;
        }
Example #28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FreezingArcher.Messaging.ItemCollectedMessage"/> class.
 /// </summary>
 /// <param name="item">Item.</param>
 /// <param name="inventoryPosition">Inventory position.</param>
 /// <param name="entity">Entity.</param>
 public ItemCollectedMessage(Entity entity, ItemComponent item, Vector2i inventoryPosition)
 {
     Entity = entity;
     Item = item;
     InventoryPosition = inventoryPosition;
     MessageId = (int) Messaging.MessageId.ItemCollected;
 }
Example #29
0
    /// <summary>
    /// Returns the indices of the squares on a grid that intersect a line 
    /// beginning at vector "start" and ending at vector "end".  Right now 
    /// uses Bresenham's algorithm which may be a bad choice.
    /// </summary>
    /// <param name="start"></param>
    /// <param name="end"></param>
    /// <returns></returns>
    public IEnumerable<Vector2i> GetIntermediatePoints(Vector2i start, Vector2i end)
    {
        // http://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm
        var x0 = start.X;
        var x1 = end.X;
        var y0 = start.Y;
        var y1 = end.Y;
        var dx = Math.Abs(x1 - x0);
        var dy = Math.Abs(y0 - y1);

        var sx = (x0 < x1)? 1 : -1;
        var sy = (y0 < y1)? 1 : -1;
        var err = dx - dy;

        while (x0 != x1 || y0 != y1)
        {
            yield return new Vector2i(x0, y0);
            var e2 = err * 2;
            if (e2 > -dy)
            {
                err -= dy;
                x0 += sx;
            }

            if (e2 < dx)
            {
                err += dx;
                y0 += sy;
            }
        }
    }
Example #30
0
 public Job_PlantSeed(Vector2i plantPos, VoxelTypes seedType, IGrowPattern growPattern)
     : base(Labors.Farm, "Plant Seed", "Planting seed")
 {
     PlantPos = plantPos;
     SeedType = seedType;
     GrowPattern = growPattern;
 }
Example #31
0
 private protected override void SetParameterImpl(string name, Vector2i value)
 {
 }
Example #32
0
 public CUIText(Vector2i position, Vector2i size) => new CUIText(position, size, string.Empty);
Example #33
0
        /*
         * layout (std140, binding = 0) uniform Uniforms {
         *
         *     mat4 viewProjection;
         *     mat4 view;
         *     mat4 projection;
         *
         *     vec3 cameraPosition;
         *     ivec3 floorCameraPosition;
         *     vec3 decimalCameraPosition;
         *
         *     vec3 sunlightDirection;
         *     float viewDistanceSquared;
         *     float viewDistanceOffsetSquared;
         *     bool waterShader;
         *     int millis;
         *     float normalizedSpriteSize;
         *     int spriteTextureLength;
         *     vec2 windowsSize;
         * };
         */

        public void SetData(Camera camera, Vector3 sd, float vds, float vdos, bool ws,
                            long ticks, float normalizedSpriteSize, int spriteTextureLength, Vector2i windowSize)
        {
            var cameraPos  = camera.Position;
            var cameraPosI = new Vector3i((int)cameraPos.X, (int)cameraPos.Y, (int)cameraPos.Z);
            var cameraPosF = new Vector3((float)cameraPos.X, (float)cameraPos.Y, (float)cameraPos.Z);

            var offset  = cameraPos - cameraPosI.ToDouble();
            var offsetF = new Vector3((float)offset.X, (float)offset.Y, (float)offset.Z);

            _millis += (int)(ticks * 1000 / CMine.TicksPerSecond);
            _millis %= 1000000;
            _ubo.Orphan();
            _ubo.Set(camera.Matrix * camera.Frustum.Matrix, 0);
            _ubo.Set(camera.Matrix, 1);
            _ubo.Set(camera.Frustum.Matrix, 2);

            _ubo.Set(cameraPosF, 3);
            _ubo.Set(cameraPosI, 4);
            _ubo.Set(offsetF, 5);


            _ubo.Set(sd, 6);
            _ubo.Set(vds, 7);
            _ubo.Set(vdos, 8);
            _ubo.Set(ws, 9);
            _ubo.Set(_millis, 10);
            _ubo.Set(normalizedSpriteSize, 11);
            _ubo.Set(spriteTextureLength, 12);
            _ubo.Set(windowSize.ToFloat(), 13);
        }
Example #34
0
 public Building(Vector2i topLeft, Color color, bool[,] footprint)
 {
     this.TopLeft   = topLeft;
     this.Color     = color;
     this.Footprint = footprint;
 }
Example #35
0
 public static Vector2i Max(Vector2i a, Vector2i b)
 {
     return(new Vector2i(Mathf.Max(a.x, b.x), Mathf.Max(a.y, b.y)));
 }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="layerState">Layer state</param>
        /// <param name="tmxSourceLayer">TMX source layer</param>
        /// <param name="destinationLayer">Destination layer</param>
        /// <param name="sourceRect">Source rectangle</param>
        /// <param name="destPos">Destination position</param>
        /// <param name="packedSpriteLookup">Packed sprite lookup</param>
        /// <param name="source">Source type</param>
        public RBTMXLayerLoader(TMXMapAsset.TMXLayerLoadState layerState, string tmxSourceLayer, int destinationLayer, Rect2i sourceRect, Vector2i destPos, PackedSpriteID[] packedSpriteLookup, RB.AssetSource source)
        {
            if (layerState == null)
            {
                Debug.LogError("LayerLoadState is null!");
                return;
            }

            this.layerState = layerState;

            mSource             = source;
            mSourceRect         = sourceRect;
            mDestPos            = destPos;
            mPackedSpriteLookup = packedSpriteLookup;
            mTmxSourceLayer     = tmxSourceLayer;
            mDestinationLayer   = destinationLayer;

            LoadLayerInfo();

            return;
        }
Example #37
0
 public static string VectoriToString(Vector2i v)
 {
     return("" + v.X + "," + v.Y);
 }
Example #38
0
        public TileAtmosphere(GridAtmosphereComponent atmosphereComponent, GridId gridIndex, Vector2i gridIndices, GasMixture mixture = null, bool immutable = false)
        {
            IoCManager.InjectDependencies(this);
            _gridAtmosphereComponent = atmosphereComponent;
            _gridTileLookupSystem = _entityManager.EntitySysManager.GetEntitySystem<GridTileLookupSystem>();
            GridIndex = gridIndex;
            GridIndices = gridIndices;
            Air = mixture;

            if(immutable)
                Air?.MarkImmutable();
        }
Example #39
0
 /// <summary>Get the colour index that will be used with dithering at the given position.</summary>
 /// <param name="position"></param>
 /// <returns></returns>
 public int ColorAt(Vector2i position)
 {
     return(ColorAt(position.X, position.Y));
 }
Example #40
0
        /// <summary>Perform a flood-fill in a way that Sierra's SCI engine does it.</summary>
        /// <param name="at"></param>
        /// <param name="matchColor"></param>
        public void DrawFillSci(Vector2i at, int matchColor)
        {
            var stack = new Stack <Vector2i>(100);

            matchColor = ProcessColor(matchColor);
            if (!Contains(at) || GetPixel(at) != matchColor || matchColor == ColorA || matchColor == ColorB)
            {
                if (Contains(at))
                {
                    DrawPixelUnsafe(at);
                }
                return;
            }
            stack.Push(at);

            while (stack.Count != 0)
            {
                var position = stack.Pop();
                int index    = PointerTo(position);
                if (data[index] != matchColor)
                {
                    continue;
                }
                DirtyPoint(position.X, position.Y);
                data[index] = ColorAt(position.X, position.Y);
                int start, end;
                index -= position.X;

                for (start = position.X; start > 0; start--)
                {
                    if (data[index + start - 1] != matchColor)
                    {
                        break;
                    }
                    data[index + start - 1] = ColorAt(start - 1, position.Y);
                }

                for (end = position.X; end < size.X - 1; end++)
                {
                    if (data[index + end + 1] != matchColor)
                    {
                        break;
                    }
                    data[index + end + 1] = ColorAt(end + 1, position.Y);
                }

                DirtyPoint(start, position.Y);
                DirtyPoint(end, position.Y);

                if (position.Y > 0)
                {
                    if (position.Y < size.Y - 1)
                    {
                        for (int x = start; x <= end; x++)
                        {
                            DrawFillAddToStackUnsafe(stack, x, position.Y - 1, matchColor);
                            DrawFillAddToStackUnsafe(stack, x, position.Y + 1, matchColor);
                        }
                    }
                    else
                    {
                        for (int x = start; x <= end; x++)
                        {
                            DrawFillAddToStackUnsafe(stack, x, position.Y - 1, matchColor);
                        }
                    }
                }
                else if (position.Y < size.Y - 1)
                {
                    for (int x = start; x <= end; x++)
                    {
                        DrawFillAddToStackUnsafe(stack, x, position.Y + 1, matchColor);
                    }
                }
            }
        }
Example #41
0
 void DrawPixelUnsafe(Vector2i position)
 {
     DrawPixelUnsafe(position.X, position.Y);
 }
Example #42
0
 /// <summary>Draw a line using Sierra SCI's algorithm</summary>
 /// <param name="a"></param>
 /// <param name="b"></param>
 public void DrawLineSci(Vector2i a, Vector2i b)
 {
     DrawLineSci(a.X, a.Y, b.X, b.Y);
 }
Example #43
0
 int PointerTo(Vector2i position)
 {
     return(position.X + position.Y * Stride);
 }
Example #44
0
 /// <summary>Draw a pixel in the <see cref="Raster"/>.</summary>
 /// <param name="position"></param>
 public void DrawPixel(Vector2i position)
 {
     DrawPixel(position.X, position.Y);
 }
Example #45
0
 /// <summary>Get whehter the coordinates are within the <see cref="Raster"/>.</summary>
 /// <param name="position"></param>
 /// <returns></returns>
 public bool Contains(Vector2i position)
 {
     return(Contains(position.X, position.Y));
 }
Example #46
0
 /// <summary>Clamp the value so that it is within the bounds of the <see cref="Raster"/>.</summary>
 /// <param name="value"></param>
 /// <returns></returns>
 public Vector2i Clamp(Vector2i value)
 {
     return(new Vector2i(ClampX(value.X), ClampY(value.Y)));
 }
Example #47
0
        static Vector2i appleCoordinates; //Declares the apples coordinates;

        static void Main()
        {
            //Defines a Random entity to take care of all randomizes calculations
            Random rnd = new Random();

            bodyParts = new List <Vector2i>();   //Defines the global list for snake body parts
            bodyParts.Add(new Vector2i(10, 10)); //Adds three bodyparts for the snake, with the first one being the head
            bodyParts.Add(new Vector2i(9, 10));
            bodyParts.Add(new Vector2i(8, 10));

            appleCoordinates = new Vector2i(rnd.Next(0, levelWidth), rnd.Next(0, levelHeight));                                                                              //Sets random apple coordinates

            RenderWindow window = new RenderWindow(new VideoMode(Convert.ToUInt32(levelWidth * cellSize), Convert.ToUInt32(levelHeight * cellSize)), "Snek9", Styles.Close); //Initalizes the window

            window.SetFramerateLimit(60);
            window.Closed     += new EventHandler(OnClose); //Initializes the eventhandlers
            window.KeyPressed += new EventHandler <KeyEventArgs>(OnKeyPress);

            //Defines a clock for gametime
            Clock gameClock = new Clock();

            setColors();                                      //Sets the colors

            Font scoreFont = new Font("Resources\\font.ttf"); //Loads a font for writing the score

            while (window.IsOpen)                             //The game loop
            {
                window.DispatchEvents();

                //All game logic starts from here
                if (!gamePaused && !playerDead) //Only update and check collissions if game not paused
                {
                    //Defines variables to store past head coordinates so that the snake can be moved a step back when it dies (looks prettier)
                    Vector2i previousHeadCoordinates = new Vector2i(0, 0);


                    if (gameClock.ElapsedTime.AsMilliseconds() >= snekTime) //Check if it should move snek
                    {
                        int elNum = bodyParts.Count();
                        for (int i = 0; i < (elNum - 1); i++) //Move each and every bodypart except snekhead to the place of the bodypart before them
                        {
                            bodyParts[elNum - i - 1] = bodyParts[elNum - (i + 1) - 1];
                        }

                        //Sets the previousHeadCoordinates variable before head's coordinates are changed
                        previousHeadCoordinates = new Vector2i(bodyParts[0].X, bodyParts[0].Y);


                        int moveNum = 0;
                        if (snekDirection % 2 != 0) //Add moveNum to Y coordinate
                        {
                            moveNum      = snekDirection - 2;
                            bodyParts[0] = new Vector2i(bodyParts[0].X, bodyParts[0].Y + moveNum);
                        }
                        else //Add moveNum to X coordinate
                        {
                            moveNum      = snekDirection - 1;
                            bodyParts[0] = new Vector2i(bodyParts[0].X + moveNum, bodyParts[0].Y);
                        }

                        gameClock.Restart(); //Restarts the timer
                    }

                    //Check for collissions with walls
                    if (bodyParts[0].X < 0 || bodyParts[0].X > 19 || bodyParts[0].Y < 0 || bodyParts[0].Y > 19)
                    {
                        //Kill player
                        playerDead = true;

                        //Move snek head a step back
                        bodyParts[0] = previousHeadCoordinates;
                    }

                    //Check for collissions with bodyparts
                    for (int i = 1; i < bodyParts.Count; i++)
                    {
                        if (bodyParts[0].X == bodyParts[i].X && bodyParts[0].Y == bodyParts[i].Y)
                        {
                            //Kill player
                            playerDead = true;

                            //Move snek head a step back
                            bodyParts[0] = previousHeadCoordinates;
                        }
                    }
                }

                if (bodyParts[0] == appleCoordinates) //Checks if snekhead has touched apple and acts accordingly
                {
                    //Moves the apple to new random coordinates
                    appleCoordinates = new Vector2i(rnd.Next(0, levelWidth), rnd.Next(0, levelHeight));

                    //Adds a new bodypart to snekbody at the coordinates of the last bodypart
                    int elNum = bodyParts.Count();
                    bodyParts.Add(new Vector2i(bodyParts[elNum - 1].X, bodyParts[elNum - 1].Y));

                    //Adds 1 to the score
                    score++;
                }

                //Clears screen to white
                window.Clear(backgroundColor);

                RectangleShape cell = new RectangleShape(new Vector2f(cellSize, cellSize)); //Defines a shape for the cell

                //Draws every bodypart
                foreach (Vector2i bodyPart in bodyParts)
                {
                    cell.Position = new Vector2f(bodyPart.X * cellSize, bodyPart.Y * cellSize);
                    if (bodyParts[0] == bodyPart)
                    {
                        cell.FillColor = snekHeadColor;
                    }
                    else
                    {
                        cell.FillColor = snekBodyColor;
                    }
                    window.Draw(cell);
                }

                //Draws the apple
                cell.Position  = new Vector2f(appleCoordinates.X * cellSize, appleCoordinates.Y * cellSize);
                cell.FillColor = appleColor;
                window.Draw(cell);

                //Draws the score
                Text scoreText = new Text(score.ToString(), scoreFont, 100);                                               //Creates a string holding the score which will be displayed
                scoreText.Scale = new Vector2f(levelWidth * cellSize * (0.0016f), levelHeight * cellSize * (0.0016f));     //Sets scale of text depending on the window size
                float textWidth  = scoreText.GetLocalBounds().Width;                                                       //Gets the width of height of the text's boundingbox
                float textHeight = scoreText.GetLocalBounds().Height;
                scoreText.Position = new Vector2f(levelWidth * cellSize - textWidth, levelHeight * cellSize - textHeight); //Sets the position to bottom right using the data from before
                scoreText.Color    = scoreTextColor;                                                                       //Sets text's color
                window.Draw(scoreText);                                                                                    //draws the text

                //Displayes the backbuffer
                window.Display();
            }
        }
Example #48
0
    public void Attack(Vector2i target)
    {
        Vector3 tPos = transform.position + (new Vector3(target.x, target.y) - transform.position) * 0.5f;

        Go.to(gameObject.transform, 0.5f, TweenManager.TweenConfigCurrent().position(tPos).setEaseType(GoEaseType.Punch).onBegin(PlayHit));
    }
Example #49
0
        private bool TryRefreshTile(GridAtmosphereComponent gam, GasOverlayData oldTile, Vector2i indices, out GasOverlayData overlayData)
        {
            var tile = gam.GetTile(indices);

            if (tile == null)
            {
                overlayData = default;
                return(false);
            }

            var tileData = new List <GasData>();

            for (byte i = 0; i < Atmospherics.TotalNumberOfGases; i++)
            {
                var gas     = _atmosphereSystem.GetGas(i);
                var overlay = _atmosphereSystem.GetOverlay(i);
                if (overlay == null || tile?.Air == null)
                {
                    continue;
                }

                var moles = tile.Air.Gases[i];

                if (moles < gas.GasMolesVisible)
                {
                    continue;
                }

                var data = new GasData(i, (byte)(MathHelper.Clamp01(moles / gas.GasMolesVisibleMax) * 255));
                tileData.Add(data);
            }

            overlayData = new GasOverlayData(tile !.Hotspot.State, tile.Hotspot.Temperature, tileData.Count == 0 ? null : tileData.ToArray());

            if (overlayData.Equals(oldTile))
            {
                return(false);
            }

            return(true);
        }
Example #50
0
 public Dynamite(Vector2i _pos)
     : base(_pos)
 {
     CurrentTex = "dynamite";
     Movable    = true;
 }
Example #51
0
 protected override void OnRenderClientSizeChanged(object sender, Vector2i e)
 {
     GL.Viewport(0, 0, e.X, e.Y);
     _eye.Aspect = e.X / Math.Max(e.Y, .001F);
     base.OnRenderClientSizeChanged(sender, e);
 }
        /// <summary>
        /// Load sprite sheet asset
        /// </summary>
        /// <param name="path">Path to asset</param>
        /// <param name="existingTexture">Existing texture to load from</param>
        /// <param name="size">Size of the texture</param>
        /// <param name="asset">SpriteSheetAsset to load into</param>
        /// <param name="source">Asset source type</param>
        /// <returns>True if successful</returns>
        public bool Load(string path, RenderTexture existingTexture, Vector2i size, SpriteSheetAsset asset, RB.AssetSource source)
        {
            this.spriteSheetAsset = asset;
            this.path             = path;

            if (asset == null)
            {
                Debug.LogError("SpriteSheetAsset is null!");
                return(false);
            }

            if (source == RB.AssetSource.Resources)
            {
                // Empty texture
                if (path == null && existingTexture == null)
                {
                    if (size.x <= 0 || size.y <= 0)
                    {
                        spriteSheetAsset.InternalSetErrorStatus(RB.AssetStatus.Failed, RB.Result.BadParam);
                        return(false);
                    }

                    RenderTexture tex = new RenderTexture(size.x, size.y, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default);
                    if (tex == null)
                    {
                        spriteSheetAsset.InternalSetErrorStatus(RB.AssetStatus.Failed, RB.Result.NoResources);
                        return(false);
                    }

                    tex.filterMode   = FilterMode.Point;
                    tex.wrapMode     = TextureWrapMode.Clamp;
                    tex.anisoLevel   = 0;
                    tex.antiAliasing = 1;

                    tex.autoGenerateMips = false;
                    tex.depth            = 0;
                    tex.useMipMap        = false;

                    tex.Create();

                    asset.internalState.texture       = tex;
                    asset.internalState.textureWidth  = (ushort)tex.width;
                    asset.internalState.textureHeight = (ushort)tex.height;
#if MESH_UPLOAD_2019_3
                    asset.internalState.texelWidth  = 0xFFFF / (float)tex.width;
                    asset.internalState.texelHeight = 0xFFFF / (float)tex.height;
#endif
                    asset.internalState.spriteGrid.cellSize.width  = (ushort)tex.width;
                    asset.internalState.spriteGrid.cellSize.height = (ushort)tex.height;
                    asset.internalState.columns    = (ushort)(asset.internalState.textureWidth / asset.internalState.spriteGrid.cellSize.width);
                    asset.internalState.rows       = (ushort)(asset.internalState.textureHeight / asset.internalState.spriteGrid.cellSize.height);
                    asset.internalState.needsClear = true;

                    if (asset.internalState.columns < 1)
                    {
                        asset.internalState.columns = 1;
                    }

                    if (asset.internalState.rows < 1)
                    {
                        asset.internalState.rows = 1;
                    }

                    // If there is no spritesheet set then set this one as the current one
                    if (RetroBlitInternal.RBAPI.instance.Renderer.CurrentSpriteSheet == null)
                    {
                        RetroBlitInternal.RBAPI.instance.Renderer.SpriteSheetSet(asset);
                    }

                    asset.progress = 1;
                    spriteSheetAsset.InternalSetErrorStatus(RB.AssetStatus.Ready, RB.Result.Success);

                    return(true);
                }
                else if (existingTexture != null)
                {
                    asset.internalState.texture       = existingTexture;
                    asset.internalState.textureWidth  = (ushort)existingTexture.width;
                    asset.internalState.textureHeight = (ushort)existingTexture.height;
#if MESH_UPLOAD_2019_3
                    asset.internalState.texelWidth  = 0xFFFF / (float)existingTexture.width;
                    asset.internalState.texelHeight = 0xFFFF / (float)existingTexture.height;
#endif
                    asset.internalState.spriteGrid.cellSize.width  = (ushort)existingTexture.width;
                    asset.internalState.spriteGrid.cellSize.height = (ushort)existingTexture.height;
                    asset.internalState.columns = (ushort)(asset.internalState.textureWidth / asset.internalState.spriteGrid.cellSize.width);
                    asset.internalState.rows    = (ushort)(asset.internalState.textureHeight / asset.internalState.spriteGrid.cellSize.height);

                    if (asset.internalState.columns < 1)
                    {
                        asset.internalState.columns = 1;
                    }

                    if (asset.internalState.rows < 1)
                    {
                        asset.internalState.rows = 1;
                    }

                    // If there is no spritesheet set then set this one as the current one
                    if (RetroBlitInternal.RBAPI.instance.Renderer.CurrentSpriteSheet == null)
                    {
                        RetroBlitInternal.RBAPI.instance.Renderer.SpriteSheetSet(asset);
                    }

                    asset.progress = 1;
                    spriteSheetAsset.InternalSetErrorStatus(RB.AssetStatus.Ready, RB.Result.Success);

                    return(true);
                }
                else
                {
                    // Synchronous load
                    var spritesTextureOriginal = Resources.Load <Texture2D>(path);
                    if (spritesTextureOriginal == null)
                    {
                        Debug.LogError("Could not load sprite sheet from " + path + ", make sure the resource is placed somehwere in Assets/Resources folder. " +
                                       "If you're trying to load a Sprite Pack then please specify \"SpriteSheetAsset.SheetType.SpritePack\" as \"sheetType\". " +
                                       "If you're trying to load from an WWW address, or Addressable Assets then please specify so with the \"source\" parameter.");
                        asset.internalState.texture = null;
                        spriteSheetAsset.InternalSetErrorStatus(RB.AssetStatus.Failed, RB.Result.NotFound);

                        return(false);
                    }

                    FinalizeTexture(spritesTextureOriginal);

                    return(asset.status == RB.AssetStatus.Ready ? true : false);
                }
            }
            else if (source == RB.AssetSource.WWW)
            {
                if (!ImageTypeSupported(path))
                {
                    Debug.LogError("WWW source supports only PNG and JPG images");
                    spriteSheetAsset.InternalSetErrorStatus(RB.AssetStatus.Failed, RB.Result.NotSupported);
                    return(false);
                }

                mWebRequest = UnityWebRequestTexture.GetTexture(path, true);
                if (mWebRequest == null)
                {
                    spriteSheetAsset.InternalSetErrorStatus(RB.AssetStatus.Failed, RB.Result.NoResources);
                    return(false);
                }

                if (mWebRequest.SendWebRequest() == null)
                {
                    spriteSheetAsset.InternalSetErrorStatus(RB.AssetStatus.Failed, RB.Result.NoResources);
                    return(false);
                }

                spriteSheetAsset.InternalSetErrorStatus(RB.AssetStatus.Loading, RB.Result.Pending);

                return(true);
            }
            else if (source == RB.AssetSource.ResourcesAsync)
            {
                mResourceRequest = Resources.LoadAsync <Texture2D>(this.path);

                if (mResourceRequest == null)
                {
                    spriteSheetAsset.InternalSetErrorStatus(RB.AssetStatus.Failed, RB.Result.NoResources);

                    return(false);
                }
            }
#if ADDRESSABLES_PACKAGE_AVAILABLE
            else if (source == RB.AssetSource.AddressableAssets)
            {
                // Exceptions on LoadAssetAsync can't actually be caught... this might work in the future so leaving it here
                try
                {
                    mAddressableRequest = Addressables.LoadAssetAsync <Texture2D>(path);
                }
                catch (UnityEngine.AddressableAssets.InvalidKeyException e)
                {
                    RBUtil.Unused(e);
                    spriteSheetAsset.SetErrorStatus(RB.AssetStatus.Failed, RB.Result.NotFound);
                    return(false);
                }
                catch (Exception e)
                {
                    RBUtil.Unused(e);
                    spriteSheetAsset.SetErrorStatus(RB.AssetStatus.Failed, RB.Result.Undefined);
                    return(false);
                }

                // Check for an immediate failure
                if (mAddressableRequest.Status == AsyncOperationStatus.Failed)
                {
                    Addressables.Release(mAddressableRequest);
                    spriteSheetAsset.SetErrorStatus(RB.AssetStatus.Failed, RB.Result.Undefined);
                    return(false);
                }

                spriteSheetAsset.progress = 0;
                spriteSheetAsset.SetErrorStatus(RB.AssetStatus.Loading, RB.Result.Pending);

                return(true);
            }
#endif

            spriteSheetAsset.InternalSetErrorStatus(RB.AssetStatus.Loading, RB.Result.Pending);

            return(true);
        }
        private bool FinalizeSpritePackInfo(byte[] bytes)
        {
            var spritePack = new RBRenderer.SpritePack();

            spritePack.sprites = new Dictionary <int, PackedSprite>();

            try
            {
                var reader = new System.IO.BinaryReader(new System.IO.MemoryStream(bytes));

                if (reader.ReadUInt16() != RBRenderer.RetroBlit_SP_MAGIC)
                {
                    Debug.Log("Sprite pack index file " + path + " is invalid!");
                    return(false);
                }

                if (reader.ReadUInt16() != RBRenderer.RetroBlit_SP_VERSION)
                {
                    Debug.Log("Sprite pack file " + path + " version is not supported!");
                    return(false);
                }

                int spriteCount = reader.ReadInt32();
                if (spriteCount < 0 || spriteCount > 200000)
                {
                    Debug.Log("Sprite pack sprite count is invalid! Please try reimporting" + path + ".rb");
                    return(false);
                }

                for (int i = 0; i < spriteCount; i++)
                {
                    int hash = reader.ReadInt32();

                    var size = new Vector2i();
                    size.x = (int)reader.ReadUInt16();
                    size.y = (int)reader.ReadUInt16();

                    var sourceRect = new Rect2i();
                    sourceRect.x      = (int)reader.ReadUInt16();
                    sourceRect.y      = (int)reader.ReadUInt16();
                    sourceRect.width  = (int)reader.ReadUInt16();
                    sourceRect.height = (int)reader.ReadUInt16();

                    var trimOffset = new Vector2i();
                    trimOffset.x = (int)reader.ReadUInt16();
                    trimOffset.y = (int)reader.ReadUInt16();

                    var packedSprite = new PackedSprite(new PackedSpriteID(hash), size, sourceRect, trimOffset);

                    spritePack.sprites.Add(hash, packedSprite);
                }
            }
            catch (System.Exception e)
            {
                Debug.Log("Sprite pack index file " + path + " is invalid! Exception: " + e.ToString());
                return(false);
            }

            spriteSheetAsset.internalState.spritePack = spritePack;

            return(true);
        }
 public static Vector2f ToVector2f(this Vector2i v)
 {
     return(new Vector2f(v.X, v.Y));
 }
        public override void Update(float frameTime)
        {
            if (_inventory == null && _playerManager != null)
            {
                //Gotta do this here because the vars are null in the constructor.
                if (_playerManager.ControlledEntity != null)
                {
                    if (_playerManager.ControlledEntity.HasComponent(ComponentFamily.Inventory))
                    {
                        var invComp =
                            (InventoryComponent)_playerManager.ControlledEntity.GetComponent(ComponentFamily.Inventory);
                        _inventory = new InventoryViewer(invComp, _userInterfaceManager, _resourceManager);
                    }
                }
            }

            _comboBg.Position = new Vector2f(Position.X, Position.Y);

            var bounds     = _comboBg.GetLocalBounds();
            var equipBgPos = Position;

            _equipBg.Position = new Vector2f(Position.X, Position.Y);
            equipBgPos       += new Vector2i((int)(bounds.Width / 2f - _equipBg.GetLocalBounds().Width / 2f), 40);
            _equipBg.Position = new Vector2f(equipBgPos.X, equipBgPos.Y);

            var comboClosePos = Position;

            comboClosePos       += new Vector2i(264, 11); //Magic photoshop ruler numbers.
            _comboClose.Position = comboClosePos;
            _comboClose.Update(frameTime);

            var tabEquipPos = Position;

            tabEquipPos       += new Vector2i(-26, 76); //Magic photoshop ruler numbers.
            _tabEquip.Position = tabEquipPos;
            _tabEquip.Color    = _currentTab == 1 ? Color.White :_inactiveColor;
            _tabEquip.Update(frameTime);

            var tabHealthPos = tabEquipPos;

            tabHealthPos       += new Vector2i(0, 3 + _tabEquip.ClientArea.Height);
            _tabHealth.Position = tabHealthPos;
            _tabHealth.Color    = _currentTab == 2 ? Color.White : _inactiveColor;
            _tabHealth.Update(frameTime);

            ClientArea = new IntRect(Position.X, Position.Y, (int)bounds.Width, (int)bounds.Height);

            switch (_currentTab)
            {
            case (1):     //Equip tab
            {
                #region Equip

                //Only set position for topmost 2 slots directly. Rest uses these to position themselves.
                var slotLeftStart = Position;
                slotLeftStart     += new Vector2i(28, 40);
                _slotHead.Position = slotLeftStart;
                _slotHead.Update(frameTime);

                var slotRightStart = Position;
                slotRightStart    += new Vector2i((int)(bounds.Width - _slotMask.ClientArea.Width - 28), 40);
                _slotMask.Position = slotRightStart;
                _slotMask.Update(frameTime);

                int vertSpacing = 6 + _slotHead.ClientArea.Height;

                //Left Side - head, eyes, outer, hands, feet
                slotLeftStart.Y   += vertSpacing;
                _slotEyes.Position = slotLeftStart;
                _slotEyes.Update(frameTime);

                slotLeftStart.Y    += vertSpacing;
                _slotOuter.Position = slotLeftStart;
                _slotOuter.Update(frameTime);

                slotLeftStart.Y    += vertSpacing;
                _slotHands.Position = slotLeftStart;
                _slotHands.Update(frameTime);

                slotLeftStart.Y   += vertSpacing;
                _slotFeet.Position = slotLeftStart;
                _slotFeet.Update(frameTime);

                //Right Side - mask, ears, inner, belt, back
                slotRightStart.Y  += vertSpacing;
                _slotEars.Position = slotRightStart;
                _slotEars.Update(frameTime);

                slotRightStart.Y   += vertSpacing;
                _slotInner.Position = slotRightStart;
                _slotInner.Update(frameTime);

                slotRightStart.Y  += vertSpacing;
                _slotBelt.Position = slotRightStart;
                _slotBelt.Update(frameTime);

                slotRightStart.Y  += vertSpacing;
                _slotBack.Position = slotRightStart;
                _slotBack.Update(frameTime);

                if (_inventory != null)
                {
                    _inventory.Position = new Vector2i(Position.X + 12, Position.Y + 315);
                    _inventory.Update(frameTime);
                }
                break;

                #endregion
            }

            case (2):     //Health tab
            {
                #region Status

                var resLinePos = new Vector2i(Position.X + 35, Position.Y + 70);

                const int spacing = 8;

                _ResBlunt.Position = resLinePos;
                resLinePos.Y      += _ResBlunt.ClientArea.Height + spacing;
                _ResBlunt.Update(frameTime);

                _ResPierce.Position = resLinePos;
                resLinePos.Y       += _ResPierce.ClientArea.Height + spacing;
                _ResPierce.Update(frameTime);

                _ResSlash.Position = resLinePos;
                resLinePos.Y      += _ResSlash.ClientArea.Height + spacing;
                _ResSlash.Update(frameTime);

                _ResBurn.Position = resLinePos;
                resLinePos.Y     += _ResBurn.ClientArea.Height + spacing;
                _ResBurn.Update(frameTime);

                _ResFreeze.Position = resLinePos;
                resLinePos.Y       += _ResFreeze.ClientArea.Height + spacing;
                _ResFreeze.Update(frameTime);

                _ResShock.Position = resLinePos;
                resLinePos.Y      += _ResShock.ClientArea.Height + spacing;
                _ResShock.Update(frameTime);

                _ResTox.Position = resLinePos;
                _ResTox.Update(frameTime);

                break;

                #endregion
            }
            }
            //Needs to update even when its not on the crafting tab so it continues to count.
        }
Example #56
0
 public DummyRenderTexture(Vector2i size, Texture texture)
 {
     Size    = size;
     Texture = texture;
 }
Example #57
0
 public IClydeViewport CreateViewport(Vector2i size, string?name = null)
 {
     return(new Viewport());
 }
        public override bool MouseUp(MouseButtonEventArgs e)
        {
            var mouseAABB = new Vector2i(e.X, e.Y);

            switch (_currentTab)
            {
            case (1):     //Equip tab
            {
                #region Equip

                //Left Side - head, eyes, outer, hands, feet
                if (_slotHead.MouseUp(e))
                {
                    return(true);
                }
                if (_slotEyes.MouseUp(e))
                {
                    return(true);
                }
                if (_slotOuter.MouseUp(e))
                {
                    return(true);
                }
                if (_slotHands.MouseUp(e))
                {
                    return(true);
                }
                if (_slotFeet.MouseUp(e))
                {
                    return(true);
                }

                //Right Side - mask, ears, inner, belt, back
                if (_slotMask.MouseUp(e))
                {
                    return(true);
                }
                if (_slotEars.MouseUp(e))
                {
                    return(true);
                }
                if (_slotInner.MouseUp(e))
                {
                    return(true);
                }
                if (_slotBelt.MouseUp(e))
                {
                    return(true);
                }
                if (_slotBack.MouseUp(e))
                {
                    return(true);
                }

                if (_inventory != null)
                {
                    if (_inventory.MouseUp(e))
                    {
                        return(true);
                    }
                }

                if (_comboBg.GetLocalBounds().Contains(mouseAABB.X, mouseAABB.Y) && _userInterfaceManager.DragInfo.IsEntity &&
                    _userInterfaceManager.DragInfo.IsActive)
                {
                    //Should be refined to only trigger in the equip area. Equip it if they drop it anywhere on the thing. This might make the slots obsolete if we keep it.
                    if (_playerManager.ControlledEntity == null)
                    {
                        return(false);
                    }

                    IEntity entity = _playerManager.ControlledEntity;

                    var equipment = (EquipmentComponent)entity.GetComponent(ComponentFamily.Equipment);
                    equipment.DispatchEquip(_userInterfaceManager.DragInfo.DragEntity.Uid);
                    _userInterfaceManager.DragInfo.Reset();
                    return(true);
                }

                break;

                #endregion
            }

            case (2):     //Health tab
            {
                #region Status

                break;

                #endregion
            }
            }

            return(false);
        }
Example #59
0
        private static void _render(IRenderHandle renderHandle, Control control, Vector2i position, Color modulate,
                                    UIBox2i?scissorBox)
        {
            if (!control.Visible)
            {
                return;
            }

            // Manual clip test with scissor region as optimization.
            var controlBox = UIBox2i.FromDimensions(position, control.PixelSize);

            if (scissorBox != null)
            {
                var clipMargin  = control.RectDrawClipMargin;
                var clipTestBox = new UIBox2i(controlBox.Left - clipMargin, controlBox.Top - clipMargin,
                                              controlBox.Right + clipMargin, controlBox.Bottom + clipMargin);

                if (!scissorBox.Value.Intersects(clipTestBox))
                {
                    return;
                }
            }

            var handle = renderHandle.DrawingHandleScreen;

            handle.SetTransform(position, Angle.Zero, Vector2.One);
            modulate       *= control.Modulate;
            handle.Modulate = modulate * control.ActualModulateSelf;
            var clip          = control.RectClipContent;
            var scissorRegion = scissorBox;

            if (clip)
            {
                scissorRegion = controlBox;
                if (scissorBox != null)
                {
                    // Make the final scissor region a sub region of scissorBox
                    var s      = scissorBox.Value;
                    var result = s.Intersection(scissorRegion.Value);
                    if (result == null)
                    {
                        // Uhm... No intersection so... don't draw anything at all?
                        return;
                    }

                    scissorRegion = result.Value;
                }

                renderHandle.SetScissor(scissorRegion);
            }

            control.DrawInternal(renderHandle);
            foreach (var child in control.Children)
            {
                _render(renderHandle, child, position + child.PixelPosition, modulate, scissorRegion);
            }

            if (clip)
            {
                renderHandle.SetScissor(scissorBox);
            }
        }
Example #60
0
 public DummyTexture(Vector2i size) : base(size)
 {
 }