Ejemplo n.º 1
0
        public override void OnCollision(GameObject other)
        {
            if (other is Farm)
            {
                if (!farmUpgraded)
                {
                    lock (FarmLock)
                    {
                        gold = 5;
                        Thread.Sleep(3000);
                    }
                }
                //The farm can be upgraded to hold two workers at once.
                if (farmUpgraded)
                {
                    UpgradeFarm.WaitOne();
                    Thread.Sleep(0);
                    gold = 5;
                    UpgradeFarm.Release();
                }
            }
            if (other is Inn)
            {
                if (!innUpgraded)
                {
                    if (gold > 0)
                    {

                        innMutex.WaitOne();
                        GameWorld.totalGold += gold;
                        gold = 0;
                        deathCount++;
                        Thread.Sleep(3000);
                        innMutex.ReleaseMutex();
                    }
                }
                //The Inn is upgradeable aswell, though this is a bigger upgrade then the Farm, hence why it is more expensive.
                else
                {
                    if (gold > 0)
                    {
                        innSpace.WaitOne();
                        GameWorld.totalGold += gold;
                        gold = 0;
                        deathCount++;
                        Thread.Sleep(0);
                        innSpace.Release();
                    }
                }

            }
        }
Ejemplo n.º 2
0
        //This is empty, because the individual objects have their own way of reacting to collision.
        public virtual void OnCollision(GameObject other)
        {

        }
Ejemplo n.º 3
0
 public bool IsCollidingWith(GameObject other)
 {
     return CollisionBox.IntersectsWith(other.CollisionBox);
 }