コード例 #1
0
ファイル: Main.cs プロジェクト: IndieRonin/LD47-Paradox
 private void InitGame()
 {
     player     = (KinematicBody)playerScene.Instance();
     orb        = (KinematicBody)OrbScene.Instance();
     startRoom  = (Spatial)StartRoomScene.Instance();
     mapBuilder = (Spatial)mapBuilderScene.Instance();
 }
コード例 #2
0
        private void SpawnProp(string name, Vector3?pos)
        {
            PackedScene   propScene = ResourceLoader.Load <PackedScene>(NetworkBoxPath);
            KinematicBody prop      = propScene?.Instance() as KinematicBody;

            if (prop == null)
            {
                return;
            }

            AddChild(prop);
            _props.Add(prop.Name, prop);
            prop.Name = name;
            if (pos != null)
            {
                Transform propTransform = prop.Transform;
                propTransform.origin.x = pos.Value.x;
                propTransform.origin.y = pos.Value.y;
                propTransform.origin.z = pos.Value.z;
                prop.Transform         = propTransform;
            }
            else
            {
                Transform propTransform = prop.Transform;
                propTransform.origin.x = DefaultSpawnPos.x;
                propTransform.origin.y = DefaultSpawnPos.y;
                propTransform.origin.z = DefaultSpawnPos.z;
                prop.Transform         = propTransform;
            }
        }
コード例 #3
0
ファイル: HumanoidFactory.cs プロジェクト: kitfka/AlleyCat
 protected override Validation <string, Humanoid> CreateService(
     string key,
     string displayName,
     MorphableRace race,
     IEnumerable <IAttribute> attributes,
     IPairedEyeSight vision,
     ILocomotion locomotion,
     Skeleton skeleton,
     IActionSet actions,
     IAnimationManager animationManager,
     KinematicBody node,
     ILoggerFactory loggerFactory)
 {
     return(new Humanoid(
                key,
                displayName,
                race,
                Sex,
                attributes,
                vision,
                locomotion,
                skeleton,
                animationManager,
                actions,
                Optional(Markers).Flatten(),
                node,
                loggerFactory));
 }
コード例 #4
0
    private void AttemptBreeding(object[] args)
    {
        KinematicBody otherBody = (KinematicBody)args[0];

        if (otherBody.GetName() == targetName)
        {
            ((Entity)otherBody.GetNode("Entity")).SendMessage("acceptBreed");
            SetState(BreedState.GoingForBreed);
        }
        else
        {
            if (!active || state == BreedState.ApproachingTarget)
            {
                if (component.Satiated < satiatedThreshold)
                {
                    return;
                }
                int n = BaseComponent.random.Next(0, 100);
                if (n < component.Breedability)
                {
                    ((Entity)otherBody.GetNode("Entity")).SendMessage("acceptBreed");
                    target     = otherBody;
                    targetName = otherBody.GetName();
                    active     = true;

                    SetState(BreedState.GoingForBreed);
                }
            }
        }
    }
コード例 #5
0
 public override void _Ready()
 {
     _camera    = (OrbitCamera)GetNode <OrbitCamera>(Camera);
     _rigidBody = this;
     _collider  = GetNode <CollisionShape>("CollisionShape");
     Radius     = _collider.Scale.x / 2;
 }
コード例 #6
0
    public override void _Ready()
    {
        maze = new Maze(ShapeGeometry.MakePolygon(6, 21, (float)Math.PI / 2),
                        new Vector2(-21, -21), new Vector2(21, 21));
        //maze = new Maze(ShapeGeometry.MakeStar(12, 21, (float)Math.PI / 2), new Vector2(-21, -21), new Vector2(21, 21));

        //Draw cells to single mesh and apply to screen
        var surfTool = MeshCreation.CreateSurfaceTool();

        var walls = maze.GetWalls();

        foreach (var wall in walls)
        {
            if (!wall.KnockedDown)
            {
                MeshCreation.AddWall(surfTool, new Vector3(wall.GetPoint1X(), 0.0f, wall.GetPoint1Y()),
                                     new Vector3(wall.GetPoint2X(), 0.0f, wall.GetPoint2Y()), 0.1f, 2.0f);
            }
        }

        this.AddChild(MeshCreation.CreateMeshInstanceFromMesh(MeshCreation.CreateMeshFromSurfaceTool(surfTool)));

        //Put players at start
        KinematicBody player       = (KinematicBody)this.GetParent().GetNode("player");
        var           startingCell = maze.GetStartingCell();

        player.SetTranslation(new Vector3(startingCell.X, 0.0f, startingCell.Y));

        //Put flag at end
        Spatial flag       = (Spatial)this.GetParent().GetNode("Flag");
        var     endingCell = maze.GetEndingCell();

        flag.SetTranslation(new Vector3(endingCell.X, 0.0f, endingCell.Y));
    }
