Example #1
0
        public void StartDemo()
        {
            f = new Field(5, 5);
            s = new Snake(new List <string>()
            {
                "0 0", "0 1", "0 2"
            });
            fd = new Food(new List <string>()
            {
                "0 4", "4 0", "4 4"
            });
            o = new Obstacles(new List <string>());
            Console.Clear();
            _display = new Display();
            Console.WriteLine("--- DEMO LEVEL ---");
            Console.WriteLine();
            _display.VisualiseFied(f.Rows, f.Cols, s.Coordinates, fd.Coordinates, o.Coordinates);

            while (fd.Coordinates.Count != 0)
            {
                _display.VisualiseManual();
                ConsoleKeyInfo inputString = Console.ReadKey();
                char           input       = inputString.KeyChar;
                MoveSnake(input);
                Console.Clear();
                Console.WriteLine("--- DEMO LEVEL ---");
                Console.WriteLine();
                _display.VisualiseFied(f.Rows, f.Cols, s.Coordinates, fd.Coordinates, o.Coordinates);
            }
            StartLevel1();
        }
Example #2
0
        public void Draw()
        {
            BG.Draw();
            Road.Draw();
            Obstacles.ForEach(o => o.Draw());
            Player.Draw();

            Foreground.Draw();

            if (Paused && !lost)
            {
                Util.DrawText("Press SPACE to jump!", new Vector2(150, 20));
            }

            if (lost)
            {
                if (highScore)
                {
                    Util.DrawText("NEW HIGH SCORE: " + score.ToString(), new Vector2(150, 20));
                }
                else
                {
                    Util.DrawText("Final score: " + score.ToString(), new Vector2(150, 20));
                }
            }

            DrawScore();
        }
Example #3
0
        public void Load(Texture2D texture)
        {
            Obstacles.Clear();
            Enemies.Clear();
            Texture = texture;
            Color[] data = new Color[Texture.Width * Texture.Height];
            Texture.GetData <Color>(data);

            var bruteTiles = new Tile[texture.Width * texture.Height];

            int tileCounter = 0;

            for (int i = 0; i < Texture.Height; i++)
            {
                for (int j = 0; j < Texture.Width; j++)
                {
                    var currentPixelColor = data[i * texture.Width + j];
                    var t = new Tile(this, new Vector2(j, i), currentPixelColor);
                    if (t.Valid)
                    {
                        bruteTiles[tileCounter] = t;
                        tileCounter++;
                    }
                }
            }

            tiles = new Tile[tileCounter];
            for (int i = 0; i < tileCounter; i++)
            {
                tiles[i] = bruteTiles[i];
            }

            Rectangle = new Rectangle(-Texture.Width * Tile.TILE_WIDTH / 2, -Texture.Height * Tile.TILE_WIDTH / 2, Texture.Width * Tile.TILE_WIDTH, Texture.Height * Tile.TILE_WIDTH);
        }
Example #4
0
        List <ICurve> GetCurves(Point point, AxisEdge edge)
        {
            var ellipse = CurveFactory.CreateEllipse(3, 3, point);
            var curves  = new List <ICurve>(Obstacles.Select(o => o as ICurve))
            {
                ellipse,
                new LineSegment(edge.Source.Point, edge.Target.Point
                                )
            };

            if (edge.RightBound < double.PositiveInfinity)
            {
                double rightOffset = edge.RightBound;
                var    del         = DirectionPerp * rightOffset;
                curves.Add(new LineSegment(edge.Source.Point + del, edge.Target.Point + del));
            }
            if (edge.LeftBound > double.NegativeInfinity)
            {
                double leftOffset = edge.LeftBound;
                var    del        = DirectionPerp * leftOffset;
                curves.Add(new LineSegment(edge.Source.Point + del, edge.Target.Point + del));
            }

            curves.AddRange((from e in PathOrders.Keys
                             let a = e.SourcePoint
                                     let b = e.TargetPoint
                                             select new CubicBezierSegment(a, a * 0.8 + b * 0.2, a * 0.2 + b * 0.8, b)).Cast <ICurve>());

            return(curves);
        }
