Пример #1
0
        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;
        }
Пример #2
0
 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;
 }
Пример #3
0
        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;
        }
Пример #4
0
 /// <summary>
 /// Gets the lap count for the given player.
 /// </summary>
 public int GetLapCount(Player player)
 {
     return lapData[player.ID].second;
 }
Пример #5
0
 public BigApple(Player user)
     : base(ref user, "BigApple")
 {
     origin = user.NodePosition;
 }
Пример #6
0
 //Player User;
 public SpeedMuffin(ref Player user)
     : base(ref user, "SpeedMuffin")
 {
     origin = user.NodePosition;
     //User = user;
 }
Пример #7
0
        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;
                            }
                        }

                    }
                }
            }
        }
Пример #8
0
 public SmartApple(Player user)
     : base(ref user, "SmartApple")
 {
     origin = user.NodePosition;
     playerManager = LKernel.GetG<PlayerManager>();
 }