private bool Interact(Entity e)
        {
            if (!Payed)
            {
                return(false);
            }

            Audio.PlaySfx("level_claw_pc");

            e.RemoveComponent <PlayerInputComponent>();
            interacting = e;
            interacting.GetComponent <StateComponent>().Become <Player.SittingState>();

            var region = CommonAse.Ui.GetSlice("key_right");

            Engine.Instance.State.Ui.Add(ia = new InteractFx(this, null, region, -5));
            region = CommonAse.Ui.GetSlice("button_x");
            Engine.Instance.State.Ui.Add(ib = new InteractFx(this, null, region, 5));

            Camera.Instance.Targets.Clear();
            Camera.Instance.Follow(claw, 1f);
            Payed = false;

            return(false);
        }
Exemple #2
0
        private void AddFx()
        {
            if (fx != null && !fx.Done)
            {
                fx.Close();
            }

            var i = GetComponent <ItemComponent>().Item;

            Engine.Instance.State.Ui.Add(fx = new InteractFx(this, i == null ? Locale.Get("place_an_item") : i.Name));
        }
        public override void Update(float dt)
        {
            base.Update(dt);

            if (maanex == null)
            {
                var room = GetComponent <RoomComponent>().Room;

                foreach (var n in room.Tagged[Tags.Npc])
                {
                    if (n is Maanex2 m)
                    {
                        maanex = m;
                        maanex.clawControll = this;
                        break;
                    }
                }
            }

            if (interacting == null || grabbing)
            {
                return;
            }

            var controller = GamepadComponent.Current;

            if (Input.WasPressed(Controls.UiSelect, controller))
            {
                grabbing = true;

                ia.Close();
                ib.Close();
                ia = ib = null;

                GetComponent <InteractableComponent>().CurrentlyInteracting?.GetComponent <InteractorComponent>()?.EndInteraction();

                claw.Grab((won, mega) => {
                    interacting.AddComponent(new PlayerInputComponent());
                    interacting = null;
                    grabbing    = false;

                    if (won)
                    {
                        maanex.GetComponent <DialogComponent>().StartAndClose(Locale.Get(mega ? "m2_0" : "m2_1"), 2);
                    }
                    else
                    {
                        maanex.GetComponent <DialogComponent>().StartAndClose("F", 2);
                    }

                    ((InGameState)Engine.Instance.State).ResetFollowing();
                });

                return;
            }

            var body  = claw.GetComponent <SensorBodyComponent>().Body;
            var speed = 420 * dt;

            var wdown = wasDown;

            if (Input.IsDown(Controls.Right, controller) || Input.IsDown(Controls.UiRight, controller))
            {
                wasDown              = true;
                body.LinearVelocity += new Vector2(speed, 0);
            }
            else
            {
                wasDown = false;
            }

            if (wdown != wasDown)
            {
                if (wasDown)
                {
                    Audio.PlaySfx("level_claw_start");
                }
                else
                {
                    Audio.PlaySfx("level_claw_stop");
                }
            }

            if (claw.X > claw.start.X + 96)
            {
                claw.X = claw.start.X + 96;
            }
        }