Example #1
0
        private Component GetBumperPosition(CompTimePair nextCTP)
        {
            Vector2   cPos = StaticData.EngineManager.CookieRB.PositionXNACenter2D;
            int       cX   = (int)cPos.X;
            int       cY   = (int)cPos.Y;
            Component cAdd = new Rope(0, 0, 100);
            Vector3   vel  = StaticData.EngineManager.CookieRB.GetVelocity();
            int       dir  = 0;

            if (!_isDirRandomized)
            {
                dir = Int32.Parse(nextCTP.Args[1]);
            }
            else
            {
                dir = _rand.Next(4);
            }

            int defX = cX - (int)StaticData.BumpHalfSize.X;
            int defY = cY - (int)StaticData.BumpHalfSize.Y;
            int X = 0, Y = 0;
            int diffS     = 20;
            int diff      = 35;
            int diffYLean = 40;
            int diffXLean = 40;

            switch ((Direction)dir)
            {
            case Direction.East:
                X = defX;
                Y = vel.Y > 0 ? cY - diff : cY + diff;
                break;

            case Direction.SouthEast:
                X = vel.X > 0 ? defX + diffS : defX - diffS;
                Y = vel.Y > 0 ? cY + diffYLean : cY - diffYLean;
                break;

            case Direction.South:
                X = defX;
                Y = vel.Y > 0 ? cY + diff : cY - (int)(2 * StaticData.BumpHalfSize.Y) - diff;
                break;

            case Direction.SouthWest:
                X = vel.X > 0 ? defX + diffS : defX - diffS;
                Y = vel.Y > 0 ? cY + diffYLean : cY - diffYLean;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            cAdd = new Bump(X, Y, (Direction)dir);
            return(cAdd);
        }
Example #2
0
        private Component GetBlowerPosition(CompTimePair nextCTP)
        {
            Vector2   cPos = StaticData.EngineManager.CookieRB.PositionXNACenter2D;
            int       cX   = (int)cPos.X;
            int       cY   = (int)cPos.Y;
            Component cAdd = new Rope(0, 0, 100);
            Vector3   acc  = StaticData.EngineManager.CookieRB.GetVelocity();
            int       dir  = 0;

            if (!_isDirRandomized)
            {
                dir = Int32.Parse(nextCTP.Args[1]);
            }
            else
            {
                dir = _rand.Next(2);
                dir = dir == 1 ? 4 : 0;
            }
            //dir = 4;

            int x = 0, y = 0;

            if (acc.Y > 0)
            {
                y = cY - 10;
            }
            else
            {
                y = cY + 10;
            }

            if (dir == 4)
            {
                x = cX + (int)StaticData.BlowerDimWidth;
            }
            else
            {
                x = cX - (int)StaticData.BlowerDimWidth;
            }

            cAdd = new Blower(x, y, (Direction)dir);
            return(cAdd);
        }
Example #3
0
        private Component GetRocketPosition(CompTimePair nextCTP)
        {
            Vector2   cPos = StaticData.EngineManager.CookieRB.PositionXNACenter2D;
            int       cX = (int)cPos.X;
            int       cY = (int)cPos.Y;
            int       rX, rY;
            Component cAdd      = new Rope(0, 0, 100);
            Vector3   vel       = StaticData.EngineManager.CookieRB.GetVelocity();
            int       dir       = 0;
            int       closeArea = StaticData.RocketCarrierCloseArea - 10;
            int       halfDimX  = (int)(StaticData.RocketCarrierHalfSize.X / 2);
            int       halfDimY  = (int)(StaticData.RocketCarrierHalfSize.Y / 2);

            if (!_isDirRandomized)
            {
                dir = Int32.Parse(nextCTP.Args[1]);
            }
            else
            {
                dir = _rand.Next(4);
            }
            //dir = 7;
            if (vel.Y > 0)
            {
                rY = cY - halfDimY;
            }
            else
            {
                rY = cY + halfDimY;
            }

            if (vel.X > 0)
            {
                rX = cX + halfDimX;
            }
            else
            {
                rX = cX - halfDimX;
            }

            cAdd = new Rocket(rX, rY, (Direction)dir);
            return(cAdd);
        }
Example #4
0
        private CompTimePair GetPlacementCTPair(ActionTimePair atPair, List <ActionTimePair> atPairs)
        {
            int minTS, maxTS;

            GetPlacementMinMaxTS(atPair, atPairs, out minTS, out maxTS);
            //int placeTS = //_rand.Next(minTS, maxTS);

            int          placeTS = _rand.Next(minTS, (minTS + maxTS) / 2);
            CompTimePair res     = null;

            switch (atPair.EType)
            {
            case EventType.BlowerPress:
                break;

            case EventType.RopeCut:
                break;

            case EventType.BubblePinch:
                res = new CompTimePair(ComponentType.Bubble, placeTS);
                break;

            case EventType.RocketPress:
                res = new CompTimePair(ComponentType.Rocket, placeTS);
                break;

            case EventType.BumperInteraction:
                break;

            case EventType.OmNomFeed:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            return(res);
        }
Example #5
0
        private void PlaceNewComp(CompTimePair nextCTP)
        {
            CompsScatteredSoFar++;
            //Shotter.TakeEngineShot();
            var fEngine = ObjectSerializer.DeepCopy(StaticData.EngineManager);

            for (int i = 0; i < 15; i++)
            {
                fEngine.Update(new GameTime());
            }

            Vector2 cPossss = StaticData.EngineManager.CookieRB.PositionXNA2D;
            Vector2 cPos    = fEngine.CookieRB.PositionXNA2D;
            //StaticData.EngineManager.CookieRB.PositionXNACenter2D;
            int       cX   = (int)cPos.X;
            int       cY   = (int)cPos.Y;
            Component cAdd = new Rope(0, 0, 100);
            Vector3   acc  = StaticData.EngineManager.CookieRB.GetAcceleration();

            switch (nextCTP.CType)
            {
            case ComponentType.Cookie:
                break;

            case ComponentType.Frog:
                cAdd = GetFrogPosition();
                break;

            case ComponentType.Blower:
                cAdd = GetBlowerPosition(nextCTP);
                break;

            case ComponentType.Rope:
                break;

            case ComponentType.Bubble:
                cAdd = new Bubble(cX - (int)StaticData.BubbleDimBubble / 2,
                                  cY - (int)StaticData.BubbleDimBubble / 2);
                //GetBubblePosition();
                break;

            case ComponentType.Water:
                break;

            case ComponentType.Rocket:
                int dirR = _rand.Next(8);
                cAdd = new Rocket(cX - (int)StaticData.RocketCarrierHalfSize.X,
                                  cY - (int)StaticData.RocketCarrierHalfSize.Y, (Direction)dirR);
                //GetRocketPosition(nextCTP);
                break;

            case ComponentType.Bump:
                int dirB = _rand.Next(3);
                dirB = dirB == 2 ? 3 : dirB;
                if (dirB == 1 || dirB == 3)
                {
                    var fEngineB = ObjectSerializer.DeepCopy(StaticData.EngineManager);
                    for (int i = 0; i < 25; i++)
                    {
                        fEngineB.Update(new GameTime());
                    }
                    cPos = fEngine.CookieRB.PositionXNA2D;
                    cX   = (int)cPos.X;
                    cY   = (int)cPos.Y;
                }
                cAdd = new Bump(cX - (int)StaticData.BumpHalfSize.X,
                                cY - (int)StaticData.BumpHalfSize.Y, (Direction)dirB);
                //cAdd = GetBumperPosition(nextCTP);
                break;

            case ComponentType.Cracker:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            if (!(cAdd is Rope))
            {
                cAdd.AddSelfToEngine();
                LevelStr += cAdd.ToString();
            }
        }