public Condiment(Drinkable drink, string condimentName, Decimal condimentPrice, Decimal discount) { this.drink = drink; this.price = condimentPrice; this.discount = discount; this.name = condimentName; }
public Drinkable GetNearestDrinkable(Agent ag) { Drinkable drinkSrc = null; float nearestDist = float.MaxValue; if (Environment.drinkSources.Count == 0) { return(null); } Vector3 delta; float dist; foreach (Drinkable dr in Environment.drinkSources) { delta = dr.transform.position - ag.transform.position; dist = delta.magnitude; if (dist < nearestDist) { nearestDist = dist; drinkSrc = dr; } } return(drinkSrc); }
public Condiment(Drinkable drink, string condimentName, Decimal condimentPrice, Decimal discount, DateTime dateTime) { this.drink = drink; this.price = condimentPrice; this.discount = discount; this.name = condimentName; this.specialDay = dateTime; }
public Item CreatePotion(int pMaxAmount) { var amount = Globals.random.Next(1, pMaxAmount + 1); // Random.Next(inclusive min, exclusive max) var type = HUtils.RandomEnumValue <EEffect>(Globals.random); var potion = new Item($"Potion of {type}", "potion", amount); var drinkableComponent = new Drinkable(type, 10); potion.AddComponent(drinkableComponent); return(potion); }
// Use this for initialization void Start() { GameObject[] drinks = GameObject.FindGameObjectsWithTag("DrinkSource"); foreach (GameObject go in drinks) { Drinkable dr = go.GetComponent <Drinkable>(); if (dr != null) { drinkSources.Add(dr); } } }
public override bool Use(ref Item i) { if (i.GetType() != typeof(Drinkable)) { return(false); } Drinkable d = (Drinkable)i; Logger.Instance.Log("Player drank: " + i.name); if (d.killPlayer) { Systems.Status.PlayerDeath(d.DeathMessage); } Systems.Status.AffectHydration(d.hydrationChange); return(true); }
public override bool Use(ref Item i) { if (i.GetType() != typeof(Drinkable)) { return(false); } Drinkable d = (Drinkable)i; //Logger.Instance.Log("Player drank: "+i.name); LogToServer logger = GameObject.Find("Logger").GetComponent <LogToServer>(); logger.sendToLog("Player drank " + i.name, "ACTION"); if (d.killPlayer) { Systems.Status.PlayerDeath(d.DeathMessage, d.DeathMessage); } Systems.Status.AffectHydration(d.hydrationChange); GameObject.Find("MeterDing").GetComponent <AudioSource>().Play(); return(true); }
// Update is called once per frame void Update() { if (priorityActivity == Activity_e.drinking && drinkSource != null) { if ((transform.position - drinkSource.transform.position).magnitude < collisionDist) // close enough to drinkSource // get drink (could be significant later) { drink = drinkSource.GetDrink(); //forget about drink source drinkSource = null; // coroutine could later be used to have specific messages play. StartCoroutine(Drinking()); } } else if (priorityActivity == Activity_e.dancing && currentActivity == Activity_e.inactive && danceFloor != null) { if ((transform.position - danceFloor.transform.position).magnitude < nearDist) { StartCoroutine("Dancing"); } } }
public Condiment(Drinkable drink) { this.drink = drink; }
IEnumerator Move() { moving = true; float startTime = Time.timeSinceLevelLoad; while (Time.timeSinceLevelLoad - startTime < moveDuration) { neighbors = GetNeighbors(this); newVelocity = velocity; newPosition = this.transform.position; // flocking behavior (could be parameterized) Vector3 neighborCenterOffset = GetAveragePosition(neighbors) - this.transform.position; newVelocity += neighborCenterOffset * 0.05f; // collision avoidance Vector3 dist; if (collisionRisks.Count > 0) { Vector3 collisionAveragePos = GetAveragePosition(collisionRisks); dist = collisionAveragePos - this.transform.position; newVelocity += dist * -0.5f; // collision avoidance amount } if (currentActivity == Activity_e.alert) { dist = Player.S.transform.position - this.transform.position; newVelocity += dist * 0.5f; } // attraction to "fun" if (priorityActivity == Activity_e.drinking && currentActivity == Activity_e.inactive) { if (drinkSource == null) { drinkSource = GetNearestDrinkable(this); } if (drinkSource != null) { dist = drinkSource.transform.position - this.transform.position; newVelocity += dist * 0.20f; } } if (priorityActivity == Activity_e.dancing && currentActivity == Activity_e.inactive || currentActivity == Activity_e.dancing) { if (danceFloor == null) { danceFloor = GameObject.FindGameObjectWithTag("DanceFloor").transform; } if (danceFloor != null) { if ((int)Playlist.S.songRatings[Playlist.S.currentTrack] * dancingInclination > 3f) { dist = danceFloor.position - this.transform.position; newVelocity += dist * 0.20f; } else { //priorityActivity = PickNewActivity(); } } } // newVelocity and newPosition ready, but wait until LateUpdate to set yield return(null); } StartCoroutine(Wait()); }