MoveViewport takes a float to allow for smoother panning. Added more scripting to shellmap

This commit is contained in:
Caleb Anderson
2010-10-21 00:17:32 -05:00
committed by Chris Forbes
parent fc72066ed2
commit ff7daf8727
6 changed files with 1286 additions and 1256 deletions

2
OpenRA.Game/Game.cs Normal file → Executable file
View File

@@ -43,7 +43,7 @@ namespace OpenRA
public static Renderer Renderer;
public static bool HasInputFocus = false;
public static void MoveViewport(int2 loc)
public static void MoveViewport(float2 loc)
{
viewport.Center(loc);
}

2
OpenRA.Game/Graphics/Viewport.cs Normal file → Executable file
View File

@@ -123,7 +123,7 @@ namespace OpenRA.Graphics
return ViewToWorld(mi.Location);
}
public void Center(int2 loc)
public void Center(float2 loc)
{
scrollPosition = this.NormalizeScrollPosition(Game.CellSize*loc - .5f * new float2(Width, Height));
}

46
OpenRA.Mods.RA/DefaultShellmapScript.cs Normal file → Executable file
View File

@@ -11,6 +11,7 @@
using System.Collections.Generic;
using System.Linq;
using OpenRA.Traits;
using System;
namespace OpenRA.Mods.RA
{
@@ -18,29 +19,48 @@ namespace OpenRA.Mods.RA
class DefaultShellmapScript: IWorldLoaded, ITick
{
Dictionary<string, Actor> Actors;
Dictionary<string, Actor> Actors;
private static int2 ViewportOrigin;
public void WorldLoaded(World w)
{
Game.MoveViewport((.5f * (w.Map.TopLeft + w.Map.BottomRight).ToFloat2()).ToInt2());
{
int2 loc = (.5f * (w.Map.TopLeft + w.Map.BottomRight).ToFloat2()).ToInt2();
Game.MoveViewport(loc);
ViewportOrigin = loc;
Actors = w.WorldActor.Trait<SpawnMapActors>().Actors;
Sound.SoundVolumeModifier = 0f;
}
int ticks = 0;
public void Tick(Actor self)
{
int ticks = 0;
float speed = 4f;
public void Tick(Actor self)
{
var loc = new float2(
(float)(System.Math.Sin((ticks + 45) % (360f * speed) * (Math.PI / 180) * 1f / speed) * 15f + ViewportOrigin.X),
(float)(System.Math.Cos((ticks + 45) % (360f * speed) * (Math.PI / 180) * 1f / speed) * 10f + ViewportOrigin.Y));
Game.MoveViewport(loc);
if (ticks == 250)
{
Actors["pdox"].Trait<Chronosphere>().Teleport(Actors["ca1"], new int2(90, 70));
Actors["pdox"].Trait<Chronosphere>().Teleport(Actors["ca2"], new int2(92, 71));
Actors["pdox"].Trait<Chronosphere>().Teleport(Actors["ca2"], new int2(92, 71));
}
if (ticks == 100)
Actors["mslo1"].Trait<NukeSilo>().Attack(new int2(98, 52));
if (ticks == 140)
Actors["mslo2"].Trait<NukeSilo>().Attack(new int2(95, 54));
if (ticks == 180)
Actors["mslo3"].Trait<NukeSilo>().Attack(new int2(95, 49));
if (ticks == 430)
{
Actors["mig1"].Trait<AttackPlane>().AttackTarget(Actors["mig1"], Actors["greeceweap"], true);
Actors["mig2"].Trait<AttackPlane>().AttackTarget(Actors["mig2"], Actors["greeceweap"], true);
Actors["mig3"].Trait<AttackPlane>().AttackTarget(Actors["mig3"], Actors["greeceweap"], true);
}
if (ticks == 100)
Actors["mslo1"].Trait<NukeSilo>().Attack(new int2(96,53));
if (ticks == 110)
Actors["mslo2"].Trait<NukeSilo>().Attack(new int2(92,53));
if (ticks == 120)
Actors["mslo3"].Trait<NukeSilo>().Attack(new int2(94,50));
ticks++;
}

View File

@@ -1 +1 @@
5065fbcb8e5b1b6cea2a003c64f9b48fcaa33e06
f1e5ed95dccfa5ba9c61f1263adffe17635ec069

File diff suppressed because it is too large Load Diff

View File

@@ -77,4 +77,4 @@ Movies:
mods/ra/movies2.yaml
LoadScreen: RALoadScreen
ShellmapUid:5065fbcb8e5b1b6cea2a003c64f9b48fcaa33e06
ShellmapUid:f1e5ed95dccfa5ba9c61f1263adffe17635ec069