コード例 #7
0
 private void LoadResources()
 {
     //Regestir for the event callback for the placing of the rooms
     PlaceExitEvent.RegisterListener(InitExitWall);
     //Init he raycasts of the room walls used for creating the room
     roofRay  = GetNode <RayCast>("Roof/RoofRay");
     floorRay = GetNode <RayCast>("Floor/FloorRay");
     frontRay = GetNode <RayCast>("FrontWall/FrontRay");
     backRay  = GetNode <RayCast>("BackWall/BackRay");
     leftRay  = GetNode <RayCast>("LeftWall/LeftRay");
     rightRay = GetNode <RayCast>("RightWall/RightRay");
     //Get the reference to the walls
     frontWall = GetNode <KinematicBody>("FrontWall");
     backWall  = GetNode <KinematicBody>("BackWall");
     leftWall  = GetNode <KinematicBody>("LeftWall");
     rightWall = GetNode <KinematicBody>("RightWall");
     roofWall  = GetNode <KinematicBody>("Roof");
     floorWall = GetNode <KinematicBody>("Floor");
     //Get the refferences to the platform sets
     platformSet1Scene = ResourceLoader.Load("res://Scenes/PlatformSet1.tscn") as PackedScene;
     platformSet2Scene = ResourceLoader.Load("res://Scenes/PlatformSet2.tscn") as PackedScene;
     platformSet3Scene = ResourceLoader.Load("res://Scenes/PlatformSet3.tscn") as PackedScene;
     platformSet4Scene = ResourceLoader.Load("res://Scenes/PlatformSet4.tscn") as PackedScene;
     platformSet5Scene = ResourceLoader.Load("res://Scenes/PlatformSet5.tscn") as PackedScene;
     platformSet6Scene = ResourceLoader.Load("res://Scenes/PlatformSet6.tscn") as PackedScene;
     platformSet7Scene = ResourceLoader.Load("res://Scenes/PlatformSet7.tscn") as PackedScene;
     //Grab the reference to the exit walls scene
     exitWallScene = ResourceLoader.Load("res://Scenes/ExitWall.tscn") as PackedScene;
 }
コード例 #8
0
        public AnimationDrivenLocomotion(
            AnimationTree animationTree,
            Skeleton skeleton,
            AnimationStates states,
            Blender2D blender,
            TimeScale timeScale,
            string idleState,
            string moveState,
            KinematicBody target,
            Physics3DSettings physicsSettings,
            ITimeSource timeSource,
            bool active,
            ILoggerFactory loggerFactory) : base(target, physicsSettings, timeSource, active, loggerFactory)
        {
            Ensure.That(animationTree, nameof(animationTree)).IsNotNull();
            Ensure.That(skeleton, nameof(skeleton)).IsNotNull();
            Ensure.That(states, nameof(states)).IsNotNull();
            Ensure.That(blender, nameof(blender)).IsNotNull();
            Ensure.That(timeScale, nameof(timeScale)).IsNotNull();
            Ensure.That(idleState, nameof(idleState)).IsNotNullOrEmpty();
            Ensure.That(moveState, nameof(moveState)).IsNotNullOrEmpty();

            AnimationTree = animationTree;
            Skeleton      = skeleton;
            States        = states;
            Blender       = blender;
            TimeScale     = timeScale;
            IdleState     = idleState;
            MoveState     = moveState;
        }
