<file_sep>﻿using UnityEngine;
using System.Collections;

public class id_player : MonoBehaviour {
	
	public Transform player;
	public Collider2D [] live;
	public  GameObject newPlayer;
	public GameObject aux; 
		
	// Use this for initialization
	void Start () {

		aux = (GameObject) Instantiate(newPlayer, transform.position, transform.rotation);
		
		player = aux.transform;

	}
	
	// Update is called once per frame
	void Update () {

		live = Physics2D.OverlapCircleAll(this.transform.position, 1f, 1 << LayerMask.NameToLayer ("Player"));

		if (live.Length > 0) {

			Vector3 newPosition = new Vector3 (player.position.x, player.position.y, transform.position.z);
		
			transform.position = new Vector3 (player.position.x, player.position.y, transform.position.z);

		}
		else {
		
			this.transform.position = new Vector3(0,-0.9f,0);

			aux = (GameObject) Instantiate(newPlayer, transform.position, transform.rotation);
			
			player = aux.transform;
		}
	}

}
<file_sep>﻿using UnityEngine;
using System.Collections;

public class enimie : MonoBehaviour
{

    // Movimento
    public float velocity;              // Velocidade do inimigo
    public bool forRigth = true;        // Indica se direção é a direita
    public float runDelay;              // Tempo que caminha prara cada direção
    private float runningTime;          // Tempo de caminhada
    private bool running;               // Indica se está andando

    //Animação
    public Transform character;          //Personagem jogavel
    private Animator anime;              //Animação do personagem

	public int life;

    // Use this for initialization
    void Start()
    {
        // Carrega a animação
        anime = character.GetComponent<Animator>();
        runningTime = 0;
        running = false;
		life = 10;

    }

    // Update is called once per frame
    void Update()
    {

        runningTime += Time.deltaTime;
        if (runningTime > runDelay)
        {
            runningTime = 0;
            if (running)
            {               
                anime.SetTrigger("stop");
                running = false;
            }
            else {

                forRigth = !forRigth;
                anime.SetTrigger("runing");
                running = true;
            }
        }

        if (forRigth && running)  {

            transform.Translate(Vector2.right * velocity * Time.deltaTime);
            transform.eulerAngles = new Vector2(0, 0);
        }

        if (!forRigth && running)  {

            transform.Translate(Vector2.right * velocity * Time.deltaTime);
            transform.eulerAngles = new Vector2(0, 180);
        }

		if (life <= 0) {

			Destroy (gameObject);
		}

    }

	void OnCollisionEnter2D (Collision2D colisor) {
		
		if (colisor.gameObject.tag == "Power1") {
			
			life -= 1;
		}
		else if (colisor.gameObject.tag == "Power2") {
			
			life -= 5;
		}
	}
}
<file_sep>﻿using UnityEngine;
using System.Collections;

public class player : MonoBehaviour {

    //Movimento
	public  float       velocity;           
	public  float       enterTime = 0.4f;   //Tempo de duração do efeito de entrada

    //Animação
	public  Transform   character;          //Personagem jogavel
	private Animator    anime;              //Animação do personagem

    //Pulo
	private bool        grounded;           //Verifica de está na terra
    public  float       force;              //Força do pulo
	public  float       jumpTime;           //Tempo do pulo
	public  float       jumpDelay = 0.7f;   //Tempo da animação
	public  Transform   ground;             //Obj abaixo do personagem

    // Disparar bola de energia
	public  GameObject[]  shotgun;            // Obj energia
    private Vector2     shotposition;       // Posição do disparo
	private bool shotting;
	private bool flaming;
	private float shotTime = 0;
	public GameObject sabre;


	// Use this for initialization
	void Start () {
	
        // Carrega a animação
		anime = character.GetComponent<Animator> ();
    }
	
	// Update is called once per frame
	void Update () {

        // Verifica tempo da animação de entrada
		if (enterTime > 0) {
		
			enterTime -= Time.deltaTime;
			anime.SetFloat ("enter", enterTime);
		}
        
        // Controla movimento
		Move ();

		// Controla o disparo
		Shoting ();
        	
	}

