Esempio n. 1
0
        public static void SpawnPlayerAtPosition(Player player, Vector3 position, Quaternion rotation)
        {
            //Make sure player controlled entities are destroyed.
            PlayerManager.Instance.DestroyPlayerControlledEntities(player);

            LoadOut loadOut = new LoadOut();

            loadOut.itemNames = new string[] { "Scout", "PlasmaFusor", "GrenadeLauncher", "ChainGun" };

            LoadOutToken loadOutToken = new LoadOutToken(loadOut);

            GameObject baseMech = DatabaseManager.Instance.PrefabDatabase.GetPrefabByName("BaseMech");
            BoltEntity entity   = BoltNetwork.Instantiate(baseMech, loadOutToken, position, rotation);

            if (entity != null)
            {
                Unit unit = entity.GetComponent <Unit>();
                unit.Setup(player.guid, player.teamId);
                unit.gameObject.AddComponent <AbilityVelocityRedirection>();

                if (player.connection == null)
                {
                    entity.TakeControl();
                }
                else
                {
                    entity.AssignControl(player.connection);
                }

                player.SetControlledEntity(entity);
            }
        }
Esempio n. 2
0
        public static void OnPlayerRequestLoadOut(Player player, LoadOut loadOut)
        {
            LoadOutToken loadOutToken = new LoadOutToken(loadOut);

            player.controlledEntity.GetComponent <RobotController>().state.LoadOutToken = loadOutToken;
        }