Example #5
0
 public override bool didCollide()
 {
     foreach (Obstacles obstacle in FarmScene.obstaclesList)
     {
         if (obstacle.collisionShape == Obstacles.CollisionShape.Circle)
         {
             boundingSphere = new BoundingSphere(new Vector3(temporaryPosition.X, temporaryPosition.Y, 0), radius);
             if (Obstacles.didCollide(boundingSphere, obstacle))
             {
                 return(true);
             }
         }
         if (obstacle.collisionShape == Obstacles.CollisionShape.Rectangle)
         {
             boundingBox = new BoundingBox(new Vector3(temporaryPosition.X + 8, temporaryPosition.Y + 8, 0), new Vector3(temporaryPosition.X + 24, temporaryPosition.Y + 24, 0));
             if (Obstacles.didCollide(boundingBox, obstacle))
             {
                 return(true);
             }
         }
     }
     foreach (CollisionsObject collisionsObject in FarmScene.collisionsObjectList)
     {
         {
             boundingBox = new BoundingBox(new Vector3(temporaryPosition.X + 8, temporaryPosition.Y + 8, 0), new Vector3(temporaryPosition.X + 24, temporaryPosition.Y + 24, 0));
             if (boundingBox.Intersects(collisionsObject.boundingBox))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Example #6
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            this.IsMouseVisible = true;

            // TODO: Add your initialization logic here
            viewport = GraphicsDevice.Viewport;

            me = this;

            ButtonSize = new Vector2(viewport.Width * 0.12f, viewport.Width * 0.06f);

            playLocation = new Vector2((viewport.Width / 2) - ButtonSize.X - (viewport.Height / 40), viewport.Height * 0.6f);
            rateLocation = new Vector2((viewport.Width / 2) + (viewport.Height / 40), viewport.Height * 0.6f);

            player    = new Player(viewport);
            obstacles = new Obstacles(viewport);

            ScoreboardSize     = new Vector2(viewport.Width * .4f, (viewport.Width * .4f) / 124 * 76);
            ScoreboardLocation = new Vector2((viewport.Width - ScoreboardSize.X) / 2, viewport.Height);

            MedalSize     = new Vector2(70 * ScoreboardSize.Y / 194);
            MedalLocation = new Vector2(27 * (ScoreboardSize.X / 320), 76 * (ScoreboardSize.Y / 194));

            base.Initialize();
        }
        public bool Remove(IEntity entity)
        {
            entity = entity.MustNotBeNull(nameof(entity));

            switch (entity)
            {
            case Node node:
                if (node.Equals(HomeNode))
                {
                    HomeNode = null;
                }
                return(Nodes.Remove(node));

            case Reflector reflector:
                return(Reflectors.Remove(reflector));

            case Obstacle obstacle:
                return(Obstacles.Remove(obstacle));

            case StorageRow storageRow:
                return(StorageRows.Remove(storageRow));

            case StorageLocation storageLocation:
                return(StorageLocations.Remove(storageLocation));

            case VirtualPoint virtualPoint:
                return(VirtualPoints.Remove(virtualPoint));

            case NodeLink nodeLink:
                return(NodeLinks.Remove(nodeLink));

            default:
                return(false);
            }
        }
Example #8
0
        public void StartNewGame(List <PlayerAction> playerActions)
        {
            Obstacles.Clear();
            Paintballs.Clear();
            PaintballHits.Clear();

            Map map = MapLoader.LoadRandomMap();

            Obstacles = map.Obstacles;
            Berries   = map.Berries;

            if (_players.Count == 1)
            {
                AIPlayer player = null;
                string   id     = string.Empty;
                for (int i = 2; i <= 6; i++)
                {
                    id              = "AI" + i.ToString();
                    player          = new AIPlayer((ushort)i, id);
                    player.Location = PlacePlayer();
                    Players.Add(id, player);
                    playerActions.Add(new PlayerAction(id, MessageConstants.PlayerActionNone));
                }
            }

            foreach (Player player in Players.Values)
            {
                player.Location = PlacePlayer();
                player.Health   = 100;
                player.Ammo     = 100;
            }
        }
Example #9
0
        public GameState(GraphicsDeviceManager g, ContentManager c, Viewport v) : base(g, c, v)
        {
            me       = this;
            viewport = v;

            ButtonSize   = new Vector2(viewport.Width * 0.34f, viewport.Width * 0.17f);
            btnPlay      = content.Load <Texture2D>("btnPlay");
            playLocation = new Vector2((viewport.Width - ButtonSize.X) / 2, viewport.Height * 0.6f);

            score         = new Score(v, c);
            score.display = true;

            player = new Player(v);
            player.LoadContent(c);

            obstacles = new Obstacles(viewport);
            obstacles.LoadContent(content);

            spriteFont   = content.Load <SpriteFont>("ScoreFont");
            READEsize    = spriteFont.MeasureString("Get Ready");
            Menusize     = spriteFont.MeasureString("Sway Copter");
            GameOverSize = spriteFont.MeasureString("Game Over");

            GameOverLocation = new Vector2((viewport.Width - spriteFont.MeasureString("Game Over").X) / 2, -GameOverSize.Y);

            Scoreboard         = content.Load <Texture2D>("Dashboard");
            ScoreboardSize     = new Vector2(viewport.Width * .9f, viewport.Width * 0.545625f);
            ScoreboardLocation = new Vector2((viewport.Width - ScoreboardSize.X) / 2, viewport.Height);

            buttonSound = c.Load <SoundEffect>("swing");
        }
Example #10
0
        private void OnShowelDelayTimerTick(object sender, EventArgs e)
        {
            _showelDelayTimer.Stop();

            DestroyHQFence();

            var brickFence = CreateBrickHQFence();

            SubscribeObstacles(brickFence);

            foreach (var obstacle in brickFence)
            {
                foreach (var playerTank in PlayersManager.Tanks)
                {
                    playerTank.CheckPosition += obstacle.GetCheckPositionListener();
                }

                foreach (var compTank in CompsManager.Tanks)
                {
                    compTank.CheckPosition += obstacle.GetCheckPositionListener();
                }
            }

            Obstacles.AddRange(brickFence);
        }
Example #11
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.A))
        {
            rb2d.transform.localRotation = Quaternion.Euler(0, 180, 0);
        }

        if (Input.GetKeyDown(KeyCode.D))
        {
            rb2d.transform.localRotation = Quaternion.Euler(0, 0, 0);
        }

        if (Input.GetKeyDown(KeyCode.Space) && !isJumping)
        {
            rb2d.velocity = Vector2.up * jumpHeight;
            isJumping     = true;
        }

        if (Input.GetKeyDown(KeyCode.X) && startSecondStage)
        {
            StartCoroutine(Obstacles.ShowObstacles());
        }

        if (completeFirstStage)
        {
            Obstacles.RemoveObstacles();
            startSecondStage = true;
        }

        if (SceneManager.GetActiveScene() == SceneManager.GetSceneByName("LevelThree"))
        {
            gameComplete = true;
        }
    }
