- Home /
Duplicate Question
5 Errors, Need help, Unexpected symbol private etc
Assets/Scripts/Drops/MobDrops.cs(134,55): error CS1525: Unexpected symbol private', expecting
identifier'
Assets/Scripts/Drops/MobDrops.cs(135,41): error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement
Assets/Scripts/Drops/MobDrops.cs(135,48): error CS1525: Unexpected symbol )', expecting
;'
Assets/Scripts/Drops/MobDrops.cs(139,23): error CS1519: Unexpected symbol `=' in class, struct, or interface member declaration
Assets/Scripts/Drops/MobDrops.cs(141,9): error CS8025: Parsing error
I dont understand whats wrong, there are 5 errors. If you can help please let me know what im not seeing, thanks!
Code Under Here
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
[RequireComponent(typeof(BoxCollider))]
[RequireComponent(typeof(AudioSource))]
public class MobDrops : MonoBehaviour {
public enum State{
open,
close,
inbetween
}
public GameObject[] parts; // parts to increase brightness of
private Color[] _defaultColors;
public GameObject particleEffect;
public AudioClip openSound; // sound for opeing the drop
public float maxDistance = 3; //max distance the player can be to open the loot
public State state;
public int WaitTime = 3;
public GameObject _player;
private Transform _myTransform;
public bool inUse = false;
private bool _used = false; //track if loot has been used or not
public List<Item> _loot = new List<Item>();
// Use this for initialization
void Start () {
_myTransform = transform;
state = MobDrops.State.close;
particleEffect.active = false;
if(!_used)
PopulateLoot (5);
_defaultColors = new Color [parts.Length];
if (parts.Length > 0)
for (int cnt = 0; cnt < _defaultColors.Length; cnt++)
_defaultColors [cnt] = parts [cnt].renderer.material.GetColor ("_Color");
}
void Update(){
if(!inUse)
return;
if(_player == null)
return;
if(Vector3.Distance(transform.position, _player.transform.position) > maxDistance)
myGUI.loot.ForceClose();
// Messenger.Broadcast("CloseLoot");
}
public void OnMouseEnter(){
Debug.Log ("Enter");
HighLight (true);
}
public void OnMouseExit(){
Debug.Log ("Exit");
HighLight (false);
}
public void OnMouseUp(){
Debug.Log ("Up");
GameObject go = GameObject.FindGameObjectWithTag ("Player");
if (go == null)
return;
if(Vector3.Distance(_myTransform.position, go.transform.position)> maxDistance && !inUse)
return;
switch(state){
case State.open:
state = MobDrops.State.inbetween;
StartCoroutine("Close");
ForceClose();
Debug.Log ("Im Closing");
break;
case State.close:
if(myGUI.loot != null){
myGUI.loot.ForceClose();
}
state = MobDrops.State.inbetween;
StartCoroutine("Open");
Debug.Log ("Im Opening");
break;
}
//if(state == MobDrops.State.close)
// Open ();
//else
// Close ();
}
private IEnumerator Open(){
myGUI.loot = this;
// animation.Play("AnimationName"); //for when we have animation if we do
//audio.PlayOneShot (openSound); // plays the sound attached to openSound
_player = GameObject.FindGameObjectWithTag("Player");
inUse = true;
particleEffect.active = true;
yield return new WaitForSeconds (WaitTime); //waits for the WaitTime amount
// change the state to open
state = MobDrops.State.open;
//create and display 5 items
//Messenger<int>.Broadcast("PopulateLoot", 5, MessengerMode.REQUIRE_LISTENER);
Messenger.Broadcast ("DisplayLoot");
}
private IEnumerator Close(){
// animation.Play("AnimationName"); //for when we have animation if we do
_player = null;
inUse = false;
particleEffect.active = false;
yield return new WaitForSeconds (WaitTime); //waits for the WaitTime amount
state = MobDrops.State.close;
if(_loot.Count == 0){
Destroy(gameObject);
}
}
private void PopulateLoot(int x){
for(int cnt = 0; cnt < x; cnt++){
_loot.Add(new Item());
_loot[cnt].Name = "I:" + Random.Range(0,100);
}
_used =true;
}
public void ForceClose(){
Messenger.Broadcast ("CloseLoot");
StopCoroutine ("Open");
StartCoroutine ("Close");
}
private void HighLight(bool glow){
if (glow){
if (parts.Length > 0)
for (int cnt = 0; cnt < _defaultColors.Length; cnt++)
parts [cnt].renderer.material.SetColor("_Color", Color.yellow);
}else{
if (parts.Length > 0)
for (int cnt = 0; cnt < _defaultColors.Length; cnt++)
parts [cnt].renderer.material.SetColor("_Color", _defaultColors[cnt]);
}
}
}
There is something very wrong with your code post because like 134 does not have the symbol 'private" on it or anywhere near it.
It looks like the messages refer to a different version of the file then the one you posted.
I tagged your question with the error messages. If you click on these tags, you'll see where people have asked the same questions before. Searching is good.
Follow this Question
Related Questions
PLEASE HELP!!!! using BergZurgArcades guide having error! 5 Answers
Why have Chinese compile the script will fail??? 2 Answers
Really Simple C# Errors I Can't Figure Out 1 Answer
Unexpected symbols 0 Answers
Whats wrong with this script? 1 Answer