예제 #1
0
        public MelonLauncher(ItemManager itemManager, MasterRenderer renderer)
            : base(renderer, itemManager, ItemType.MelonLauncher)
        {
            ModelOffset      = new Vector3(-3.15f, -4f, 0.5f);
            aimModelOffset   = new Vector3(-0.75f, -2.35f, -6f);
            ThirdpersonScale = 0.7f;

            fovAnim   = new FloatAnim();
            modelAnim = new Vector3Anim();

            LoadModel("Models/melon-launcher.aosm");

            if (!GlobalNetwork.IsServer)
            {
                if (!itemManager.IsReplicated)
                {
                    AudioBuffer throwAudioBuffer = AssetManager.LoadSound("Weapons/Grenade/throw.wav");

                    if (throwAudioBuffer != null)
                    {
                        throwAudioSource = new AudioSource(throwAudioBuffer);
                        throwAudioSource.IsSourceRelative = true;
                        throwAudioSource.Pitch            = 1.5f;
                        throwAudioSource.Gain             = 0.2f;
                    }
                }
            }
        }
예제 #2
0
        public Gun(ItemManager itemManager, MasterRenderer renderer)
            : base(renderer, itemManager, ItemType.Gun)
        {
            CurrentMag = GunConfig.MagazineSize;
            StoredAmmo = GunConfig.MagazineSize * GunConfig.MaxStoredMags;

            if (GlobalNetwork.IsClient && GlobalNetwork.IsConnected)
            {
                ServerMag        = (ushort)CurrentMag;
                ServerStoredAmmo = (ushort)StoredAmmo;
            }

            fovAnim     = new FloatAnim();
            modelAnim   = new Vector3Anim();
            muzzleFlash = itemManager.GetMuzzleFlash();

            if (!GlobalNetwork.IsServer)
            {
                if (itemManager.IsReplicated)
                {
                    if (GunConfig.PrimaryFireAudio?.ReplicatedFilepath != null)
                    {
                        fireAudioSource = LoadAudioFromConfig(GunConfig.PrimaryFireAudio, replicated: true, far: false);
                    }

                    if (GunConfig.PrimaryFireAudio?.FarFilepath != null)
                    {
                        fireFarAudioSource = LoadAudioFromConfig(GunConfig.PrimaryFireAudio, replicated: true, far: true);
                    }

                    if (GunConfig.ReloadAudio?.ReplicatedFilepath != null)
                    {
                        reloadAudioSource = LoadAudioFromConfig(GunConfig.ReloadAudio, replicated: true);
                    }
                }
                else
                {
                    if (GunConfig.PrimaryFireAudio?.LocalFilepath != null)
                    {
                        fireAudioSource = LoadAudioFromConfig(GunConfig.PrimaryFireAudio);
                    }

                    if (GunConfig.ReloadAudio?.LocalFilepath != null)
                    {
                        reloadAudioSource = LoadAudioFromConfig(GunConfig.ReloadAudio);
                    }

                    AudioBuffer dryFireBuffer = AssetManager.LoadSound("Weapons/dry-fire.wav");

                    if (dryFireBuffer != null)
                    {
                        dryFireAudioSource = new AudioSource(dryFireBuffer);
                        dryFireAudioSource.IsSourceRelative = true;
                        dryFireAudioSource.Gain             = 0.5f;
                    }
                }
            }
        }
예제 #3
0
        public CameraFX(Player player, Camera camera)
        {
            this.player = player;
            this.camera = camera;

            offsetAnim      = new Vector3Anim();
            shakeFactorAnim = new FloatAnim();
            rollAnim        = new FloatAnim();
        }
예제 #4
0
        public ItemViewbob(Player player)
        {
            this.player = player;

            bobAnim      = new Vector3Anim();
            tiltAnim     = new FloatAnim();
            swayAnim     = new Vector3Anim();
            kickbackAnim = new FloatAnim();

            lastYaw   = Camera.Active.Yaw;
            lastPitch = Camera.Active.Pitch;

            cc = player.GetComponent <CharacterController>();
        }
