Exemple #1
0
        // TODO
        // Refactor
        public override void Render(GBitmap screen)
        {
            int x = iX - 2;
            int y = iY - 2;

            int YAtlas = 9;

            if (BindingMaster || CurrentInvItemAKey != 1 || IsHolding())
            {
                YAtlas = 12;
            }

            screen.Blit(Art.Rotate(Art.GRAPHICS[0, YAtlas + TrackState], (int)Direction * 90), x, y);
            Art.GRAPHICS[1, 9].ChangeHue(UnitColors.GetUnitHue(Id));

            int ol = 10;
            int ot = 10;

            if (Direction == Directions.Right)
            {
                ot *= 0;
                ol *= -1;
            }
            else if (Direction == Directions.Down)
            {
                ol *= 0;
                ot *= -1;
            }
            else if (Direction == Directions.Left)
            {
                ot *= 0;
            }
            else if (Direction == Directions.Up)
            {
                ol *= 0;
            }

            screen.Blit(Art.Rotate(Art.GRAPHICS[1, 9], (int)Direction * 90), x + ol, y + ot);

            if (IsHolding())
            {
                HandedItem.Render(screen, Id, iX, iY, Direction);
            }
            else
            {
                if (BindingMaster)
                {
                    InvItem KeepingItem = InvItem.GetInvItem(GetSlaveEntityMoving().ToString());
                    if (!KeepingItem.ToString().Equals("inventory-item"))
                    {
                        KeepingItem.Render(screen, Id, iX, iY, Direction);
                        KeepingItem.RenderHologram(screen, Id, iX, iY);
                    }
                }
                else if (CurrentInvItemAKey != 1)
                {
                    InvItem HoldingItem = InvItem.GetInvItem(InvItem.GetNameByIndex(CurrentInvItemAKey - 1));
                    HoldingItem.Render(screen, Id, iX, iY, Direction);
                    HoldingItem.RenderHologram(screen, Id, iX, iY);
                }
            }

            if (!Controllable)
            {
                Color col = Color.Green;
                if (Health < MaxHealth * 1 / 3)
                {
                    col = Color.Red;
                }
                else if (Health < MaxHealth * 2 / 3)
                {
                    col = Color.Yellow;
                }
                screen.FillRect(col, x + 3, y + H, (int)((double)Health / MaxHealth * W), 4);
            }
        }
Exemple #2
0
        public override void Update()
        {
            Shooting = false;
            UpdateMoving();
            UpdateBonuses();
            UpdateInventory();

            IntersectingTiles = GameLevel.GetIntersectingTiles(this);

            // Self-destruction, yay!
            if (GameLevel.Input.Z.Clicked)
            {
                Damage(10);
            }

            LastUsedInvItem = null;
            if (GameLevel.Input.Attack.Clicked)
            {
                LastUsedInvItem = InvItem.GetPlayersInvItem(Id, CurrentInvItemAKey);
                LastUsedInvItem.Use(Id);
            }
            else
            {
                Shooting = false;
            }

            if (SkippedAnimTicks++ > 1)
            {
                SkippedAnimTicks = 0;
                if (AnimState++ >= 2)
                {
                    AnimState = 0;
                }
            }

            if (ReqAngle != 0)
            {
                Angle += 6;
                if (Angle >= ReqAngle)
                {
                    ReqAngle = 0;
                    Angle    = 0;
                }
            }

            // =================
            // Dragging entities
            GEntity Range = null;

            if (Direction == Directions.Up)
            {
                Range = new GEntity(X, Y - 4, W, H);
            }
            if (Direction == Directions.Right)
            {
                Range = new GEntity(X, Y, W + 8, H);
            }
            if (Direction == Directions.Down)
            {
                Range = new GEntity(X, Y, W, H + 8);
            }
            if (Direction == Directions.Left)
            {
                Range = new GEntity(X - 8, Y, W, H);
            }

            List <GEntity> InRangeEntities = GameLevel.GetIntersectingEntities(Range);
            bool           PassUnbindTick  = false;

            if (InRangeEntities.Count > 0)
            {
                GEntity E = InRangeEntities[0];

                if (E.Draggable && E.Owner == Id)
                {
                    E.HasFocus = true;
                    if (GameLevel.Input.E.Clicked)
                    {
                        DropBindedEntity();
                        E.BindMasterEntityMoving(this);
                        SetSlaveEntityMoving(E);
                        PassUnbindTick = true;
                    }
                }
            }

            if (!PassUnbindTick && BindingMaster && GameLevel.Input.E.Clicked)
            {
                DropBindedEntity();
            }

            GameLevel.ShowGrid = !IsHolding() && BindingMaster && InvItem.GetInvItem(GetSlaveEntityMoving().ToString()).ToString().Equals("inventory-item") || CurrentInvItemAKey != 1;

            int r = 200;

            GameLevel.RevealFog(iX - r / 2 + W / 2, iY - r / 2 + H / 2, r);
        }