コード例 #9
0
 protected override Validation <string, AnimationDrivenLocomotion> CreateService(
     KinematicBody target,
     Physics3DSettings physicsSettings,
     ILoggerFactory loggerFactory)
 {
     return
         (from manager in AnimationManager
          .ToValidation("Failed to find the animation manager.")
          from skeleton in Skeleton
          .ToValidation("Failed to find the skeleton.")
          from states in StatesPath.TrimToOption().Bind(manager.FindStates)
          .ToValidation($"Unable to find an AnimationStates control at '{StatesPath}'.")
          from blender in Blend2DPath.TrimToOption().Bind(manager.FindBlender2D)
          .ToValidation($"Unable to find a Blender2D control at '{Blend2DPath}'.")
          from timeScale in TimeScalePath.TrimToOption().Bind(manager.FindTimeScale)
          .ToValidation($"Unable to find a TimeScale control at '{TimeScalePath}'.")
          from idleState in IdleState.TrimToOption()
          .ToValidation("Idle state value was not specified.")
          from moveState in MoveState.TrimToOption()
          .ToValidation("Move state value was not specified.")
          select new AnimationDrivenLocomotion(
              manager.AnimationTree,
              skeleton,
              states,
              blender,
              timeScale,
              idleState,
              moveState,
              target,
              physicsSettings,
              this,
              Active,
              loggerFactory));
 }
コード例 #10
0
        public override void _Ready()
        {
            GD.Print("NOTIFY: SpawnOwnPlayer Ready started");
            _globals = GetNode <Globals>("/root/Globals");
            if (_globals.PlayingAsHost)
            {
                GD.Print("NOTIFY: SpawnOwnPlayer as Host");
                PackedScene   playerScene = ResourceLoader.Load <PackedScene>(_playerPath);
                KinematicBody player      = playerScene?.Instance() as KinematicBody;
                if (player == null)
                {
                    return;
                }

                CallDeferred("add_child", player);
                _globals.OwnPlayerBody = player;

                player.Name = _globals.HostId.ToString();
                Transform playerTransform = player.Transform;
                playerTransform.origin = DefaultSpawnPos;
                player.Transform       = playerTransform;
            }
            else
            {
                GD.Print("NOTIFY: SpawnOwnPlayer as Client, sending");
                var packet = Utils.GetSpawnBytes(true, _globals.OwnId.ToString(),
                                                 ActionType.PlayerSpawn, DefaultSpawnPos);
                SteamNetworking.SendP2PPacket(_globals.HostId, packet, (uint)packet.Length,
                                              EP2PSend.k_EP2PSendReliable);
            }
        }
コード例 #11
0
ファイル: RLCharacterAgent.cs プロジェクト: gilcoder/AI4U
        public override void OnSetup()
        {
            body            = GetParent()  as KinematicBody;
            initialPosition = body.Translation;
            initialRotation = body.Rotation;

            base.OnSetup();
            onFloorSensor = new KinematicBodyOnFloorSensor();
            onFloorSensor.perceptionKey = "is_on_floor";
            onFloorSensor.type          = SensorType.sbool;
            onFloorSensor.shape         = new int[] {};
            onFloorSensor.isState       = true;
            onFloorSensor.resettable    = true;
            onFloorSensor.OnBinding(this);
            AddSensor(onFloorSensor);

            positionSensor = new PositionSensor();
            positionSensor.perceptionKey = "my_position";
            positionSensor.type          = SensorType.sfloatarray;
            positionSensor.shape         = new int[] { 3 };
            positionSensor.isState       = true;
            positionSensor.isGlobal      = this.globalPositionSensor;
            positionSensor.resettable    = true;
            positionSensor.OnBinding(this);
            AddSensor(positionSensor);
        }
コード例 #12
0
            public override void initialize()
            {
                base.initialize();

                _body             = entity.addComponent <KinematicBody>();
                _body.maxVelocity = new Vector2(200, 200);
                _body.drag        = new Vector2(80, 80);
            }
コード例 #13
0
 public override void _Ready()
 {
     teleportPoint = GetNode <Spatial>("../StartRoom/TeleportPoint");
     teleportTimer = GetNode <Timer>("TeleportTimer");
     winTimer      = GetNode <Timer>("WinTimer");
     player        = GetNode <KinematicBody>("../PlayerBody");
     SetStateEvent.RegisterListener(SetState);
 }
