Ejemplo n.º 1
0
 private void NectarUpdated(NectarProperty nectarProperty, SimObject simObject)
 {
     if (nectarProperty.HasNectar)
     {
         Console.WriteLine("Hive got nectar!!!");
         nectarProperty.DrainNectar();
     }
 }
Ejemplo n.º 2
0
        protected override void OnSimObjectUpdating(SimObject simObject, SimModel simModel, SimState simState)
        {
            var nectarProp = simObject.GetProperty <NectarProperty>();

            if (nectarProp == null)
            {
                nectarProp = new NectarProperty();
                simObject.Properties.Add(nectarProp);
            }
            nectarProp.FillNectar();
        }
Ejemplo n.º 3
0
 private void NectarUpdated(NectarProperty nectarProperty, SimObject simObject)
 {
     if (nectarProperty.HasNectar)
     {
         simObject.Color    = Colors.Green;
         simObject.Velocity = simObject.Location.GetDirection(_hive.Location).ScalarMultiply(Speed);
     }
     else if (!nectarProperty.HasNectar)
     {
         GiveRandomDirection(simObject, Speed);
         simObject.Color = Colors.Black;
     }
 }
Ejemplo n.º 4
0
 public bool GetNectarFrom(NectarProperty nectarProperty)
 {
     if (nectarProperty == null)
     {
         return(false);
     }
     lock (_nectarLockObject)
     {
         lock (nectarProperty._nectarLockObject)
         {
             if (HasNectar || !nectarProperty.HasNectar)
             {
                 return(false);
             }
             HasNectar = true;
             nectarProperty.HasNectar = false;
             return(true);
         }
     }
 }