Exemple #1
0
	public void Rule1(float dt, World world){ 
	switch (s1)
	{

	case -1:
	if(!(Source.PlanetStats.IsSome))
	{

	s1 = -1;
return;	}else
	{

	goto case 6;	}
	case 6:
	___direction10 = ((Target.Position) - (BaseShip.Position));
	if(((((Target.Owner.IsSome) && (((Target.Owner.Value) == (BaseShip.Owner))))) && (((Target.PlanetStats.Value.Research) > (Source.PlanetStats.Value.Research)))))
	{

	___direction11 = ((___direction10.normalized) * (((2.5f) + (((0.35f) * (Target.PlanetStats.Value.Research))))));	}else
	{

	___direction11 = ((___direction10.normalized) * (((2.5f) + (((0.35f) * (Source.PlanetStats.Value.Research))))));	}
	Velocity = ___direction11;
	BaseShip.Position = BaseShip.Position;
	Target = Target;
	s1 = 3;
return;
	case 3:
	if(!(((0f) > (UnityEngine.Vector3.Dot(___direction11,(Target.Position) - (BaseShip.Position))))))
	{

	s1 = 3;
return;	}else
	{

	goto case 2;	}
	case 2:
	___next_hop14 = (

(Target.Neighbours).Select(__ContextSymbol220 => new { ___n10 = __ContextSymbol220 })
.SelectMany(__ContextSymbol221=> (world.Planets).Select(__ContextSymbol222 => new { ___q14 = __ContextSymbol222,
                                                      prev = __ContextSymbol221 })
.Where(__ContextSymbol223 => ((((__ContextSymbol223.prev.___n10.Item1) == (Target.UnityPlanet))) && (((__ContextSymbol223.prev.___n10.Item2) == (__ContextSymbol223.___q14.UnityPlanet)))))
.Select(__ContextSymbol224 => __ContextSymbol224.___q14)
.ToList<Planet>())).ToList<Planet>();
	if(((___next_hop14.Count) > (0)))
	{

	___next_hop15 = ___next_hop14.Head();	}else
	{

	___next_hop15 = Target;	}
	Velocity = Vector3.zero;
	BaseShip.Position = Target.Position;
	Target = ___next_hop15;
	s1 = -1;
return;	
	default: return;}}
