public void MakeFriends(IPanda panda1, IPanda panda2) { if (panda1.Equals(panda2)) { throw new PandasMustBeDifferentException(); } if (!this.pandasInNetwork.ContainsKey(panda1)) { this.pandasInNetwork.Add(panda1, new List<int>()); } if (!(this.pandasInNetwork.ContainsKey(panda2))) { this.pandasInNetwork.Add(panda2, new List<int>()); } // TODO : fix check for already friends if (!this.pandasInNetwork[panda1].Contains(panda2.GetHashCode()) && !this.pandasInNetwork[panda2].Contains(panda1.GetHashCode())) { this.pandasInNetwork[panda1].Add(panda2.GetHashCode()); this.pandasInNetwork[panda2].Add(panda1.GetHashCode()); } else { throw new PandasAlreadyFriendsException(); } }
private IEnumerator Using(IPanda panda) { float timeStarted = Time.time; while (_isActive && _usingPandas.Contains(panda) && Time.time - timeStarted < _eroConsumable.TimeGivingNutrition) { if (((IConsumable)_eroConsumable).CanConsume(panda)) { Debug.Log("Using ERO"); _eroConsumable.DoAction(panda); yield return(new WaitForSeconds(_tickDurationInSeconds)); if (panda == null) { break; } } } if (_usingPandas.Contains(panda)) { _usingPandas.Remove(panda); } TryDestroyingActivityArea(); }
private void DisallowRelease(IPanda panda) { if (currentPanda == panda) { currentPanda = null; myButton.interactable = false; } }
private void AllowRelease(IPanda panda) { currentPanda = panda; if (GameManager.instance.pandaManager.pandasOnDisplay.Count > 2) { myButton.interactable = true; } }
public IEnumerable<IPanda> FriendsOf(IPanda panda) { var friends = from pandas in this.pandasInNetwork.Keys join hash in this.pandasInNetwork[panda] on pandas.GetHashCode() equals hash select pandas; return friends; }
public bool AreFriends(IPanda panda1, IPanda panda2) { if (HasPanda(panda1) && HasPanda(panda2)) { if (_pandaUsers[panda1.GetHashCode()].Friends.Contains(panda2.GetHashCode()) && _pandaUsers[panda2.GetHashCode()].Friends.Contains(panda1.GetHashCode())) { return true; } } return false; }
public bool AreFriends(IPanda panda1, IPanda panda2) { if (panda1.Equals(panda2)) { throw new PandasMustBeDifferentException(); } return this.pandasInNetwork[panda1].Contains(panda2.GetHashCode()); }
private IEnumerator Eating(IPanda panda, PandaActivityFlag activityFlag) { Assert.IsFalse(_eatingPandas.Contains(panda)); _eatingPandas.Add(panda); activityFlag.AddActivity(this); var dummyPanda = (panda as DummyPanda); var navmeshAgent = dummyPanda.GetComponentNotNull <NavMeshAgent>(); while (CanApplyPile(panda) && PandaIsHungry(panda)) { navmeshAgent.velocity = Vector3.zero; navmeshAgent.isStopped = true; dummyPanda.GetComponentNotNull <PandaSpriteOrientationChanger>() .AlignOrientationToVelocity((transform.position - dummyPanda.transform.position).normalized); //UpdateNavmeshAgent(panda); var foodToEat = Pile.RetriveFoodFromPile(); dummyPanda.StartAnimationState(PandaAnimationState.Eating); Debug.Log("EATING: " + foodToEat.Food); var foodTimeGivingNutrition = foodToEat.Food.timeGivingNutrition; SoundManager.instance.PlaySustainedTheme(dummyPanda.gameObject, SoundType.Eating, foodTimeGivingNutrition + 0.3f); yield return(new WaitForSeconds(foodTimeGivingNutrition)); Debug.Log("EATEN: " + foodToEat.Food); if (panda == null) { break; } dummyPanda.StopAnimationState(PandaAnimationState.Eating); ((IConsumable)foodToEat.Food).Consume(panda); if (foodToEat.Drug != null) { if (((IConsumable)foodToEat.Drug).CanConsume(panda)) { Debug.Log("Consuming drug: " + foodToEat.Drug); (foodToEat.Drug).DoAction(panda); } } navmeshAgent.isStopped = false; } if (!(panda == null)) { activityFlag.RemoveActivity(this); } _eatingPandas.Remove(panda); if (!_eatingPandas.Any()) { Pile.ThereAreNoEatinPandasLeft(); } }
public void AddPanda(IPanda panda) { if (!this.pandasInNetwork.ContainsKey(panda)) { this.pandasInNetwork.Add(panda, new List<int>()); } else { throw new PandasAlreadyExists(); } }
public List<IPanda> FriendsOf(IPanda panda) { List<IPanda> ListOfPandas = new List<IPanda>(); var pandaAndHash = from pandas in _pandaUsers join hash in panda.Friends on pandas.Key equals hash select pandas.Value; foreach (var item in pandaAndHash) { ListOfPandas.Add(item); } return ListOfPandas; }
public float RetriveAttractionForPanda(IPanda panda) { return(FoodConsumables.Sum(c => { if (!PandaCanConsumeFood(panda, c)) { return 0; } return c.Food.range * c.Amount; }) * 0.1f * Mathf.Max(0, 10 - panda.GetFullness())); }
private void ReleaseAPandaToForrest() { if ((currentPanda as MonoBehaviour).isActiveAndEnabled) { SoundManager.instance.PlayOneShotSound(SoundType.Yay); currentPanda.GoToForest(); GameManager.instance.pandaManager.pandasReleasedToForrest++; GameManager.instance.notificationManager.OnPandaReleased?.Invoke(); progress.fillAmount = (float)GameManager.instance.pandaManager.pandasReleasedToForrest / (float)GameManager.instance.pandaManager.pandasToWin; myButton.interactable = false; currentPanda = null; } }
public List<IPanda> FriendsOf(IPanda panda) { List<IPanda> ListOfPandas = new List<IPanda>(); //ListOfPandas = _pandaUsers.Select(panda.GetHashCode() => ); var pandaAndHash = from pandas in _pandaUsers join hash in panda.Friends on pandas.GetHashCode() equals hash select panda; foreach (var item in pandaAndHash) { ListOfPandas.Add(item); } return ListOfPandas; }
public override void DoAction(IPanda panda) { switch (drugType) { case DrugType.ero: panda.ChangeEro(m_drugValue); break; case DrugType.hp: panda.ChangeHealth(m_drugValue); break; case DrugType.food: panda.ChangeFullness(m_drugValue); break; } }
public void MakeFriends(IPanda panda1, IPanda panda2) { if (!_pandaUsers.ContainsKey(panda1.GetHashCode())) { _pandaUsers.Add(panda1.GetHashCode(), panda1); } //else panda1 = _pandaUsers[panda1.GetHashCode()]; if (!_pandaUsers.ContainsKey(panda2.GetHashCode())) { _pandaUsers.Add(panda2.GetHashCode(), panda2); } //else panda2 = _pandaUsers[panda2.GetHashCode()]; if (!panda1.Friends.Contains(panda2.GetHashCode())) { panda1.Friends.Add(panda2.GetHashCode()); panda2.Friends.Add(panda1.GetHashCode()); } else { throw new PandasAlreadyFriendsException(); } }
public int ConnectionLevel(IPanda panda1, IPanda panda2) { if (panda1.Equals(panda2)) { throw new PandasMustBeDifferentException(); } int counter = 0; var queue = new Queue<PandasWithLevel>(); List<int> visited = new List<int>(); visited.Add(panda1.GetHashCode()); queue.Enqueue(new PandasWithLevel(panda1.GetHashCode(), 0)); while (queue.Count > 0) { PandasWithLevel currPanda = queue.Dequeue(); if (currPanda.PandaHash.Equals(panda2.GetHashCode())) { //Console.WriteLine(counter); return currPanda.Level; } //var neighbours = this.pandasInNetwork.Select(x => x.Key).Where(y => y.GetHashCode() == hash).ToList(); IList<int> neighbours = new List<int>(); foreach (var panda in this.pandasInNetwork.Keys) { if (currPanda.PandaHash == panda.GetHashCode()) { neighbours = this.pandasInNetwork[panda]; } } foreach (int hash in neighbours.Where(neighbour => !visited.Contains(neighbour))) { visited.Add(hash); queue.Enqueue(new PandasWithLevel(hash.GetHashCode(), currPanda.Level + 1)); } } return -1; }
public int ConnectionLevel(IPanda panda1, IPanda panda2) { var pending = new Queue<PandaWithLevel>(); var visited = new List<int>(); pending.Enqueue(new PandaWithLevel { Level = 0, Panda = panda1.GetHashCode() }); while (pending.Count > 0) { var currPanda = pending.Dequeue(); var connectionLevel = currPanda.Level + 1; if (currPanda.Panda == panda2.GetHashCode()) return connectionLevel - 1; if (!visited.Contains(currPanda.Panda)) { visited.Add(currPanda.Panda); foreach (var friend in _pandaUsers[currPanda.Panda].Friends) { pending.Enqueue(new PandaWithLevel { Level = connectionLevel, Panda = friend }); } } } return -1; }
public bool CanMateWith(IPanda otherPanda) { return((!_flag.IsDuringActivity) && (otherPanda.GetGender() != _thisPanda.GetGender()) && (_thisPanda.GetEro() > _EroThresholdForSex) && _thisPanda.GetFullness() > GameManager.instance.pandaManager.GetMinimumFullnessForMating()); }
private void PredictThirdPanda(IPanda firstPanda, IPanda secondPanda) { var pandaStats = childPandaCreator.CreateChildStats(firstPanda.GetStats(), secondPanda.GetStats()); childPandaRepresentation.LoadPanda(pandaStats); }
public override void DoAction(IPanda panda) { panda.ChangeFullness(m_foodNutritionalValue); }
// Update is called once per frame void Update() { var panda = Util.RaycastPanda(); if (panda == null) { return; } if (Input.GetMouseButtonDown(0)) { SoundManager.instance.PlayOneShotSound(SoundType.MenuClick); if (choosingTwoPandas) { if (firstPanda == panda) { panda.Deselect(1); firstPandaRepresentation.Clear(); firstPanda = null; childPandaRepresentation.Clear(); return; } if (secondPanda == panda) { panda.Deselect(2); secondPandaRepresentation.Clear(); secondPanda = null; childPandaRepresentation.Clear(); return; } if (firstPanda == null) { firstPanda = panda; panda.Select(1); firstPandaRepresentation.LoadPanda(firstPanda.GetStats()); if (firstPanda != null && secondPanda != null && firstPanda.GetGender() != secondPanda.GetGender()) { PredictThirdPanda(firstPanda, secondPanda); } return; } if (secondPanda == null) { secondPanda = panda; panda.Select(2); secondPandaRepresentation.LoadPanda(secondPanda.GetStats()); if (firstPanda != null && secondPanda != null && firstPanda.GetGender() != secondPanda.GetGender()) { PredictThirdPanda(firstPanda, secondPanda); } return; } } else { if (firstPanda == panda) { panda.Deselect(1); firstPandaRepresentation.Clear(); firstPanda = null; return; } if (firstPanda != null) { firstPanda.Deselect(1); } firstPanda = panda; panda.Select(1); firstPandaRepresentation.LoadPanda(firstPanda.GetStats()); } } }
public IEnumerable<IPanda> FirendsOf(IPanda panda) { var neighbours = this.pandasInNetwork.Select(x => x.Key).Where(y => this.pandasInNetwork[panda].Contains(y.GetHashCode())); return neighbours; }
internal static PandaDTO ConvertToDto(IPanda panda) { return new PandaDTO {Name = panda.Name, Email = panda.Email, Gender = panda.Gender}; }
public void Select(IPanda panda, int slot) { throw new System.NotImplementedException(); }
public float RetriveAttraction(IPanda panda) { return(ForceMagnitude); }
public override void DoAction(IPanda panda) { panda.ChangeEro(m_eroNutritionalValue); }
private bool PandaIsHungry(IPanda panda) { return(panda.IsNotFull()); }
public PandaStats ComputePairingStats(IPanda panda1, IPanda panda2) { throw new System.NotImplementedException(); }
private bool CanApplyPile(IPanda panda) { return(Pile.HasEadibleFoodForPanda(panda)); }
private static bool PandaCanConsumeFood(IPanda panda, FoodWithItsAmount c) { return(((IConsumable)c.Food).CanConsume(panda)); }
public bool AreConnected(IPanda panda1, IPanda panda2) { return ConnectionLevel(panda1, panda2) > 0; }
public void AddPanda(IPanda panda) { if (_pandaUsers.ContainsKey(panda.GetHashCode())) throw new PandaAlreadyThereException(); else _pandaUsers.Add(panda.GetHashCode(), panda); }
public bool HasPanda(IPanda panda) { return this.pandasInNetwork.ContainsKey(panda); }
public bool HasPanda(IPanda panda) { return _pandaUsers.ContainsKey(panda.GetHashCode()); }
void Awake() { _activeForceFields = new List <IForceField>(); _panda = this.GetComponentNotNull <IPanda>(); }
void IConsumable.Consume(IPanda panda) { DoAction(panda); //GameManager.instance.ConsumableManager.Consume(this); }
bool IConsumable.CanConsume(IPanda panda) { return(true); }
public virtual void DoAction(IPanda panda) { }
public float RetriveAttraction(IPanda panda) { return(_pile.RetriveAttractionForPanda(panda)); }
public int HowManyGenderInNetwork(int level, IPanda panda, GenderType gender) { int pandasWithGender = 0; var pending = new Queue<PandaWithLevel>(); var visited = new List<int> { panda.GetHashCode() }; int connectionLevel = 0; pending.Enqueue(new PandaWithLevel { Level = 0, Panda = panda.GetHashCode() }); foreach(var friend in panda.Friends) { pending.Enqueue(new PandaWithLevel { Level = connectionLevel, Panda = friend }); } while (pending.Count > 0 && connectionLevel <= level) { var currPanda = pending.Dequeue(); connectionLevel = currPanda.Level + 1; if (!visited.Contains(currPanda.Panda)) { visited.Add(currPanda.Panda); if (_pandaUsers[currPanda.Panda].Gender == gender) pandasWithGender++; foreach (var friend in _pandaUsers[currPanda.Panda].Friends) { pending.Enqueue(new PandaWithLevel { Level = connectionLevel, Panda = friend }); } } } return pandasWithGender; }
public bool HasEadibleFoodForPanda(IPanda panda) { return(FoodConsumables.Any(c => PandaCanConsumeFood(panda, c))); }