public ActionResult DeleteConfirmed(int id) { Seasonal seasonal = db.Seasonals.Find(id); db.Seasonals.Remove(seasonal); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "GenreID,SeasonName")] Seasonal seasonal) { if (ModelState.IsValid) { db.Entry(seasonal).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(seasonal)); }
public ActionResult Create([Bind(Include = "GenreID,SeasonName")] Seasonal seasonal) { if (ModelState.IsValid) { db.Seasonals.Add(seasonal); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(seasonal)); }
// GET: Seasonals/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Seasonal seasonal = db.Seasonals.Find(id); if (seasonal == null) { return(HttpNotFound()); } return(View(seasonal)); }
public static WearableProduct.SeasonalPreference ConvertSeasonalPreference(Seasonal seasonal) { switch (seasonal) { case Seasonal.AUTUMN: return(WearableProduct.SeasonalPreference.AUTUMN); case Seasonal.SPRING: return(WearableProduct.SeasonalPreference.SPRING); case Seasonal.SUMMER: return(WearableProduct.SeasonalPreference.SUMMER); case Seasonal.WINTER: return(WearableProduct.SeasonalPreference.WINTER); } return(WearableProduct.SeasonalPreference.NONE); }
static void DrawGizmoForMyScript(Seasonal scr, GizmoType gizmoType) { Gizmos.color = Color.yellow; float y1 = -6f; float y2 = 70f; foreach (float x in new float[] { SeasonalSystem.SEASONAL_OFFSET * -1f, SeasonalSystem.SEASONAL_OFFSET * 0f, SeasonalSystem.SEASONAL_OFFSET * 1f, SeasonalSystem.SEASONAL_OFFSET * 2f, }) { Gizmos.DrawLine(new Vector3(x, y1, 0), new Vector3(x, y2, 0)); } }
static void DrawGizmoForMyScript(Seasonal scr, GizmoType gizmoType) { Gizmos.color = new Color(1f, 1f, 1f, 0.5f); foreach (Renderer rend in scr.gameObject.GetComponentsInChildren <Renderer>()) { //DrawRectangle(Vector3.zero, rend.bounds); DrawRectangle(new Vector3(+SeasonalSystem.SEASONAL_OFFSET, 0f, 0f), rend.bounds); DrawRectangle(new Vector3(-SeasonalSystem.SEASONAL_OFFSET, 0f, 0f), rend.bounds); } Gizmos.color = Color.green; foreach (Collider2D collider in scr.gameObject.GetComponentsInChildren <Collider2D>()) { //DrawRectangle(Vector3.zero, collider.bounds); DrawRectangle(new Vector3(+SeasonalSystem.SEASONAL_OFFSET, 0f, 0f), collider.bounds); DrawRectangle(new Vector3(-SeasonalSystem.SEASONAL_OFFSET, 0f, 0f), collider.bounds); } }
void FixedUpdate() { if (!mSleeping) { if (mTargetFruit == null) { SeasonalSystem seasonSystem = SeasonalSystem.GetSingleton(); Season season = GetComponent <Seasonal>().Season; if (transform.localPosition.x < seasonSystem.GetSeasonX1(season)) { SetFacingDirection(1); } if (transform.localPosition.x > seasonSystem.GetSeasonX2(season)) { SetFacingDirection(-1); } } else { float distToTarget = mTargetFruit.transform.position.x - transform.position.x; if (Mathf.Abs(distToTarget) <= 0.1f) { // stop moving (unless we get another fruit) mEating = true; GetComponent <Animator>().SetBool("eating", mEating); Destroy(mTargetFruit); mTargetFruit = null; // sync all pandas with this one SeasonalSystem seasonalSystem = SeasonalSystem.GetSingleton(); Seasonal seasonal = GetComponent <Seasonal>(); Season season = seasonal.Season; List <Seasonal> pandas = seasonalSystem.GetSeasonalVariants(seasonal); float relativeX = transform.position.x - seasonalSystem.GetSeasonX1(season); for (int i = 0; i < 4; ++i) { if (i != (int)Season.WINTER) { continue; // I know the loop is unnecessary now, but it's here because of design churn, and maybe it'll be needed again... } //if(i == (int)season || i == (int)Season.SPRING || i == ) continue; Season s = (Season)i; float seasonX = seasonalSystem.GetSeasonX1(s); Transform panda = pandas[i].transform; panda.position = new Vector3(seasonX + relativeX, transform.position.y, transform.position.z); } } else { SetFacingDirection(distToTarget > 0 ? 1 : -1); } } if (mTargetFruit && !mEating) { // Accelerate to desired velocity Rigidbody2D rb = GetComponent <Rigidbody2D>(); float desiredV = mFacing * mSpeed; float deltaV = desiredV - rb.velocity.x; float desiredAccel = deltaV / Time.fixedDeltaTime; float maxAccel = 30f; float actualAccel = Mathf.Min(Mathf.Abs(desiredAccel), maxAccel) * Mathf.Sign(desiredAccel) * 1000; rb.AddForce(new Vector2(actualAccel, 0f)); } } }
public virtual void RenderInspectorGUI() { Name = EditorGUILayout.TextField("Name", Name); Price = EditorGUILayout.FloatField("Price ", Price); ParkitectObj[] pkObjects = ModPayload.Instance.ParkitectObjs.Where(x => x.Prefab != null).ToArray(); ParkitectObj pkObject = pkObjects.SingleOrDefault(x => x.Key == Key); int index = -1; if (pkObject == null) { Key = ""; } else { index = Array.IndexOf(pkObjects, pkObject); } index = EditorGUILayout.Popup("object", index, pkObjects.Select(x => x.Prefab.name + " (" + x.GetObjectTag() + ")").ToArray()); if (index < pkObjects.Length && index >= 0) { Key = pkObjects[index].Key; } ProductType = (ProductType)EditorGUILayout.EnumPopup("Product Type", ProductType); if (ProductType == ProductType.ON_GOING || ProductType == ProductType.CONSUMABLE) { HandSide = (HandSide)EditorGUILayout.EnumPopup("Hand Side", HandSide); IsTwoHanded = EditorGUILayout.Toggle("Is Two Handed", IsTwoHanded); IsInterestingToLookAt = EditorGUILayout.Toggle("Is Interesting To Look At", IsInterestingToLookAt); } switch (ProductType) { case ProductType.ON_GOING: { Duration = EditorGUILayout.IntField("Duration ", Duration); RemoveWhenDepleted = EditorGUILayout.Toggle("Remove When Depleted", RemoveWhenDepleted); DestroyWhenDepleted = EditorGUILayout.Toggle("Destroy When Depleted", DestroyWhenDepleted); } break; case ProductType.CONSUMABLE: { ConsumeAnimation = (ConsumeAnimation)EditorGUILayout.EnumPopup("Consume Animation ", ConsumeAnimation); Temprature = (Temperature)EditorGUILayout.EnumPopup("Temprature ", Temprature); Portions = EditorGUILayout.IntField("Portions ", Portions); } break; case ProductType.WEARABLE: { BodyLocation = (Body)EditorGUILayout.EnumPopup("Body Location ", BodyLocation); SeasonalPrefrence = (Seasonal)EditorGUILayout.EnumPopup("Seasonal Prefrence ", SeasonalPrefrence); TempreaturePrefrence = (Temperature)EditorGUILayout.EnumPopup("Tempreature Prefrence", TempreaturePrefrence); HideHair = EditorGUILayout.Toggle("Hide Hair", HideHair); HideOnRide = EditorGUILayout.Toggle("Hide On Ride", HideOnRide); } break; } DrawIngredients(); }
public virtual void DeSerialize(Dictionary <string, object> elements) { if (elements.ContainsKey("Name")) { Name = (string)elements["Name"]; } if (elements.ContainsKey("Price")) { Price = Convert.ToSingle(elements["Price"]); } if (elements.ContainsKey("key")) { Key = (string)elements["key"]; } if (elements.ContainsKey("ProductType")) { ProductType = (ProductType)Enum.Parse(typeof(ProductType), (string)elements["ProductType"]); } if (ProductType == ProductType.ON_GOING || ProductType == ProductType.CONSUMABLE) { if (elements.ContainsKey("Hand")) { HandSide = (HandSide)Enum.Parse(typeof(HandSide), (string)elements["Hand"]); } if (elements.ContainsKey("IsInterestingToLookAt")) { IsInterestingToLookAt = (bool)elements["IsInterestingToLookAt"]; } if (elements.ContainsKey("IsTwoHanded")) { IsTwoHanded = (bool)elements["IsTwoHanded"]; } } switch (ProductType) { case ProductType.ON_GOING: { if (elements.ContainsKey("Duration")) { Duration = Convert.ToInt32(elements["Duration"]); } if (elements.ContainsKey("RemoveWhenDepleted")) { RemoveWhenDepleted = (bool)elements["RemoveWhenDepleted"]; } if (elements.ContainsKey("DestroyWhenDepleted")) { DestroyWhenDepleted = (bool)elements["DestroyWhenDepleted"]; } } break; case ProductType.CONSUMABLE: { if (elements.ContainsKey("ConsumeAnimation")) { ConsumeAnimation = (ConsumeAnimation)Enum.Parse(typeof(ConsumeAnimation), (string)elements["ConsumeAnimation"]); } if (elements.ContainsKey("Temprature")) { Temprature = (Temperature)Enum.Parse(typeof(Temperature), (string)elements["Temprature"]); } if (elements.ContainsKey("Portions")) { Portions = Convert.ToInt32(elements["Portion"]); } } break; case ProductType.WEARABLE: { if (elements.ContainsKey("BodyLocation")) { BodyLocation = (Body)Enum.Parse(typeof(Body), (string)elements["BodyLocation"]); } if (elements.ContainsKey("SeasonalPrefrence")) { SeasonalPrefrence = (Seasonal)Enum.Parse(typeof(Seasonal), (string)elements["SeasonalPrefrence"]); } if (elements.ContainsKey("TempreaturePrefrence")) { TempreaturePrefrence = (Temperature)Enum.Parse(typeof(Temperature), (string)elements["TempreaturePrefrence"]); } if (elements.ContainsKey("HideOnRide")) { HideOnRide = (bool)elements["HideOnRide"]; } if (elements.ContainsKey("HideHair")) { HideHair = (bool)elements["HideHair"]; } } break; } if (elements.ContainsKey("Ingredients")) { foreach (var ing in (List <object>)elements["Ingredients"]) { ShopIngredient ingredient = new ShopIngredient(); ingredient.DeSerialize(ing as Dictionary <string, object>); Ingredients.Add(ingredient); } } }
void Start() { mCameraObj = GameObject.FindObjectOfType <CameraMovement>().gameObject; // Find all seasonal objects in the scene Seasonal[] seasonalObjs = (Seasonal[])GameObject.FindObjectsOfType(typeof(Seasonal)); foreach (Season season in Enum.GetValues(typeof(Season))) { // Compute the initial center for every season mSeasonToSeasonCentre[season] = (0.5f + (int)season) * SEASONAL_OFFSET; mRootObjectsBySeason.Add(season, new List <Seasonal>()); mObjectsBySeason.Add(season, new List <Seasonal>()); } // Create a copy of each (root) seasonal object for each season foreach (Seasonal seasonal in seasonalObjs) { // Only copy root objects if (seasonal.transform.parent != null) { continue; } List <Seasonal> seasonalVariants = new List <Seasonal>(); foreach (Season season in Enum.GetValues(typeof(Season))) { Seasonal seasonalObj = seasonal; if (season != Season.SPRING) { seasonalObj = GameObject.Instantiate(seasonal.gameObject).GetComponent <Seasonal>(); } seasonalObj.Season = season; Vector3 pos = seasonalObj.transform.position; seasonalObj.transform.position = new Vector3(pos.x + (SEASONAL_OFFSET * (int)season), pos.y, pos.z); mRootObjectsBySeason[season].Add(seasonalObj); mObjectsBySeason[season].Add(seasonalObj); seasonalVariants.Add(seasonalObj); } Dictionary <Season, Seasonal[]> seasonalChildrenPerVariant = new Dictionary <Season, Seasonal[]>(); foreach (Seasonal seasonalObj in seasonalVariants) { mObjectToSeasonalVariants.Add(seasonalObj, seasonalVariants); seasonalChildrenPerVariant.Add(seasonalObj.Season, seasonalObj.GetComponentsInChildren <Seasonal>()); } // In case a root seasonal object had seasonal children, find and update those as well. // it should set season for the child and it should make a list of the equivalent children in seasonal variations // This relies on GetComponentsInChildren returning children in a predictable order for (int i = 0; i < seasonalChildrenPerVariant[Season.SPRING].Length; i++) { // For this function, ignore the roots, they were already handled. just look at the children. if (seasonalChildrenPerVariant[Season.SPRING][i].transform.parent == null) { continue; } List <Seasonal> seasonalVariantsForTheChild = new List <Seasonal>(); foreach (Season season in Enum.GetValues(typeof(Season))) { Seasonal[] seasonalChildrenArray = seasonalChildrenPerVariant[season]; Seasonal seasonalChildObj = seasonalChildrenArray[i]; seasonalChildObj.Season = season; seasonalVariantsForTheChild.Add(seasonalChildObj); mObjectToSeasonalVariants.Add(seasonalChildObj, seasonalVariantsForTheChild); mObjectsBySeason[season].Add(seasonalChildObj); } } } }
public List <Seasonal> GetSeasonalVariants(Seasonal s) { return(mObjectToSeasonalVariants[s]); }