// Use this for initialization
    public void init(GameController gContr, float x, float y, float quadR, float quadG, float quadB)
    {
        controller = gContr;
        healthBar = gameObject.transform.parent.FindChild("Health").GetComponent<LaserHealth> ();
        captain = GameObject.Find ("Crew").GetComponent<MoveCaptain> ();
        healthBar = gameObject.transform.parent.FindChild ("Health").GetComponent<LaserHealth> ();
        controller.MakeSprite (gameObject, "Button", transform.parent, 0, 0, 1, 1, 300);
        gameObject.name = "Button";
        gameObject.GetComponent<SpriteRenderer> ().sortingLayerName = "BottomRhsUI";
        gameObject.transform.localPosition = new Vector3 (x, y, 0);
        gameObject.AddComponent<BoxCollider2D> ();

        sprite = GetComponent<SpriteRenderer> ();
        darkenSprite = (.7f);
        upColor = new Color (quadR, quadG, quadB);
        downColor = new Color (quadR*darkenSprite, quadG*darkenSprite, quadB*darkenSprite);
        sprite.color = upColor;
    }
Beispiel #2
0
	public void init (GameController gContr) {
		controller = gContr;
		gameObject.AddComponent<Rigidbody2D> ().isKinematic = true;
		gameObject.AddComponent<BoxCollider2D> ().isTrigger = true;
		transform.localPosition = new Vector3 (-3.2f, -4, 0);
		gameObject.name = "Ship";
		tag = "PlayerController";

		laserLevel = GameObject.Find("Lasers").GetComponentInChildren<LaserHealth>();
		shieldLevel = GameObject.Find("Shields").GetComponentInChildren<ComponentHealth>();
		engineLevel = GameObject.Find("Engines").GetComponentInChildren<ComponentHealth>();
<<<<<<< HEAD
		animator = this.GetComponent<Animator> ();
		animator.SetInteger ("Direction", 0);
		jets = Jet.GetComponent<Animator> ();
		jets.SetInteger ("Direction", 0);
		jets.SetInteger ("Power", 3);
=======
		JET = GameObject.Find ("Jets");
		direction = this.gameObject.GetComponent<Animator> ();
//		jets = JET.GetComponent<Animator> ();

<<<<<<< HEAD
>>>>>>> PrefabsToCode


		direction.SetInteger ("Direction", 0);
		jets.SetInteger ("Power", 3);
=======
//		direction.SetInteger ("Direction", 0);
//		jets.SetInteger ("Power", 3);
>>>>>>> origin/PrefabsToCode
		// loads template for laser prefab instantiation


		// clock tracks time passed, ship fires when clock passes threshold. clock then resets.
		clock = 0;
		fireInterval = 32f;

		initd = true;
	}
Beispiel #3
0
    void Fire()                              //atirar
    {
        audioSource.PlayOneShot(shootSound); //tocar som de acertar

        //criar bullet
        GameObject bullet = Instantiate(laserPrefab, bulletSpawn.position, bulletSpawn.rotation);

        bullet.layer = LayerMask.NameToLayer("PlayerBullet");      //informar layer da bala

        LaserHealth bulletH = bullet.GetComponent <LaserHealth>(); //pegar script de vida da bala

        if (bulletH != null)                                       //se conseguiu
        {
            bulletH.source       = "Character";                    //informar fonte da bala
            bulletH.bulletDamage = bulletDamage;                   //informar dano da bala
        }

        //bullet.GetComponent<LaserController2>().bulletSpawnTransform = gameObject.transform.GetChild(0); //pega o transform do primeiro filho (bullet spawn)
        //bullet.gameObject.SendMessageUpwards("SetBulletSpawnTransform", gameObject.transform.GetChild(0), SendMessageOptions.DontRequireReceiver); //enviar transform, nao requisitar erro caso nao encontre

        //destruir bullet apos x segundos
        Destroy(bullet, bulletLifeTime); //tempo de vida da bullet
    }