public WindowBoundingBox() { SpaceOverride = SpaceOverrideEnum.Replace; Gravity = 0; _bounds = new CollisionShape2D(); }
public override void _Ready() { _team = (Team)GetNode("Team"); _team.CurrentTeamCode = _defaultTeamCode; _captureTeamCode = _team.CurrentTeamCode; _unitDisplayLabel = ((Label)(GetNode("UnitDisplay/Name"))); _unitDisplay = (UnitDisplay)GetNode("UnitDisplay"); _collisionShape = (CollisionShape2D)GetNode("CollisionShape2D"); _rng = new RandomNumberGenerator(); _rng.Randomize(); _base = (Sprite)GetNode("Base"); _boundry = (Sprite)GetNode("Boundry"); _timer = (Timer)GetNode("CaptureTimer"); agentsEntered = new Godot.Collections.Array(); for (int index = 0; index < Enum.GetNames(typeof(Team.TeamCode)).Length; index++) { agentsEntered.Add(0); } // Update unit display SetCaptureBaseTeam(_team.CurrentTeamCode); }
float headingX = +1.0f; //-1 to the left, +1 to the right public override void _Ready() { sprIdle = GetNode <Sprite>("sprIdle"); sprRun = GetNode <Sprite>("sprRun"); sprJumpLong = GetNode <Sprite>("sprJumpLong"); sprJumpShort = GetNode <Sprite>("sprJumpShort"); sprFall = GetNode <Sprite>("sprFall"); sprClimb = GetNode <Sprite>("sprClimb"); animPlayer = GetNode <AnimationPlayer>("AnimationPlayer"); colFront = GetNode <CollisionShape2D>("colFront"); colBottom = GetNode <CollisionShape2D>("colBottom"); colRun = GetNode <CollisionShape2D>("colRun"); colBase = GetNode <CollisionShape2D>("colBase"); colUpper = GetNode <CollisionShape2D>("colUpper"); grabArea = GetNode <Area2D>("GrabArea"); grabArea.Connect("body_entered", this, "OnGrab"); rayFloor = GetNode <RayCast2D>("rayFloor"); TurnOnSpr(SprObj.SprIdle); }
public override void Initialize(Vector2 position, int size = 8) { base.Initialize(Position, size: size); SetCollisionMaskBit(1, true); CollisionLayer = 0; CollisionShape2D hurtCollider = new CollisionShape2D(); RectangleShape2D hurtBoxShape = new RectangleShape2D(); _hurtArea.SetCollisionLayerBit(0, false); _hurtArea.SetCollisionLayerBit(2, true); _hurtArea.SetCollisionMaskBit(19, true); _hurtArea.SetCollisionMaskBit(0, false); _hurtArea.Name = "HurtBox"; hurtBoxShape.Extents = new Vector2(size / 2f, size / 2f); hurtCollider.Shape = hurtBoxShape; _hurtArea.AddChild(hurtCollider); AddChild(_hurtArea); CollisionShape2D alertCollider = new CollisionShape2D(); CircleShape2D alertBoxShape = new CircleShape2D(); _alertArea.Name = "AlertCircle"; _alertArea.SetCollisionMaskBit(19, true); _alertArea.SetCollisionMaskBit(0, false); _alertArea.CollisionLayer = 0; alertBoxShape.Radius = 35; alertCollider.Shape = alertBoxShape; _alertArea.AddChild(alertCollider); AddChild(_alertArea); _alertArea.Connect("area_entered", this, "_OnPlayerEnter"); _hurtArea.Connect("area_entered", this, "_OnPlayerTouch"); AddToGroup("Enemies"); }
public override void _Ready() { CharacterSprite = this.GetChildNode <Sprite>(nameof(CharacterSprite)); AnimationPlayer = this.GetChildNode <AnimationPlayer>(); CollisionShape2D = this.GetChildNode <CollisionShape2D>(nameof(CollisionShape2D)); State = this.GetChildNode <StateComponent>(); Stats = this.GetChildNode <Stats>(); CharacterHitBox = this.GetChildNode <CharacterHitBox>(); CharacterHitBox.Disable(); CharacterHurtBox = this.GetChildNode <CharacterHurtBox>(); BlinkAnimationPlayer = this.GetChildNodeOrNull <AnimationPlayer>(nameof(BlinkAnimationPlayer)); CharacterHurtBox.Connect(nameof(CharacterHurtBox.DamageReceived), this, nameof(ReceiveDamage)); HpIndicator = this.GetChildNode <HpIndicator>(); HpIndicator.Visible = true; Stats.Connect(nameof(Stats.HpWasChanged), HpIndicator, nameof(HpIndicator.OnChangeHp)); Stats.Connect(nameof(Stats.MaxHpWasChanged), HpIndicator, nameof(HpIndicator.OnChangeMaxHP)); HpIndicator.UpdateHealthIndication(); InvincibilityComponent = this.GetChildNode <InvincibilityComponent>(); InvincibilityComponent.Connect(nameof(InvincibilityComponent.InvincibilityStarted), this, nameof(StartInvincibility)); InvincibilityComponent.Connect(nameof(InvincibilityComponent.InvincibilityEnded), this, nameof(EndInvincibility)); }
public override void _Ready() { collisionShape = GetNode <CollisionShape2D>("CollisionShape2D"); playerHandler = GetNode <Position2D>("PlayerHandler"); Direction = Mathf.Polar2Cartesian(1.0f, Rotation).Round().Sign(); if (Direction.x == 1) { TransitionMargin = Margin.Left; } else if (Direction.x == -1) { TransitionMargin = Margin.Right; } else if (Direction.y == 1) { TransitionMargin = Margin.Bottom; } else { TransitionMargin = Margin.Top; } Stage = GetNode <Stage>("../.."); }
public override void _Ready() { _collisionShape2d = GetNode <CollisionShape2D>("CollisionShape2D"); _animationPlayer = GetNode <AnimationPlayer>("AnimationPlayer"); _blinkAnimationPlayer = GetNode <AnimationPlayer>("BlinkAnimationPlayer"); _deathTimer = GetNode <Timer>("DeathTimer"); _selectableComponent = GetNode <SelectableComponent>("SelectableComponent"); _sprite = GetNode <Sprite>("Sprite"); _sprite.Texture = _spriteTexture; _velocity = Vector2.Right.Rotated(Mathf.Deg2Rad(Main.RNG.RandfRange(MIN_ANGLE, MAX_ANGLE))); _velocity *= Main.RNG.RandfRange(MIN_SPEED, MAX_SPEED); _stateMachine.AddState(State.BOUNCING, StateBouncing); _stateMachine.AddState(State.SEPARATE, StateSeparate); _stateMachine.AddState(State.SETTLED, StateSettled); _stateMachine.AddState(State.PICKED_UP, StatePickedUp); _stateMachine.SetInitialState(State.BOUNCING); AddToGroup(GROUP); _deathTimer.Connect("timeout", this, nameof(OnDeathTimerTimeout)); _selectableComponent.Connect(nameof(SelectableComponent.Selected), this, nameof(OnSelected)); _selectableComponent.Connect(nameof(SelectableComponent.SelectEnter), this, nameof(OnSelectEnter)); _selectableComponent.Connect(nameof(SelectableComponent.SelectLeave), this, nameof(OnSelectLeave)); }
public override void _Ready() { hurtArea = GetNode <Area2D>("HurtArea"); pillarShape = GetNode <CollisionShape2D>("PillarShape"); pillarAnim = GetNode <AnimatedSprite>("PillarAnim"); restTimer = GetNode <Timer>("RestTimer"); }
public override void _Ready() { Character = this.GetParentNodeRecurse <Character>(); CollisionShape2D = this.GetChildNode <CollisionShape2D>(); Connect("area_entered", this, nameof(OnAreaEntered)); }
/// <summary> /// Add a line segment. /// </summary> /// <param name="start">Start position</param> /// <param name="end">End position</param> public void AddSegment(Vector2 start, Vector2 end) { var segment = new SegmentShape2D() { A = start, B = end }; var shape = new CollisionShape2D() { Shape = segment }; segments.Add(segment); shapes.Add(shape); AddChild(shape); var lineSprite = new SimpleLineSprite() { PositionA = GlobalPosition + segment.A, PositionB = GlobalPosition + segment.B, Modulate = BaseColor, Width = 2 }; lineSprites.Add(lineSprite); AddChild(lineSprite); }
public override void _Ready() { bushSprite = GetNode <Sprite>("BushSprite"); bushShape = GetNode <CollisionShape2D>("BushBody/BushBodyShape"); deathTimer = GetNode <Timer>("DeathTimer"); leafParticles = GetNode <Particles2D>("LeafParticles"); }
public override void _Ready() { _collisionShape = GetNode <CollisionShape2D>("CollisionShape2D"); _leftWall = GetParent().GetNode <StaticBody2D>("LeftWall"); _rightWall = GetParent().GetNode <StaticBody2D>("RightWall"); _animationPlayer = GetNode <AnimationPlayer>("AnimationPlayer"); }
public override void _Ready() { CrashAudio = GetNode <AudioStreamPlayer2D>("CrashAudio"); HookLaunchAudio = GetNode <AudioStreamPlayer2D>("HookLaunchAudio"); PickupCreatureAudio = GetNode <AudioStreamPlayer2D>("PickupCreatureAudio"); CreaturesCaught = new Godot.Collections.Dictionary <string, int>(); CreaturesCost = new Godot.Collections.Dictionary <string, int>(); Hookable = true; Hook = GetNode <Node2D>("Hook"); HookChain = GetNode <ColorRect>("HookChain"); OriginalHookChainHeight = HookChain.GetRect().Size.y; HookHitBoxCollision = GetNode <CollisionShape2D>("Hook/Claw/Area2D/CollisionShape2D"); HookHitBoxCollision.Disabled = true; HookLaunch = GetNode <Tween>("HookLaunch"); HookRetract = GetNode <Tween>("HookRetract"); HookChainLaunch = GetNode <Tween>("HookChainLaunch"); HookChainRetract = GetNode <Tween>("HookChainRetract"); OriginalHookPosition = Hook.Position; CrashParticles = GetNode <Particles2D>("CrashParticles"); Bubbler = GetNode <Particles2D>("Bubbler"); }
float dangerZonePositionModifier = 1.255f; // hardcoded number, how much the x position of the zone is divded public override void _Ready() { if (laneImg == null) { GD.PushError("You must set laneImg for Lane!"); GD.PrintStack(); GetTree().Quit(1); } TextureButton button = GetNode <TextureButton>("Button"); spawnPoint = button.RectGlobalPosition + new Vector2(70, 30); GetNode <Sprite>("Sprite").Texture = laneImg; Events.roundWon += OnRoundWon; Events.dinoDiedInstance += OnDinoDiedInstance; // we're an empty lane, don't allow deploys if (Curve.GetPointCount() == 0) { button.Hide(); return; } dangerZoneCollision = GetNode("DangerZone").GetNode <CollisionShape2D>("DangerZoneCollision"); var dangerBox = new RectangleShape2D(); // make a hitbox for the danger zone dangerZoneCollision.Shape = dangerBox; // divide by 1/2 since that's how extents work // divide x by 1/3 since we want it to be that big dangerBox.Extents = new Vector2(laneImg.GetSize().x / 2 / 3, laneImg.GetSize().y / 2 * GetNode <Sprite>("Sprite").Scale.y); dangerZoneCollision.Position = new Vector2(this.GlobalPosition.x / dangerZonePositionModifier, 0); }
public override void _Ready() { sprite = GetNode <Sprite>("Sprite"); shape = GetNode <CollisionShape2D>("CollisionShape2D"); regions = new Dictionary(); regions.Add(Items.barrelBlack_side, new Rect2(532, 90, 56, 40)); regions.Add(Items.barrelBlack_top, new Rect2(220, 89, 48, 48)); regions.Add(Items.barrelGreen_side, new Rect2(476, 90, 56, 40)); regions.Add(Items.barrelGreen_top, new Rect2(220, 137, 48, 48)); regions.Add(Items.barrelRed_side, new Rect2(420, 94, 56, 40)); regions.Add(Items.barrelRed_top, new Rect2(172, 89, 48, 48)); regions.Add(Items.barrelRust_side, new Rect2(588, 90, 56, 40)); regions.Add(Items.barrelRust_top, new Rect2(172, 137, 48, 48)); regions.Add(Items.barricadeMetal, new Rect2(532, 130, 56, 56)); regions.Add(Items.barricadeWood, new Rect2(72, 130, 56, 56)); regions.Add(Items.fenceRed, new Rect2(336, 443, 32, 96)); regions.Add(Items.fenceYellow, new Rect2(216, 550, 32, 104)); regions.Add(Items.sandbagBeige, new Rect2(164, 282, 44, 64)); regions.Add(Items.sandbagBeige_open, new Rect2(518, 350, 55, 84)); regions.Add(Items.sandbagBrown, new Rect2(622, 278, 44, 64)); regions.Add(Items.sandbagBrown_open, new Rect2(596, 450, 55, 84)); regions.Add(Items.treeBrown_large, new Rect2(0, 654, 128, 128)); regions.Add(Items.treeBrown_small, new Rect2(694, 118, 72, 72)); regions.Add(Items.treeGreen_large, new Rect2(128, 654, 128, 128)); regions.Add(Items.treeGreen_small, new Rect2(694, 190, 72, 72)); }
public void Initialize(Vector2 position) { base.Initialize(position); SetCollisionMaskBit(1, true); sprite.Frames = ResourceLoader.Load("res://entities/player/Player.tres") as SpriteFrames; sprite.Play("default"); ChangeState(state); var hurtArea = new Area2D(); var hurtCollider = new CollisionShape2D(); var hurtBoxShape = new RectangleShape2D(); hurtArea.SetCollisionLayerBit(19, true); hurtArea.SetCollisionLayerBit(0, false); hurtArea.CollisionMask = 0; hurtArea.Name = "HurtBox"; hurtBoxShape.Extents = new Vector2(2f, 4f); hurtCollider.Shape = hurtBoxShape; hurtArea.AddChild(hurtCollider); hurtArea.Connect("body_entered", this, "OnTouchedByEnemy"); AddChild(hurtArea); Texture gradient = ResourceLoader.Load("res://assets/gradients/radial.png") as Texture; _light.Texture = gradient; _light.Scale = _baseLightScale; _light.Color = new Color(1f, 1f, 1f, .3f); AddChild(_light); AddChild(_lightTween); AddToGroup("Players"); }
// Called when the node enters the scene tree for the first time. public override void _Ready() { _spawnArea = GetNode <CollisionShape2D>("SpawnArea/Area"); _shape = _spawnArea.Shape as RectangleShape2D; areaStart = _spawnArea.Position - _shape.Extents; areaEnd = _spawnArea.Position + _shape.Extents; }
public override void _Ready() { screenSize = GetViewportRect().Size; colorRandom = new Random(); animatedSprite = (AnimatedSprite)GetNode("AnimatedSprite"); colorSprite = (Sprite)GetNode("ColorSprite"); actualColor = colorSprite.Modulate; collisionShape2D = (CollisionShape2D)GetNode("CollisionShape2D"); particles = (Particles2D)GetNode("Particles2D"); animationPlayer = (AnimationPlayer)GetNode("Control/AnimationPlayer"); changeColorTimer = (Timer)GetNode("ChangeColorTimer"); changeColorTimer.Start(); Connect("body_entered", this, nameof(OnBodyEntered)); changeColorTimer.Connect("timeout", this, nameof(ChangeColor)); AddUserSignal("scoreUp"); AddUserSignal("hit"); SetPosition(GetViewportRect().Size / 2); colorSprite.Modulate = Colors.colors[colorRandom.Next(0, Colors.colors.Length)]; actualColor = colorSprite.Modulate; AnimationColorTimer = (Timer)GetNode("AnimationColorTimer"); }
private Vector2[] GetVerticesFromCollisionShape(CollisionShape2D collisionShape) { if (collisionShape.Shape is RectangleShape2D rect) { // Return the vertices in a clockwise order return(new Vector2[] { collisionShape.GlobalPosition + new Vector2(-rect.Extents.x, -rect.Extents.y), collisionShape.GlobalPosition + new Vector2(rect.Extents.x, -rect.Extents.y), collisionShape.GlobalPosition + new Vector2(rect.Extents.x, rect.Extents.y), collisionShape.GlobalPosition + new Vector2(-rect.Extents.x, rect.Extents.y), }); } else if (collisionShape.Shape is ConvexPolygonShape2D convex) { // convex.Points already contains the list of vertices // but they need to be offset to correctly reflect changes in the editor Vector2[] result = convex.Points; for (int i = 0; i < result.Length; i++) { result[i] += collisionShape.GlobalPosition; } return(result); } throw new NotImplementedException("Tried to get vertices from a not implemented shape type."); }
// Called when the node enters the scene tree for the first time. public override void _Ready() { _camera = GetNode <Camera2D>("../MainCamera"); _camera.Call("SetFollow", this.GetPath()); foreach (var node in Atmo.OgmoLoader.OgmoLoader.nodes) { node.Set("target", GetPath()); Enemy.PlayerPath = GetPath(); //node.Set("node", node.GetPath()); } _hud = GetNode <Control>("../CanvasLayer/HUD"); Image = GetNode <AnimatedSprite>("AnimatedSprite"); _collisionShape2D = GetNode <CollisionShape2D>("CollisionShape2D"); _overlord = GetNode("/root/Overlord"); BoxL = GetNode <Area2D>("SideBoxL"); BoxR = GetNode <Area2D>("SideBoxR"); BoxB = GetNode <Area2D>("BottomBox"); this.Connect("HealthChanged", _hud, "on_set_health"); this.Connect("AnimationChanged", _hud, "on_animation_changed"); SetDeferred("Health", maxHealth); //Health = maxHealth; Power = 0; // Spice = 100; // Energy = 0f; MaxEnergy = 3; EnergyRechargeRate = 2f; //JumpStrenth = 660; RunSpeed = 200; DashMultiplier = 3.5f; HorizontalDrag = 50; Gravity = Overlord.STANDARD_GRAVITY; // image.RenderStep = 1; // GameWorld.player = this; // Type = KQ.CollisionTypePlayer; Abilities = new Abilities(this); Abilities.GiveAllAbilities(); MovementInfo = new MovementInfo(this); InputController = new Controller(); PlayerStateController = new PlayerStateController(new PSIdle(this)); Image.Connect("animation_finished", this, "AnimationComplete"); // AddResponse(PickupType.AirDash, OnAirDashPickup); // AddResponse(PickupType.AirJump, OnAirJumpPickup); // AddResponse(PickupType.Jump, OnJumpPickup); // AddResponse(PickupType.Dash, OnDashPickup); }
public override void _Ready() { animationPlayer = GetNode <AnimationPlayer>(animationPlayerPath); lightOccluder2D = GetNode <LightOccluder2D>(lightOccluder2DPath); collisionShape2D = GetNode <CollisionShape2D>(collisionShape2DPath); openSprite = GetNode <Sprite>(openSpritePath); closedSprite = GetNode <Sprite>(closedSpritePath); }
// Called when the node enters the scene tree for the first time. public override void _Ready() { _map = this.GetNode <Map>("../../MainMap"); _gameManager = this.GetNode <GameManager>("../../../Root"); _collisionShape = this.GetNode <CollisionShape2D>("./CollisionShape2D"); UpdateGridPosition(); }
/// <summary> /// Initialise the node when the game engine is ready /// </summary> public override void _Ready() { collisionObject = (CollisionShape2D)this.GetNode("CollisionObject"); areaExplosion = (Area2D)this.GetNode("AreaExplosion"); Connect("body_entered", this, "OnBodyEnter"); //areaExplosion.Connect("body_entered", this, "CollidTerrain"); }
public override void _Ready() { sprite = GetNode <AnimatedSprite>("AnimatedSprite"); collisionShape = GetNode <CollisionShape2D>("CollisionShape2D"); hitPlayer = GetNodeOrNull <RawAudioPlayer2D>("HitPlayer"); hasDisappear = sprite.Frames.HasAnimation("disappear"); sprite.Play("default"); }
/// <summary> /// Create a default polygon. /// </summary> public SimplePolygon() { polygonShape2D = new ConvexPolygonShape2D(); collisionShape2D = new CollisionShape2D() { Shape = polygonShape2D }; }
public override void _Ready() { _player = GetNode <Player>(".."); _hitBox = _player.GetNode <Area2D>("HitBox"); _hitBoxOriginalX = _hitBox.Position.x; _hitCollision = _hitBox.GetNode <CollisionShape2D>("CollisionShape2D"); _hitCollision.Disabled = true; }
// Called when the node enters the scene tree for the first time. public override void _Ready() { CollisionShape = GetNode <CollisionShape2D>("StaticBody2D/CollisionShape2D"); var shape = CollisionShape.Shape as RectangleShape2D; CollisionHeight = shape.Extents.y; CollisionWidth = shape.Extents.x; }
private Vector2 _screenSize; // size of gme window public override void _Ready() { _screenSize = GetViewport().GetSize(); collisionShape2D = (CollisionShape2D)GetNode("CollisionShape2D"); Hide(); // Called every time the node is added to the scene. // Initialization here }
public override void _Ready() { collisionShape = GetNode <CollisionShape2D>("CollisionShape2D"); Random rand = new Random(); AngularVelocity = (float)((rand.NextDouble() - 0.5f) * 55); }
public override void _Ready() { m_CollisionShape2D = (CollisionShape2D)GetNode("CollisionShape2D"); m_AnimatedSprite = (AnimatedSprite)GetNode("AnimatedSprite"); m_AnimatedSprite.Play(); m_AudioStreamPlayer2D = (AudioStreamPlayer2D)GetNode("Noise"); }