Exemple #2
0
public AttackingShip(Ship baseship, Planet target)
	{JustEntered = false;
 frame = World.frame;
		Target = target;
		Strength = 0f;
		BaseShip = baseship;
		
}
Exemple #3
0
public TravelingShip(Planet n, Planet s, Ship baseship)
	{JustEntered = false;
 frame = World.frame;
		Velocity = new UnityEngine.Vector3(1f,1f,1f);
		Target = n;
		Source = s;
		BaseShip = baseship;
		
}
Exemple #4
0
public Battle(Planet n)
	{JustEntered = false;
 frame = World.frame;
		UnityBattle = UnityBattle.Instantiate(n.Position);
		SmallestFleet = (new Nothing<AttackingShip>());
		ShipsToMerge = (

Enumerable.Empty<MergingShip>()).ToList<MergingShip>();
		Planet = n;
		NextPossibleOwner = (new Nothing<Commander>());
		AttackingShips = (

Enumerable.Empty<AttackingShip>()).ToList<AttackingShip>();
		
}
Exemple #5
0
public Ship(Commander o, UnityEngine.Vector3 pos, System.Int32 amount, Planet final_target, Planet target, Planet source, Option<UnityShip> BaseShip)
	{JustEntered = false;
 frame = World.frame;
		UnityShip ___unityShip00;
		if(BaseShip.IsSome)
			{
			___unityShip00 = BaseShip.Value;
			}else
			{
			___unityShip00 = UnityShip.Instantiate(pos,target.Position);
			}
		UnityShip = ___unityShip00;
		Target = target;
		Source = source;
		Owner = o;
		InitialPosition = pos;
		FinalTarget = final_target;
		AmountOfShips = amount;
		
}
Exemple #6
0
	public void Rule0(float dt, World world){ 
	switch (s0)
	{

	case -1:
	
	counter30 = -1;
	if((((Sources).Count) == (0)))
	{

	goto case 1;	}else
	{

	___s010 = (Sources)[0];
	goto case 3;	}
	case 3:
	counter30 = ((counter30) + (1));
	if((((((Sources).Count) == (counter30))) || (((counter30) > ((Sources).Count)))))
	{

	goto case 1;	}else
	{

	___s010 = (Sources)[counter30];
	goto case 4;	}
	case 4:
	IntermediateHops = IntermediateHops;
	Temp = (new Just<Planet>(___s010));
	IsDone = IsDone;
	s0 = 16;
return;
	case 16:
	___temp_in_IntermediateHops00 = (

(IntermediateHops).Select(__ContextSymbol171 => new { ___i04 = __ContextSymbol171 })
.Where(__ContextSymbol172 => ((__ContextSymbol172.___i04.Item1) == (Temp.Value)))
.Select(__ContextSymbol173 => __ContextSymbol173.___i04)
.ToList<Tuple<Planet, Planet>>()).ToList<Tuple<Planet, Planet>>();
	goto case 5;
	case 5:
	if(!(((((!(((Target) == (Temp.Value)))) && (((Temp.Value.Owner) == (___s010.Owner))))) && (((___temp_in_IntermediateHops00.Count) == (0))))))
	{

	s0 = 3;
return;	}else
	{

	goto case 6;	}
	case 6:
	___next_hop02 = (

(Temp.Value.Neighbours).Select(__ContextSymbol174 => new { ___h02 = __ContextSymbol174 })
.SelectMany(__ContextSymbol175=> (world.Planets).Select(__ContextSymbol176 => new { ___p011 = __ContextSymbol176,
                                                      prev = __ContextSymbol175 })
.Where(__ContextSymbol177 => ((((__ContextSymbol177.prev.___h02.Item1) == (Target.UnityPlanet))) && (((__ContextSymbol177.___p011.UnityPlanet) == (__ContextSymbol177.prev.___h02.Item2)))))
.Select(__ContextSymbol178 => __ContextSymbol178.___p011)
.ToList<Planet>())).ToList<Planet>();
	___next_hop03 = ___next_hop02.Head();
	if(((___next_hop03.Owner) == (___s010.Owner)))
	{

	goto case 7;	}else
	{

	goto case 8;	}
	case 7:
	___lst00 = ((

(new Cons<Tuple<Planet, Planet>>(new Casanova.Prelude.Tuple<Planet,Planet>(Temp.Value,___next_hop03),(new Empty<Tuple<Planet, Planet>>()).ToList<Tuple<Planet, Planet>>())).ToList<Tuple<Planet, Planet>>()).ToList<Tuple<Planet, Planet>>()).Concat(IntermediateHops).ToList<Tuple<Planet, Planet>>();
	UnityEngine.Debug.Log(((Temp.Value.Name) + (" -> ")) + (___next_hop03.Name));
	IntermediateHops = ___lst00;
	Temp = (new Just<Planet>(___next_hop03));
	IsDone = IsDone;
	s0 = 5;
return;
	case 8:
	IntermediateHops = IntermediateHops;
	Temp = (new Just<Planet>(___next_hop03));
	IsDone = IsDone;
	s0 = 5;
return;
	case 1:
	IntermediateHops = IntermediateHops;
	Temp = Temp;
	IsDone = true;
	s0 = 0;
return;
	case 0:
	if(!(false))
	{

	s0 = 0;
return;	}else
	{

	s0 = -1;
return;	}	
	default: return;}}
