public Item SpawnItem(Player user, string itemName) { Item spawnedItem = null; //There is probably a better way to do this. switch(itemName) { case "SmartApple": { spawnedItem = new SmartApple(user); activeItems.Add(spawnedItem); } break; case "SpeedMuffin": { spawnedItem = new SpeedMuffin(ref user); activeItems.Add(spawnedItem); } break; default: { }break; } //if(spawnedItem!= null) return spawnedItem; }
public DummyItem(string itemType, Player _focus) { focus = _focus; Vector3 pos = focus.NodePosition; pos.y += 2; dummy = LKernel.GetG<Spawner>().Spawn(itemType, pos); Launch.OnEveryUnpausedTenthOfASecondEvent += EveryTenth; }
public Item(ref Player user, string itemName) { User = user; try { Body = LKernel.GetG<Spawner>().Spawn(itemName, User.Kart.ActualPosition + User.Kart.Vehicle.ForwardVector * 5.0f); } catch (Exception e) { } OnUse(); Launch.OnEveryUnpausedTenthOfASecondEvent += EveryTenth; }
/// <summary> /// Gets the lap count for the given player. /// </summary> public int GetLapCount(Player player) { return lapData[player.ID].second; }
public BigApple(Player user) : base(ref user, "BigApple") { origin = user.NodePosition; }
//Player User; public SpeedMuffin(ref Player user) : base(ref user, "SpeedMuffin") { origin = user.NodePosition; //User = user; }
protected override void OnUse() { base.OnUse(); LKernel.GetG<SoundMain>().Play3D("Apple Firing.mp3", origin, false); //Initial velocity: Forward at player speed + 10, with a good bit of up. //Vector3 itemVel = User.Kart.Vehicle.ForwardVector; //itemVel *= User.Kart.VehicleSpeed + 10.0f; //itemVel.y = 200.0f; //Body.Body.ApplyCentralImpulse(itemVel); Vector3 itemVel = User.Kart.Body.LinearVelocity * 1.2f; // using a multiplier is better, because if you add, the apple will go off at a weird angle sometimes itemVel.y = 200f; Body.Body.ApplyCentralImpulse(itemVel); Vector3 vecToPlayer; float leastLength = 0; if (LKernel.GetG<PlayerManager>().Players.Length > 1) { foreach (Player p in LKernel.GetG<PlayerManager>().Players) { if (p != User) { targetfound = true; vecToPlayer = Body.RootNode.Position - p.Kart.ActualPosition; //first kart is selected as initial target if (target == null) { target = p; leastLength = vecToPlayer.SquaredLength; } else { if (vecToPlayer.SquaredLength < leastLength) { leastLength = vecToPlayer.SquaredLength; target = p; } } } } } }
public SmartApple(Player user) : base(ref user, "SmartApple") { origin = user.NodePosition; playerManager = LKernel.GetG<PlayerManager>(); }