Example #12
0
        private void OnPlayerTookShowel(object sender, EventArgs e)
        {
            DestroyHQFence();

            var concreteFence = CreateConcreteHQFence();

            SubscribeObstacles(concreteFence);

            foreach (var obstacle in concreteFence)
            {
                foreach (var playerTank in PlayersManager.Tanks)
                {
                    playerTank.CheckPosition += obstacle.GetCheckPositionListener();
                }

                foreach (var compTank in CompsManager.Tanks)
                {
                    compTank.CheckPosition += obstacle.GetCheckPositionListener();
                }
            }

            Obstacles.AddRange(concreteFence);

            _showelDelayTimer.Stop();
            _showelDelayTimer.Start();
        }
Example #13
0
        public void ListenToBonuses()
        {
            for (int i = 0; i < Obstacles.Count; i++)
            {
                if (IsCollision(Obstacles[i]) && Obstacles[i].GetType().Equals(typeof(Bonus)))
                {
                    Obstacles.RemoveAt(i);
                    GameStats.BonusDropChance -= 1;
                    switch (random.Next(0, 4))
                    {
                    case (int)BonusModifiers.Obstacles:
                        GameStats.ObstacleDropChance -= Settings.ObstacleBonusModifier;
                        GameStats.LastEvent           = new GameEvent($"-{Settings.ObstacleBonusModifier}% Obstacle chance");
                        break;

                    case (int)BonusModifiers.Delay:
                        GameStats.GameSpeedDelay += Settings.DelayBonusModifier;
                        GameStats.LastEvent       = new GameEvent($"+{Settings.DelayBonusModifier} ms Delay");
                        break;

                    case (int)BonusModifiers.Live:
                        GameStats.LivesCount += Settings.LiveBonusModifier;
                        GameStats.LastEvent   = new GameEvent($"+{Settings.LiveBonusModifier} Life");
                        break;

                    case (int)BonusModifiers.Bonus:
                        GameStats.BonusDropChance += Settings.BonusDropModifier;
                        GameStats.LastEvent        = new GameEvent($"+{Settings.BonusDropModifier - 1}% Bonus Chance");
                        break;
                    }
                }
            }
        }
Example #14
0
    private Vector3 AvoidObstacles()
    {
        Obstacles closest = null;
        float     minDist = float.MaxValue;

        foreach (Obstacles ob in thisList)
        {
            if (ob.IsInFrontOf(this))
            {
                float dist = ob.ToObstacle(this).sqrMagnitude;
                if (dist < minDist)
                {
                    minDist = dist;
                    closest = ob;
                }
            }
        }
        if (closest != null && closest.IsDangerousTo(this))
        {
            Vector3 left      = Helper.Perpendicularize(heading);
            float   dot       = Vector3.Dot(left, closest.ToObstacle(this));
            float   direction = dot < 0 ? 1 : -1;

            Vector3 forceTurn  = left * 5f * direction;
            Vector3 forceBreak = this.velocity * -1.5f;

            return(forceTurn + forceBreak);
            //return force turn + forceBreak
        }
        return(Vector3.zero);
    }
Example #15
0
    void GenerateObstacles(Vector3 position)
    {
        int       index = Random.Range(0, obstacles.Length);
        Obstacles obs   = (GameObject.Instantiate(obstacles[index]) as Obstacles);

        obs.InitSelf(position, this.transform);
    }
