示例#1
0
文件: Player.cs 项目: Tankooni/OwlMan
    // 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);
    }
示例#2
0
 public override void _Ready()
 {
     Connect("area_entered", this, nameof(OnHit));
     GetNode <Timer>("FireRate").Connect("timeout", this, nameof(Shoot));
     _deathAudio = GetNode <AudioStreamPlayer2D>("DeathAudio");
     _anim       = GetNode <AnimatedSprite>("AnimatedSprite");
     _anim.Play("enemy_" + enemyVersion);
     _anim.Connect("animation_finished", this, nameof(OnAnimationFinished));
 }
示例#3
0
 public override void _Ready()
 {
     base._Ready();
     _animatedSprite           = GetNodeOrNull <AnimatedSprite>(_animatedSpritePath ?? string.Empty);
     _projectileSpawnComponent = GetNodeOrNull <ProjectileSpawnComponent>(_projectileSpawnComponentPath ?? string.Empty);
     _pursueState           = GetNodeOrNull(_pursueStateNodePath ?? string.Empty) as IStateExector;
     _attackIntentComponent = GetNodeOrNull <AttackIntentComponent>(_attackIntentComponentPath ?? string.Empty);
     _animatedSprite?.Connect("animation_finished", this, nameof(OnAnimationFinished));
 }
示例#4
0
 public override void _Ready()
 {
     lifetimeTimer = (Timer)GetNode("Lifetime");
     Connect("body_entered", this, "OnBodyEntered");
     lifetimeTimer.Connect("timeout", this, "OnLifetimeTimeout");
     sprite    = GetNode <Sprite>("Sprite");
     explosion = GetNode <AnimatedSprite>("Explosion");
     explosion.Connect("animation_finished", this, "OnExplosionFinished");
 }
示例#5
0
        public override void _Ready()
        {
            base._Ready();

            _weapon             = GetNode <WeaponBase>("Weapon");
            _weapon.OwnerEntity = this;

            _animatedSprite = GetNode <AnimatedSprite>("AnimatedSprite");
            _animatedSprite.Connect("animation_finished", this, nameof(OnAnimationFinished));
        }
示例#6
0
 public void Shoot()
 {
     if (AttackSoundName != null && !AttackSoundName.Empty())
     {
         Overlord.OwlOverlord.PlaySound(AttackSoundName, this.GlobalPosition);
     }
     animatedSprite.Play("attack");
     animatedSprite.Connect("animation_finished", animatedSprite, "play", new Array {
         "idle"
     }, (uint)ConnectFlags.Oneshot);
 }
示例#7
0
//*-------------------------------------------------------------------------*//

    #region GODOT METHODS

    public override void _Ready()
    {
        _animation = GetNode <AnimatedSprite>("AnimatedSprite");
        _animation.Connect("animation_finished", this, nameof(_on_AnimationFinished));

        _audioMove = GetNode <AudioStreamPlayer>("Audio/Move");

        _boss = GetParent().GetNode <Boss>("Boss");

        // Steering AI - Set the player node as leader
        Utils.LeaderToFollow = this;
    }
示例#8
0
        //Whether a wave group should refire instantly after finishing
        //private bool[] fireInstantly;

        public override void _Ready()
        {
            List <AnimatedSprite[]> waveslist = new List <AnimatedSprite[]>();

            //Get all children that are Groups, these are assumed to have exclusively AnimatedSprites children
            int i = 0;

            foreach (Node child in this.GetChildren())
            {
                //Check that this actually is a sprite group
                if (!child.Name.StartsWith("group"))
                {
                    continue;
                }

                //Waves in this group
                //I can't use LINQ cos some twat decided Godot.Collections.Array shouldn't support it
                //Thanks a lot
                AnimatedSprite[] groupWaves = new AnimatedSprite[child.GetChildren().Count];
                i = 0;
                foreach (Node waveAsNode in child.GetChildren())
                {
                    AnimatedSprite wave = waveAsNode as AnimatedSprite;
                    //Call wave finished with index when finished
                    wave.Connect("animation_finished", this, nameof(_OnWaveEnded),
                                 new Godot.Collections.Array(new object[] { wave, waveslist.Count, i }));
                    //Generate wave speed
                    wave.SpeedScale = this.GenerateWaveSpeed(wave);

                    groupWaves[i] = wave;
                    i++;
                }

                waveslist.Add(groupWaves);
            }

            this.waves = waveslist.ToArray();

            SceneTreeTimer tmr;

            i = 0;
            //Fire off all the groups at regular intervals
            foreach (AnimatedSprite[] group in this.waves)
            {
                tmr = GetTree().CreateTimer((this.duration / this.waves.Count()) * i);
                tmr.Connect("timeout", this, nameof(StartWave), new Godot.Collections.Array(new object[] { i }));
                i++;
            }
        }
