Exemplo n.º 1
0
 private static Vector3 LoadVector3(IReadOnlyList <IVariable> parameters, int x, int y, int z)
 {
     return(new Vector3(
                YololValue.Number(parameters[x].Value),
                YololValue.Number(parameters[y].Value),
                YololValue.Number(parameters[z].Value)
                ));
 }
Exemplo n.º 2
0
 private static Quaternion LoadQuaternion(IReadOnlyList <IVariable> parameters, int w, int x, int y, int z)
 {
     return(new Quaternion(
                YololValue.Number(parameters[x].Value),
                YololValue.Number(parameters[y].Value),
                YololValue.Number(parameters[z].Value),
                YololValue.Number(parameters[w].Value)
                ));
 }
Exemplo n.º 3
0
        private static void Add(IReadOnlyList <IVariable> parameters)
        {
            var acc = 0f;

            foreach (var variable in parameters)
            {
                acc += YololValue.Number(variable.Value);
            }

            parameters[0].Value = (Number)acc;
        }
Exemplo n.º 4
0
            public void Update(float elapsedTime, YololContext ctx, Scene scene)
            {
                // Change gun angles
                var tgtElevation = ctx.Get(_elevationName);

                _elevation.Value = MoveTo(_elevation.Value, YololValue.Number(tgtElevation.Value, MinElevation, MaxElevation), ElevationSpeed * elapsedTime);
                var tgtBearing = ctx.Get(_bearingName);

                _bearing.Value = MoveToAngle(_bearing.Value, YololValue.Number(tgtBearing.Value, 0, 360), BearingSpeed * elapsedTime);

                // Copy angles back to Yolol
                var actualElevation = ctx.Get(_actualElevationName);

                actualElevation.Value = (Number)_elevation.Value;
                var actualBearing = ctx.Get(_actualBearingName);

                actualBearing.Value = (Number)_bearing.Value;

                // Check if gun is ready
                var ready = ctx.Get(_gunReadyName);

                _cooldownTime -= elapsedTime;
                if (_cooldownTime <= 0)
                {
                    ready.Value = (Number)true;
                }

                // Fire gun
                var trigger = ctx.Get(_gunTriggerName);
                var t       = trigger.Value;

                if (_cooldownTime <= 0 && t.Type == Yolol.Execution.Type.Number && t.Number > (Number)0)
                {
                    trigger.Value = t - (Number)1;
                    _cooldownTime = CooldownTime;
                    ready.Value   = (Number)false;

                    // Work out what the fuse setting is for this gun and then spawn a shell
                    var fuseVar = ctx.Get(_gunFuseName);
                    var fuse    = Math.Clamp(fuseVar.Value.Type == Yolol.Execution.Type.Number ? (float)fuseVar.Value.Number : 0, MinFuse, MaxFuse);
                    scene.Add(_shellFactory.Create(fuse, _team.Value, _position.Value, _velocity.Value + GunDirection() * ShellSpeed));
                }
            }
Exemplo n.º 5
0
        private void WorldDir(IReadOnlyList <IVariable> parameters)
        {
            var bearing   = YololValue.Number(parameters[0].Value, 0, 360);
            var elevation = YololValue.Number(parameters[1].Value, 0, 360);

            var bearingAxis   = LoadVector3(parameters, 2, 3, 4);
            var elevationAxis = LoadVector3(parameters, 5, 6, 7);

            var dir = Targeting.WorldDirection(
                elevation,
                Vector3.Normalize(elevationAxis),
                bearing,
                Vector3.Normalize(bearingAxis),
                _orientation.Value
                );

            parameters[0].Value = (Number)dir.X;
            parameters[1].Value = (Number)dir.Y;
            parameters[2].Value = (Number)dir.Z;
        }
Exemplo n.º 6
0
 protected override float BeamRange(YololContext ctx)
 {
     return(YololValue.Number(ctx.Get(":radar_beam_range").Value, MinRange, MaxRange));
 }
Exemplo n.º 7
0
 protected override float BeamAngle(YololContext ctx)
 {
     return(YololValue.Number(ctx.Get(":radar_beam_angle").Value, MinAngle, MaxAngle));
 }
Exemplo n.º 8
0
 protected override float Bearing(YololContext ctx)
 {
     return(YololValue.Number(ctx.Get(":radar_bearing").Value, 0, 360));
 }
Exemplo n.º 9
0
 protected override float Elevation(YololContext ctx)
 {
     return(YololValue.Number(ctx.Get(":radar_elevation").Value, 0, 360));
 }
 private static float GetNumber(IVariable?v)
 {
     return(YololValue.Number(v?.Value ?? (Number)0, -1, 1));
 }
Exemplo n.º 11
0
 private static float LoadSingle(IReadOnlyList <IVariable> parameters, int v)
 {
     return(YololValue.Number(parameters[v].Value));
 }