Example #16
0
 public void Clear()
 {
     NavObstacles.Clear();
     NavSurfaces.Clear();
     Obstacles.Clear();
     Surfaces.Clear();
 }
Example #17
0
    private void Awake()
    {
        gridWidth  = Utils.CeilPower2(gridWidth) + 1;
        gridHeight = Utils.CeilPower2(gridHeight) + 1;

        gridLayout = PlayerPrefs.GetInt("layout");

        gameGrid  = new int[gridWidth, gridHeight];
        snake     = new Snake();
        obstacles = new Obstacles(gridLayout, gameGrid);
        food      = new Food();

        OnSnakeFoodEncounter += delegate
        {
            snake.OnFoodEncounter();
            Score++;
        };

        OnSnakeObstacleEncounter += delegate
        {
            snake.OnObstacleEncounter();
            DisplayGameOverScreen();
        };

        //Always keep this adding order.
        plottables.Add(obstacles);
        plottables.Add(food);
        plottables.Add(snake);

        movementDirection = new Vector2Int(1, 0);
    }
Example #18
0
 void ParseObstacle()
 {
     Obstacles.Clear();
     ObsColliders.Clear();
     ObsColliders2D.Clear();
     Obstacle[]   temps      = GetComponentsInChildren <Obstacle>();
     Collider[]   colTemps   = GetComponentsInChildren <Collider>();
     Collider2D[] colTemps2D = GetComponentsInChildren <Collider2D>();
     MainCollider   = GetComponent <Collider>();
     MainCollider2D = GetComponent <Collider2D>();
     if (temps != null)
     {
         foreach (var item in temps)
         {
             Obstacles.Add(item);
         }
     }
     if (colTemps != null)
     {
         foreach (var item in colTemps)
         {
             ObsColliders.Add(item);
         }
     }
     if (colTemps2D != null)
     {
         foreach (var item in colTemps2D)
         {
             ObsColliders2D.Add(item);
         }
     }
 }
Example #19
0
    private void Update()
    {
        var temp = CheckObstacleForward();

        if (temp.Length != 0)
        {
            Obstacles.Clear();
            Obstacles.AddRange(temp);
            SetState(bypassObstacleState);
        }
        else if (!currentState.IsFinished)
        {
            currentState.Run();
        }
        else
        {
            if (TargetFood != null)
            {
                SetState(moveToFoodState);
            }
            else
            {
                SetState(findFoodState);
            }
        }
    }
Example #20
0
        public override void Update(GameTime gt)
        {
            if ((Mouse.LeftMouseDown || Mouse.RightMouseDown) && Mouse.CanPress)
            {
                Point coords = GetCoordinates(Mouse.Position);

                if (Mouse.LeftMouseDown)
                {
                    if (SpotExists(coords))
                    {
                        foreach (int[] pair in Spots)
                        {
                            if (pair[0] == coords.X && pair[1] == coords.Y)
                            {
                                Spots.Remove(pair);

                                break;
                            }
                        }
                    }
                    else
                    {
                        Spots.Add(new int[2] {
                            coords.X, coords.Y
                        });
                    }

                    Console.WriteLine("\n=========================================\nNew Spots:");
                    Spots.ForEach(x => Console.WriteLine("\t\t\t\tnew int[] { " + x[0] + ", " + x[1] + " },"));
                }
                else
                {
                    if (SpotExists(coords))
                    {
                        if (ObstacleExists(coords.X, coords.Y))
                        {
                            foreach (int[] pair in Obstacles)
                            {
                                if (pair[0] == coords.X && pair[1] == coords.Y)
                                {
                                    Obstacles.Remove(pair);

                                    break;
                                }
                            }
                        }
                        else
                        {
                            Obstacles.Add(new int[2] {
                                coords.X, coords.Y
                            });
                        }

                        Console.WriteLine("\n=========================================\nNew Obstacles:");
                        Obstacles.ForEach(x => Console.WriteLine("\t\t\t\tnew int[] { " + x[0] + ", " + x[1] + " },"));
                    }
                }
            }
        }
        void ShowRightTree(params ICurve[] curves)
        {
            var l = Obstacles.Select(c => new DebugCurve(c));

            l = l.Concat(rightConeSides.Select(s => new DebugCurve("brown", ExtendSegmentToZ(s))));
            l = l.Concat(curves.Select(c => new DebugCurve("red", c)));
            LayoutAlgorithmSettings.ShowDebugCurvesEnumeration(l);
        }
Example #22
0
        private void AddWall()
        {
            Obstacles wall     = new Obstacles();
            Vector2   position = new Vector2(GraphicsDevice.Viewport.Width + enemyTexture.Width / 2, random.Next(100, GraphicsDevice.Viewport.Height - 100));

            wall.Initialize(GraphicsDevice.Viewport, wallTexture, position);
            walls.Add(wall);
        }
