Unity code does not compile

Asked

Viewed 109 times

-3

using UnityEngine;
using System.Collections;

public class Player : MovingObject {

    public int pointsPerFood = 10; // Numero de pontos cada vez que pegar comida.
    public int pointsPerSoda = 20; // "" pegar Soda.
    public int wallDamage = 1; //Quanto o player causa de dano no muro.
    public float restartLevelDelay = 1f; //Tempo em segundos para reiniciar o level.

    private Animator animator;// usado para armazenar o animator do player.
    private int food; //Armazena a comida do player no level atual.

    //Override do start MovingObject
    protected override void Start ()
    {
        animator = GetComponent <Animator>();

        //pega a quantidade de vida total
        food = GameManager.instance.playerFoodPoints;


        base.Start ();

    }

    //e chamado qunado o player fica inativo ou desabilitado.
    private void OnDisable()
    {
        //Quando o player for desabilitado armazenar a quantidade de comida no GameManager.
        GameManager.instance.playerFoodPoints = food;

    }

    // Update is called once per frame
    private void Update () 
    {
        //so vamos fazr alguma coisa se for o turno do player
        if (!GameManager.instance.playerTurn)
            return;

        int horizontal = 0;
        int vertical = 0;

        //pega o input do input manager horizontal e arredonda para inteiro
        horizontal = (int) (Input.GetAxisRaw ("horizontal"));

        //pega o input do input manager vertical e arredonda para inteiro
        vertical = (int) (Input.GetAxisRaw ("vertical"));


        //verificar se o personagem se move somente em uma direçao
        if (horizontal != 0) 
        {
            vertical = 0;

        }

        //verificar que existe um valor nao zero em alguma direçao
        if (horizontal != 0 || vertical != 0) 
        {
            //chama a fuçao AttempMove passando o parametro generico wall
            AttemptMove<Wall> (horizontal, vertical);

        }



    }

    //Override do MoveObject
    protected override void AttemptMove <T> (int xDir, int yDir)
    {
        //toda vez que ele se mover ele consome comida
        //food = food -1;
        food--;

        base.AttemptMove <T> ( xDir, yDir);

        RaycastHit2D hit;

        CheckIfGameOver ();

        GameManager.instance.playerTurn = false;

    }

    //override do MovingObjects
    protected override void OnCantMove <T> (T component)
    {
        Wall hitWall = component as Wall;

        //quando se tenta mover contra um muro vc ataca ele
        hitWall.DamageWall (wallDamage);

        //dispara gatilho para trocar a animaçao do player atacando 'playerchop'
        animator.SetTrigger ("playerChop");

    }

    private void OnTriggerEnter2D (Collider2D other);
    {
        //checa se e a saida.
        if (other.tag == "exit");
        {
            invoke ("Restart" , restartLevelDelay);

            enabled = false;

        }
        else if(other.tag == "Food")
        {
            //adicionar a quantidade de comida
            food += pointsPerFood;

            Other.GameObject.SetActive(false);

        }
        else if(other.tag == "Soda")
        {
            //adicionar a quantidade de comida
            food += pointsPerSoda;

            Other.GameObject.SetActive(false);

        }
    }



    private void Restart ()
    {

        Application.LoadLevel (Application.loadedLevel);

    }

    //perder comida quando player apanhar do zumbi
    public boid LoseFood (int loss)
    {
        animator.SetTrigger ("playerHit");

        food -= loss;

        CheckIfGameOver ();

    }




    //verificar se o player esta sem comida, se sim gameover.
    private void CheckIfGameOver ()
    {
        //verificar comida do player
        if (food == 0)
        {
            //chama o game over do GameManeger
            GameManager.instance.GameOver ();

        }

    }










}

erro

  • 5

    You can already see that there are several purely typos. Review why you did not follow the correct one. Unless the tutorial is all wrong, then you shouldn’t follow it. If you still have questions that go beyond typos, put the code here and the errors. All as same text. Images are tricky for us to analyze and help. Copy and put what’s in the IDE and not a photo of the IDE.

  • 1

    Can you [Edit] the question and join the code? just as it is hard to help...

  • put the code now... :3

  • I edited now the question to facilitate, pardon the people who tried to help and could not understand...

  • What are the errors presented?

  • 1

    Looks like it’s just a typo. We can close the question?

  • 1

    To ask a new question, open a new one, do not edit the same question. And put enough information so people can help you, otherwise the question will be closed anates to be answered.

  • Another tip: put a title that describes your problem. "Help with script" serves as a title for all questions on the site.

  • 1

    Got it, vlw guys solved. This was my first post here, sorry any mistake on my part. Helped a lot. : 3

  • @Rannysantos Take a look at [tour]. You can accept an answer if it solved your problem. You can vote for all the posts on the site as well. Did any help you more? You need something to be improved?

Show 5 more comments

1 answer

1

If you take the ; on these two lines should already solve all problems:

private void OnTriggerEnter2D (Collider2D other) {
    //checa se e a saida.
    if (other.tag == "exit")

I put in the Github for future reference.

If you have other problems, tell me to update the answer.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.