예제 #1
0
    public override void _PhysicsProcess(float delta)
    {
        UpdateGems();
        GetNode <OmniLight>("OmniLight").Rotate(new Vector3(0, 1, 0), delta);
        GetNode <OmniLight>("OmniLight").Translate(new Vector3(0, 0, 2 * delta));

        if (!mouseClicked)
        {
            return;
        }
        mouseClicked = false;

        Vector2 mpos       = GetViewport().GetMousePosition();
        var     spaceState = GetWorld().DirectSpaceState;
        float   rayLength  = 1000;
        var     camera     = GetNode <Camera>("Camera");
        var     from       = camera.ProjectRayOrigin(mpos);
        var     to         = from + camera.ProjectRayNormal(mpos) * rayLength;

        Godot.Collections.Array excl = new Godot.Collections.Array();
        excl.Add(this);
        var result = spaceState.IntersectRay(from, to, excl);

        if (result.Count > 0)
        {
            Godot.Object o = (Godot.Object)result["collider"];
            if (o != null)
            {
                StaticBody sb = o as StaticBody;
                if (sb != null)
                {
                    //GD.Print("DBG> "+sb.Name);
                    CheckAndDestroy(sb.Name);
                }
            }
        }
    }
예제 #2
0
 //LEARN: This connection is done with the EDITOR and generates empty
 //[connection signal="body_entered" from="." to="." method="OnBirdBodyEntered"]
 private void OnBirdBodyEntered(Godot.Object body)
 {
     if (State == BirdStates.Flapping && body is Ground)
     {
         camera.Shake();
         HitAudioPlayer.Play();
         PlayDieAsync();
         GD.Print("Ground collision from Flapping");
         SetState(BirdStates.Ground);
     }
     else if (State == BirdStates.Flapping && body is Pipe)
     {
         camera.Shake();
         HitAudioPlayer.Play();
         GD.Print("Pipe collision from Flapping");
         SetState(BirdStates.Hit);
     }
     else if (State == BirdStates.Hit && body is Ground)
     {
         DiedAudioPlayer.Play();
         GD.Print("Ground collision from Hit");
         SetState(BirdStates.Ground);
     }
 }
예제 #3
0
 public override void Edit(Godot.Object obj)
 {
     if (IsInstanceValid(obj))
     {
         if (obj is CustomPath pth)
         {
             path = pth;
             if (IsInstanceValid(path.curve))
             {
                 path.curve.EmitSignal("changed");
             }
             GD.Print("Edit");
         }
     }
     else
     {
         CustomPath pre = path;
         path = null;
         if (IsInstanceValid(pre))
         {
             pre.curve.EmitSignal("changed");
         }
     }
 }
예제 #4
0
        /// <summary>
        /// Track a new asset reference. Will be called during asset creation, after the asset content is downloaded
        /// or retrieved from cache.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="containerId"></param>
        /// <param name="asset"></param>
        /// <param name="colliderGeo"></param>
        /// <param name="source"></param>
        public void Set(Guid id, Guid containerId, Object asset,
                        ColliderGeometry colliderGeo = null, AssetSource source = null)
        {
            if (!Assets.ContainsKey(id))
            {
                Assets[id] = new AssetMetadata(id, containerId, asset, colliderGeo, source);
            }

            if (Callbacks.TryGetValue(id, out List <AssetCallback> callbacks))
            {
                Callbacks.Remove(id);
                foreach (var cb in callbacks)
                {
                    try
                    {
                        cb?.Invoke(Assets[id]);
                    }
                    catch (Exception e)
                    {
                        GD.PushError(e.ToString());
                    }
                }
            }
        }
예제 #5
0
    public override void Update(Godot.Object agent)
    {
        BasePlayer p = agent as BasePlayer;

        _movement.z = 0;
        if (Input.IsKeyPressed(GD.KEY_LEFT))
        {
            _movement.z -= p.Attributes.RunSpeed * _airControlFactor;
            p.SetFacing(eUnitFacing.LEFT);
        }
        if (Input.IsKeyPressed(GD.KEY_RIGHT))
        {
            _movement.z += p.Attributes.RunSpeed * _airControlFactor;
            p.SetFacing(eUnitFacing.RIGHT);
        }
        p.Velocity.y -= Const.Gravity * p.GetPhysicsProcessDeltaTime();
        p.Velocity.z += _movement.z;
        if (Math.Abs(p.Velocity.z) > p.Attributes.RunSpeed)
        {
            p.Velocity.z = p.Velocity.z / Math.Abs(p.Velocity.z) * p.Attributes.RunSpeed;
        }

        base.Update(agent);
    }
예제 #6
0
    public void bind_external_function(
        string func_name,
        Godot.Object gd_object,
        string method_name,
        bool lookahead_safe)
    {
        if (story == null)
        {
            PushNullStoryError();
            return;
        }

        try
        {
            story.BindExternalFunctionGeneral(
                func_name,
                (object[] args) => gd_object.Call(method_name, args),
                lookahead_safe);
        }
        catch (Exception e)
        {
            HandleException(e);
        }
    }
    public override void Update(Godot.Object agent)
    {
        BaseUnit u    = agent as BaseUnit;
        Vector3  diff = _target.GetTranslation() - u.GetTranslation();

        if (diff.z < 0)
        {
            u.SetFacing(eUnitFacing.LEFT);
        }
        if (diff.z > 0)
        {
            u.SetFacing(eUnitFacing.RIGHT);
        }

        if (diff.Length() > u.Attributes.RunSpeed)
        {
            diff = diff.Normalized() * u.Attributes.RunSpeed;
        }

        u.Velocity.z = diff.z;
        u.Velocity.y = -Const.Gravity;

        base.Update(agent);
    }