Example #23
0
 public void AddObstacle(Obstacle obstacle)
 {
     Obstacles.Add(obstacle);
     foreach (Edge edge in edges)
     {
         edge.active = false;
     }
 }
Example #24
0
 private void ClearObstacles()
 {
     for (int i = 0; i < ObstacleCount(); i++)
     {
         canvasContainer.RemoveObstacleFromCanvas(Obstacles[i]);
     }
     Obstacles.Clear();
 }
Example #25
0
 public static void SetState(State state)
 {
     if (state == State.HOME)
     {
         instance.SetPath(Obstacles.PathTo(instance.transform.position, GameObject.FindGameObjectWithTag("Home").transform.position));
     }
     Player.state = state;
 }
Example #26
0
        private IEnumerable <DebugCurve> GetGraphDebugCurves()
        {
            List <DebugCurve> l =
                VisibilityGraph.Edges.Select(e => new DebugCurve(50, 0.1, "blue", new LineSegment(e.SourcePoint, e.TargetPoint))).ToList();

            l.AddRange(Obstacles.Select(o => new DebugCurve(1, "green", o.BoundaryCurve)));
            return(l);
        }
Example #27
0
 private void Reset()
 {
     Paused    = false;
     lost      = false;
     highScore = false;
     score     = 0;
     Obstacles.Clear();
     Player.Reset();
 }
Example #28
0
 public void RandomSpawnVehicle(PlayerVehicle p, Obstacle o)
 {
     _spawnpoints = _random.Next(0, 3);
     o.X          = positionX [_spawnpoints];
     o.Y          = UtilityFunction.InitialY;
     DifficultyHandler(p, o);
     Obstacles.Add(o);
     o.Draw();
 }
Example #29
0
        public void StartLevel3()
        {
            f = new Field(7, 7);
            s = new Snake(new List <string>()
            {
                "2 0", "1 0", "0 0"
            });
            fd = new Food(new List <string>()
            {
                "0 2", "0 3", "0 4", "0 5", "0 6",
                "1 4", "1 6",
                "2 1", "2 4", "2 6",
                "3 1", "3 4", "3 6",
                "4 0", "4 1", "4 2", "4 3", "4 4", "4 6",
                "5 0", "5 6",
                "6 0", "6 1", "6 2", "6 3", "6 4", "6 5", "6 6"
            }
                          );
            o = new Obstacles(new List <string>()
            {
                "0 1",
                "1 1", "1 2", "1 3", "1 5",
                "2 5",
                "3 5",
                "4 5",
                "5 1", "5 2", "5 3", "5 4", "5 5",
            }
                              );
            Console.Clear();
            _display = new Display();
            Console.WriteLine("--- 3rd LEVEL ---");
            Console.WriteLine();
            _display.VisualiseFied(f.Rows, f.Cols, s.Coordinates, fd.Coordinates, o.Coordinates);

            while (fd.Coordinates.Count != 0)
            {
                _display.VisualiseManual();
                ConsoleKeyInfo inputString = Console.ReadKey();
                char           input       = inputString.KeyChar;
                if (input == 'r')
                {
                    StartLevel1();
                }
                if (input == 'l')
                {
                    StartLevel3();
                }
                MoveSnake(input);
                Console.Clear();
                Console.WriteLine("--- 3rd LEVEL ---");
                Console.WriteLine();
                _display.VisualiseFied(f.Rows, f.Cols, s.Coordinates, fd.Coordinates, o.Coordinates);
            }

            StartLevel4();
        }
Example #30
0
 public Entity UpdateObstacle(Position start, Position end)
 {
     ImmutableDictionary <Position, int> .Builder tmpo = Obstacles.ToBuilder();
     if (tmpo.ContainsKey(start))
     {
         tmpo.Remove(start);
     }
     tmpo[end] = Dungeon.Wall;
     return(UpdateWith(obstacles: tmpo.ToImmutable()));
 }
Example #31
0
        private void btnTestCaseTwo_Click(object sender, RoutedEventArgs e)
        {
            myCanvas.Children.Clear();
            obstacles = new Obstacles(){new CircleObstacle(new Point(10, 4), 4),
            new CircleObstacle(new Point(10, 16), 6),
            new CircleObstacle(new Point(18, 14), 4)};

            Point startPoint = new Point(2.1, 20.1);
            Point goalPoint = new Point(16.1, 1.1);

            DrawStuff(startPoint, goalPoint);
        }
Example #32
0
        public Workspace(double xMin, double xMax, double yMin, double yMax)
        {
            XMin = xMin;
            XMax = xMax;
            YMin = yMin;
            YMax = yMax;
            Obstacles = new Obstacles();
            Milestones = new List<Node>();
            _pathCache = new Queue<List<Node>>();

            // The distance we are willing to accept using the cached path
            _cacheAcceptanceDistance = Math.Min(Height, Width) / 40.0;
        }