    // Controla caminhada e pulo
	void Move () {

        // Verifica se player estrá no chão
		grounded = Physics2D.Linecast (this.transform.position, ground.position, 1 << LayerMask.NameToLayer ("Cenary"));
        // Verifica se está correndo
        anime.SetFloat ("run", Mathf.Abs (Input.GetAxis ("Horizontal")));
        // Verifica se está caindo
		anime.SetFloat ("force", Mathf.Abs (this.GetComponent<Rigidbody2D>().velocity.y));

        // Verifica se seta direita é pressionada
		if (Input.GetAxisRaw ("Horizontal") > 0) {

			transform.Translate (Vector2.right * velocity * Time.deltaTime);
			transform.eulerAngles = new Vector2(0,0);
        }

        // Verifica se seta esquerda é pressionada
        if (Input.GetAxisRaw ("Horizontal") < 0) {
			
			transform.Translate (Vector2.right * velocity * Time.deltaTime);
			transform.eulerAngles = new Vector2 (0,180);
        }

        // Verifica se espaço é pressionado
        if (Input.GetButtonDown ("Jump") && grounded) {

			GetComponent<Rigidbody2D>().AddForce (force * transform.up);
			anime.SetTrigger ("jump");
			jumpTime = jumpDelay;
		}

        // Verifica se voltou para o chão
		if (grounded) {
		
			anime.SetTrigger ("ground");
		}
		
        // Verifica o tempo de pulo
		if (jumpTime > -0.1)
			jumpTime -= Time.deltaTime;

	}

	void OnCollisionEnter2D (Collision2D colisor) {
		
		if (colisor.gameObject.tag == "Enimie") {

			// Destroi personagem
			Destroy(gameObject);
			/*
			// reinicia posiçao
			transform.position = new Vector3 (0f, -0.9f, 0f);
			transform.eulerAngles = new Vector2(0,0);

			//Cria novo personagem
			Instantiate(gameObject, transform.position, transform.rotation);
			*/
		}
	}

	void Shoting (){

		// Atualiza a animaçao
		anime.SetBool ("shot", (shotting || flaming));

		shotposition = transform.position;
		
		if (transform.eulerAngles.y == 0)
			shotposition.x += 0.15f;
		else
			shotposition.x -= 0.15f;
		
		// Dispara o tiro
		if (Input.GetKeyDown ("left ctrl") && !flaming) {
			
			shotting = true;

		}
		if (Input.GetKeyUp("left ctrl") && shotting) {
			
			if (shotTime < 1){
				
				Instantiate(shotgun[1], shotposition, transform.rotation);
			}
			else {
				
				Instantiate(shotgun[2], shotposition, transform.rotation);
			}
			
			shotTime = 0;
			shotting = false;
		}

		// Dispara o sabre de fogo
		if (Input.GetKeyDown ("left alt") && !shotting) {
			
			flaming = true;

			sabre = (GameObject) Instantiate(shotgun[0], shotposition, transform.rotation);

		}
		if (Input.GetKeyUp("left alt") && flaming) {
			
			//sabre.; 

			flaming = false;
		}

		if (shotting == true)
			shotTime += Time.deltaTime;

	}
}
<file_sep>﻿using UnityEngine;
using System.Collections;

public class sabre : MonoBehaviour {
	
	public Transform player;
	private Vector2 newPosition;

	// Use this for initialization
	void Start () {

		Destroy (gameObject, 1f);
	}
	
	// Update is called once per frame
	void Update () {
		/*
		newPosition = player.position;

		if (player.eulerAngles.y == 0) {
			transform.eulerAngles.y = 180;
			newPosition.x += 0.15f;
		} else {
			transform.eulerAngles.y = 0;
			newPosition.x -= 0.15f;
		}

		transform.position = new Vector3 (newPosition.x, newPosition.y, transform.position.z);
		*/

	}

	void DestroySabre (){

		Destroy (gameObject);
	}
}
<file_sep>﻿using UnityEngine;
using System.Collections;

public class energy : MonoBehaviour {

    private float timeLife;
    public float MaxTimeLife;
    public float velocity;

    // Use this for initialization
    void Start () {

        timeLife = 0;
	}
	
	// Update is called once per frame
	void Update () {

        timeLife += Time.deltaTime;
        if (timeLife > MaxTimeLife) {

            Destroy(gameObject);
        }

        transform.Translate(Vector2.right * velocity * Time.deltaTime);

    }
    // Destroi objeto ao tocar inimigo
	void OnCollisionEnter2D (Collision2D colisor) {

        if (colisor.gameObject.tag == "Enimie") {

            Destroy(gameObject);
        }
	}
}
