コード例 #1
0
 public void Attack()
 {
     AttackTimer.Start(0.5f);
     Attacking = true;
     CanAttack = false;
     Animation.Play("Attack");
     AttackHitbox.Position = new Vector2(Mathf.Abs(AttackHitbox.Position.x) * (Sprite.FlipH ? -1 : 1), 0);
     AttackCooldown.Start(1.5f);
 }
コード例 #2
0
  public override void _Process(float delta)
  {
      var g = GetTree().GetNodesInGroup("Player");

      Node2D[] p = new Node2D[g.Count];
      g.CopyTo(p, 0);
      p = p.Where(n => (n as Knight).Health > 0).ToArray();
      p = p.Where(n => n.GlobalPosition.DistanceTo(GlobalPosition) < 40).ToArray();

      if (p.Any() && AttackCooldown.TimeLeft == 0 && Health > 0)
      {
          var k = p.FirstOrDefault();

          Sprite.FlipH = k.GlobalPosition < GlobalPosition;
          AttackCooldown.Start(3f);
          ShootTimer.Start(1.5f);
          Animation.Play("A");
      }
  }
コード例 #3
0
    public override void _Process(float delta)
    {
        if (Health <= 0)
        {
            return;
        }

        var bs = Area.GetOverlappingBodies();
        var a  = new Node2D[bs.Count];

        bs.CopyTo(a, 0);
        a = a.Where(b => b is Knight).ToArray();
        if (TeleportCooldown.TimeLeft == 0)
        {
            if (a.Any())
            {
                TeleportMove.Start(1f);
                TeleportCooldown.Start(4f);
                Animation.Play("Teleport");
                AttackCooldown.Start(1.6f);
            }
            else if (GlobalPosition != Start)
            {
                TeleportMove.Start(1f);
                TeleportCooldown.Start(4f);
                Animation.Play("Teleport");
                AttackCooldown.Start(1.6f);
            }
        }
        else
        {
            if (AttackCooldown.TimeLeft == 0)
            {
                TeleportCooldown.Start(3f);
                AttackCooldown.Start(3f);
                Animation.Play("Attack");
                FireballTimer.Start(1f);
            }
        }
    }