Example #33
0
        public bool Link(Obstacles obstacles)
        {
            List<Point> testPoints = GetPoints(50);
            // We are going to sample 50 points along our line to look for collisions
            foreach (Obstacle obstacle in obstacles)
            {
                // Checks to see if the point has any chance of colliding with the obstacle
                // If there isn't a chance then don't test all of the points
                if((FirstPoint.X > obstacle.MaxX && SecondPoint.X > obstacle.MaxX) ||
                    (FirstPoint.X < obstacle.MinX && SecondPoint.X < obstacle.MinX) ||
                    (FirstPoint.Y > obstacle.MaxY && SecondPoint.Y > obstacle.MaxY) ||
                    (FirstPoint.Y < obstacle.MinY && SecondPoint.Y < obstacle.MinY))
                    continue;

                foreach(Point point in testPoints)
                    if(obstacle.Collides(point))
                        return false;
            }
            return true;
        }
Example #34
0
	public void OnObstacleCollision(Obstacles obstacle)
	{
		switch(obstacle)
		{
			case Obstacles.LAG:
				Debug.Log("LAG");
				playerController.stats.isLaggy = true;
				break;
			case Obstacles.SHOWER:
				Debug.Log("SHOWER");
				playerController.stats.earnedMoney = 0;
				break;
			case Obstacles.TABLE:
				Debug.Log("TABLE");
				playerController.stats.earnedMoney /= 2;
				break;
		}

		updater.UpdateUI();
	}
Example #35
0
        static void Main(string[] args)
        {
            int Width = 80;
            int Height = 45;
            Console.SetBufferSize(Width, Height);
            Console.SetWindowSize(Width - 1, Height - 1);

            Obstacles border = new Obstacles();
            border.setBorder(Width, Height);
            border.setObstacles(Width, Height);

            Point p1 = new Point(2, 2, '*');
            Snake snake = new Snake(p1, 3, Direction.Right);
            snake.Drow();

            FoodCreator foodCreator = new FoodCreator(Width - 3, Height - 3, '#');
            Point food = foodCreator.CreateFood();
            food.Draw();
            int k = 150;

            while (true)
            {
                if (snake.Eat(food))
                {
                    food = foodCreator.CreateFood();
                    food.Draw();
                    k -= 5;
                }

                if (Console.KeyAvailable)
                {
                    ConsoleKeyInfo key = Console.ReadKey();
                    snake.Pressure(key.Key);
                }

                Thread.Sleep(k);
                snake.Move();
                Console.SetCursorPosition(0, 0);
            }
        }
Example #36
0
        private Obstacles GenerateBaseFarmObstacles()
        {
            Obstacles obstacles = new Obstacles();

            obstacles.Add(new RectangleObstacle(new HomeworkTwo.Point(3.8, 3.8), 7.6, 7.6));
            obstacles.Add(new RectangleObstacle(new HomeworkTwo.Point(1.8, 11.5), 3.6, 6));

            obstacles.Add(new RectangleObstacle(new HomeworkTwo.Point(16.5, 3.8), 10.5, 7.6));
            obstacles.Add(new RectangleObstacle(new HomeworkTwo.Point(21, 10), 1, 10));

            obstacles.Add(new RectangleObstacle(new HomeworkTwo.Point(9, 12), 6, 6));
            obstacles.Add(new RectangleObstacle(new HomeworkTwo.Point(9, 20), 2, 4));

            obstacles.Add(new RectangleObstacle(new HomeworkTwo.Point(18.8, 24), 7.5, 2.5));
            obstacles.Add(new RectangleObstacle(new HomeworkTwo.Point(20, 26), 5, 1.5));

            obstacles.Add(new RectangleObstacle(new HomeworkTwo.Point(28.5, 16.5), 4, 3));
            obstacles.Add(new RectangleObstacle(new HomeworkTwo.Point(26.5, 18.9), 1, 2.2));

            obstacles.Add(new RectangleObstacle(new HomeworkTwo.Point(38, 16), 4, 10));
            obstacles.Add(new RectangleObstacle(new HomeworkTwo.Point(28.1, 21.2), 7.5, 1.2));
            obstacles.Add(new RectangleObstacle(new HomeworkTwo.Point(32.3, 22.5), 1, 10));
            obstacles.Add(new RectangleObstacle(new HomeworkTwo.Point(34.8, 24), 4, 4));

            return obstacles;
        }
