void SetupWormholePriceStream(ITrade trade) { if (trade == null) { throw new ArgumentNullException("trade"); } _priceSubject.Dispose(); _priceSubject = new Subject<PriceDto>(); var wormhole = new Wormhole(WormHoleConstants.AppGroup, WormHoleConstants.Directory); wormhole.PassMessage(WormHoleConstants.StartUpdates, trade.CurrencyPair); wormhole.ListenForMessage<PriceDto>( WormHoleConstants.CurrencyUpdate, price => { if (price == null) { Console.WriteLine("Watch: wormhole price is null!"); return; } Console.WriteLine("Watch: got PriceDto: " + price.Bid + " / " + price.Ask); _priceSubject.OnNext(price); } ); _wormhole = wormhole; }
public WormholeSender(IReactiveTrader reactiveTrader) { _wormhole = new Wormhole(WormHoleConstants.AppGroup, WormHoleConstants.Directory); _wormhole.ListenForMessage<string>(WormHoleConstants.StartUpdates, currencyPair => { Console.WriteLine($"Starting Watch updates for {currencyPair}"); _wormholeSubscription.Dispose(); _wormholeSubscription = reactiveTrader .PricingServiceClient .GetSpotStream(currencyPair) .Distinct(x => x.CreationTimestamp) .Subscribe(price => { Console.WriteLine($"Sending update for {currencyPair}: {price.Ask} / {price.Bid}"); _wormhole.PassMessage(WormHoleConstants.CurrencyUpdate, price); }); }); _wormhole.ListenForMessage<string>(WormHoleConstants.StopUpdates, _ => { Console.WriteLine($"Stopping Watch updates"); _wormholeSubscription.Dispose(); }); }
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { Current = this; wormHole = new Wormhole ("group.co.conceptdev.WatchTodo", "messageDir"); var FileManager = new NSFileManager (); var appGroupContainer = FileManager.GetContainerUrl ("group.co.conceptdev.WatchTodo"); var appGroupContainerPath = appGroupContainer.Path; Console.WriteLine ("agcpath: " + appGroupContainerPath); var sqliteFilename = "TodoSQLite.db3"; // App Group storage, shared with Watch Extension var path = Path.Combine(appGroupContainerPath, sqliteFilename); var conn = new SQLiteConnection (path); Database = new TodoItemDatabase(conn); // HACK: temporary population of data if (Database.GetItems ().Count() == 0) { Database.SaveItem (new TodoItem { Name = "buy pineapple" }); Database.SaveItem (new TodoItem { Name = "buy dragon fruit", Done = true }); Database.SaveItem (new TodoItem { Name = "buy honeydew" }); Database.SaveItem (new TodoItem { Name = "buy rockmelon" }); } return true; }
public override void Awake(NSObject context) { base.Awake (context); // Configure interface objects here. Console.WriteLine ("{0} awake with context", this); _wormHole = new Wormhole ("group.tech.seamlessthingies.ccmqttex", "messageDir"); }
public ViewController(IntPtr handle) : base(handle) { wormHole = new Wormhole ("group.com.clancey.wormhole", "messageDir"); wormHole.ListenForMessage<string> ("watchButton", (message) => { ButtonLabel.Text = message; }); wormHole.PassMessage ("watchButton",1); }
public override void Awake(NSObject context) { base.Awake (context); wormHole = new Wormhole ("group.com.clancey.wormhole", "messageDir"); wormHole.ListenForMessage<ButtonMessage> (ButtonMessage.MessageType, (message) => { SelectionLabel.SetText(message.Id.ToString()); }); // Configure interface objects here. Console.WriteLine ("{0} awake with context", this); }
public override void Awake(NSObject context) { base.Awake(context); wormHole = new Wormhole("group.com.clancey.wormhole", "messageDir"); wormHole.ListenForMessage <ButtonMessage> (ButtonMessage.MessageType, (message) => { SelectionLabel.SetText(message.Id.ToString()); }); // Configure interface objects here. Console.WriteLine("{0} awake with context", this); }
private int GetWormholePriority(Wormhole wormhole) { int currentScore = GetWormholeScore(wormhole.Location, GetWormholeLocation(wormhole.Partner)); int improvedScore = GetWormholeScore(BestWormholePushLocation(wormhole), GetWormholeLocation(wormhole.Partner)); int improvementDelta = currentScore - improvedScore; int maxPossibleImprovement = game.PushDistance * 2; // Moved PushDistance away from enemy locations towards our locations. int bonus = wormhole.TurnsToReactivate == 0 ? 1 : 0; return(ScaleToRange(0, maxPossibleImprovement, MAX_PRIORITY, MIN_PRIORITY, improvementDelta) - bonus); // TODO: Scale improvementDelta / maxPossibleImprovement to priorities range and add/subtract bonus. }
private bool TryPushWormhole(Pirate pirate, Wormhole wormhole) { if (pirate.CanPush(wormhole)) { // Push the wormhole var pushLocation = BestWormholePushLocation(wormhole); pirate.Push(wormhole, pushLocation); movedWormholeLocations[wormhole] = pushLocation; Print(pirate + " pushes " + wormhole + " towards " + pushLocation); return(true); } return(false); }
public int GetWormholeLocationScore(Wormhole wormhole, Location wormholeLocation, Location partner) { int score = 0; var best = bestMothershipAndCapsulePair(wormhole); int distance = WormholePossibleLocationDistance( best.First().GetLocation(), best.Last().GetLocation(), wormhole.Location, NewWormholeLocation[wormhole.Partner]); score += ScaleNumber(distance, wormhole.TurnsToReactivate, scale); return(score); }
public void AlignWith(Wormhole hole) //This ensures that the transforms don't degrade over time { relativeRotation = Random.Range(0, curveSegmentCount) * 360f / pipeSegementCount; transform.SetParent(hole.transform, false); transform.localPosition = Vector3.zero; transform.localRotation = Quaternion.Euler(0f, 0f, -hole.curveAngle); transform.Translate(0f, hole.curveRadius, 0f); transform.Rotate(relativeRotation, 0f, 0f); transform.Translate(0f, -curveRadius, 0f); transform.SetParent(hole.transform.parent); transform.localScale = Vector3.one; }
public static AMission Load(Ikadn.IkadnBaseObject rawData, ObjectDeindexer deindexer) { var dataStruct = rawData as IkonComposite; var destination = deindexer.Get <StarData>(dataStruct[DestinationKey].To <int>()); Wormhole usedWormhole = null; if (dataStruct.Keys.Contains(WormholeKey)) { usedWormhole = deindexer.Get <Wormhole>(dataStruct[WormholeKey].To <int>()); } return(new MoveMission(destination, usedWormhole)); }
private void Awake() //Spawns in a pipe segment when the object awakens { holes = new Wormhole[holeCount]; for (int i = 0; i < holes.Length; i++) { Wormhole hole = holes[i] = Instantiate <Wormhole>(holePrefab); hole.transform.SetParent(transform, false); hole.Generate(); if (i > 0) { hole.AlignWith(holes[i - 1]); } } }
public void SaveGameWormhole(Wormhole wormhole) { Debug.Log(JsonUtility.ToJson(wormhole, true)); DirectoryInfo dirInf = new DirectoryInfo(Application.persistentDataPath + "/Online/" + game.getGame().getName() + "/Wormholes/"); if (!dirInf.Exists) { Debug.Log("Creating subdirectory"); dirInf.Create(); } File.WriteAllText(Application.persistentDataPath + "/Online/" + game.getGame().getName() + "/Wormholes/" + wormhole.getName() + ".wormhole", JsonUtility.ToJson(wormhole, true)); }
private void HostXobj_OnCloudMessageReceived(Wormhole cloudSession) { string strMsgID = cloudSession.GetString("msgID"); switch (strMsgID) { case "testButtonClickCallback": string strVal = cloudSession.GetString("callbackval"); if (!string.IsNullOrEmpty(strVal)) { MessageBox.Show(strVal); } break; } }
void GenerateWormholes() { int whcount = _random.Next(0, MAX_CHARTED_WORMHOLES); for (int i = 0; i < whcount; i++) { Wormhole w = new Wormhole( "Uncharted Wormhole", GetRandomLocation(20), _random); _wormholes.Add(w); _pointsOfInterest.Add(w); } }
private static int DistanceThroughWormhole(Location from, MapObject to, Wormhole wormhole, IEnumerable <Wormhole> wormholes, int turnsElapsed, int pirateSpeed) { // return from.Distance(wormhole) + // ClosestDistance(wormhole.Partner.Location, to, // wormholes.Where(w => w.Id != wormhole.Id && w.Id != wormhole.Partner.Id)); int turns = 0; if (to.Distance(wormhole) / pirateSpeed < wormhole.TurnsToReactivate - turnsElapsed) { turns = wormhole.TurnsToReactivate - (to.Distance(wormhole) / pirateSpeed) - turnsElapsed; } return(from.Distance(wormhole) + turns * pirateSpeed + ClosestDistance(wormhole.Partner.Location, to, wormholes.Where(w => w.Id != wormhole.Id && w.Id != wormhole.Partner.Id), to.Distance(wormhole) / pirateSpeed + turns + turnsElapsed, pirateSpeed)); }
private void HostXobj_OnCloudMessageReceived(Wormhole cloudSession) { string strMsgID = cloudSession.GetString("msgID"); switch (strMsgID) { case "UserControl6_testButtonClickCallback": string strVal = cloudSession.GetString("callbackval"); if (!string.IsNullOrEmpty(strVal)) { MessageBox.Show(strVal + " CloudMessage Process by UserControl6"); button1.Text = strVal; } break; } }
public override void Awake(NSObject context) { base.Awake(context); _wormHole = new Wormhole (AppSettings.iOSAppGroupIdentifier, AppSettings.iOSAppGroupDirectory); _wormHole.ListenForMessage<NextPillsMessage> (NextPillsMessage.MessageType, UpdateUI); var waitingAttrString = new NSAttributedString("Please, open Patients on your iPhone", new UIStringAttributes { Font = UIFont.SystemFontOfSize(14, UIFontWeight.Light) }); waitingLabel.SetText(waitingAttrString); var nextInAttrString = new NSAttributedString("Next", new UIStringAttributes { Font = UIFont.SystemFontOfSize(14, UIFontWeight.Medium) }); nextInLabel.SetText(nextInAttrString); ToggleUI(true); }
void OnCollisionExit(Collision collision) { if (wormholed) { Debug.Log("EXIT:" + collision.gameObject.name + " " + newWormhole.gameObject.name + " " + numColliders.ToString()); if (collision.gameObject == newWormhole.gameObject) { numColliders -= 1; if (numColliders == 0) { wormholed = false; newWormhole = null; } } } }
public Dictionary <Pirate, MapObject> PushWormhole(Wormhole wormhole, List <Pirate> availablePirates, bool Assign) { // Checks if the wormhole can be pushed to a better location, and if is it returns the new location. // List<Location> candidates = new List<Location>(); // candidates.Add(wormhole.GetLocation()); // const int steps = 24; // for (int i = 0; i < steps; i++) // { // double angle = System.Math.PI * 2 * i / steps; // double deltaX = pirate.PushDistance * System.Math.Sin(angle); // double deltaY = pirate.PushDistance * System.Math.Cos(angle); // Location option = wormhole.Location.Add(new Location(-(int)deltaX, (int)deltaY)); // if (!option.InMap()) // { // continue; // } // candidates.Add(option); // } Dictionary <Pirate, MapObject> PiratePush = new Dictionary <Pirate, MapObject>(); List <MapObject> best = bestMothershipAndCapsulePair(wormhole); foreach (MapObject mapObject in best) { Pirate closestPirate = availablePirates.OrderBy(pirate => pirate.Distance(wormhole)).FirstOrDefault(); if (closestPirate == null) { break; } PiratePush.Add(closestPirate, mapObject); availablePirates.Remove(closestPirate); myPirates.Remove(closestPirate); if (closestPirate.CanPush(wormhole)) { closestPirate.Push(wormhole, mapObject); NewWormholeLocation[wormhole] = mapObject.GetLocation(); FinishedTurn[closestPirate] = true; } else if (Assign) { AssignDestination(closestPirate, wormhole.GetLocation().Towards(closestPirate, wormhole.WormholeRange)); } wormhole = wormhole.Partner; } return(PiratePush); }
public override void ViewDidLoad() { base.ViewDidLoad(); // Perform any additional setup after loading the view, typically from a nib. wormhole = new Wormhole("group.co.hussam.wristcontrol", "messageDir"); wormhole.PassMessage("isPhoneRunning", true); wormhole.ListenForMessage <int> ("watchTaps", (count) => { if (count > watchTaps) { watchTaps = count; InvokeOnMainThread(() => { watchTapsLabel.Text = watchTaps.ToString(); }); } }); }
private static int DistanceThroughWormhole(Location from, MapObject to, Wormhole wormhole, IEnumerable <Wormhole> wormholes, int turnsElapsed, int pirateSpeed) { // DistanceThroughWormhole tries to find the best route's distance from a location to another, using a spaceobject with a certain speed (pirateSpeed). // It tries to map the shortest route from point A to point B, taking shortcuts through wormholes when needed. // When a pirate must wait for a wormhole to reactivate, we consider those turns wasted waiting as distance wasted, and therefore, we also create a variable turnsElapsed. // When we try to calculate how much time a pirate spends waiting for any wormhole to reactivate, we must know how many turns have been elapsed since the start of the route. // For reasons above, when we calculate the distance through additional wormholes, we give the function the "turnsElapsed" so that it knows if it should expect to wait at a certain wormhole upon arrival. int turns = 0; if (to.Distance(wormhole) / pirateSpeed < wormhole.TurnsToReactivate - turnsElapsed) { turns = wormhole.TurnsToReactivate - (to.Distance(wormhole) / pirateSpeed) - turnsElapsed; } return(from.Distance(wormhole) + turns * pirateSpeed + ClosestDistance(wormhole.Partner.Location, to, wormholes.Where(w => w.Id != wormhole.Id && w.Id != wormhole.Partner.Id), to.Distance(wormhole) / pirateSpeed + turns + turnsElapsed, pirateSpeed)); }
private static void Cosmos_OnBindCLRObjToWebPage(object SourceObj, Wormhole eventWormhole, string eventName) { switch (eventName) { case "SizeChanged": { Form thisForm = SourceObj as Form; thisForm.SizeChanged += ThisForm_SizeChanged; } break; case "OnClick": { Button thisbtn = SourceObj as Button; thisbtn.Click += Thisbtn_Click; } break; case "TextChanged": { TextBox textBox = SourceObj as TextBox; if (textBox != null) { textBox.TextChanged += TextBox_TextChanged; } } break; case "OnMyCustomClick": { DemoComponents.ucButtonsAndTextBoxes ucButtonsAndTextBoxes = SourceObj as DemoComponents.ucButtonsAndTextBoxes; if (ucButtonsAndTextBoxes != null) { ucButtonsAndTextBoxes.MyCustomClick += UcButtonsAndTextBoxes_MyCustomClick; } } break; case "OnAfterSelect": { TreeView thisTreeview = SourceObj as TreeView; thisTreeview.AfterSelect += ThisTreeview_AfterSelect; } break; } }
public void WormholeShouldDisplaceBlueGooseFromLocalBubbleToSchedarSector() { // arrange var localBubble = new List <Spacecraft> { blueGoose, serenity, babylon5, ussVoyager }; var schedarSector = new List <Spacecraft> { samulakiStation }; var wormhole = new Wormhole(localBubble, schedarSector); // act wormhole.Displace(blueGoose); // assert localBubble.Should().NotContain(blueGoose); schedarSector.Should().Contain(blueGoose); }
public string PrintPath(List <MapObject> path) { string s = ""; foreach (MapObject l in path) { if (l is Wormhole) { Wormhole z = l as Wormhole; s += "Wormhole number " + z.Id + "===> "; } else { s += "target " + l; } } return(s); }
//PICKUPS public void ApplyPickUp(Extra pickup) { if (pickup is Shield) { if (shieldCount < maxCollectableShields) { Shield shield = (Shield)pickup; shields.Enqueue(shield); shieldCount++; HUDManager.GetInstance().CollectShield(shieldCount); } } else if (pickup is Wormhole) { warpDrive = (Wormhole)pickup; StartCoroutine(Wormhole_C(warpDrive)); } }
public override void ViewDidLoad() { base.ViewDidLoad (); // Perform any additional setup after loading the view, typically from a nib. btnConnect.Enabled = true; btnPush.Enabled = false; lbConnected.TextColor = UIColor.Red; lbConnected.Text = "Not connected"; lbStatus.Text = "..."; _wormHole = new Wormhole ("group.tech.seamlessthingies.ccmqttex", "messageDir"); _wormHole.ListenForMessage<string> ("emotion", (message) => { _mqttClient.Publish("mqttdotnet/pubtest", "Hi from your watch!", QoS.BestEfforts, false); InvokeOnMainThread(() => { lbStatus.Text = "got message from watch: " + _i.ToString();}); _i++; }); _mqttClient = MqttClientFactory.CreateClient ("tcp://m11.cloudmqtt.com:12360", Guid.NewGuid ().ToString (), "mike", "cloudmqtt"); _mqttClient.Connected += (object sender, EventArgs e) => { InvokeOnMainThread (() => { btnConnect.Enabled = false; btnPush.Enabled = true; lbConnected.TextColor = UIColor.Green; lbConnected.Text = "Connected"; _connected = true; }); }; _mqttClient.ConnectionLost += (object sender, EventArgs e) => { InvokeOnMainThread (() => { btnConnect.Enabled = true; btnPush.Enabled = false; lbConnected.TextColor = UIColor.Red; lbConnected.Text = "Not connected"; _connected = false; }); }; _mqttClient.Connect (true); }
// Update is called once per frame void Update() { float delta = velocity * Time.deltaTime; distanceTravelled += delta; systemRotation += delta * deltaRotation; if (systemRotation >= currentHole.CurveAngle) //Using the curve angle to detect the end of a pipe segment { delta = (systemRotation - currentHole.CurveAngle) / deltaRotation; currentHole = holePrefab.SetUpNextPipe(); // deltaRotation = 360f / (2f * Mathf.PI * currentHole.CurveRadius); SetUpCurrentHole(); systemRotation = delta * deltaRotation; } holePrefab.transform.localRotation = Quaternion.Euler(0f, 0f, systemRotation); UpdateAvatarRotation(); }
public bool isPortalDangerous(Wormhole wormhole) { int count = 0; foreach (Pirate p in GameSettings.Game.GetEnemyLivingPirates()) { if (p.Distance(wormhole) <= p.PushRange) { if (count > 1) { return(true); } else { count++; } } } return(false); }
public List <MapObject> bestMothershipAndCapsulePair(Wormhole wormhole) { List <MapObject> best = new List <MapObject>(); Location partnerLocation = wormhole.Partner.Location; Mothership bestMothership = game.GetMyMotherships() //Closest Mothership to wormhole .OrderBy(mothership => mothership.Distance(wormhole.Location)) .FirstOrDefault(); Capsule bestCapsule = game.GetMyCapsules() //Closest Capsule to partner .OrderBy(capsule => capsule.Distance(wormhole.Partner)) .FirstOrDefault(); if (NewWormholeLocation[wormhole.Partner] != partnerLocation) { partnerLocation = wormhole.Partner.Location.Towards(partnerLocation, game.PushDistance); } int distance = WormholePossibleLocationDistance(bestMothership.Location, bestCapsule.Location, wormhole.Location, partnerLocation); bestMothership = game.GetMyMotherships() //Closest Mothership to partner .OrderBy(mothership => mothership.Distance(wormhole.Partner)) .FirstOrDefault(); bestCapsule = game.GetMyCapsules() //Closest Capsule to wormholelocation .OrderBy(capsule => capsule.Distance(wormhole.Location)) .FirstOrDefault(); int distance2 = WormholePossibleLocationDistance(bestMothership.Location, bestCapsule.Location, wormhole.Location, partnerLocation); if (distance < distance2) { bestMothership = game.GetMyMotherships() //Closest Mothership to wormhole .OrderBy(mothership => mothership.Distance(wormhole.Location)) .FirstOrDefault(); bestCapsule = game.GetMyCapsules() //Closest Capsule to partner .OrderBy(capsule => capsule.Distance(wormhole.Partner)) .FirstOrDefault(); best.Add(bestMothership); best.Add(bestCapsule); return(best); } best.Add(bestMothership); best.Add(bestCapsule); return(best); }
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { Current = this; wormHole = new Wormhole("group.co.conceptdev.WatchTodo", "messageDir"); var FileManager = new NSFileManager(); var appGroupContainer = FileManager.GetContainerUrl("group.co.conceptdev.WatchTodo"); var appGroupContainerPath = appGroupContainer.Path; Console.WriteLine("agcpath: " + appGroupContainerPath); var sqliteFilename = "TodoSQLite.db3"; // App Group storage, shared with Watch Extension var path = Path.Combine(appGroupContainerPath, sqliteFilename); var conn = new SQLiteConnection(path); Database = new TodoItemDatabase(conn); // HACK: temporary population of data if (Database.GetItems().Count() == 0) { Database.SaveItem(new TodoItem { Name = "buy pineapple" }); Database.SaveItem(new TodoItem { Name = "buy dragon fruit", Done = true }); Database.SaveItem(new TodoItem { Name = "buy honeydew" }); Database.SaveItem(new TodoItem { Name = "buy rockmelon" }); } return(true); }
void generateTwin() { int width, height; height = Consts.sizeToArea[GameGameObject.instance.game.getSize()]; width = height; System.Random random = new System.Random(); Dictionary <Vector2, bool> planetLocs = new Dictionary <Vector2, bool>(); foreach (Planet planet in GameGameObject.instance.game.getPlanets()) { planetLocs.Add(new Vector2(planet.getX(), planet.getY()), true); } Vector2 loc = new Vector2(random.Next(width), random.Next(height)); while (!isValidLocation(loc, planetLocs, Consts.planetMinDistance)) { loc = new Vector2(random.Next(width), random.Next(height)); } GameObject go = GameObject.Instantiate(WormholeGameObject.gameObject, WormholeGameObject.gameObject.transform.parent); Wormhole wormhole = new Wormhole(getName().Replace('a', 'b'), (int)loc.x, (int)loc.y); go.GetComponent <WormholeGameObject>().setWormhole(wormhole); go.GetComponent <WormholeGameObject>().getWormhole().twinID = getID(); twinID = go.GetComponent <WormholeGameObject>().getWormhole().getID(); GameGameObject.instance.game.addWormholes(go.GetComponent <WormholeGameObject>().getWormhole()); go.transform.localPosition = new Vector3(go.GetComponent <WormholeGameObject>().getWormhole().getX() - width / 2, go.GetComponent <WormholeGameObject>().getWormhole().getY() - height / 2); go.name = wormhole.getName(); go.SetActive(true); go.transform.SetAsFirstSibling(); Debug.Log("Wormhole: " + wormhole.getName()); }
private void RecalculateSolarSystems(Map spaceMap) { foreach (var solarSystem in spaceMap.Systems) { try { SolarSystems.Add(solarSystem.Name, solarSystem); foreach (var connection in solarSystem.ConnectedSolarSystems) { var connectedSolarSystem = SpaceMap.Systems.FirstOrDefault(system => system.Name == connection); if (connectedSolarSystem?.Name == null) { continue; } if (connectedSolarSystem.IsDeleted) { continue; } var pointFrom = new Point(solarSystem.LocationInMap.X, solarSystem.LocationInMap.Y); var pointTo = new Point(connectedSolarSystem.LocationInMap.X, connectedSolarSystem.LocationInMap.Y); //Draw connection line center var centerLinePoint = new Point((pointFrom.X + pointTo.X) / 2, (pointFrom.Y + pointTo.Y) / 2); var newConnection = new Wormhole { Location = centerLinePoint, SolarSystemFrom = solarSystem.Name, SolarSystemTo = connectedSolarSystem.Name }; Wormholes.Add(newConnection); } } catch (Exception ex) { _commandsLog.ErrorFormat("[MapView.RecalculateSolarSystems] Critical error {0}", ex); } } }
/** * Generate the Wormholes from the given save */ private void generateWormholes(Game game) { DirectoryInfo dirInf = new DirectoryInfo(GameLocation + "/Wormholes/"); Debug.Log(dirInf.ToString()); if (dirInf.Exists) { FileInfo[] files = dirInf.GetFiles("*.wormhole"); foreach (FileInfo file in files) { Wormhole wormhole = JsonUtility.FromJson <Wormhole>(File.ReadAllText(file.FullName)); GameObject go = GameObject.Instantiate(baseWormhole, planetParent.transform); go.GetComponent <WormholeGameObject>().setWormhole(wormhole); game.addWormholes(go.GetComponent <WormholeGameObject>().getWormhole()); go.transform.localPosition = new Vector3(go.GetComponent <WormholeGameObject>().getWormhole().getX() - game.getWidth() / 2, go.GetComponent <WormholeGameObject>().getWormhole().getY() - game.getHeight() / 2); go.name = wormhole.getName(); go.SetActive(true); } } }
private Location BestWormholePushLocation(Wormhole wormhole) { // Returns the most favorable position to push the wormhole to, taking into consideration position of capsules and motherships. var bestOption = wormhole.Location; var bestOptionScore = GetWormholeScore(wormhole.Location, GetWormholeLocation(wormhole.Partner)); for (int i = 0; i < CircleSteps; i++) { double angle = System.Math.PI * 2 * i / CircleSteps; double deltaX = game.HeavyPushDistance * System.Math.Cos(angle); double deltaY = game.HeavyPushDistance * System.Math.Sin(angle); Location newWormholeLocation = new Location((int)(wormhole.Location.Row - deltaY), (int)(wormhole.Location.Col + deltaX)); int newLocationScore = GetWormholeScore(newWormholeLocation, GetWormholeLocation(wormhole.Partner)); if (newLocationScore < bestOptionScore) { bestOption = newWormholeLocation; bestOptionScore = newLocationScore; } } return(bestOption); }
// Called every frame the boss is attacking private void RippingReality() { // Play animation m_animator.SetTrigger("Cut"); AudioManager.Instance.PlaySound("riftAppear"); StartCoroutine(Wait(1.0f, () => { // Spawn reality attack m_wormhole = Instantiate(m_wormholePrefab, m_wormholeSpawn.position, Quaternion.identity).GetComponent <Wormhole>(); m_wormhole.m_boss = this; m_wormhole.Init(m_wormholeProjectilePrefab); m_state = EState.wormholeAttack; })); if (m_state == EState.rippingReality) { m_state = EState.idle; } }
public override void Awake(NSObject context) { base.Awake(context); _wormHole = new Wormhole(AppSettings.iOSAppGroupIdentifier, AppSettings.iOSAppGroupDirectory); _wormHole.ListenForMessage <NextPillsMessage> (NextPillsMessage.MessageType, UpdateUI); var waitingAttrString = new NSAttributedString("Please, open Patients on your iPhone", new UIStringAttributes { Font = UIFont.SystemFontOfSize(14, UIFontWeight.Light) }); waitingLabel.SetText(waitingAttrString); var nextInAttrString = new NSAttributedString("Next", new UIStringAttributes { Font = UIFont.SystemFontOfSize(14, UIFontWeight.Medium) }); nextInLabel.SetText(nextInAttrString); ToggleUI(true); }
public GameLayer(float scaleX, float scaleY) { contentScaleFactorY = scaleY; contentScaleFactorX = scaleX; var speedFactor = contentScaleFactorX < contentScaleFactorY ? contentScaleFactorX : contentScaleFactorY; monkeySpeed *= (float)speedFactor; var touchListener = new CCEventListenerTouchAllAtOnce (); touchListener.OnTouchesEnded = OnTouchesEnded; AddEventListener (touchListener, this); Color = new CCColor3B (CCColor4B.White); Opacity = 255; visibleBananas = new List<CCSprite> (); hitBananas = new List<CCSprite> (); // batch node for physics balls ballsBatch = new CCSpriteBatchNode ("balls", 100); ballTexture = ballsBatch.Texture; AddChild (ballsBatch, 1, 1); AddGrass (); AddSun (); StartScheduling (); CCSimpleAudioEngine.SharedEngine.PlayBackgroundMusic ("sounds/backgroundMusic", true); #if IOS wormhole = new Wormhole ("group.com.mikebluestein.GoneBananas", "messageDir"); wormhole.ListenForMessage<int> ("dpad", (message) => { CCPoint ds; float delta = 25.0f; switch (message) { case 1: //right float dx0 = allowableMovementRect.Size.Width - monkey.Position.X; delta = dx0 < delta ? dx0 : delta; ds = new CCPoint (delta, 0); break; case 2: //left delta = monkey.Position.X - delta < 0 ? 0 : delta; ds = new CCPoint (-delta, 0); break; case 3: //up float dy0 = allowableMovementRect.Size.Height - monkey.Position.Y; delta = dy0 < delta ? dy0 : delta; ds = new CCPoint (0, delta); break; case 4: //down delta = monkey.Position.Y - delta < 0 ? 0 : delta; ds = new CCPoint (0, -delta); break; default: ds = new CCPoint (); break; } var dt = delta / monkeySpeed; var moveMonkey = new CCMoveBy (dt, ds); monkey.RunAction (walkRepeat); monkey.RunActions (moveMonkey, new CCDelayTime (0.2f), walkAnimStop); }); #endif }
public override void Awake (NSObject context) { base.Awake (context); wormHole = new Wormhole ("group.com.mikebluestein.GoneBananas", "messageDir"); }
void OnTriggerEnter(Collider other) { if(other.GetComponent<Collider>().tag == Tags.Asteroid) { _hasCollision = true; _boostParticles.startSize = 0; StartCoroutine(EngineSoundOff()); StartCoroutine(CollisionVelocity()); } if(other.GetComponent<Collider>().tag == Tags.WormholeEnter) { _hasWormhole = true; _wormholeEnter = other.GetComponent<Wormhole>(); _wormholeExit = other.transform.root.GetComponent<Wormhole>(); _boostParticles.startSize = 0; StartCoroutine(WormholeEnter()); } if(other.GetComponent<Collider>().tag == Tags.Blackhole) { _blackHole = other.GetComponent<Blackhole>(); _boostParticles.Stop(); StartCoroutine(BlackholeEnter()); } if(other.GetComponent<Collider>().tag == Tags.Pulsar) { if(!_isRocketHasPulsarVelocity) { _isRocketHasPulsarVelocity = true; _blackHole = other.GetComponent<Blackhole>(); GetComponent<Rigidbody>().AddForce( transform.forward * (10.5f + Vector3.Distance(transform.position, other.transform.position)), ForceMode.Impulse); StartCoroutine(DisablePulsarVelocity()); } } }
public HomeView (IntPtr handle) : base (handle) { _wormhole = new Wormhole(AppSettings.iOSAppGroupIdentifier, AppSettings.iOSAppGroupDirectory); }
private PlanetSystem readSystem(string dataText, string fileName, StreamReader reader, bool isHomeSystem) { if (dataText == "<{>") { // Start of block PlanetSystem system = new PlanetSystem(); string name = ""; string line = reader.ReadLine().Trim (); while (line != "<}>") { string[] lineParts; //Split category name from data lineParts = line.Split(":".ToCharArray(), 2); //Remove any extra whitespace from parts & set descriptive variables string newDataType = gameManager.LanguageMgr.StringToDataType(lineParts[0] = lineParts[0].Trim ()); string newDataText = lineParts[1] = lineParts[1].Trim (); if (newDataType == "Name") { name = readTextLine(newDataType, newDataText, fileName); if (name != "") { system.HasRealName = true; } else { system.HasRealName = false; } } else if (newDataType == "Expansion") { system.Expansion = gameManager.LanguageMgr.StringToExpansion(readTextLine(newDataType, newDataText, fileName)); } else if (newDataType == "Type") { string typeString = readTextLine (newDataType, newDataText, fileName); if (typeString != gameManager.LanguageMgr.StringToSTag("Standard") && typeString != gameManager.LanguageMgr.StringToSTag("Empty")) { if (isHomeSystem) { system.SysTypes = new SType[2]{gameManager.LanguageMgr.StringToSType(typeString), SType.Home}; } else { system.SysTypes = new SType[1]{gameManager.LanguageMgr.StringToSType (typeString)}; } } else if (isHomeSystem) { system.SysTypes = new SType[1]{SType.Home}; } } else if (newDataType == "Planets") { Planet[] planets = readPlanetsBlock(newDataType, newDataText, fileName, reader); ArrayList planetsForSystem = new ArrayList(); ArrayList wormholesForSystem = new ArrayList(); foreach(Planet planet in planets){ string[] parts = planet.Name.Split(' '); if (parts.Length == 2 && parts[1] == gameManager.LanguageMgr.StringToSTag ("Wormhole")) { Wormhole wormhole = new Wormhole(); wormhole.Name = planet.Name; wormholesForSystem.Add (wormhole); } else { planetsForSystem.Add (planet); } } system.Planets = (Planet[])planetsForSystem.ToArray(typeof(Planet)); system.Wormholes = (Wormhole[])wormholesForSystem.ToArray(typeof(Wormhole)); } else if (newDataType == "ID") { system.Id = readTextLine (newDataType, newDataText, fileName); } line = reader.ReadLine().Trim (); } // End of block if (system.HasRealName == false) { foreach(Planet planet in system.Planets){ if (name != "") { name += "/"; } name += planet.Name; } foreach(Wormhole wormhole in system.Wormholes) { if (name != "") { name += "/"; } name += wormhole.Name; } if (name == "") { name = gameManager.LanguageMgr.STagToString ("Empty") + " " + gameManager.LanguageMgr.STagToString("System"); } system.Name = name; } else if (system.Planets.Length == 1 && system.SysTypes.Length == 1 && system.SysTypes[0] == SType.Special){ system.Name = system.Planets[0].Name + " " + name; } else { system.Name = name; } if (system.Id == default(string)) { system.Id = system.Name; } return system; } else { throw new System.Exception(string.Format("Error reading file {0}:: got \"{1}\" should be <{>", fileName, dataText)); } }