Exemple #7
0
public PlanetInfo(Planet p, PlanetStatModifier psm)
	{JustEntered = false;
 frame = World.frame;
		UpgradeState = (new Nothing<System.Int32>());
		UnityStat = UnityStat.FindStat(p.UnityPlanet);
		StatModifiers = psm;
		ResearchState = ResearchNeutral;
		ResearchOn = 0.25f;
		ResearchOff = -0.25f;
		ResearchNeutral = -0.1f;
		ResearchCost = -0.5f;
		Research = p.Owner.Value.Research;
		ProductivityState = ResearchNeutral;
		Productivity = p.Owner.Value.Production;
		Planet = p;
		DefenseState = ResearchNeutral;
		Defense = p.Owner.Value.Defense;
		AttackState = ResearchNeutral;
		Attack = p.Owner.Value.Attack;
		
}
Exemple #8
0
public Link(UnityLink l, Planet p1, Planet p2, System.Boolean are_sources_reversed)
	{JustEntered = false;
 frame = World.frame;
		UnityLink = l;
		TravelingShips = (

Enumerable.Empty<TravelingShip>()).ToList<TravelingShip>();
		Target = p2;
		SourcesReversed = are_sources_reversed;
		Source = p1;
		ShipsToRemove = (

Enumerable.Empty<TravelingShip>()).ToList<TravelingShip>();
		AutoHopActive = false;
		
}
Exemple #9
0
public AutoHopManager(List<Planet> sources, Planet target)
	{JustEntered = false;
 frame = World.frame;
		Temp = (new Nothing<Planet>());
		Target = target;
		Sources = sources;
		IsDone = false;
		IntermediateHops = (

Enumerable.Empty<Tuple<Planet, Planet>>()).ToList<Tuple<Planet, Planet>>();
		
}
Exemple #10
0
        public override void InitializeEnvironment()
        {
            bool useCustomTerrain = false;

            if (useCustomTerrain)
            {
                try
                {
                    physicsManager.PhysicsSystem.Gravity = Vector3.Zero;
                    physicsManager.AddGravityController(new Vector3(0, -101, 0), 100, 10);
                    /*terrain = new Terrain(new Vector3(0, -15, 0), // position
                        //new Vector3(100f, .1f, 100f),  // X with, possible y range, Z depth
                                            new Vector3(15000f, .55f, 15000f),  // X with, possible y range, Z depth
                                            100, 100, graphicsDevice, moon);*/
                    planet = new Planet(new Vector3(0, -101, 0), // Position
                        new Vector3(100, 100, 100), // Radius
                        0, Math.PI / 8, 2, graphicsDevice, moon);

                    objectsToAdd.Add(planet.ID, planet);
                    //objectsToAdd.Add(terrain.ID, terrain);
                }
                catch (Exception E)
                {
                    System.Diagnostics.Debug.WriteLine(E.StackTrace);
                }
            }
            else
            {
                try
                {
                    // some video cards can't handle the >16 bit index type of the terrain
                    HeightmapObject heightmapObj = new HeightmapObject(terrainModel, Vector2.Zero, new Vector3(0, 0, 0));
                    objectsToAdd.Add(heightmapObj.ID, heightmapObj);
                }
                catch (Exception E)
                {
                    // if that happens just create a ground plane
                    //planeObj = new PlaneObject(planeModel, 0.0f, new Vector3(0, -15, 0), "");
                    //newObjects.Add(planeObj.ID, planeObj);
                    System.Diagnostics.Debug.WriteLine(E.StackTrace);
                }
            }
        }
Exemple #11
0
	public void Rule15(float dt, World world){ 
	switch (s15)
	{

	case -1:
	if(Selected)
	{

	goto case 42;	}else
	{

	s15 = -1;
return;	}
	case 42:
	if(((LandedShips) > (0)))
	{

	goto case 44;	}else
	{

	s15 = -1;
return;	}
	case 44:
	if(((((world.TargetedPlanet.IsSome) && (Battle.IsNone))) && (!(world.InputMonitor.ShiftKey))))
	{

	goto case 46;	}else
	{

	s15 = -1;
return;	}
	case 46:
	if(world.InputMonitor.ControlKey)
	{

	___amount_of_ships150 = LandedShips;	}else
	{

	___amount_of_ships150 = ((System.Int32)((((LandedShips) + (1))) / (2)));	}
	___target151 = world.TargetedPlanet.Value;
	___next_hop150 = (

(this.Neighbours).Select(__ContextSymbol131 => new { ___h150 = __ContextSymbol131 })
.SelectMany(__ContextSymbol132=> (world.Planets).Select(__ContextSymbol133 => new { ___q152 = __ContextSymbol133,
                                                      prev = __ContextSymbol132 })
.Where(__ContextSymbol134 => ((((__ContextSymbol134.prev.___h150.Item1) == (world.TargetedPlanet.Value.UnityPlanet))) && (((__ContextSymbol134.prev.___h150.Item2) == (__ContextSymbol134.___q152.UnityPlanet)))))
.Select(__ContextSymbol135 => __ContextSymbol135.___q152)
.ToList<Planet>())).ToList<Planet>();
	ShipToSend = (

(new Cons<TravelingShip>(new TravelingShip(___next_hop150.Head(),this,new Ship(Owner.Value,Position,___amount_of_ships150,world.TargetedPlanet.Value,___next_hop150.Head(),this,(new Nothing<UnityShip>()))),(new Empty<TravelingShip>()).ToList<TravelingShip>())).ToList<TravelingShip>()).ToList<TravelingShip>();
	LandedShips = 0;
	s15 = 47;
return;
	case 47:
	ShipToSend = (

Enumerable.Empty<TravelingShip>()).ToList<TravelingShip>();
	LandedShips = LandedShips;
	s15 = -1;
return;	
	default: return;}}
