private void btnMNZCAP_Click(object sender, EventArgs e) { int maxi = 0, maxj = 0, max = 33; for (int i = 0; i < 4; i++) { for (int j = 0; j < 32; j++) { for (int t = 0; t < 4; t++) { W[t] = Word.Parse("0000 0000 0000 0000 0000 0000 0000 0000"); } W[i].SetBit('1', j); Serpent.ApplySerpentPermutation(ref W[0], ref W[1], ref W[2], ref W[3]); int cnt = Serpent.NonZeroColumnNumber(W); if (cnt == 2) { max = cnt; maxi = i; maxj = j; MessageBox.Show(string.Format("Max: {0}\nWord: {1}\nBit: {2}", max, maxi, maxj)); } } } //MessageBox.Show(string.Format("Max: {0}\nWord: {1}\nBit: {2}",max,maxi,maxj)); }
static void InitialiseGame(Serpent Joueur1, Serpent ennemi1) { Console.SetCursorPosition(0, 0); DrawPerso(Joueur1); DrawEnnemy(ennemi1); //Dois rajouter autres fonctionc draw ennemy pour les autres fantomes }
public void OnDestroy() { Collider[] colliders = Physics.OverlapSphere(transform.position, mDamageRadius); Serpent serpent = null; for (int i = 0, n = colliders.Length; i < n; ++i) { Collider c = colliders[i]; if (c.attachedRigidbody != null) { c.attachedRigidbody.AddExplosionForce(mExplosionForce * c.attachedRigidbody.mass, transform.position, mDamageRadius); Debug.DrawLine(transform.position, c.transform.position, Color.red, 60.0f); } if (serpent == null) { SerpentSegment segment = c.GetComponentInParent <SerpentSegment>(); if (segment != null) { serpent = segment.mSerpent; } } } if (serpent != null) { serpent.TakeDamage(mDamagePower); } Quaternion rot = Quaternion.LookRotation(transform.position.normalized, Vector3.forward); GameObject explosion = Instantiate(mExplosionPrefab, transform.position, rot) as GameObject; explosion.transform.localScale = Vector3.one * mDamageRadius; Destroy(explosion, 2.0f); }
public void Start() { if (mSerpent == null) { mSerpent = GetComponent <Serpent>(); } }
public void Start() { if(mSerpent == null) { mSerpent = GetComponent<Serpent>(); } }
private async void Deorbit(object sender, RoutedEventArgs e) { if (scriptTask == null) { return; } // Only start if it is not running. if (scriptTask.Status.Equals(TaskStatus.Running)) { Console.WriteLine("Script can't be run while another script has already been started."); return; } if (!scriptTask.IsCompletedSuccessfully) { Console.WriteLine("Deorbit can be only run after running the launch sequence."); return; } // Ask user for confirmation. MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("Are you sure you want to deorbit the rocket?", "Deorbit Confirmation", System.Windows.MessageBoxButton.YesNo); if (messageBoxResult == MessageBoxResult.Yes) { Console.WriteLine("Starting Serpent..."); scriptTask = Task.Run(() => Serpent.DeorbitalStageLoop()); await scriptTask; Console.WriteLine("Exiting Serpent."); } }
public async Task <bool> SerpentPull() { if (!Me.IsQuestObjectiveComplete(QuestId, 1)) { var serpent = Serpent.First(); if (serpent.Location.Distance(Me.Location) > 15) { TreeRoot.StatusText = "Moving to Serpent"; Navigator.MoveTo(serpent.Location); serpent.Target(); return(true); } serpent.Face(); await Coroutine.Sleep(3000); WoWMovement.MoveStop(); SpellManager.Cast(SpellId); await Coroutine.Sleep(1500); TreeRoot.StatusText = "Finished Pulling!"; _isBehaviorDone = true; return(true); } return(false); }
private async void Launch(object sender, RoutedEventArgs e) { // Only start if it is not running. if (scriptTask != null && scriptTask.Status.Equals(TaskStatus.Running)) { Console.WriteLine("Script can't be run while another script has already been started."); return; } // Ask user for confirmation. MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("Are you sure you want to launch the rocket?", "Launch Confirmation", System.Windows.MessageBoxButton.YesNo); if (messageBoxResult == MessageBoxResult.Yes) { Console.WriteLine("Starting Serpent..."); int apoapsis, periapsis; // Try getting text from GUI if (!Int32.TryParse(orbitApoapsisAltBox.Text, out apoapsis)) { Console.WriteLine("Apoapsis value is incorrect. Exiting."); return; } if (!Int32.TryParse(orbitPeriapsisAltBox.Text, out periapsis)) { Console.WriteLine("Periapsis value is incorrect. Exiting."); return; } Console.WriteLine($"Initializing Serpent with an apoapsis of {apoapsis} m and a periapsis of {periapsis} m."); scriptTask = Task.Run(() => Serpent.Start(apoapsis, periapsis, true, lbResult, progress)); await scriptTask; Console.WriteLine("Exiting Serpent."); } }
public void TrierPlatTest() { List <Plat> listPlat = new List <Plat>() { new Plat { TypePlat = "Sucrerie", PlatId = 1001, NbrBouchee = 3 }, new Plat { TypePlat = "Carnivore", PlatId = 1001, NbrBouchee = 4 }, new Plat { TypePlat = "Végéterien", PlatId = 1001, NbrBouchee = 4 }, new Plat { TypePlat = "Carnivore", PlatId = 1001, NbrBouchee = 4 }, new Plat { TypePlat = "Sucrerie", PlatId = 1001, NbrBouchee = 4 }, new Plat { TypePlat = "Végéterien", PlatId = 1001, NbrBouchee = 4 } }; Serpent kaa = new Serpent(); Plat p = kaa.TrierPlat(listPlat); Assert.AreEqual(listPlat[0], p); }
public void BeEaten(Serpent eater) { // heal the serpent eater.Digest(mHealAmount); World.Instance.mScoreManager.AddScore(mScoreValue); AudioController.Instance.PlayPickupFishSfx(); Destroy(gameObject); }
/// <summary> /// SetSerpent /// </summary> /// <param name="tmpSerpent"></param> public void SetSerpent(Serpent tmpSerpent) { if (tmpSerpent != null) { X = tmpSerpent.X; Y = tmpSerpent.Y; } }
/// <summary> /// Constructeur /// </summary> //public Serpent() //{ //} public Serpent(Serpent serpent) { if (serpent != null) { X = serpent.X; Y = serpent.Y; } }
private void btnSBox_Click(object sender, EventArgs e) { ParseWandO(); Serpent.ApplySerpentSBox(ref W[0], ref W[1], ref W[2], ref W[3], (int)nupSbox.Value); FillO(W); }
public void BeEaten(Serpent eater) { // heal the serpent eater.Digest(mHealAmount); World.Instance.mScoreManager.AddScore(mScoreValue); AudioController.Instance.PlayPickupFishSfx (); Destroy(gameObject); }
private void btnInvPerm_Click(object sender, EventArgs e) { ParseWandO(); Serpent.ApplySerpentInvPermutation(ref O[0], ref O[1], ref O[2], ref O[3]); FillW(O); }
public void BeEaten(Serpent eater) { eater.GrowSegment(); World.Instance.mScoreManager.AddScore(mScoreValue); AudioController.Instance.PlayPickupCrateSfx(); AudioController.Instance.ToBattleSnapshot(1); Destroy(gameObject); }
private void btnPerm_Click(object sender, EventArgs e) { ParseWandO(); Serpent.ApplySerpentPermutation(ref W[0], ref W[1], ref W[2], ref W[3]); FillO(W); }
private void btnInvSBox_Click(object sender, EventArgs e) { ParseWandO(); Serpent.ApplySerpentInvSBox(ref O[0], ref O[1], ref O[2], ref O[3], (int)nupSbox.Value); FillW(O); }
public void BeEaten(Serpent eater) { eater.GrowSegment(); World.Instance.mScoreManager.AddScore(mScoreValue); AudioController.Instance.PlayPickupCrateSfx (); AudioController.Instance.ToBattleSnapshot (1); Destroy(gameObject); }
private void btnNonZeroColumnNumber_Click(object sender, EventArgs e) { ParseWandO(); int nw = Serpent.NonZeroColumnNumber(W); int no = Serpent.NonZeroColumnNumber(O); MessageBox.Show(string.Format("Non-zero Column Number\nW: {0}\nO: {1}", nw, no)); }
private void CollectExperiments(object sender, RoutedEventArgs e) { try { Serpent.CollectExperimentResults(progress); } catch (Exception err) { Console.WriteLine($"Couldn't perform action: {err.Message}"); } }
private void btnImp_Click(object sender, EventArgs e) { ParseWandO(); try { MessageBox.Show(Serpent.Impossible(W, O).ToString()); } catch (Exception exp) { MessageBox.Show(exp.Message); } }
private void OnTriggerExit2D(Collider2D collision) { if (collision.gameObject.tag == "Player") { GameData.movementHandler.currentGravityZone = null; } potentialSerpent = collision.gameObject.GetComponent <Serpent>(); if (potentialSerpent != null) { potentialSerpent.isInNoGravityZone = false; } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.tag == "Player") { GameData.movementHandler.currentGravityZone = this; GameData.grappleHandler.noGravityMaxTractionSpeed = maxTractingSpeedInNGZone; } potentialSerpent = collision.gameObject.GetComponent <Serpent>(); if (potentialSerpent != null) { potentialSerpent.isInNoGravityZone = true; } }
private void StartGame() { SerpentController controller = FindObjectOfType<SerpentController>(); controller.mAttract = false; mSerpent = controller.GetComponent<Serpent>(); GameObject canvas = GameObject.Find("/Canvas-MainUI"); Transform mainUI = canvas.transform.Find("MainUI"); mainUI.gameObject.SetActive(true); Transform attractUI = canvas.transform.Find("AttractUI"); attractUI.gameObject.SetActive(false); mInGame = true; }
private static bool Serpent_updateAnimation_prefix(Serpent __instance, GameTime time) { if (__instance.Health <= 0 || Config.MonstersIgnorePlayer) { var ftn = typeof(Monster).GetMethod("updateAnimation", BindingFlags.NonPublic | BindingFlags.Instance).MethodHandle.GetFunctionPointer(); var action = (Action <GameTime>)Activator.CreateInstance(typeof(Action <GameTime>), __instance, ftn); action(time); __instance.Sprite.Animate(time, 0, 9, 40f); typeof(Monster).GetMethod("resetAnimationSpeed", BindingFlags.NonPublic | BindingFlags.Instance).Invoke((Monster)__instance, new object[] { }); return(false); } return(true); }
private void btnAutoOpStart_Click(object sender, EventArgs e) { try { ParseWandO(); for (int i = 0; i < lstAutoOpList.Items.Count; i++) { string s = lstAutoOpList.Items[i].ToString(); if (s.Contains(" - ")) { // S-Box int rnd = int.Parse(s.Split(new string[] { " - " }, StringSplitOptions.None)[1]); if (s.Contains("Inverse")) { // Inverse Serpent.ApplySerpentInvSBox(ref W[0], ref W[1], ref W[2], ref W[3], rnd); } else { // Normal Serpent.ApplySerpentSBox(ref W[0], ref W[1], ref W[2], ref W[3], rnd); } } else { // Permutation if (s.Contains("Inverse")) { // Inverse Serpent.ApplySerpentInvPermutation(ref W[0], ref W[1], ref W[2], ref W[3]); } else { // Normal Serpent.ApplySerpentPermutation(ref W[0], ref W[1], ref W[2], ref W[3]); } } } FillO(W); } catch { MessageBox.Show("There was an error!"); } }
private void StartGame() { SerpentController controller = FindObjectOfType <SerpentController>(); controller.mAttract = false; mSerpent = controller.GetComponent <Serpent>(); GameObject canvas = GameObject.Find("/Canvas-MainUI"); Transform mainUI = canvas.transform.Find("MainUI"); mainUI.gameObject.SetActive(true); Transform attractUI = canvas.transform.Find("AttractUI"); attractUI.gameObject.SetActive(false); mInGame = true; }
private void btnOquestion_Click(object sender, EventArgs e) { ParseWandO(); dbg.ClearDebug(); int[] a = Serpent.NonZeroColumnPositions(O); string pos = string.Join("-", a); dbg.WriteLine("Details for O: \r\n"); dbg.WriteLine(string.Format("Number of 0 in O: {0}", Word.WordsContainZero(O))); dbg.WriteLine(string.Format("Number of 1 in O: {0}", Word.WordsContainOne(O))); dbg.WriteLine(string.Format("Number of ? in O: {0}\r\n", Word.WordsContainQuestionMark(O))); dbg.WriteLine(string.Format("Non-Zero Columns (#{0}): {1}", a.Length, pos)); MessageBox.Show("General Information has been created for O.\r\nFor details please check Log Screen."); }
private void btnTest_Click(object sender, EventArgs e) { // Minimum number of non-zero columns string[] a1 = { "1101", "1111" }; string[] a2 = { "0101", "1100" }; string[] a3 = { "0011", "0110", "1001", "1010", "1011", "1100", "1110", "1111" }; int min = 32, mini = 0, minj = 0, mink = 0; for (int i = 0; i < a1.Length; i++) { for (int j = 0; j < a2.Length; j++) { for (int k = 0; k < a3.Length; k++) { for (int t = 0; t < 4; t++) { W[t] = Word.Parse("0000 0000 0000 0000 0000 0000 0000 0000"); } Serpent.SetBitSlice(ref W, Word.Parse(a1[i]), 30); Serpent.SetBitSlice(ref W, Word.Parse(a2[j]), 27); Serpent.SetBitSlice(ref W, Word.Parse(a3[k]), 17); Serpent.ApplySerpentInvPermutation(ref W[0], ref W[1], ref W[2], ref W[3]); int cnt = Serpent.NonZeroColumnNumber(W); if (cnt < min) { min = cnt; mini = i; minj = j; mink = k; } } } } MessageBox.Show(string.Format("Min: {0}\n i: {1} j: {2} k: {3}", min, a1[mini], a2[minj], a3[mink])); }
private void btnTest1_Click(object sender, EventArgs e) { dbg.ClearDebug(); dbg.WriteLine("In Serpent We have broken!\r\n"); Word[] tmpW = new Word[4]; int[] a = new int[] { 2, 4, 5, 9, 10, 14 }; int[] b = new int[] { 5, 7, 12, 14 }; int konuma = 25, konumb = 22; for (int i = 0; i < a.Length; i++) { for (int j = 0; j < b.Length; j++) { for (int t = 0; t < 4; t++) { tmpW[t] = Word.Parse("0000 0000 0000 0000 0000 0000 0000 0000"); } Word worda = a[i].ToWord(4); Word wordb = b[j].ToWord(4); Serpent.SetBitSlice(ref tmpW, worda, konuma); Serpent.SetBitSlice(ref tmpW, wordb, konumb); Serpent.ApplySerpentInvPermutation(ref tmpW[0], ref tmpW[1], ref tmpW[2], ref tmpW[3]); int[] nzcpos = Serpent.NonZeroColumnPositions(tmpW); string pos = string.Join("-", nzcpos); dbg.WriteLine(string.Format("a: {0} b: {1} Number of Non-Zero Columns: {2}\r\nPositions: {3}\r\n", a[i], b[j], nzcpos.Length, pos)); } } MessageBox.Show("Check Log Screen!"); }
static void eatingTime(Serpent Joueur1, Serpent ennemi1, ref char[,] tabPacMan, ref char cerise) { bool manger = false; if (manger = false && tabPacMan[Joueur1.posY, Joueur1.posX] == cerise) { //fonctionne pas manger = true; if (timeup <= 200) // 1000 = 1sec { if (tabPacMan[Joueur1.posY, Joueur1.posX] == tabPacMan[ennemi1.posY, ennemi1.posX]) { Console.SetCursorPosition(14, 12); DrawEnnemy(ennemi1); } } else { time = 0; manger = false; } } }
//public Znake_ViewModel ZnakeViewModel => ServiceLocator.Current.GetInstance<Znake_ViewModel>(); #endregion public Main_ViewModel(IDataService dataService) { _dataService = dataService; _itemsLock = new object(); Grille = _dataService.InitGrille(30, 30); BindingOperations.EnableCollectionSynchronization(Grille, _itemsLock); serpent = new Serpent() { DerniereDirection = Direction.Ouest, NumSerpent = 1, Queue = new List <Position>(), Tete = new Position() { X = 0, Y = 0 } }; _dispatcherTimer = new DispatcherTimer(); _dispatcherTimer.Tick += dispatcherTimer_Tick; _dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 100); //Every 100ms _dispatcherTimer.Start(); }
public virtual void ApplyDamage(Serpent target) { target.TakeDamage(mDamagePower); }
/********* ** Private methods *********/ private void SpawnEntity(string command, string[] args) { //We need a world to spawn monsters in, duh if (Context.IsWorldReady) { // Determine if we have arguments if (args.Length > 0) { //Set defaults NPC entity = null; int xTile = Game1.player.getTileX(); int yTile = Game1.player.getTileY(); int amount = 1; //Ensure provided coordinatees are actually coordinates try { //Determine X tile if (args.Length >= 2) { if (!args[1].Equals("~")) { xTile = int.Parse(args[1]); } } //Determine Y tile if (args.Length >= 3) { if (!args[1].Equals("~")) { yTile = int.Parse(args[2]); } } } catch (Exception) { Monitor.Log("Arguments 1 and 2 must be coordinates or '~' to use the Farmer's coordinates! Make sure you don't add any brackets!"); return; } try { if (args.Length >= 4) { amount = int.Parse(args[3]); if (amount < 1) { throw new Exception(); } } } catch (Exception) { Monitor.Log("Argument 3 must be an amount larger than 0!"); return; } Vector2 pos = new Vector2(xTile, yTile); for (int i = 0; i < amount; i++) { // Determine the monster to spawn switch (args[0]) { case "greenSlime": entity = new GreenSlime(pos, 0); break; case "blueSlime": entity = new GreenSlime(pos, 40); break; case "redSlime": entity = new GreenSlime(pos, 80); break; case "purpleSlime": entity = new GreenSlime(pos, 121); break; case "yellowSlime": entity = new GreenSlime(pos, new Color(255, 255, 50)); break; case "blackSlime": Random r = new Random(); entity = new GreenSlime(pos, new Color(40 + r.Next(10), 40 + r.Next(10), 40 + r.Next(10))); break; case "bat": entity = new Bat(pos); break; //minelevel: 0 - 40 - 80 - 171 -> type case "frostBat": entity = new Bat(pos, 40); break; case "lavaBat": entity = new Bat(pos, 80); break; case "iridiumBat": entity = new Bat(pos, 171); break; case "bug": entity = new Bug(pos, 0); break; //available areatypes: 121 -> armored case "armoredBug": entity = new Bug(pos, 121); break; case "fly": entity = new Fly(pos); break; //hard -> mutant case "mutantFly": entity = new Fly(pos, true); break; case "ghost": entity = new Ghost(pos); break; //name -> carbon ghost case "carbonGhost": entity = new Ghost(pos, "Carbon Ghost"); break; case "grub": entity = new Grub(pos); break; //hard -> mutant case "mutantGrub": entity = new Grub(pos, true); break; case "rockCrab": entity = new RockCrab(pos); break; //name -> iridium crab case "lavaCrab": entity = new LavaCrab(pos); break; case "iridiumCrab": entity = new RockCrab(pos, "Iridium Crab"); break; case "metalHead": entity = new MetalHead(pos, 80); break; //mineareas: 0, 40, 80 - seems to only spawn at 80+ case "rockGolem": entity = new RockGolem(pos); break; //mineareas: 0, 40, 80 - changes health and damage; difficultymod: case "wildernessGolem": entity = new RockGolem(pos, 5); break; case "mummy": entity = new Mummy(pos); break; case "serpent": entity = new Serpent(pos); break; case "shadowBrute": entity = new ShadowBrute(pos); break; case "shadowShaman": entity = new ShadowShaman(pos); break; case "skeleton": entity = new Skeleton(pos); break; case "squidKid": entity = new SquidKid(pos); break; case "duggy": entity = new Duggy(pos); break; case "dustSpirit": entity = new DustSpirit(pos); break; } if (entity != null) { entity.currentLocation = Game1.currentLocation; entity.setTileLocation(new Vector2(xTile, yTile)); Game1.currentLocation.addCharacter(entity); } else { Monitor.Log($"{args[0]} not found! Type monster_list to view a list of available monsters to spawn!"); return; } } Monitor.Log($"{amount} {entity.Name} added at {entity.currentLocation.Name} {entity.getTileX()},{entity.getTileY()}", LogLevel.Info); } else { Monitor.Log("Usage: monster_spawn <name> [posX] [posY] [amount]\n\nUses Farmer's coordinates if none or '~' was given."); } } else { Monitor.Log("Load a save first!"); } }
public override void ApplyDamage(Serpent target) { // don't apply damage here }