コード例 #14
0
ファイル: Turret.cs プロジェクト: LeonWilzer/Godot-Test-FPS
 public void BodyEnteredVision(Godot.Object _body)
 {
     if (_currentTarget == null && _body is KinematicBody)
     {
         _currentTarget    = (Godot.Object)_body;
         _currentKinematic = (KinematicBody)_body;
         _isActive         = true;
     }
 }
コード例 #15
0
 private void _on_Area_body_exited(KinematicBody body)                                      //si el cuerpo entro al area esta relacionado al puntaje
 {
     if (body.IsInGroup("pajaro"))                                                          //si esta en el grupo pajaro
     {
         GD.Print("el pajaro paso por la columna");                                         //imprimo por consola
         GetParent().GetParent <Nivel1>().puntuacion++;                                     //sumo 1 a puntuación
         ((AudioStreamPlayer)GetTree().GetNodesInGroup("sonido_puntos")[0]).Playing = true; //pongo play al sonido puntos
     }
 }
コード例 #16
0
ファイル: Body.cs プロジェクト: blukatdevelopment/3DProject
 public virtual void AssignActor(Actor actor, bool addCamera, string headNodePath)
 {
     this.actor = actor;
     head       = FindNode(headNodePath) as KinematicBody;
     if (addCamera)
     {
         camera = new Camera();
         head.AddChild(camera);
     }
 }
コード例 #17
0
 // Called when the node enters the scene tree for the first time.
 public override void _Ready()
 {
     _door = GetNode <KinematicBody>("Door");
     _area = GetNode <Area>("Area");
     _area.Connect("body_entered", this, "BodyEnteredArea");
     _area.Connect("body_exited", this, "BodyExitedArea");
     _maxTotalTransform = _door.GlobalTransform.Translated(new Vector3(MaxOpen, 0, 0));
     _originalTransform = _door.GlobalTransform;
     _translation       = GlobalTransform;
     _opening           = false;
 }
コード例 #18
0
ファイル: Enemy.cs プロジェクト: blockspacer/Gladiator-2094
 // Called when the node enters the scene tree for the first time.
 public override void _Ready()
 {
     arena     = GetTree().GetRoot().GetNode <Arena>("Spatial");
     ani       = GetNode <AnimationPlayer>("AnimationPlayer");
     nav       = GetNode <Navigation>("../Navigation");
     head      = GetNode <Spatial>("Head");
     player    = GetNode <KinematicBody>("../Player");
     playerPos = player.Translation;
     path      = nav.GetSimplePath(Translation, playerPos, true);
     pathPos   = Translation;
 }
コード例 #19
0
 protected abstract Validation <string, TCharacter> CreateService(
     string key,
     string displayName,
     TRace race,
     IEnumerable <IAttribute> attributes,
     TVision vision,
     TLocomotion locomotion,
     Skeleton skeleton,
     IActionSet actions,
     IAnimationManager animationManager,
     KinematicBody node,
     ILoggerFactory loggerFactory);
コード例 #20
0
 protected override Validation <string, TLocomotion> CreateService(
     KinematicBody target, ILoggerFactory loggerFactory)
 {
     return(PhysicsSettings.Bind(v => Optional(v.Value))
            .ToValidation("Failed to read physics 3D settings.")
            .Bind(settings => CreateService(target, settings, loggerFactory))
            .Map(service =>
     {
         service.ApplyGravity = ApplyGravity;
         return service;
     }));
 }
コード例 #21
0
    public override void _Ready()
    {
        GD.Randomize();

        player = (KinematicBody)GetNode(playerNode);
        feet   = (RayCast)GetNode(feetNode);

        for (int i = 0; i < GetChildCount(); i++)
        {
            footStepList[GetChild(i).Name] = (Node)GetChild(i);
        }
    }
コード例 #22
0
 public override void OnBinding(Agent agent)
 {
     type = SensorType.sfloatarray;
     body = agent.GetBody() as KinematicBody;
     if (itemName != null)
     {
         for (int i = 0; i < itemName.Length; i++)
         {
             nameCode[itemName[i]] = itemCode[i];
         }
     }
 }