예제 #8
0
    public override void Enter(Godot.Object agent)
    {
        BasePlayer p = agent as BasePlayer;

        p.AnimPlayer.TransitionNodeSetCurrent("movement", 1);
    }
 public static bool Is(this Object obj, string property) => obj.Get(property) as bool? ?? false;
예제 #10
0
 private void _on_HandArea_area_exited(Godot.Object body)
 {
     BodiesInPunchArea.Remove(body);
 }
예제 #11
0
 void _on_Tween_tween_completed(Godot.Object @object, NodePath key)
 {
     this.QueueFree();
 }
예제 #12
0
 public CommandBuilder AddCommand(string name, Godot.Object target, string targetMethodName)
 {
     Godot.Object consoleCommand = _console.Call("add_command", name, target, targetMethodName) as Godot.Object;
     return(new CommandBuilder(consoleCommand));
 }
예제 #13
0
 public void GetNodeType(Godot.Object optional)
 {
     optional.Call(this.GetMethodSet(), projectileType);
 }
예제 #14
0
 public Timer UntilSignal(Godot.Object Emitter, String Event, double TimeLimit)
 {
     Watcher.Call("watch", Emitter, Event);
     return((Timer)Yielder.Call("until_signal", TimeLimit, Emitter, Event));
 }
예제 #15
0
 public void UnWatch(Godot.Object Emitter, String Event)
 {
     Watcher.Call("unwatch", Emitter, Event);
 }
예제 #16
0
 private void _onDamageCalculation(int damage, Vector2 hitDir, Godot.Object source, Team sourceTeam, Godot.Object target)
 {
     if (target != null && IsInstanceValid(target))
     {
         if (target.HasMethod(nameof(Agent.TakeDamage)))
         {
             Agent targetAgent = (Agent)(target);
             Agent sourceAgent = (Agent)(source);
             targetAgent.TakeDamage(damage, hitDir, sourceAgent, sourceTeam);
         }
         else if (target.HasMethod(nameof(Obstacle.TakeEnvironmentDamage)))
         {
             ((Obstacle)(target)).TakeEnvironmentDamage(damage);
         }
         else if (target.HasMethod(nameof(Shield.TakeShieldDamage)))
         {
             ((ShieldPhysics)(target)).TakeShieldDamage(damage);
         }
     }
 }
예제 #17
0
 public void ConnectToMouseMovement(Godot.Object target, string name)
 {
     Connect(nameof(InputHandler.MouseMoved), target, name);
 }
예제 #18
0
 public void RegisterStateChange(Godot.Object target, string method)
 {
     Connect(nameof(ChangedState), target, method);
 }
예제 #19
0
 public void IsInactive(Godot.Object optional)
 {
     optional.Call(this.GetMethodSet(), projectileAction.Inactive);
 }
예제 #20
0
 // Update handler methods without disconnecting.
 public void UpdateServer(Godot.Object obj, string playerJoin, string playerLeave)
 {
     this.GetTree().Connect("network_peer_connected", obj, playerJoin);
     this.GetTree().Connect("network_peer_disconnected", obj, playerLeave);
 }
예제 #21
0
 public void _OnAreaEntered(Godot.Object otherArea)
 {
     ((Ball)((Node)otherArea).GetParent()).BallWasCaught();
 }
예제 #22
0
 // Update handler methods without disconnecting.
 public void UpdateClient(Godot.Object obj, string success, string peerJoin, string fail)
 {
     GetTree().Connect("connected_to_server", obj, success);
     GetTree().Connect("connection_failed", obj, fail);
     GetTree().Connect("network_peer_connected", obj, peerJoin);
 }
예제 #23
0
 private void _on_HandArea_area_entered(Godot.Object body)
 {
     BodiesInPunchArea.Add(body);
 }
예제 #24
0
 async private void Initialize(Godot.Object pScene)
 {
     await ToSignal(pScene, "ready");
 }
 public override bool Handles(Godot.Object @object)
 {
     return(@object != null && (@object is VegetationSpawner));
 }
예제 #26
0
파일: Test.cs 프로젝트: Atlinx/WAT-Mono
 protected Timer UntilSignal(Godot.Object emitter, string signal, double time)
 {
     Watcher.Call("watch", emitter, signal);
     return((Timer)Yielder.Call("until_signal", time, emitter, signal));
 }
예제 #27
0
 public void GetDirection(Godot.Object response)
 {
     response.EmitSignal(SignalKey.SET_DATA, direction);
 }
예제 #28
0
파일: Test.cs 프로젝트: Atlinx/WAT-Mono
 protected void UnWatch(Godot.Object emitter, string signal)
 {
     Watcher.Call("unwatch", emitter, signal);
 }
예제 #29
0
    public override bool IsTriggered(Godot.Object agent)
    {
        BaseEnemy e = agent as BaseEnemy;

        return(e.Attributes.Health <= 0);
    }
예제 #30
0
 private void _OnBodyEntered(Godot.Object body)
 {
     ((Node)body).QueueFree();
     QueueFree();
 }