public static IEquippable CreatePlayerMelee( MeleeHitVolume volume, SwordThrowProjectile projectile, LaserDot aimLaser) { InvWeapMelee weapon = new InvWeapMelee( volume, projectile, aimLaser, 0.3f, 25); return(weapon); }
public void CmdShoot(Vector2 direction, Vector2 position) { GameObject laser = (GameObject)Instantiate(laserDot, position, Quaternion.identity); LaserDot dot = laser.GetComponent <LaserDot>(); Player p = GetComponent <Player>(); laser.GetComponent <Rigidbody2D>().velocity = bulletSpeed * direction; dot.bulletOwner = p; dot.gunType = p.gunNum; NetworkServer.Spawn(laser.gameObject); }
public InvWeapMelee( MeleeHitVolume volume, SwordThrowProjectile projectile, LaserDot aimLaser, float refireTime, int damage) { _volume = volume; _projectile = projectile; _aimLaser = aimLaser; _refireTime = refireTime; _damage = damage; }
public LaserDot[] GenerateShotgunShells(Vector2 direction, Vector2 position) { LaserDot[] lasers = new LaserDot[5]; Vector2 newDir; for (int i = 0; i < 5; i++) { newDir = Quaternion.AngleAxis(Random.Range(-10, 10), Vector3.back) * direction; lasers[i] = (LaserDot)CreateParticle((Particle)laserDot, position); //lasers[i].GetComponent<Rigidbody2D>().velocity = velocity * newDir; } return(lasers); }
// 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); }
// 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); }