コード例 #23
0
    // Start is called before the first frame update
    private void Awake()
    {
        this.kinematic = GetComponent <KinematicBody>();

        if (this.path)
        {
            StartCoroutine(this.CoroutinePatrol());
        }
        else
        {
            StartCoroutine(this.CoroutineWaitAndJump());
        }
    }
コード例 #24
0
    public void CalcMeshes()
    {
        KinematicBody player = (KinematicBody)FindNode("Player");
        int           ocx = 0; int ocy = 0;

        while (true)
        {
            try {
                Vector3 ppos = player.Translation;
                int     cx   = (int)Math.Round((ppos.x) / 16);
                int     cy   = (int)Math.Round((ppos.z) / 16);

                if (ocx != cx || ocy != cy)
                {
                    GD.Print("player at chunk " + cx + "," + cy);
                }
                Label lbl = (Label)FindNode("Label");
                if (lbl != null)
                {
                    lbl.Text = "player at chunk " + cx + "," + cy;
                }

                ocx = cx; ocy = cy;
                for (int r = 0; r < vischunks; r++)
                {
                    for (int r2 = -r; r2 < r + 1; r2++)
                    {
                        TestAndCreateChunk(cx - r2, cy - r);
                        TestAndCreateChunk(cx - r2, cy + r);
                        TestAndCreateChunk(cx - r, cy - r2);
                        TestAndCreateChunk(cx + r, cy - r2);
                    }
                }
                lock (lck) foreach (Chunk c in chunks.Values)
                    {
                        try
                        {
                            if (!c.mesh_ready)
                            {
                                c.CalcMesh();
                            }
                        }
                        catch (Exception ex)
                        {
                            GD.PrintErr("Exception: " + ex.Message);
                        }
                    }
                AddChilds();
            } catch (Exception e) { GD.PrintErr(e); }
        }
    }
コード例 #25
0
        private void OnCollisionExit(KinematicBody body)
        {
            var player = body as Movement;

            if (player == null)
            {
                return;
            }

            _player           = null;
            _enabled          = false;
            player.GravityDir = Vector3.Down;
            //AddSphere(body.Translation);
        }
コード例 #26
0
ファイル: Turret.cs プロジェクト: LeonWilzer/Godot-Test-FPS
    public void BodyExitedVision(Godot.Object _body)
    {
        if (_currentTarget != null && _body == _currentTarget)
        {
            _currentTarget    = null;
            _currentKinematic = null;
            _isActive         = false;

            _flashTimer           = 0;
            _fireTimer            = 0;
            _nodeFlashTwo.Visible = false;
            _nodeFlashOne.Visible = false;
        }
    }
コード例 #27
0
    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        // Get references to parts of tanks
        trackleft  = (MeshInstance)GetNode("TrackLeft");
        trackright = (MeshInstance)GetNode("TrackRight");
        body       = (MeshInstance)GetNode("Body");
        turret     = (KinematicBody)GetNode("Turret");
        gun        = (MeshInstance)GetNode("Turret/TurretMesh/Gun");

        // load sounds
        trackmovementsound = (AudioStreamPlayer3D)GetNode("SoundGroup/TrackMovementSound");
        firesound          = (AudioStreamPlayer3D)GetNode("SoundGroup/FireSound");
        explodesound       = (AudioStreamPlayer3D)GetNode("SoundGroup/ExplosionSound");
        soundgroup         = GetNode("SoundGroup");

        // load cameras
        thirdpersoncamera = (Camera)GetNode("ThirdPersonCam");
        firstpersoncamera = (Camera)GetNode("Turret/TurretMesh/Gun/BulletSpawn/Camera");

        // reference to explosion for death
        explosion = (Particles)GetNode("Explosion/Particles");
        explosion.SetEmitting(false);

        // Load bullet scene
        bulletscene = ResourceLoader.Load("res://Bullet.tscn") as Godot.PackedScene;

        // Set a color for the tank
        setTankColor(defaultTankColor);

        health = maxhealth;

        // add signals
        AddUserSignal("dec_local_health");
        AddUserSignal("respawn");
        AddUserSignal("bullet_fired");

        // connect respawn timer
        AddChild(deathtimer);
        deathtimer.Connect("timeout", this, "Respawn");
        deathtimer.SetWaitTime(RESPAWN_SECONDS);

        SetProcess(true);

        // required to appear at spawn
        MoveAndSlide(new Vector3(0, 0, 0), new Vector3(0, 1, 0), true);

        // enforce no flying tanks issue #20
        originalY = Transform.origin.y;
    }
