private void Start() { GlobalVars.Instance.DropedWeaponAllClear(); GlobalVars.Instance.ApplyAudioSource(); GlobalVars.Instance.SwitchFlashbang(bVis: false, Vector3.zero); GlobalVars.Instance.resetFever(timeover: true); InitializeFirstPerson(); battleChat = GetComponent <BattleChat>(); BrickManManager.Instance.OnStart(); delayLoad = true; deltaTime = 0f; BlackHole component = GameObject.Find("Main").GetComponent <BlackHole>(); if (component != null) { component.placeTo(new Vector3(37f, -15f, 37f)); } GameObject gameObject = GameObject.Find("Main"); if (gameObject != null) { ShooterTools component2 = gameObject.GetComponent <ShooterTools>(); if (component2 != null) { component2.DoBuff(); } } }
private void VoidAttack() { BasicIdleMovement(blackHoleWhoAmI > -1 ? 0.8f : 0.2f); if (timers["ARCHATK"] == 50) //Spawn projectile { int p = Projectile.NewProjectile(npc.Center, Vector2.Zero, ModContent.ProjectileType <Projectiles.VoidCastProjectile>(), 60, 1f, Main.myPlayer); Main.projectile[p].timeLeft = ArchonAttackMaxTime - 50; blackHoleWhoAmI = p; } else if (timers["ARCHATK"] > 50 && timers["ARCHATK"] < ArchonAttackMaxTime - 100 && blackHoleWhoAmI > -1) //Control void projectile & break if hit { if (!BlackHole.active) { return; } BlackHole.velocity = BlackHole.DirectionTo(Target.Center) * 4; for (int i = 0; i < Main.maxProjectiles; ++i) { Projectile proj = Main.projectile[i]; if (i != blackHoleWhoAmI && proj.active && !proj.hostile && proj.friendly && proj.DistanceSQ(BlackHole.Center) < 40 * 40) //Detect all friendly projectiles { proj.Kill(); } } } }
// Update is called once per frame void Update() { if (gameManager.IsGameActive()) { for (int i = 0; i < gameManager.BlackHoles.Count; i++) { BlackHole script = gameManager.BlackHoles[i].GetComponent <BlackHole>(); Vector2 vec = (transform.localPosition - gameManager.BlackHoles[i].transform.localPosition); if (vec.magnitude < (script.currentSize / 2)) { Feed(script); } else if (vec.magnitude < script.currentPullSize) { if (script.isActive) { Gravitate(gameManager.BlackHoles[i].transform.position, script.currentSize, script.currentPullSize); } } } UpdatePosition(); } }
/// <summary> /// Resets values of the current contour settings /// </summary> private void RestartValues() { // if we change a type of a stone, everything will be reseted ContourRock contourRck = contourRocks.Where(ctr => ctr.contour_name.Equals(((ComboBoxItem)contourNameCombo.SelectedItem).Content)).First(); contourRocks.Remove(contourRck); A_Rock contextRock = null; if (blackHoleCmbIt.IsSelected && !(contourRck.rock is BlackHole)) { contextRock = new BlackHole(); } if (generatorCmbIt.IsSelected && !(contourRck.rock is Generator)) { contextRock = new Generator(); } if (gravitonCmbIt.IsSelected && !(contourRck.rock is Graviton)) { contextRock = new Graviton(); } if (magnetonCmbIt.IsSelected && !(contourRck.rock is Magneton)) { contextRock = new Magneton(); } if (contextRock != null) { contourRck.rock = contextRock; } contourRocks.Add(contourRck); }
private void Update() { VerifyLocalController(); if (null != localController && showFx) { deltaTime += Time.deltaTime; if (deltaTime > 3f) { deltaTime = 0f; showFx = false; if (!localController.IsDead && !localController.bungeeRespawn) { P2PManager.Instance.SendPEER_BLACKHOLE_EFF(localController.TranceformPosition); BlackHole component = GameObject.Find("Main").GetComponent <BlackHole>(); localController.TranceformPosition = component.gotoPos(MyInfoManager.Instance.Slot); localController.ActivateBlackhole = true; localController.ActivateBlackholeUser = userSeq; if (MyInfoManager.Instance.Seq == userSeq) { GlobalVars.Instance.PlayOneShot(sndEnd); } } } } }
private static BlackHole CreateBlackHole(float density, float blackHoleActiveTime) { var hole = new BlackHole() { Name = "Black Hole" }; hole.DrawStrategy = new PhysicsShapeDrawStrategy() { Color = Color.Violet }; hole.Physics.FixtureDescription = new CircleDescription() { Radius = 2.0f, Density = density, CollisionCategory = Category.None }; Behave.This(hole) .BlendIn(forSeconds: 0.7f) .AndAtTheSameTime() .After(blackHoleActiveTime) .BlendOut(forSeconds: 1) .Despawn(); return(hole); }
private void btBlackHole_Click(object sender, EventArgs e) { BlackHole blackHole = new BlackHole(); astroEditors.Add(blackHole.uid, EditBlackHole); AddNewAstroObject(blackHole); }
public override void OnHitByItem(Player player, Item item, int damage, float knockback, bool crit) { if (GetArchon.enchantment == Archon.Archon.Enchantment.Void && item.melee && blackHoleWhoAmI != -1) { BlackHole.Kill(); blackHoleWhoAmI = -1; } }
public override object ToUFEEffect() { var eff = new BlackHole(); eff.LocationX = _StartX; eff.LocationY = _StartY; return(eff); }
new void ApplyChanges() { base.ApplyChanges(); BlackHole newBlackHole = new BlackHole(blackHole.Name, blackHole.Position, blackHole.Mass); //blackHole.Size = BlackHole.GetRadius(blackHole.Mass); blackHole = newBlackHole; }
/// <summary> /// Adds a stone to a gameboard /// </summary> private void InsertRockImage(System.Windows.Input.MouseButtonEventArgs e) { if (MouseInTableArea(e, dragImage_new)) { int left = (int)e.GetPosition(tablePanel).X - dragImage_mousePos_X; int top = (int)e.GetPosition(tablePanel).Y - dragImage_mousePos_Y; // sets handler so that we can manipulate with the object dragImage_new.MouseDown += new System.Windows.Input.MouseButtonEventHandler(RockImageOld_MouseDown); dragImage_new.MouseUp += new System.Windows.Input.MouseButtonEventHandler(rockImage_MouseUp); // check the type of the object to insert A_TableObject object_to_put = null; if ((A_TableObject)dragImage_new.DataContext is Graviton) { object_to_put = new Graviton(); ((Graviton)object_to_put).Name = "Graviton"; ((Graviton)object_to_put).BaseSettings = tableManager.TableDepositor.table.Settings.gravitonSettings; } if ((A_TableObject)dragImage_new.DataContext is Generator) { object_to_put = new Generator(); ((Generator)object_to_put).Name = "Generator"; ((Generator)object_to_put).BaseSettings = tableManager.TableDepositor.table.Settings.generatorSettings; } if ((A_TableObject)dragImage_new.DataContext is Magneton) { object_to_put = new Magneton(); ((Magneton)object_to_put).Name = "Magneton"; ((Magneton)object_to_put).BaseSettings = tableManager.TableDepositor.table.Settings.magnetonSettings; } if ((A_TableObject)dragImage_new.DataContext is BlackHole) { object_to_put = new BlackHole(); ((BlackHole)object_to_put).Name = "BlackHole"; ((BlackHole)object_to_put).BaseSettings = tableManager.TableDepositor.table.Settings.blackHoleSettings; } // sets position object_to_put.Position = PointHelper.TransformPointToEuc(new FPoint(left * CommonAttribService.ACTUAL_TABLE_SIZE_MULTIPLIER + dragImage_new.Width / 2, top * CommonAttribService.ACTUAL_TABLE_SIZE_MULTIPLIER + dragImage_new.Height / 2), CommonAttribService.ACTUAL_TABLE_WIDTH, CommonAttribService.ACTUAL_TABLE_HEIGHT); dragImage_new.DataContext = object_to_put; // add it into a system tableManager.InsertObject(object_to_put); rockImages.Add(dragImage_new); } else { // icon is beyond the border of the game table -> delete it if (tablePanel.mainGrid.Children.Contains(dragImage_new)) { tablePanel.mainGrid.Children.Remove(dragImage_new); } } dragImage_new = null; }
void Awake() { base.Awake(); shockwavePrefab = Resources.Load <GameObject>("Prefabs/Shockwave"); coneShotPrefab = Resources.Load <ConeShot>("Prefabs/ConeShot"); weaveShotPrefab = Resources.Load <WeaveShot>("Prefabs/WeaveShot"); clusterBombPrefab = Resources.Load <ClusterBomb>("Prefabs/ClusterBomb"); blackHolePrefab = Resources.Load <BlackHole>("Prefabs/BlackHole"); }
protected void CreateBlackHole(Vector3 spawnPoint) { if (!alreadyHit) { BlackHole blackHole = GameObject.Instantiate(data.blackHolePrefab, spawnPoint, Quaternion.identity).GetComponent <BlackHole>(); blackHole.SetupBlackHole(data.blackHoleRadius, player.playerNumber, data.blackHoleGravity, data.blackHoleDuration, player.controller.playerColor); alreadyHit = true; } }
public void EnterHole(BlackHole blackHole) { if (!isActiveted) { return; } this.blackHole = blackHole; BlackHole.onBlackHole += MoveToBlackHole; }
public void LeaveHole() { if (blackHole == null) { return; } BlackHole.onBlackHole -= MoveToBlackHole; blackHole = null; }
void MakeBlackHole() { if (isRiki) { shape.enabled = false; Destroy(rb); } BlackHole.Create(t.position, item.power); }
public void ANullPropertyValueShouldNotSerializeAsAnEmptyElement() { var serializer = new XmlSerializer<BlackHole>(x => x.Indent()); var blackHole = new BlackHole { Type = null }; var xml = serializer.Serialize(blackHole); Assert.That(xml, Is.Not.StringMatching(@"<Type\s*/>")); }
void Awake() { if (instance == null) { instance = this; } else { Destroy(this); } }
public void PullTowards(BlackHole blackHole, float pullMagnitude) { if (this == null) //Dumb check because Unity calls this even if it destroys the object { return; } Vector3 pull = blackHole.transform.position - transform.position; Velocity += pull.normalized * pullMagnitude; }
/// <summary> /// Sets prototypes of all stones for the bottom bar /// </summary> private void SetToolContext() { Graviton rck = new Graviton(); Generator gn = new Generator(); Magneton mg = new Magneton(); BlackHole blh = new BlackHole(); tablePanel.tableToolPanel.generatorRockImage.DataContext = gn; tablePanel.tableToolPanel.gravityRockImage.DataContext = rck; tablePanel.tableToolPanel.magnetonRockImage.DataContext = mg; tablePanel.tableToolPanel.blackHoleRockImage.DataContext = blh; }
// Update is called once per frame void Update() { var x = 0; if (Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D)) { x = -1; } if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A)) { x = 1; } if (!movementEnabled) { x = 0; } var totalGravity = BlackHole.AccelerationAtPoint(transform.position); var newVelocity = rg.velocity + Vector2.Dot(totalGravity, transform.right) * (Vector2)transform.right * Time.deltaTime; var angle = (Mathf.Atan2(newVelocity.y, newVelocity.x) - Mathf.PI * 0.5f) + x * rotationSpeed * Time.deltaTime; transform.rotation = Quaternion.Euler(0, 0, angle * Mathf.Rad2Deg); rg.velocity = (Vector2)transform.up * (speed + currentBoost); if (Time.time - boostTime > boostDuration) { currentBoost = Mathf.Lerp(currentBoost, 0, 4 * Time.deltaTime); } if (Input.GetKeyDown(KeyCode.Space) && boostButton.interactable) { Jump(); } if (Time.time - boostTime > boostCooldown) { boostIcon.sprite = boostActive; boostButton.interactable = true; } else { boostIcon.sprite = boostInactive; boostButton.interactable = false; } if (Input.GetKeyDown(KeyCode.W)) { var go = GameObject.Instantiate(duck, transform.position, Quaternion.identity) as GameObject; go.GetComponent <Rigidbody2D>().velocity = transform.up * duckSpeed; } }
public void ANullPropertyValueShouldNotSerializeAsAnEmptyElement() { var serializer = new XmlSerializer <BlackHole>(x => x.Indent()); var blackHole = new BlackHole { Type = null }; var xml = serializer.Serialize(blackHole); Assert.That(xml, Is.Not.StringMatching(@"<Type\s*/>")); }
public void VerifyThatAPropertyOfTypeTypeCanSuccessfullyRoundTrip(Type type) { var serializer = new XmlSerializer<BlackHole>(x => x.Indent()); var blackHole = new BlackHole { Type = type }; var xml = serializer.Serialize(blackHole); var roundTrip = serializer.Deserialize(xml); Assert.That(roundTrip.Type, Is.EqualTo(blackHole.Type)); }
IEnumerator SpawnPortal() { BlackHole myPortal = portalPrefab; while (numberOfBHToSpawn > 0) { yield return(new WaitForSecondsRealtime(timeBetweenSpawns)); Instantiate(myPortal, spawnPositions[Random.Range(0, spawnPositions.Length)], Quaternion.identity, transform); numberOfBHToSpawn--; } spawningFinished = true; }
public void BlackHoleTest() { var value = new BlackHole(null, Vector3 <HugeNumber> .Zero); var json = JsonSerializer.Serialize(value); Console.WriteLine(); Console.WriteLine(json); var deserialized = JsonSerializer.Deserialize <BlackHole>(json); Assert.AreEqual(value, deserialized); Assert.AreEqual(json, JsonSerializer.Serialize(deserialized)); }
public void TryTeleportTo(BlackHole from, BlackHole hole) { if (lastBlackHole == from && Time.time - lastBlackHoleTime < 1f) { // Too soon return; } CameraFollower.instance.StartLerp(); transform.position = hole.transform.position; lastBlackHole = hole; lastBlackHoleTime = Time.time; }
public void VerifyThatAPropertyOfTypeTypeCanSuccessfullyRoundTrip(Type type) { var serializer = new XmlSerializer <BlackHole>(x => x.Indent()); var blackHole = new BlackHole { Type = type }; var xml = serializer.Serialize(blackHole); var roundTrip = serializer.Deserialize(xml); Assert.That(roundTrip.Type, Is.EqualTo(blackHole.Type)); }
void OnTriggerEnter(Collider col) { if (col.GetComponent <Magnet>()) { Destroy(col.gameObject); Debug.Log("GameOver"); } else { Magnet.RemoveAttractor(this); BlackHole.RegisterSink(); Destroy(gameObject); } }
public override Item CreateItem(double left, double top) { var id = Guid.NewGuid().ToString(); var randomItemNumber = _rnd.Next(0, 45); Item item; switch (randomItemNumber) { case int n when(n <= 30): item = new Star(id, left, top, 5); break; case int n when(n > 31 && n <= 32): item = new Shield(id, left, top, new Star(id, left, top, 5)); break; case 33: item = new Asteroid(id, left, top, new Star(id, left, top, 5)); break; case 34: item = new Asteroid(id, left, top, new Shield(id, left, top, new Star(id, left, top, 5))); break; case int n when(n >= 35 && n <= 36): item = new Rocket(id, left, top); break; case int n when(n >= 37 && n <= 42): item = new AlienFood(id, left, top); break; case 43: item = new BlackHole(id, left, top); break; case 44: item = new SpaceSuit(id, left, top); break; default: item = new SpaceSuit(id, left, top); break; } return(item); }
void HandleOnPenaltyTime(float penaltyTime, BlackHole blackHole) { // Add penalty //this.penaltyTime += penaltyTime; // Red flickering float time = 0.5f; Sequence seq = DOTween.Sequence(); seq.Append(label.DOColor(Color.red, time)); seq.Append(label.DOColor(Color.white, time)); seq.SetLoops(3); seq.Play(); }
public BlackHoleMapUnit(Map map, BlackHole blackHole, Vector movementOffset) : base(map, blackHole, movementOffset) { this.blackHole = blackHole; var gravityWells = blackHole.GravityWells; GravityWellInfos = new BlackHoleGravityWellInfo[gravityWells.Count]; for (int i = 0; i < GravityWellInfos.Length; i++) { GravityWellInfos[i] = new BlackHoleGravityWellInfo(gravityWells[i]); } }
void Awake() { if (Instance == null) { Instance = this; } else if (Instance != this) { Destroy(gameObject); } mr = GetComponent <MeshRenderer>(); col = GetComponent <Collider>(); depth = transform.position.z - Camera.main.transform.position.z; }
/// <summary> /// /// </summary> /// <param name="star"></param> public void AddBlackHole(BlackHole blackHole) { _blackHoles.Add(blackHole); // _blackHoleMeshes.Add( }
private IEnumerable<bool> _cooperativeForce(StackContext sctx, Action<PValue> setReturnValue) { if (sctx == null) throw new ArgumentNullException("sctx"); while (true) { //Check if evaluation resulted in exception if (_exception != null) throw _exception; //Check if value is available if (_value != null) break; //Prevent infinite loops if (_blackHole.Trap()) continue; //If we have been trapped, check exception again //Tag thunk as being evaluated _blackHole = BlackHole.Active(Thread.CurrentThread.ManagedThreadId); Debug.Indent(); //We need to save stack space here, so try to invoke via IStackAware // Since most expressions are closures, this has a high success rate var stackAware = _expr.Value as IStackAware; if (stackAware != null) { //Exception handler defined in creation of cooperative context var exprCtx = stackAware.CreateStackContext(sctx, _parameters); sctx.ParentEngine.Stack.AddLast(exprCtx); yield return true; _value = exprCtx.ReturnValue; } else { try { _value = _expr.IndirectCall(sctx, _parameters); } catch (Exception ex) { _blackHole = _blackHole.Inactivate(); _value = PType.Null; _exception = ex; throw; } } Debug.Unindent(); var t = _value.Value as Thunk; if (t != null) { //Assimilate nested thunk _blackHole = t._blackHole; _expr = t._expr; _parameters = t._parameters; _value = t._value; _exception = t._exception; continue; } else { //Release expression _expr = null; _parameters = null; _blackHole = _blackHole.Inactivate(); break; } } setReturnValue(_value); yield break; }
PValue IIndirectCall.IndirectCall(StackContext sctx, PValue[] args) { CooperativeContext coopctx = null; coopctx = new CooperativeContext(sctx, f => _cooperativeForce(coopctx, f)) { ExceptionHandler = ex => { _blackHole = _blackHole.Inactivate(); _value = PType.Null; _exception = ex; return false; } }; var fctx = sctx as FunctionContext; if (fctx != null) { //Turn CLR call into Prexonite stack call fctx._UseVirtualMachineStackInstead(); sctx.ParentEngine.Stack.AddLast(coopctx); return PType.Null; } else { //Traditional implementation using the managed stack return sctx.ParentEngine.Process(coopctx); } }
/// <summary> /// /// </summary> private void InitUniverse() { if (_universe != null) { _universe.Clear(); _universe = null; } if (_starBufferManager != null) { _starBufferManager.Clear(); _starBufferManager = null; } _universe = new Octree(SettingsLocal.GetAsInt("MaxStarsPerSector")); List<string> galaxies = SettingsLocal.AllValuesAsString("Universe" + CurrentUniverseID() +"GalaxyID"); _starBufferManager = new StarBufferManager( SettingsLocal.GetAsInt("StarBufferSize"), GetTotalStarCount(galaxies)); var galaxyStars = new List<LinkedList<StarBufferIndex>>(galaxies.Count); foreach (string galaxyID in galaxies) { long numberfStars = SettingsLocal.GetAsLong( "Galaxy" + galaxyID + "NumberOfStars"); int distributionIterations = SettingsLocal.GetAsInt( "Galaxy" + galaxyID + "DistributionIterations"); float starVelocity = SettingsLocal.GetAsFloat("Galaxy" + galaxyID + "StarVelocity"); var stars = new LinkedList<StarBufferIndex>(); Color col = Color.FromArgb(SettingsLocal.GetAsInt("Galaxy" + galaxyID + "StarColor")); for (long a = 0; a < numberfStars; a++) { stars.AddLast(GenerateRandomStar(galaxyID, distributionIterations, starVelocity, col)); } galaxyStars.Add(stars); var blackHole = new BlackHole { PosX = (float)SettingsLocal.GetAsDouble("Galaxy" + galaxyID + "PositionX"), PosY = (float)SettingsLocal.GetAsDouble("Galaxy" + galaxyID + "PositionY"), PosZ = (float)SettingsLocal.GetAsDouble("Galaxy" + galaxyID + "PositionZ"), Mass = (float)SettingsLocal.GetAsDouble("Galaxy" + galaxyID + "SupermassiveBlackHoleSolarMasses") }; _universe.AddBlackHole(blackHole); } bool anyStarsLeft = true; while (anyStarsLeft) { anyStarsLeft = false; for (int a = 0; a < galaxyStars.Count; a++) { if (galaxyStars[a].Count == 0) continue; anyStarsLeft = true; _universe.AddStar(galaxyStars[a].First.Value); galaxyStars[a].RemoveFirst(); } } }