Esempio n. 1
0
        private static Projectile SpawnLocal(Vector2 position, Vector2 direction, float speed, int seed)
        {
            var spawned = PoolObject.Spawn(Spawnables.Get <Projectile>("Projectile"));

            spawned.transform.position = position;
            spawned.Direction          = direction;
            spawned.Speed = speed;
            spawned.Seed  = seed;

            return(spawned);
        }
Esempio n. 2
0
        public static void DisplayShot(Vector2 start, Vector2 end)
        {
            if (effect == null)
            {
                effect = Spawnables.Get <HitscanEffect>("HitscanEffect");
            }

            var spawned = PoolObject.Spawn(effect);

            spawned.Set(start, end);
        }
Esempio n. 3
0
        /// <summary>
        /// Sets the mounted weapon to the mounted weapon with the specified prefab name. Only works when called from the server.
        /// If the weapon is null, the current weapon is removed instantly.
        /// </summary>
        /// <param name="spot">The spot. Should be on this vehicle, and not null!</param>
        /// <param name="mountedWeaponName">The name of the prefab.</param>
        public void SetWeapon(MountedWeaponSpot spot, string mountedWeaponName)
        {
            if (string.IsNullOrWhiteSpace(mountedWeaponName))
            {
                Debug.LogError("Null or whitespace name. Cannot set mounted weapon!");
                return;
            }

            var spawnable = Spawnables.Get <MountedWeapon>(mountedWeaponName);

            if (spawnable != null)
            {
                var spawned = Instantiate(spawnable);
                SetWeapon(spot, spawned);
                JNet.Spawn(spawned.gameObject);
            }
            else
            {
                Debug.LogError($"Failed to spawn mounted weapon from name {mountedWeaponName}.");
            }
        }