コード例 #1
0
        public void Shooting(WeaponPositionType weaponPos)
        {
            var weapon = weaponPos == WeaponPositionType.PRIMARY ? _PrimaryWeapon : _SecondaryWeapon;

            if (weapon == null || Time.time < _nextShotTimes[(int)weaponPos])
            {
                return;
            }
            _nextShotTimes[(int)weaponPos] = Time.time + weapon.cooldownDuration;

            //Fire a bit in front of position
            var shootPos = (Vector2)transform.position + Util.AngleToForward(_angle) * 0.25f;             //TODO, make value part of weapon? maybe find pos from turret?

            //Create and send command
            var shootCmd = new ShootProjectileCommand
            {
                type = weapon.type,
                pos  = transform.position,
                dir  = _cannonDirection
            };

            CmdShooting(shootCmd, Game.Client.connectionToServer.connectionId);
        }
コード例 #2
0
        private void CmdShooting(ShootProjectileCommand cmd, int connId)
        {
            var weapon = WeaponLibrary.GetWeaponData(cmd.type);

            Game.Spawns.ShootProjectile(cmd.pos, cmd.dir, weapon, connId);
        }