コード例 #28
0
ファイル: Barrel.cs プロジェクト: StadnickiK/GodotProject
//  // Called every frame. 'delta' is the elapsed time since the previous frame.
    public override void _Process(float delta)
    {
        var upDir = new Vector3(1, 0, 0);

        targetPos  = GetNode <RigidBody>("/root/World/Target");
        ktargetPos = GetNode <KinematicBody>("/root/World/KTarget");
        //LookAt(ktargetPosition.GlobalTransform.origin,upDir);
        //LookAt(targetPos.GlobalTransform.origin,upDir);

        //ray.LookAt(targetPos.GlobalTransform.origin,upDir);
        //GD.Print(delta);
        if (ray.IsColliding())
        {
            ShootAnim(delta);
        }
    }
コード例 #29
0
ファイル: Main.cs プロジェクト: nirasv/Falling
    void _on_Spawner_timeout()
    {
        Spatial spatial = GetNode <Spatial>("Spatial/Tunnel/Spatial");

        obstacle = (KinematicBody)obstacleScene.Instance();
        AddChild(obstacle);
        obstacle.Translation = new Vector3(0, 0, 52);

        var timer = GetNode <Timer>("Spawner");

        timer.WaitTime = RangeLerp(time, 1, trackLenght, 0.5f, 0.05f);
        if (progressBar.Value > progressBar.MaxValue)
        {
            GetTree().ReloadCurrentScene();
        }
        progressBar.Value += timer.WaitTime;
    }
コード例 #30
0
    private void GeneratePlatformSet()
    {
        //3hours and 31min left and this decides to work perfectly the first time round, why not hte loos 4 hours ago WHYYYYYYY!?!??!1?!!
        //Seed the random number generator
        rng.Seed = OS.GetTicksUsec();
        int platformSet = rng.RandiRange(1, 7);

        switch (platformSet)
        {
        case 1:
            platformSet1 = (KinematicBody)platformSet1Scene.Instance();
            AddChild(platformSet1);
            break;

        case 2:
            platformSet2 = (KinematicBody)platformSet2Scene.Instance();
            AddChild(platformSet2);
            break;

        case 3:
            platformSet3 = (KinematicBody)platformSet3Scene.Instance();
            AddChild(platformSet3);
            break;

        case 4:
            platformSet4 = (KinematicBody)platformSet4Scene.Instance();
            AddChild(platformSet4);
            break;

        case 5:
            platformSet5 = (KinematicBody)platformSet5Scene.Instance();
            AddChild(platformSet5);
            break;

        case 6:
            platformSet6 = (KinematicBody)platformSet6Scene.Instance();
            AddChild(platformSet6);
            break;

        case 7:
            platformSet7 = (KinematicBody)platformSet7Scene.Instance();
            AddChild(platformSet7);
            break;
        }
    }
コード例 #31
0
 void Awake()
 {
     body = GetComponent<KinematicBody>();
     costumeBuilder = GetComponent<CostumeBuilder>();
 }
コード例 #32
0
 void Awake()
 {
     body = transform.parent.GetComponent<KinematicBody>();
 }
コード例 #33
0
 void Awake()
 {
     player = GameObject.FindGameObjectWithTag("Player");
     body = GetComponent<KinematicBody>();
     player.GetComponent<TaskList>().aliensRemaining++;
 }
コード例 #34
0
 void Awake()
 {
     boxCollider = (BoxCollider2D)transform.collider2D;
     body = GetComponent<KinematicBody>();
 }
コード例 #35
0
 void Awake()
 {
     body = GetComponent<KinematicBody>();
 }