示例#9
0
 public override void _Ready()
 {
     GetNode <Timer>("FireRate").Connect("timeout", this, nameof(CanShoot));
     screenSize = GetViewport().Size;
     _anim      = GetNode <AnimatedSprite>("AnimatedSprite");
     _anim.Connect("animation_finished", this, nameof(OnAnimationFinished));
     _shootAudio  = GetNode <AudioStreamPlayer2D>("ShootAudio");
     _shieldAudio = GetNode <AudioStreamPlayer2D>("ShieldAudio");
     _deathAudio  = GetNode <AudioStreamPlayer2D>("DeathAudio");
     _shield      = GetNode <Area2D>("Shield");
     Connect("area_entered", this, nameof(Hit));
     GetNode <Area2D>("DefendLine").Connect("area_entered", this, nameof(lineHit));
     _shield.Hide();
     _shield.GetNode <CollisionShape2D>("CollisionShape2D").Disabled = true;
 }
示例#10
0
 public override void _Ready()
 {
     gunTimer          = (Timer)GetNode("GunTimer");
     gunTimer.WaitTime = GunCooldown;
     turret            = (Sprite)GetNode("Turret");
     muzzle            = (Position2D)turret.GetNode("Muzzle");
     gunTimer.Connect("timeout", this, "OnGunTimer");
     player    = GetNode <AnimationPlayer>("AnimationPlayer");
     hitbox    = GetNode <CollisionShape2D>("CollisionShape2D");
     explosion = GetNode <AnimatedSprite>("Explosion");
     body      = GetNode <Sprite>("Body");
     health    = MaxHealth;
     EmitSignal("HealthChanged", health * 100f / MaxHealth);
     EmitSignal("AmmoChanged", Ammo * 100 / MaxAmmo);
     explosion.Connect("animation_finished", this, "ExplosionFinished");
 }
示例#11
0
    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        game             = GetNode <Game>("/root/Game");
        Globals.Scene    = GetNode <Node2D>("..");
        animatedSprite   = GetNode <AnimatedSprite>("AnimatedSprite");
        platformDetector = GetNode <RayCast2D>("PlatformDetector");

        camera = GetNode <Camera2D>("Camera");
        camera.CustomViewport = GetNode("../..");
        map       = GetNode <Map>("..");
        debugText = GetNode <Label>("Z/DebugText");

        fadeAnim = GetNode <AnimationPlayer>("../../CanvasLayer/Z/FadeRect/AnimationPlayer");

        animatedSprite.Connect("animation_finished", this, "OnFinished");
        SpawnPosition = Position;
    }
示例#12
0
    private bool PlayerMoveGrid(Godot.Collections.Dictionary result)
    {
        if (result.Count != 0)                                 // if there is something there
        {
            EmitSignal(nameof(chestTest), result["position"]); // tell the chests to check if it was them that we hit

            if (((Node2D)result["collider"]).HasMethod("SubtractHeart") && !attacking)
            {
                ((Monster)result["collider"]).SubtractHeart();
                attacking    = true;
                currectSlash = (AnimatedSprite)playerSlash.Instance();
                GetParent().AddChild(currectSlash);
                currectSlash.Playing  = true;
                currectSlash.Frame    = 0;
                currectSlash.Position = ((Monster)result["collider"]).Position;
                currectSlash.Connect("animation_finished", this, nameof(_onSlashEnd));
                soundManager.Call("PlayAffect", "res://Sounds/slash.wav");
            }
            return(false);
        }

        return(true);
    }
示例#13
0
 public override void _Ready()
 {
     _controllable = GetNode <Controllable>("..");
     _sprite       = GetNode <AnimatedSprite>("AnimatedSprite");
     _sprite.Connect("animation_finished", this, nameof(OnAnimatedSpriteFinished));
 }
示例#14
0
 // Called when the node enters the scene tree for the first time.
 public override void _Ready()
 {
     animatedSprite = GetNode <AnimatedSprite>("AnimatedSprite");
     animatedSprite.Play(EffectName);
     animatedSprite.Connect("animation_finished", this, "Delete");
 }