Example #37
0
        /// <summary>
        /// Generates all the city stuff
        /// </summary>
        private void GenerateCity()
        {
            backgroundName = "City";
            Obstacles obstacles = new Obstacles();

            // Create obstacles
            for (double i = 3.5; i <= 38; i = i + 5.5)
                for (double j = 25.5; j <= 38; j = j + 5.5)
                    obstacles.Add(new RectangleObstacle(new HomeworkTwo.Point(j,i), 4, 4));

            for (double i = 25.5; i <= 38; i = i + 5.5)
                for (double j = 3.5; j <= 22; j = j + 5.5)
                    obstacles.Add(new RectangleObstacle(new HomeworkTwo.Point(j,i), 4, 4));

            // Set up workspace and generate nodes
            _workspace = new Workspace(X_MIN, X_MAX, Y_MIN, Y_MAX) { Obstacles = obstacles };
            _workspace.GenerateEvenGraph((UInt16)(X_RANGE + 1), (UInt16)(Y_RANGE + 1));

            Workspace airWorkspace = new Workspace(X_MIN, X_MAX, Y_MIN, Y_MAX) { };
            airWorkspace.GenerateEvenGraph((UInt16)(X_RANGE + 1), (UInt16)(Y_RANGE + 1));

            List<Node> groundPatrolPath = new List<Node>() {
                airWorkspace.GetNode(new HomeworkTwo.Point(1, 20)),
                airWorkspace.GetNode(new HomeworkTwo.Point(20, 20)),
                airWorkspace.GetNode(new HomeworkTwo.Point(20, 1)),
                airWorkspace.GetNode(new HomeworkTwo.Point(1, 1))};

            List<Node> airPatrolPath = new List<Node>() {
                airWorkspace.GetNode(new HomeworkTwo.Point(1, 39)),
                airWorkspace.GetNode(new HomeworkTwo.Point(39, 39)),
                airWorkspace.GetNode(new HomeworkTwo.Point(39, 1)),
                airWorkspace.GetNode(new HomeworkTwo.Point(1, 1))};

            // Create our agents
            List<RobotBase> pursuerRobots = new List<RobotBase>() {
                new GroundPursuer(GroundPursuerPatrol.TheInstance,
                    new HomeworkTwo.Point(1,1), // location
                    RADIUS, // radius
                    new Vector2D(), // intial velocity
                    MAX_SPEED * .8f, // max speed
                    new Vector2D(), // intial heading
                    MASS, // mass
                    new Vector2D(), // scale
                    TURN_RATE, // turn rate
                    MAX_FORCE, // max force
                    groundPatrolPath, // patrol path
                    _workspace, // traversability map
                    _workspace), // visibility map

                new AerialPursuer(AerialPursuerPatrol.TheInstance,
                    new HomeworkTwo.Point(1,15), // location
                    RADIUS, // radius
                    new Vector2D(), // intial velocity
                    MAX_SPEED, // max speed
                    new Vector2D(), // intial heading
                    MASS, // mass
                    new Vector2D(), // scale
                    TURN_RATE, // turn rate
                    MAX_FORCE, // max force
                    airPatrolPath, // patrol path
                    airWorkspace, // traversability map
                    airWorkspace) }; // visibility map

            List<Target> targetRobots = new List<Target>() { new Target(TargetPatrol.TheInstance,
                new HomeworkTwo.Point(30,39), // location
                RADIUS, // radius
                new Vector2D(), // intial velocity
                MAX_SPEED, // max speed
                new Vector2D(), // intial heading
                MASS, // mass
                new Vector2D(), // scale
                TURN_RATE, // turn rate
                MAX_FORCE, // max force
                new List<Node>(), // patrol path
                _workspace, // traversability map
                _workspace)}; // visibility map

            // Create our robot group with our agents
            _robotGroup = new RobotGroup(pursuerRobots, targetRobots, TIME_STEP_LENGTH, TIME_HORIZON, VISIBLITY_CRITERIA);
        }
    void placeObstacle()
    {
        selectedObstacle.transform.position = placingPoint;
        TurnObstacleNormal(selectedObstacle.gameObject);
        foreach(Transform t in selectedObstacle.GetComponentsInChildren<Transform>())
        {
            TurnObstacleNormal(t.gameObject);
        }

        foreach (Collider col in selectedObstacle.GetComponentsInChildren<Collider>())
        {
            col.enabled = true;
        }

        selectedObstacle.tag = "Obstacle";

        if (Random.Range(0, 2) == 0)
        {
            selectedObstacle.transform.localScale = new Vector3(1, 0, 1);
            placingObstacle = false;
            StartCoroutine(applyGrowingAnimation(selectedObstacle.gameObject));
            selectedObstacle = null;

        }
        else
        {
            selectedObstacle.transform.position += (Vector3.up * 10);
            placingObstacle = false;
            StartCoroutine(applyFallingAnimation(selectedObstacle.gameObject, placingPoint));
            selectedObstacle = null;
        }

        allowMove[currentKey - 1] = false;
        coolDownCounters[currentKey - 1] = 0;

        placingPoint = Vector3.zero;
        //begin changes by shreyas
        if (num_key_pressed != null)
        {
            num_key_pressed(999);  //passing invalid value to clear the highlighting
        }
        //end changes
    }
 private IEnumerator MoveToVault(Vector3 position, Vector3 axisNormal, Obstacles obs)
 {
     moveToVaultPosition = position;
     movingToVault = true;
     while(transform.position != position && Vector3.Dot((position - transform.position), axisNormal) < 0)
     {
         yield return new WaitForFixedUpdate();
     }
     movingToVault = false;
     StartAnimation(obs);
 }
 void resetObstacle()
 {
     selectedObstacle.transform.position = 200 * Vector3.up;
     Destroy(selectedObstacle.gameObject);
     placingObstacle = false;
     placingPoint = Vector3.zero;
     foreach(MeshRenderer t in selectedObstacle.GetComponentsInChildren<MeshRenderer>())
     {
         t.material.color = Color.white;
     }
     selectedObstacle = null;
 }
    void checkNumberKey()
    {
        if (Input.GetKeyDown(KeyCode.Alpha1) ||
            Input.GetKeyDown(KeyCode.Alpha2) ||
            Input.GetKeyDown(KeyCode.Alpha3) ||
            Input.GetKeyDown(KeyCode.Alpha4) ||
            Input.GetKeyDown(KeyCode.Alpha5) ||
            Input.GetKeyDown(KeyCode.Alpha6))
        {
            string keyPreseed = Input.inputString;
            int keyNum = System.Convert.ToInt32(keyPreseed);

            // KEYNUM NO OF CARDS IN HAND
            if (keyNum >= 1 && keyNum <= 6)
            {
                if (allowMove[keyNum - 1])
                {

                    if (selectedObstacle != null)
                    {
                        Destroy(selectedObstacle.gameObject);
                    }

                    selectedObstacle = GameObject.Instantiate(OperatorHand[keyNum - 1], Vector3.one, OperatorHand[keyNum - 1].transform.localRotation) as Obstacles;
                    foreach(Transform t in selectedObstacle.GetComponentsInChildren<Transform>())
                    {
                        t.gameObject.layer = LayerMask.NameToLayer("IgnorePlayer");
                    }
                    foreach (Collider col in selectedObstacle.GetComponentsInChildren<Collider>())
                    {
                        col.enabled = false;
                    }

                    placingObstacle = true;
                    currentKey = keyNum;
                }

                // code changes by Shreyas

                if (num_key_pressed != null)
                {
                    num_key_pressed(keyNum);
                }

                //end of changes
            }

        }
    }
    private void StartAnimation(Obstacles obs)
    {
        if (obs.get_to_lock_orientation())
        {
            transform.forward = obs.get_orientation_facing(transform.position);
        }

        Obstacles.Fatigue obs_fatigue = obs.get_fatigue();
        fatigue_pool.arms -= obs_fatigue.arms;
        fatigue_pool.core -= obs_fatigue.core;
        fatigue_pool.legs -= obs_fatigue.legs;
        ColorBody();

        string trigger = obs.get_animation_trigger();
        characterRigidbody.isKinematic = true;
        characterCollider.enabled = false;
        targetAnimator.SetTrigger(trigger);
    }