Exemple #12
0
	public void Rule1(float dt, World world){ 
	switch (s1)
	{

	case -1:
	count_down1 = 1f;
	goto case 11;
	case 11:
	if(((count_down1) > (0f)))
	{

	count_down1 = ((count_down1) - (dt));
	s1 = 11;
return;	}else
	{

	goto case 9;	}
	case 9:
	___posx10 = UnityEngine.Random.Range(175f,200f);
	___posz10 = UnityEngine.Random.Range(175f,200f);
	if(((UnityEngine.Random.value) > (0.5f)))
	{

	___posx11 = ___posx10;	}else
	{

	___posx11 = ((___posx10) * (-1f));	}
	if(((UnityEngine.Random.value) > (0.5f)))
	{

	___posz11 = ___posz10;	}else
	{

	___posz11 = ((___posz10) * (-1f));	}
	___mass10 = UnityEngine.Random.Range(3f,350f);
	___position10 = new UnityEngine.Vector3(___posx11,0f,___posz11);
	___velocity10 = ((UnityEngine.Vector3.Normalize((___position10) * (-1f))) * (UnityEngine.Random.Range(1f,6f)));
	___rotv10 = new UnityEngine.Vector3(UnityEngine.Random.Range(-50f,50f),UnityEngine.Random.Range(-50f,50f),UnityEngine.Random.Range(-50f,50f));
	___newPlanet10 = new Planet(___position10,___mass10,___velocity10,___rotv10);
	Planets = new Cons<Planet>(___newPlanet10, (Planets)).ToList<Planet>();
	s1 = -1;
return;	
	default: return;}}
        public void OnUpdate()
        {
            m_direction = -this.GameObj.Transform.Pos;
            this.GameObj.Transform.Angle = m_direction.Xy.Angle + MathF.RadAngle180;

            Vector3         moveDelta       = Time.TimeMult * m_direction * m_speed;
            LevelController levelController = this.GameObj.ParentScene.FindComponent <LevelController>();

            // Hovering animation
            {
                SpriteRenderer sprite = this.GameObj.GetComponent <SpriteRenderer>();
                if (this.initialSpriteRect == Rect.Empty)
                {
                    this.initialSpriteRect = sprite.Rect;
                }
                float hoverTimeOffset = (float)(this.GameObj.Id.GetHashCode() % 1000) / 1000.0f;
                sprite.Rect = new Rect(
                    this.initialSpriteRect.X,
                    this.initialSpriteRect.Y + 10.0f * (1.0f + MathF.Sin(2.0f * (float)Time.GameTimer.TotalSeconds + hoverTimeOffset)),
                    this.initialSpriteRect.W,
                    this.initialSpriteRect.H);
            }

            switch (m_shipState)
            {
            case ShipState.MoveToTarget:
                this.GameObj.Transform.MoveBy(moveDelta);
                if (IsInShootingRange())
                {
                    StartScanning();
                }
                break;

            case ShipState.ScanTarget:
                //Log.Game.Write("countdownTime: {0}, lastDelta: {1}", m_countdownToAttack, Time.LastDelta);
                if (m_beamSoundInstance == null || m_beamSoundInstance.Disposed)
                {
                    m_beamSoundInstance        = DualityApp.Sound.PlaySound(m_beamSound);
                    m_beamSoundInstance.Looped = true;
                    m_beamSoundInstance.Pitch  = MathF.Rnd.NextFloat(0.8f, 1.25f);
                }
                m_countdownToAttack -= Time.LastDelta / 1000;
                if (levelController == null || levelController.IsGameOver)
                {
                    m_beamSoundInstance.Volume = 0.1f + 0.1f * MathF.Clamp(1.0f - ((float)m_countdownToAttack / (float)m_scanDuration), 0.0f, 1.0f);
                }
                else
                {
                    m_beamSoundInstance.Volume = 0.5f + 0.5f * MathF.Clamp(1.0f - ((float)m_countdownToAttack / (float)m_scanDuration), 0.0f, 1.0f);
                }

                UpdateLineRenderer(false);
                if (m_countdownToAttack <= 0)
                {
                    //Log.Game.Write("distance: {0}", this.GameObj.Transform.Pos.LengthSquared);
                    Vector2 hitPos;
                    if (ScanPlanet(out hitPos))
                    {
                        m_hitPosition = new Vector3(hitPos.X, hitPos.Y, 0);
                        StartShooting();
                    }
                    else
                    {
                        StartLeaving();
                    }
                    m_beamSoundInstance.FadeOut(0.1f);
                }
                break;

            case ShipState.ShootTarget:
                if (m_target != null)
                {
                    if (levelController != null && !levelController.IsGameOver)
                    {
                        DualityApp.Sound.PlaySound(m_lockAcquiredSound);
                    }

                    Planet planetComp = m_target.GetComponent <Planet>();
                    if (planetComp != null)
                    {
                        planetComp.IncreaseDetectionCounter();
                    }
                }
                SpawnParticle();
                m_shipState = ShipState.LockPosition;
                break;

            case ShipState.LeaveTarget:
                this.GameObj.Transform.MoveBy(-moveDelta);
                if (IsOutsideRange())
                {
                    StartWaiting();
                }
                break;

            case ShipState.Waiting:
                m_countdownToAttack -= Time.LastDelta / 1000;
                if (m_countdownToAttack <= 0)
                {
                    StartMovingToTarget();
                }
                break;

            case ShipState.LockPosition:
                // occasionally spawn particles pulled towards the ship
                m_countdownToAttack -= Time.LastDelta / 1000;
                if (m_countdownToAttack <= 0)
                {
                    SpawnParticle();
                }
                break;

            default:
                break;
            }
        }
