// Use this for initialization void Start() { butterflyBody = body.GetComponent <Butterfly> (); freq = butterflyBody.flapFreq; amp = butterflyBody.flapAmplitude; flipMultiplier = 1f; }
public override void OnInspectorGUI() { Butterfly bf = (Butterfly)target; bf.zoneSize = EditorGUILayout.Vector3Field("Zone size", bf.zoneSize); serializedObject.Update(); #pragma warning disable CS0618 // 类型或成员已过时 EditorGUIUtility.LookLikeInspector(); #pragma warning restore CS0618 // 类型或成员已过时 SerializedProperty layers = serializedObject.FindProperty("butterflyObjects"); EditorGUILayout.PropertyField(layers, true); serializedObject.ApplyModifiedProperties(); #pragma warning disable CS0618 // 类型或成员已过时 EditorGUIUtility.LookLikeControls(); #pragma warning restore CS0618 // 类型或成员已过时 bf.butterflyCount = EditorGUILayout.IntField("Flies count", bf.butterflyCount); bf.maxSpeed = EditorGUILayout.FloatField("Max speed", bf.maxSpeed); bf.arrivalRadius = EditorGUILayout.FloatField("Arrival radius", bf.arrivalRadius); if (GUI.changed) { EditorUtility.SetDirty(bf); } }
/// <summary> /// Create an animal object of a species (Bee,Butterfly) of Insect cateogry. /// </summary> /// <param name="Species">Species: Bee, Butterfly, etc.</param> /// <returns>Object of the Species type.</returns> /// <remarks></remarks> public static Insect CreateInsect(InsectSpecies Species) { Insect animalObj = null; //type not known at this time //type determined by late binding switch (Species) { case InsectSpecies.Bee: animalObj = new Bee(); //Late binding break; //Continue with the rest case InsectSpecies.Butterfly: animalObj = new Butterfly(); //Late binding break; default: Debug.Assert(false, "To be completed!"); break; } //Set the category animalObj.Category = CategoryType.Insect; return(animalObj); //return the created animal object. }
protected void Page_Load(object sender, EventArgs e) { lblStart.Text = DateTime.Now.ToString(); if (!IsPostBack) { FillExpiryDates(ddlExpiryDates); FilterConditions filterConditions = new FilterConditions(); //filterConditions.SPLowerRange = MySession.Current.RecordsObject.strikePrices.Min(); //filterConditions.SPHigherRange = MySession.Current.RecordsObject.strikePrices.Max(); //filterConditions.SPExpiry = Convert.ToInt32(ddlSPExpiry.SelectedValue); filterConditions.ContractType = ddlContractType.SelectedValue; filterConditions.OcType = rblOCType.SelectedValue; filterConditions.StrategyType = enumStrategyType.BUTTERFLY.ToString(); filterConditions.TimeGap = timeAddGap; filterConditions.ExpiryDate = ddlExpiryDates.SelectedValue; filterConditions.PercentageRange = iPercentageRage; filterConditions.SPDifference = 100; DataSet dataSetResult = Butterfly.GetButterflySpreadStrategies(filterConditions); PopulateDataSet(dataSetResult); PopulateFilterFields(filterConditions); Page.LoadComplete += new EventHandler(Page_LoadComplete); } }
//Creating children (and possibly laying them) void Breeding() { //Get stats from both butterflies //Disable other butterfly //create eggs with stats from both //egg hatches after a time Butterfly other = currentTarget.GetComponentInParent <Butterfly>(); //Possibly move this to a function on other butterfly? other.breedPoints -= SimulationManager.instance.breedPointsNeeded; other.ChangeState(State.wander); other.stomachFill -= eggCost; other.flapActive = true; other.currentTarget = null; breedPoints -= SimulationManager.instance.breedPointsNeeded; stomachFill -= eggCost; ChangeState(State.wander); flapActive = true; currentTarget = null; GameObject egg = Instantiate(SimulationManager.instance.eggPrefab, transform.position + transform.up, Quaternion.identity); egg.GetComponent <Egg>().SetParents(this, other); }
public IActionResult Create(Butterfly butterfly) { if (ModelState.IsValid) { var lastButterfly = _data.ButterfliesList.LastOrDefault(); butterfly.CreatedDate = DateTime.Today; if (butterfly.PhotoAvatar != null && butterfly.PhotoAvatar.Length > 0) { butterfly.ImageMimeType = butterfly.PhotoAvatar.ContentType; butterfly.ImageName = Path.GetFileName(butterfly.PhotoAvatar.FileName); butterfly.Id = lastButterfly.Id + 1; _butterfliesQuantityService.AddButterfliesQuantityData(butterfly); using (var memoryStream = new MemoryStream()) { butterfly.PhotoAvatar.CopyTo(memoryStream); butterfly.PhotoFile = memoryStream.ToArray(); } _data.AddButterfly(butterfly); return(RedirectToAction("Index")); } return(View(butterfly)); } else { return(View(butterfly)); } }
// Get: Hunters/Void/5 public IActionResult Void(int id, string answer = null) { //Debug.WriteLine("----------------------------User--->" + User.FindFirst(ClaimTypes.NameIdentifier).Subject.ToString()); //Debug.WriteLine("----------------------------User--->" + _manager.GetUserName(User)); string email = _manager.GetUserName(User); Hunter hunter = _context.Hunters.FirstOrDefault(h => h.Email == email); Butterfly butterfly = _context.Butterflies.FirstOrDefault(b => b.Id == id); Vote vote = new Vote() { Butterfly = butterfly, Hunter = hunter }; //Debug.WriteLine("----->>>>>" + hunter.Name + "<<<<<"); if (answer == null) { return(View(vote)); } else { if (answer == "yes") { hunter.Voted = true; butterfly.Ranking = butterfly.Ranking + 1; _context.SaveChanges(); } return(Redirect("~/Butterflies")); } }
public IActionResult GetImage(int id) { Butterfly requestedButterfly = _data.GetButterflyById(id); if (requestedButterfly != null) { string webRootpath = _environment.WebRootPath; string folderPath = "\\images\\"; string fullPath = webRootpath + folderPath + requestedButterfly.ImageName; if (System.IO.File.Exists(fullPath)) { var fileOnDisk = new FileStream(fullPath, FileMode.Open); byte[] fileBytes; using (var br = new BinaryReader(fileOnDisk)) { fileBytes = br.ReadBytes((int)fileOnDisk.Length); } return(File(fileBytes, requestedButterfly.ImageMimeType)); } else { if (requestedButterfly.PhotoFile.Length > 0) { File(requestedButterfly.PhotoFile, requestedButterfly.ImageMimeType); } } } return(NotFound()); }
public static Critter MakeButterfly(int x, int y, int baseFrame) { var bfly = new Butterfly(new Vector2(x, y)); bfly.baseFrame = baseFrame; bfly.sprite.CurrentFrame = baseFrame; return(bfly); }
protected void btnFilterResults_Click(object sender, EventArgs e) { FilterConditions filterConditions = new FilterConditions(); filterConditions.SPLowerRange = Convert.ToInt32(ddlSPLowerRange.SelectedValue); filterConditions.SPHigherRange = Convert.ToInt32(ddlSPHigherRange.SelectedValue); if (ddlSPExpiry.SelectedValue.Equals("NONE")) { filterConditions.SPExpiry = 0; } else { filterConditions.SPExpiry = Convert.ToInt32(ddlSPExpiry.SelectedValue); } filterConditions.ContractType = ddlContractType.SelectedValue; filterConditions.OcType = rblOCType.SelectedValue; filterConditions.StrategyType = enumStrategyType.BUTTERFLY.ToString(); filterConditions.TimeGap = timeAddGap; filterConditions.ExpiryDate = ddlExpiryDates.SelectedValue; filterConditions.PercentageRange = 0; filterConditions.SPDifference = 100; DataSet dataSetResult = Butterfly.GetButterflySpreadStrategies(filterConditions); PopulateDataSet(dataSetResult); PopulateFilterFields(filterConditions); //DataSet filteredDataSet = new DataSet(); //foreach (DataTable dataTable in dataSetResult.Tables) //{ // //List<string> sp = dataTable.AsEnumerable().Select(x => x["Strike Price"].ToString()).ToList(); // //Find Lowest and Highest value in the given table column // int iLowestSP = int.MaxValue; // int iHighestSP = int.MinValue; // int iMiddleSP = 0; // foreach (DataRow dr in dataTable.Rows) // { // int currentSP = Convert.ToInt32(dr.Field<string>("StrikePrice")); // iLowestSP = Math.Min(iLowestSP, currentSP); // iMiddleSP = Math.Max(iLowestSP, currentSP); // iMiddleSP = Math.Min(iHighestSP, currentSP); // iHighestSP = Math.Max(iHighestSP, currentSP); // } // if (filterConditions.SPLowerRange == iLowestSP && // filterConditions.SPHigherRange == iHighestSP && // filterConditions.SPExpiry == iMiddleSP) // { // filteredDataSet.Tables.Add(dataTable.Copy()); // } //} ////dataSetResult = Butterfly.GetButterflySpreadStrategies(filterConditions); //PopulateDataSet(filteredDataSet); }
static void Main() { Application.Run(new NameForm()); Complex xComplex = new Complex(12.3f, 13.4f); Complex yComplex = new Complex(12.5f, 13.6f); Butterfly butterfly = CocoonFactory.getButterfly(12.4f); butterfly.Execute(xComplex, yComplex); }
public bool unitTestAddButterfly(int tag, string species) { Butterfly butterfly = new Butterfly(); butterfly.tagNumber = tag; butterfly.species = species; query.addButterfly(butterfly); return true; }
public void SetParents(Butterfly parentA, Butterfly parentB) { parent1 = parentA; parent2 = parentB; hatchTime = parent1.eggHatchTime; childNumber = parent2.childNumber; hasParents = true; }
public void AddButterfliesQuantityData(Butterfly butterfly) { if (ButterfliesQuantityDictionary.ContainsKey(butterfly.ButterflyFamily.Value)) { ButterfliesQuantityDictionary[butterfly.ButterflyFamily.Value] += butterfly.Quantity; } else { ButterfliesQuantityDictionary.Add(butterfly.ButterflyFamily.Value, butterfly.Quantity); } }
private void OnTriggerEnter2D(Collider2D collision) { Butterfly b = collision.GetComponent <Butterfly>(); if (b) { if (list[1].Contains(b)) { list[1].Remove(b); } } }
private void OnTriggerExit2D(Collider2D collision) { Butterfly b = collision.GetComponent <Butterfly>(); if (b) { if (!list[1].Contains(b) && list[0].Contains(b)) { list[1].Add(b); } } }
public static Critter MakeButterfly(int x, int y, int baseFrame, bool island = false) { var bfly = new Butterfly(new Vector2(x, y)); bfly.baseFrame = baseFrame; bfly.sprite.CurrentFrame = baseFrame; if (island) { Mod.instance.Helper.Reflection.GetField <bool>(bfly, "islandButterfly").SetValue(true); } return(bfly); }
// Purpose: Adds a butterfly object to database // Input: Butterfly object // Output: N/A // Pre-conditions: Each field of Butterfly object must be defined and valid // Post-conditions: Butterfly object is added to database public void addButterfly(Butterfly butterfly) { MySqlCommand cmd = new MySqlCommand(); cmd.Connection = connection; cmd.CommandText = "INSERT INTO tagged_butterfly VALUES (" + "@tagNumber, @species, 1);"; cmd.Prepare(); cmd.Parameters.AddWithValue("@tagNumber", butterfly.tagNumber); cmd.Parameters.AddWithValue("@species", butterfly.species); cmd.ExecuteNonQuery(); }
void OnSceneGUI() { Butterfly bf = (Butterfly)target; Bounds zone = new Bounds(bf.transform.position, bf.zoneSize); Color faceColor = new Color(0, 0.5f, 0, 0.02f); Color edgeColor = new Color(0, 1, 0, 0.1f); Vector3[] verts = new Vector3[4]; verts[0] = new Vector3(zone.min.x, zone.min.y, zone.min.z); verts[1] = new Vector3(zone.min.x, zone.min.y, zone.max.z); verts[2] = new Vector3(zone.max.x, zone.min.y, zone.max.z); verts[3] = new Vector3(zone.max.x, zone.min.y, zone.min.z); Handles.DrawSolidRectangleWithOutline(verts, faceColor, edgeColor); // top verts[0] = new Vector3(zone.min.x, zone.max.y, zone.min.z); verts[1] = new Vector3(zone.min.x, zone.max.y, zone.max.z); verts[2] = new Vector3(zone.max.x, zone.max.y, zone.max.z); verts[3] = new Vector3(zone.max.x, zone.max.y, zone.min.z); Handles.DrawSolidRectangleWithOutline(verts, faceColor, edgeColor); // left verts[0] = new Vector3(zone.min.x, zone.min.y, zone.min.z); verts[1] = new Vector3(zone.min.x, zone.min.y, zone.max.z); verts[2] = new Vector3(zone.min.x, zone.max.y, zone.max.z); verts[3] = new Vector3(zone.min.x, zone.max.y, zone.min.z); Handles.DrawSolidRectangleWithOutline(verts, faceColor, edgeColor); // right verts[0] = new Vector3(zone.max.x, zone.min.y, zone.min.z); verts[1] = new Vector3(zone.max.x, zone.min.y, zone.max.z); verts[2] = new Vector3(zone.max.x, zone.max.y, zone.max.z); verts[3] = new Vector3(zone.max.x, zone.max.y, zone.min.z); Handles.DrawSolidRectangleWithOutline(verts, faceColor, edgeColor); // front verts[0] = new Vector3(zone.min.x, zone.min.y, zone.min.z); verts[1] = new Vector3(zone.min.x, zone.max.y, zone.min.z); verts[2] = new Vector3(zone.max.x, zone.max.y, zone.min.z); verts[3] = new Vector3(zone.max.x, zone.min.y, zone.min.z); Handles.DrawSolidRectangleWithOutline(verts, faceColor, edgeColor); // back verts[0] = new Vector3(zone.min.x, zone.min.y, zone.max.z); verts[1] = new Vector3(zone.min.x, zone.max.y, zone.max.z); verts[2] = new Vector3(zone.max.x, zone.max.y, zone.max.z); verts[3] = new Vector3(zone.max.x, zone.min.y, zone.max.z); Handles.DrawSolidRectangleWithOutline(verts, faceColor, edgeColor); }
public DemoDrawing(SpriteBatch spriteBatch, GraphicsDeviceManager graphics, ContentManager contentManager) { _spriteBatch = spriteBatch; _graphics = graphics; _contentManager = contentManager; engine = new Butterfly(new MonoGameSubEngine(_graphics, _spriteBatch)); SysCore.SystemFont = new LindaEngine.WorldModel.Content.Font() { ContentName = "systemFont", Content = contentManager.Load <SpriteFont>(@"Fonts\Segoe") }; }
public IActionResult GetImage(int id) { Butterfly requestedButterfly = _data.GetButterflyById(id); if (requestedButterfly != null) { return(null); } else { return(NotFound()); } }
private void OnTriggerEnter(Collider other) { AkSoundEngine.PostEvent("Collect", gameObject); Butterfly newButterfly = other.gameObject.AddComponent <Butterfly>(); speed = Mathf.Clamp(speed + butterflySpeedBoost, 0f, maxSpeed); Destroy(other.gameObject.GetComponent <BoxCollider>()); Destroy(other.gameObject.GetComponent <ParticleSystem>()); newButterfly.transform.localEulerAngles = new Vector3(0f, -90f); newButterfly.transform.SetParent(null); Random.InitState(transform.position.GetHashCode()); newButterfly.PreparePosition(Random.Range(5, lastPosLength)); butterflies.Add(newButterfly); }
private void OnTriggerStay(Collider other) { Butterfly butterfly = other.GetComponent <Butterfly>(); if (butterfly) { amount -= consumeRate * Time.deltaTime; butterfly.adjustHappiness(happinessRate); if (amount <= 0) { Destroy(gameObject); } } }
private static StaticModInt <TMod>[] ConvolutionFFTInner <TMod>(StaticModInt <TMod>[] a, StaticModInt <TMod>[] b) where TMod : struct, IStaticMod { Butterfly <TMod> .Calculate(a); Butterfly <TMod> .Calculate(b); for (int i = 0; i < a.Length; i++) { a[i] *= b[i]; } Butterfly <TMod> .CalculateInv(a); return(a); }
protected override ValidationResult IsValid(object value, ValidationContext validationContext) { var service = (IButterfliesQuantityService)validationContext.GetService(typeof(IButterfliesQuantityService)); Butterfly butterfly = (Butterfly)validationContext.ObjectInstance; if (butterfly.ButterflyFamily != null) { int?quantity = service.GetButterflyFamilyQuantity(butterfly.ButterflyFamily.Value); int?sumQuantity = quantity + butterfly.Quantity; if (sumQuantity > _maxAmount) { return(new ValidationResult(string.Format("Limit of butterflies from the same family in the store is {0} butterflies. Currently there are {1}", _maxAmount, quantity))); } } return(ValidationResult.Success); }
static void Main(string[] args) { Prototype prototype = null; Prototype bud = null; prototype = new Worm("Worm"); bud = prototype.Clone(); Console.WriteLine(bud.Name); prototype = new CaseWorm("CaseWorm"); bud = prototype.Clone(); Console.WriteLine(bud.Name); prototype = new Butterfly("Butterfly"); bud = prototype.Clone(); Console.WriteLine(bud.Name); Console.ReadKey(); }
float[] ButterflyToArray(Butterfly parent) { float[] stats = new float[numberOfStats]; stats[0] = parent.flapY; stats[1] = parent.flapX; stats[2] = parent.rotSpeed; stats[3] = parent.wanderRotSpeed; stats[4] = parent.stomachCapactity; stats[5] = parent.wanderFlapFreq; stats[6] = parent.targetingFlapBelowFreq; stats[7] = parent.targetingFlapAboveFreq; stats[8] = parent.visionRange; stats[9] = parent.feedTime; stats[10] = parent.eggHatchTime; stats[11] = parent.eggCost; stats[12] = parent.childNumber; return(stats); }
public static Insect CreateInsect(InsectSpecies Species) { /// <summary /// Static method that creates choosen Animal, determed on the parameter Species. /// Insect animalObj set to null; /// <returns>animalObj with created animal object</returns> /// </summary Insect animalObj = null; switch (Species) { case InsectSpecies.Bee: animalObj = new Bee(); break; case InsectSpecies.Butterfly: animalObj = new Butterfly(); break; } animalObj.Category = CategoryType.Insect; return animalObj; }
public async Task <IActionResult> Create( [Bind("Id,Name,Range,Ranking,IsProtected,AuthorId,Description,ImgURL")] Butterfly butterfly) { if (!IsImageUrl(butterfly.ImgURL)) { butterfly.ImgURL = "/img/img00.jpg"; } string email = _manager.GetUserName(User); butterfly.AuthorId = _context.Hunters.FirstOrDefault(h => h.Email == email).HunterId; if (ModelState.IsValid) { _context.Add(butterfly); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(butterfly)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Range,Ranking,IsProtected,AuthorId,Description,ImgURL")] Butterfly butterfly) { Debug.WriteLine("--------------------------Edit--Post--->" + id + "<---"); //if (id != butterfly.Id) //{ // return NotFound(); //} butterfly.Id = id; if (!IsImageUrl(butterfly.ImgURL)) { Debug.WriteLine("--------------------------URL--Post--->" + butterfly.ImgURL + "<---"); butterfly.ImgURL = "/img/img00.jpg"; } if (ModelState.IsValid) { try { _context.Update(butterfly); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ButterflyExists(butterfly.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(butterfly)); }
/// <summary>Create a butterfly.</summary> /// <param name="baseFrame">The base frame in the critter tilesheet.</param> /// <param name="island">Whether to create an island butterfly.</param> public static CritterBuilder ForButterfly(int baseFrame, bool island = false) { return(new( makeCritter : (x, y) => { Butterfly butterfly = new Butterfly(new Vector2(x, y)) { baseFrame = baseFrame, sprite = { CurrentFrame = baseFrame } }; if (island) { Mod.Instance.Helper.Reflection.GetField <bool>(butterfly, "islandButterfly").SetValue(true); } return butterfly; }, isThisCritter : critter => critter is Butterfly butterfly && butterfly.baseFrame == baseFrame && island == Mod.Instance.Helper.Reflection.GetField <bool>(critter, "islandButterfly").GetValue() )); }
Butterfly ArrayToButterfly(float[] stats, Butterfly target) { Butterfly butterfly = target; butterfly.flapY = stats[0]; butterfly.flapX = stats[1]; butterfly.rotSpeed = stats[2]; butterfly.wanderRotSpeed = stats[3]; butterfly.stomachCapactity = (int)stats[4]; butterfly.wanderFlapFreq = stats[5]; butterfly.targetingFlapBelowFreq = stats[6]; butterfly.targetingFlapAboveFreq = stats[7]; butterfly.visionRange = stats[8]; butterfly.feedTime = stats[9]; butterfly.eggHatchTime = stats[10]; butterfly.eggCost = (int)stats[11]; butterfly.childNumber = (int)stats[12]; butterfly.stomachFill = (int)(butterfly.stomachCapactity * 0.25f); return(butterfly); }
// Purpose: Finds a butterfly in the database by tag // Input: Tag number // Output: Butterfly object // Pre-conditions: Each field of Butterfly object must be defined and valid // Post-conditions: Butterfly object must not be null public Butterfly getButterfly(int tag) { MySqlCommand cmd = new MySqlCommand(); MySqlDataReader reader; Butterfly butterfly = new Butterfly(); cmd.Connection = connection; cmd.CommandText = "SELECT * FROM tagged_butterfly WHERE tag_number = @tagNumber;"; cmd.Prepare(); cmd.Parameters.AddWithValue("@tagNumber", tag); reader = cmd.ExecuteReader(); if (reader.Read()) { butterfly.tagNumber = reader.GetInt32(0); butterfly.species = reader.GetString(1); butterfly.numSightings = reader.GetInt32(2); reader.Close(); return butterfly; } else { reader.Close(); return null; } }
// Purpose: Populates a list with every butterfly in the database // Input: N/A // Output: List<Butterfly> containing all butterflies in the database // Pre-conditions: Database must not be empty // Post-conditions: List must contain at least one element public List<Butterfly> getAll() { List<Butterfly> list = new List<Butterfly>(); MySqlCommand cmd = new MySqlCommand(); MySqlDataReader reader; cmd.Connection = connection; cmd.CommandText = "SELECT * FROM tagged_butterfly;"; cmd.Prepare(); reader = cmd.ExecuteReader(); while (reader.Read()) { Butterfly butterfly = new Butterfly(); butterfly.tagNumber = reader.GetInt32(0); butterfly.species = reader.GetString(1); butterfly.numSightings = reader.GetInt32(2); list.Add(butterfly); } if (list.Count == 0) { reader.Close(); return null; } else { reader.Close(); return list; } }
public void AddButterfly(Butterfly butterfly) { ButterfliesList.Add(butterfly); }
public bool unitTestGetButterfly(int tag) { Butterfly butterfly = new Butterfly(); if ((butterfly = query.getButterfly(tag)) == null) return false; else { Console.WriteLine(" Tag: " + butterfly.tagNumber); Console.WriteLine(" Species: " + butterfly.species); return true; } }
public void updateButterfly(TrackingEntry entry) { int tagNumber = entry.tagNumber; if (tagNumber == -1) return; else { Butterfly butterfly = new Butterfly(); ButterflyQuery butterflyQuery = new ButterflyQuery(connection); butterfly = butterflyQuery.getButterfly(tagNumber); if(butterfly == null) { butterfly = new Butterfly(); butterfly.tagNumber = tagNumber; butterfly.species = entry.species; butterflyQuery.addButterfly(butterfly); } else { butterflyQuery.incrementSightings(butterfly.tagNumber); } } }