Example #43
0
        private Obstacles GenerateBaseBridgeObstacles()
        {
            Obstacles obstacles = new Obstacles();

            obstacles.Add(new RectangleObstacle(new HomeworkTwo.Point(3.6, 6.3), 6.2, 11.2));
            obstacles.Add(new RectangleObstacle(new HomeworkTwo.Point(3.6, 18.7), 6.2, 12.2));
            obstacles.Add(new RectangleObstacle(new HomeworkTwo.Point(3.6, 31), 6.2, 11.2));
            obstacles.Add(new RectangleObstacle(new HomeworkTwo.Point(3.2, 38.7), 7, 3));

            obstacles.Add(new RectangleObstacle(new HomeworkTwo.Point(12.5, 6.3), 10, 11));
            obstacles.Add(new RectangleObstacle(new HomeworkTwo.Point(12.5, 18.7), 10, 12.2));
            obstacles.Add(new RectangleObstacle(new HomeworkTwo.Point(12.5, 31), 10, 11.2));
            obstacles.Add(new RectangleObstacle(new HomeworkTwo.Point(12.5, 38.7), 10, 2.7));

            obstacles.Add(new RectangleObstacle(new HomeworkTwo.Point(34, 1), 10.5, 2));
            obstacles.Add(new RectangleObstacle(new HomeworkTwo.Point(34, 7.4), 10.5, 9.7));
            obstacles.Add(new RectangleObstacle(new HomeworkTwo.Point(34, 18), 10.5, 10));
            obstacles.Add(new RectangleObstacle(new HomeworkTwo.Point(34, 27.5), 10.5, 7.5));
            obstacles.Add(new RectangleObstacle(new HomeworkTwo.Point(34, 35), 10.5, 6.5));
            obstacles.Add(new RectangleObstacle(new HomeworkTwo.Point(33, 39.5), 14, 1));

            return obstacles;
        }