Exemple #14
0
public Battle(Planet planet)
	{JustEntered = false;
 frame = World.frame;
		MySource = planet;
		FleetsToMerge = (

Enumerable.Empty<AttackingFleetToMerge>()).ToList<AttackingFleetToMerge>();
		FleetsToDestroyNextTurn = (

Enumerable.Empty<AttackingFleet>()).ToList<AttackingFleet>();
		DefenceLost = (new Nothing<System.Int32>());
		AttackingFleets = (

Enumerable.Empty<AttackingFleet>()).ToList<AttackingFleet>();
		AttackLost = (new Nothing<System.Int32>());
		
}
Exemple #15
0
public Link(UnityLine ul, Planet s, Planet d)
	{JustEntered = false;
 frame = World.frame;
		UnityLine = ul;
		TravellingFleets = (

Enumerable.Empty<TravellingFleet>()).ToList<TravellingFleet>();
		Source = s;
		IsAutoRouteActive = false;
		Destination = d;
		
}
Exemple #16
0
public TravellingFleet(Fleet myfleet, Planet destination)
	{JustEntered = false;
 frame = World.frame;
		UnityEngine.Vector3 ___velocity00;
		___velocity00 = (destination.Position) - (myfleet.Position);
		UnityEngine.Vector3 ___velocity_norm00;
		___velocity_norm00 = ___velocity00.normalized;
		Velocity = ___velocity_norm00;
		MyFleet = myfleet;
		MaxVelocity = 1f;
		Destination = destination;
		
}