Ejemplo n.º 1
0
        public bool isCollision(ref SightBonus bonus, Smile currSmile)
        {
            float deltaX = bonus.Position.X - currSmile.Position.X;
            float deltaY = bonus.Position.Y - currSmile.Position.Y;
            double r = Math.Sqrt(deltaX * deltaX + deltaY * deltaY);

            if (r <= Size)
            {
                double k = Size / r;
                float newX = currSmile.Position.X * (1 - (float)k) + bonus.Position.X * (float)k;
                float newY = currSmile.Position.Y * (1 - (float)k) + bonus.Position.Y * (float)k;
                bonus.Position = new Vector2(newX, newY);
                bonus.Rectangle = new Rectangle((int)newX, (int)newY, bonus.Rectangle.Width, bonus.Rectangle.Height);

                return true;
            }

            return false;
        }
Ejemplo n.º 2
0
 bool isAlone(Smile currSmile)
 {
     for (int i = 0; i < smile.allSmiles.Count(); i++)
     {
         if ((currSmile != smile.allSmiles[i]) && isCollision(currSmile, smile.allSmiles[i]))
             return false;
     }
     return true;
 }
Ejemplo n.º 3
0
        bool isAlone(Smile currSmile, List<bool> was, ref bool isYZero)
        {
            if (currSmile.Position.Y == 0) isYZero = true;
            if (isYZero) return false;

            for (int i = smile.allSmiles.Count() - 1; i >= 0; i--)
                if (!was[i] && isCollision(currSmile, smile.allSmiles[i]))
                {
                    was[i] = true;
                    if (!isAlone(smile.allSmiles[i], was, ref isYZero)) break;
                }

            if (isYZero) return false;

            return true;
        }
Ejemplo n.º 4
0
        public bool isCollision(Bonus bonus, Smile currSmile)
        {
            int deltaX = (int)Math.Abs(bonus.Position.X - currSmile.Position.X);
            int deltaY = (int)Math.Abs(bonus.Position.Y - currSmile.Position.Y);

            if (Math.Sqrt(deltaX * deltaX + deltaY * deltaY) <= sizeOfSmile) return true;
            return false;
        }
Ejemplo n.º 5
0
        public bool isImposition(Bullet bullet, Smile currSmile)
        {
            int deltaX = (int)Math.Abs(bullet.Position.X - currSmile.Position.X);
            int deltaY = (int)Math.Abs(bullet.Position.Y - currSmile.Position.Y);

            if (Math.Sqrt(deltaX * deltaX + deltaY * deltaY) <= sizeOfSmile / 2 + sizeOfSmile / 4) return true;
            return false;
        }
Ejemplo n.º 6
0
 public bool isCollision(Line line, Smile currSmile)
 {
     if (currSmile.Rectangle.Y >= line.Rectangle.Y) return true;
     return false;
 }
Ejemplo n.º 7
0
        public bool isCollision(Smile smile1, Smile smile2)
        {
            float deltaX = smile1.Position.X - smile2.Position.X;
            float deltaY = smile1.Position.Y - smile2.Position.Y;
            double r = deltaX * deltaX + deltaY * deltaY;
            //            double r = Math.Sqrt(deltaX * deltaX + deltaY * deltaY);

            if (r <= sizeOfSmile * sizeOfSmile + 1) return true;
            //            if (r <= sizeOfSmile + 1) return true;

            return false;
        }
Ejemplo n.º 8
0
        public static void newGame()
        {
            setConstants();

            amountOfShot = 0;

            smile = new Smile();
            lifeBonus = new LifeBonus();
            choiceBonus = new ChoiceBonus();
            sightBonus = new SightBonus();

            for (int i = 0; i < maxNumInRow; i++)
                for (int j = 0; j < maxNumInCol; j++)
                {
                    if (smile.Create(i, j)) ;
                    else if (heartIsAvailable && lifeBonus.Create(i, j));
                    else if (sightIsAvailable && choiceBonus.Create(i, j));
                    else if (palmIsAvailable && sightBonus.Create(i, j));
                }

            bullet = new Bullet();
            bullet.Create();

            nextBullet = new Bullet();
            nextBullet.Create();
            nextBullet.Position = new Vector2(140, ScreenSize.Y - sizeOfSmile - 20);
        }
Ejemplo n.º 9
0
        public bool Create(int i, int j)
        {
            int color = rand.Next(1, 9);
            Texture2D currentTexture = TextureLoad.RedSmile;
            bool isExist = false;
            TextureLoad.SetColor(color, ref currentTexture, ref isExist);
            Vector2 position = new Vector2(i * Size, j * Size);

            Smile smile = new Smile(currentTexture, new Rectangle(i * Size, j * Size, Size, Size), Size, Size, position, color);
            if (isExist && color > 0 && color < Game1.maxAmountOfSmile && (j == 0 || !isAlone(smile)))
            {
                allSmiles.Add(smile);
                return true;
            }
            return false;
        }
Ejemplo n.º 10
0
 private bool isAlone(Smile smile)
 {
     for (int i = 0; i < allSmiles.Count(); i++)
     {
         if ((smile != allSmiles[i]) && isCollision(smile, allSmiles[i]))
             return false;
     }
     return true;
 }