fixed line-endings on *.cs
This commit is contained in:
@@ -21,52 +21,52 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.FileFormats;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
class ScreenShakerInfo : ITraitInfo
|
||||
{
|
||||
public object Create( Actor self ) { return new ScreenShaker(); }
|
||||
}
|
||||
|
||||
public class ScreenShaker : ITick
|
||||
{
|
||||
int ticks = 0;
|
||||
List<Tuple<int, float2, int>> shakeEffects = new List<Tuple<int, float2, int>>();
|
||||
|
||||
public void Tick (Actor self)
|
||||
{
|
||||
using OpenRA.FileFormats;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
class ScreenShakerInfo : ITraitInfo
|
||||
{
|
||||
public object Create( Actor self ) { return new ScreenShaker(); }
|
||||
}
|
||||
|
||||
public class ScreenShaker : ITick
|
||||
{
|
||||
int ticks = 0;
|
||||
List<Tuple<int, float2, int>> shakeEffects = new List<Tuple<int, float2, int>>();
|
||||
|
||||
public void Tick (Actor self)
|
||||
{
|
||||
Game.viewport.Scroll(getScrollOffset());
|
||||
shakeEffects.RemoveAll(t => t.a == ticks);
|
||||
ticks++;
|
||||
}
|
||||
|
||||
public void AddEffect(int time, float2 position, int intensity)
|
||||
{
|
||||
shakeEffects.Add(Tuple.New(ticks + time, position, intensity));
|
||||
}
|
||||
|
||||
public float2 getScrollOffset()
|
||||
{
|
||||
int xFreq = 4;
|
||||
int yFreq = 5;
|
||||
|
||||
return GetIntensity() * new float2(
|
||||
(float) Math.Sin((ticks*2*Math.PI)/xFreq) ,
|
||||
(float) Math.Cos((ticks*2*Math.PI)/yFreq));
|
||||
}
|
||||
|
||||
public float GetIntensity()
|
||||
shakeEffects.RemoveAll(t => t.a == ticks);
|
||||
ticks++;
|
||||
}
|
||||
|
||||
public void AddEffect(int time, float2 position, int intensity)
|
||||
{
|
||||
shakeEffects.Add(Tuple.New(ticks + time, position, intensity));
|
||||
}
|
||||
|
||||
public float2 getScrollOffset()
|
||||
{
|
||||
int xFreq = 4;
|
||||
int yFreq = 5;
|
||||
|
||||
return GetIntensity() * new float2(
|
||||
(float) Math.Sin((ticks*2*Math.PI)/xFreq) ,
|
||||
(float) Math.Cos((ticks*2*Math.PI)/yFreq));
|
||||
}
|
||||
|
||||
public float GetIntensity()
|
||||
{
|
||||
var cp = Game.viewport.Location
|
||||
+ .5f * new float2(Game.viewport.Width, Game.viewport.Height);
|
||||
|
||||
var intensity = 24 * 24 * 100 * shakeEffects.Sum(
|
||||
e => e.c / (e.b - cp).LengthSquared);
|
||||
|
||||
return Math.Min(intensity, 10);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
var intensity = 24 * 24 * 100 * shakeEffects.Sum(
|
||||
e => e.c / (e.b - cp).LengthSquared);
|
||||
|
||||
return Math.Min(intensity, 10);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user