예제 #5
0
        public ServerMPPlayer(World world, Vector3 position, Team team)
            : base(null, world, new SimpleCamera(), position, team)
        {
            camera = GetCamera();

            playerTransforms = new List <PlayerTransform>();
            bulletsToFire    = new Queue <NetworkBullet>();
            movementAnim     = new Vector3Anim();

            // Let client's handle movement.
            // - We don't need to bother with terrain collision, only entity collision.
            // - Gravity shouldn't be bother with either.
            CharacterController.CanCollideWithTerrain = false;
            CharacterController.IsAffectedByGravity   = false;

            CharacterController.OnCollision += CharacterController_OnCollision;

            CreateStarterBackpack();
        }
예제 #6
0
        public CommandPost(Vector3 position, Team team)
            : base(position)
        {
            startPosition = position;
            Team          = team;

            positionAnim = new Vector3Anim();

            // Setup physics body
            float   cubeSize = 1.5f; // blockSize * dims
            Vector3 size     = new Vector3(cubeSize * 9, cubeSize * 10, cubeSize * 7);

            PhysicsBody = new VoxelPhysicsBody(size, 2f, cubeSize);
            AddComponent(PhysicsBody);

            PhysicsBody.CanCollideWithSoft  = true;
            PhysicsBody.CanBePushedBySoft   = false;
            PhysicsBody.IsAffectedByGravity = true;
            PhysicsBody.CanBeSteppedOn      = false;

            if (!GlobalNetwork.IsServer)
            {
                // Setup renderer
                renderer = new VoxelRenderComponent();
                AddComponent(renderer);

                string modelPath = team == Team.A ? "Models/commandpost-red.aosm" : "Models/commandpost-blue.aosm";
                renderer.VoxelObject = AssetManager.LoadVoxelObject(modelPath, BufferUsageHint.StaticDraw);

                if (commandpostIconTex == null)
                {
                    commandpostIconTex = GLoader.LoadTexture("Textures/Gui/commandpost.png");
                }

                // Setup icon
                IconRenderer icon = new IconRenderer();
                AddComponent(icon);

                icon.Size   = new Vector2(16, 16);
                icon.Image  = new Image(commandpostIconTex, team == Team.A ? new Color(255, 0, 0, 128) : new Color(0, 0, 255, 128));
                icon.Offset = renderer.VoxelObject.UnitSize / 2f;
            }
        }
        public ReplicatedPlayer(MasterRenderer renderer, World world, SimpleCamera camera, Vector3 position, Team team)
            : base(renderer, world, camera, position, team)
        {
            this.camera = camera;

            interpPos = new Vector3Anim();
            interpPos.SnapTo(position);

            yawAnim   = new FloatAnim();
            pitchAnim = new FloatAnim();

            // This is fully server controlled
            ItemManager.DontUpdateItems   = true;
            ItemManager.IsReplicated      = true;
            CharacterController.IsEnabled = false;

            CreateStarterBackpack();

            AudioBuffer jumpAudioBuffer = AssetManager.LoadSound("Player/jump.wav");

            if (jumpAudioBuffer != null)
            {
                jumpAudioSource             = new AudioSource(jumpAudioBuffer);
                jumpAudioSource.Gain        = 0.2f;
                jumpAudioSource.MaxDistance = 100f;
            }

            AudioBuffer landAudioBuffer = AssetManager.LoadSound("Player/land.wav");

            if (landAudioBuffer != null)
            {
                landAudioSource             = new AudioSource(landAudioBuffer);
                landAudioSource.Gain        = 0.2f;
                landAudioSource.MaxDistance = 120f;
            }

            walkingAudioSource = new CyclicAudioSource("Player/footstep.wav", 1, 0f,
                                                       relative: false, maxDistance: 100f);

            runningAudioSource = new CyclicAudioSource("Player/run.wav", 1, 0f,
                                                       relative: false, maxDistance: 200f);
        }