Ejemplo n.º 1
0
    public SwordThrowProjectile SpawnThrownSword(bool addToTree = true, Node overrideParent = null)
    {
        Node parent = SelectParent(addToTree, overrideParent);
        SwordThrowProjectile result = ZqfGodotUtils.CreateInstance <SwordThrowProjectile>(Path_ThrownSword, parent);

        return(result);
    }
Ejemplo n.º 2
0
        public static IEquippable CreatePlayerMelee(
            MeleeHitVolume volume,
            SwordThrowProjectile projectile,
            LaserDot aimLaser)
        {
            InvWeapMelee weapon = new InvWeapMelee(
                volume, projectile, aimLaser, 0.3f, 25);

            return(weapon);
        }
Ejemplo n.º 3
0
 public InvWeapMelee(
     MeleeHitVolume volume,
     SwordThrowProjectile projectile,
     LaserDot aimLaser,
     float refireTime,
     int damage)
 {
     _volume     = volume;
     _projectile = projectile;
     _aimLaser   = aimLaser;
     _refireTime = refireTime;
     _damage     = damage;
 }
Ejemplo n.º 4
0
    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        Main m = GetNode <Main>("/root/main");

        _input = new FPSInput();

        _hudState            = new HUDPlayerState();
        _hudState.health     = 80;
        _hudState.ammoLoaded = 999;
        _hudState.weaponName = "Stakegun";

        // find Godot scene nodes
        _body       = GetNode <KinematicWrapper>("actor_base");
        _body.actor = this;
        _body.HideModels();

        _head = GetNode <Spatial>("actor_base/head");

        _laserDot = GetNode <LaserDot>("laser_dot");
        _laserDot.CustomInit(_head, uint.MaxValue, 1000);

        _thrownSword = m.factory.SpawnThrownSword(false);
        m.AddOrphanNode(_thrownSword);

        // init components
        _fpsCtrl = new FPSController(_body, _head);


        // Inventory
        _inventory = new ActorInventory();
        _inventory.Init(_head, 1);

        // Add weapons
        _inventory.AddWeapon(AttackFactory.CreatePlayerShotgun(_head, _body));
        _inventory.AddWeapon(AttackFactory.CreateStakegun(_head, _body));

        m.cam.AttachToTarget(_head);
    }
Ejemplo n.º 5
0
 public void SetDiscProjectile(SwordThrowProjectile proj)
 {
     _projectile = proj;
 }
Ejemplo n.º 6
0
    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        //_main = GetNode<Main>("/root/main");
        _main = Main.i;

        _input = new FPSInput();

        _hudState            = new HUDPlayerState();
        _hudState.health     = 80;
        _hudState.ammoLoaded = 999;
        _hudState.weaponName = "Stakegun";

        // find Godot scene nodes
        _body       = GetNode <KinematicWrapper>("actor_base");
        _body.actor = this;
        _body.HideModels();

        _head        = GetNode <Spatial>("actor_base/head");
        _meleeVolume = _head.GetNode <MeleeHitVolume>("melee_hit_volume");

        ///////////////////////////////////////
        // view models

        // grab hands placeholder and attach it to the head node
        _handsPlaceholder = GetNode <ViewModel>("hands_placeholder");
        Transform t = _handsPlaceholder.GlobalTransform;

        RemoveChild(_handsPlaceholder);
        _head.AddChild(_handsPlaceholder);
        _handsPlaceholder.GlobalTransform = t;
        _handsPlaceholder.SetEnabled(false);

        // same for placeholder gun
        _gunPlaceholder = GetNode <ViewModel>("view_placeholder_gun");
        ZqfGodotUtils.SwapSpatialParent(_gunPlaceholder, _head);
        _gunPlaceholder.SetEnabled(true);
        _viewModel = _gunPlaceholder;

        _laserDot = GetNode <LaserDot>("laser_dot");
        _laserDot.CustomInit(_head, uint.MaxValue, 1000);

        _thrownSword = _main.factory.SpawnThrownSword(false);
        _main.AddOrphanNode(_thrownSword);

        // init components
        _fpsCtrl = new FPSController(_body, _head);


        // Inventory
        _inventory = new ActorInventory();
        _inventory.Init(_head, 1);

        // Add weapons
        SwordThrowProjectile prj = _main.factory.SpawnThrownSword();

        _inventory.AddWeapon(AttackFactory.CreatePlayerMelee(_meleeVolume, prj, _laserDot));
        _inventory.AddWeapon(AttackFactory.CreatePlayerShotgun(_head, _body));
        _inventory.AddWeapon(AttackFactory.CreateStakegun(_head, _body));
        _inventory.AddWeapon(AttackFactory.CreateLauncher(_head, _body));
        _inventory.AddWeapon(new InvWeapGodhand(_head, _laserDot));
        _inventory.SelectWeaponByIndex(1);

        _main.cam.AttachToTarget(_head, Vector3.Zero, GameCamera.ParentType.Player);

        if (_entId == 0)
        {
            // no id previous set, request one
            _entId = _main.game.ReserveActorId(1);
            _main.game.RegisterActor(this);
        }

        _main.Broadcast(GlobalEventType.PlayerSpawned, this);
    }