コード例 #1
0
 public override void _Ready()
 {
     GetNode("Vision_Area").Connect("body_entered", this, nameof(BodyEnteredVision));
     GetNode("Vision_Area").Connect("body_exited", this, nameof(BodyExitedVision));
     _nodeTurretHead = GetNode <Spatial>("Head");
     _nodeRayCast    = GetNode <RayCast>("Head/Ray_Cast");
     _nodeFlashOne   = GetNode <Spatial>("Head/Flash");
     _nodeFlashTwo   = GetNode <Spatial>("Head/Flash_2");
     _nodeRayCast.AddException(this);
     _nodeRayCast.AddException(GetNode("Base/Static_Body"));
     _nodeRayCast.AddException(GetNode("Head/Static_Body"));
     _nodeRayCast.AddException(GetNode("Vision_Area"));
     _smokeParticles          = GetNode <Particles>("Smoke");
     _smokeParticles.Emitting = false;
     _turretHealth            = MaxTurretHealth;
 }
コード例 #2
0
ファイル: Turret.cs プロジェクト: LeonWilzer/Godot-Test-FPS
    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        _TurretDamageBullet  = 20;
        _TurretDamageRaycast = 5;

        _flashTime  = 0.1f;
        _flashTimer = 0;

        _fireTime  = 0.8f;
        _fireTimer = 0;

        _ammoInTurret     = 20;
        _ammoInFullTurret = 20;
        _ammoReloadTime   = 4;
        _ammoReloadTimer  = 0;

        _isActive = false;

        _playerHeight = 3;

        _maxTurretHealth = 60;
        _turretHealth    = _maxTurretHealth;

        _destroyedTime  = 20;
        _destroyedTimer = 0;

        _bulletScene = ResourceLoader.Load <PackedScene>("res://weaponry/bullets/standard/StandardBullet.tscn");

        GetNode <Area>("Vision_Area").Connect("body_entered", this, "BodyEnteredVision");
        GetNode <Area>("Vision_Area").Connect("body_exited", this, "BodyExitedVision");

        _nodeTurretHead = GetNode <Spatial>("Head");
        _nodeRaycast    = GetNode <RayCast>("Head/Ray_Cast");
        _nodeFlashOne   = GetNode <MeshInstance>("Head/Flash");
        _nodeFlashTwo   = GetNode <MeshInstance>("Head/Flash_2");

        _nodeRaycast.AddException(this);
        _nodeRaycast.AddException(GetNode <StaticBody>("Base/Static_Body"));
        _nodeRaycast.AddException(GetNode <StaticBody>("Head/Static_Body"));
        _nodeRaycast.AddException(GetNode <Area>("Vision_Area"));

        _nodeFlashOne.Visible = false;
        _nodeFlashTwo.Visible = false;

        _smokeParticles          = GetNode <Particles>("Smoke");
        _smokeParticles.Emitting = false;
    }
コード例 #3
0
    public override void _Ready()
    {
        GetNode <Area>("Vision_Area").Connect("body_entered", this, "BodyEnteredVision");
        GetNode <Area>("Vision_Area").Connect("body_exited", this, "BodyExitedVision");

        _nodeHead     = GetNode <Spatial>("Head");
        _nodeRaycast  = GetNode <RayCast>("Head/Ray_Cast");
        _nodeFlashOne = GetNode <MeshInstance>("Head/Flash");
        _nodeFlashTwo = GetNode <MeshInstance>("Head/Flash_2");

        _nodeRaycast.AddException(this);
        _nodeRaycast.AddException(GetNode <StaticBody>("Base/Static_Body"));
        _nodeRaycast.AddException(GetNode <StaticBody>("Head/Static_Body"));
        _nodeRaycast.AddException(GetNode <Area>("Vision_Area"));

        _nodeFlashOne.Visible = false;
        _nodeFlashTwo.Visible = false;

        _smokeParticles          = GetNode <CPUParticles>("Smoke");
        _smokeParticles.Emitting = false;

        _turretHealth = MAX_TURRET_HEALTH;
    }
コード例 #4
0
    public override void _Ready()
    {
        // Get nodes
        BodyNode   = GetNode("Body") as Spatial;
        CameraNode = BodyNode.GetNode("Camera") as CameraFirstPerson;
        ViewModel  = CameraNode.GetNode("ViewModel") as PlayerViewModel;

        // Firing Raycast
        FiringRaycast         = CameraNode.GetNode("FiringRaycast") as RayCast;
        FiringRaycast.Enabled = true;
        FiringRaycast.AddException(this);
        FiringRaycast.CastTo = new Vector3(0, 0, -100.0f);

        // FloorRay setup
        FloorRay = GetNode("FloorRay") as RayCast;
        FloorRay.AddException(this);

        // Set mouse mode to captured
        Input.SetMouseMode(Input.MOUSE_MODE_CAPTURED);

        // Set default vars
        ResetVars();
    }
コード例 #5
0
        public CharacterPlayer(int x, int y, Level level)
            : base(x, y, level)
        {
            if (level != null)
            {
                _camera         = new Camera();
                _camera.Current = true;

                switch (Type)
                {
                case CharacterType.Player_East:
                    _camera.Transform = Transform.Identity.Rotated(Vector3.Up, Mathf.Pi * -0.5f);
                    break;

                case CharacterType.Player_West:
                    _camera.Transform = Transform.Identity.Rotated(Vector3.Up, Mathf.Pi * 0.5f);
                    break;

                case CharacterType.Player_South:
                    _camera.Transform = Transform.Identity.Rotated(Vector3.Up, Mathf.Pi * -1.0f);
                    break;
                }

                _moveSpeed = Level.CellSize * 200.0f;
                _turnSpeed = 3f;

                _useRay               = new RayCast();
                _useRay.Enabled       = true;
                _useRay.ExcludeParent = true;
                _useRay.CastTo        = Vector3.Forward * (Level.CellSize * 0.5f);
                _useRay.CollisionMask = (uint)(
                    Level.CollisionLayers.Characters |
                    Level.CollisionLayers.Static |
                    Level.CollisionLayers.Walls);
                _useRay.AddException(this);

                _camera.AddChild(_useRay);

                _flashDuration = 0.5f;

                _flashRect                  = new ColorRect();
                _flashRect.MouseFilter      = Control.MouseFilterEnum.Ignore;
                _flashRect.Color            = new Color(0.75f, 0.75f, 0f, 1f);
                _flashRect.AnchorTop        =
                    _flashRect.AnchorLeft   = 0f;
                _flashRect.AnchorRight      =
                    _flashRect.AnchorBottom = 1f;
                _flashRect.SetAsToplevel(true);
                _flashRect.ShowOnTop = true;
                _flashRect.Visible   = false;

                _flashTween = new Tween();
                _flashTween.Connect("tween_all_completed", this, "OnFlashTweenCompleted");
                _flashRect.AddChild(_flashTween);

                _flashCanvas = new CanvasLayer();
                _flashCanvas.AddChild(_flashRect);

                _camera.AddChild(_flashCanvas);

                AddChild(_camera);

                SetProcess(true);
                SetPhysicsProcess(true);
            }
        }