Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
This question was closed Sep 23, 2017 at 11:42 PM by guilhermecorintho for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by guilhermecorintho · Sep 23, 2017 at 10:34 PM · errorerror message

error CS0201 (2d roguelike)

"Assets/Scripts/BoardManager.cs(65,26): error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement"

That error redirects me to line 65: ( gridPositions.RemoveAt [randomIndex];)

But I can not find the error. All code below:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using System;
 using Random = UnityEngine.Random;
 
 public class BoardManager : MonoBehaviour {
 
     [Serializable]
     public class Count{
         public int minimum;
         public int maximum;
 
         public Count(int min, int max)
         { // construct
             minimum = min;
             maximum = max;
         }
     }
 
     public int columns = 8;
     public int rows = 8;
 
     public Count wallCount = new Count(5,9);
     public Count foodCount = new Count(1,5);
 
     public GameObject exit;
     public GameObject[] floorTiles;
     public GameObject[] wallTiles;
     public GameObject[] enemyTiles;
     public GameObject[] foodTiles;
     public GameObject[] outerWallTiles;
 
     private Transform boardHolder;
     private List <Vector3> gridPositions = new List<Vector3> ();
 
     void initialiseList(){
         gridPositions.Clear();    
         for (int i = 1; i < columns - 1; i++) {
             for (int j = 1; j < rows -1; j++){
                 gridPositions.Add (new Vector3 (i, j, 0f));
             }
         }
     }
 
     void boardSetup(){ // to set outerWall and floor of the game
         boardHolder = new GameObject ("Board").transform;
 
         for (int x = -1; x < columns + 1; x++) {
             for (int y = -1; y < rows + 1; y++) {
                 GameObject toInstantiate = floorTiles [Random.Range (0, floorTiles.Length)]; // instantiate random floor tiles in the range
                 if (x == -1 || x == columns || y == -1 || y == rows) {
                     toInstantiate = outerWallTiles [Random.Range (0, outerWallTiles.Length)]; // to instantiate random outer wall tiles in the range
 
                     GameObject instance = Instantiate (toInstantiate, new Vector3 (x, y, 0f), Quaternion.identity) as GameObject;
                     instance.transform.SetParent (boardHolder);
                 }
             }
         }
     }
 
     Vector3 RandomPosition(){
         int randomIndex = Random.Range (0, gridPositions.Count);
         Vector3 randomPosition = gridPositions [randomIndex];
         gridPositions.RemoveAt [randomIndex];
         return randomPosition;
     }
 
     void layoutObjectAtRandom(GameObject[] tileArray, int minimum, int maximum){ // spawn the titles randomly
         int objectCount = Random.Range(minimum, maximum + 1); // para decidir quantas paredes por exemplo terá no nivel
         for (int x = 0; x < objectCount; x++) {
             Vector3 randomPosition = RandomPosition ();
             GameObject tileChoice = tileArray[Random.Range(0,tileArray.Length)];
             Instantiate (tileChoice, randomPosition, Quaternion.identity);
         }
     }
 
     public void setupScene(int level){
         boardSetup ();
         initialiseList ();
         layoutObjectAtRandom (wallTiles, wallCount.minimum, wallCount.maximum);
         layoutObjectAtRandom (foodTiles, foodCount.minimum, foodCount.maximum);
         int enemyCount = (int)Mathf.Log (level, 2f);
         layoutObjectAtRandom (enemyTiles, enemyCount, enemyCount);
         Instantiate (exit, new Vector3 (columns - 1, rows - 1, 0f), Quaternion.identity);
     }
 }
 


Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

  • Sort: 
avatar image
0
Best Answer

Answer by guilhermecorintho · Sep 23, 2017 at 11:42 PM

Sorry Guys, I must use () instead of [].

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Follow this Question

Answers Answers and Comments

136 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

0xc000007b error on 64 bit machine? 1 Answer

My Unity Project says i have compile errors but they won't show up! please Help!,My unity project says I have compile errors but they aren't showing up at the bottom of my screen! Please Help!!1 0 Answers

Error, host set to 1 Answer

Failed to parse configuration for gameId: xxxxxx System.Threading._ThreadPoolWaitCallback:PerformWaitCallback() 3 Answers

NullReferenceException: Object reference not set to an instance of an object 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges