Example #1
0
    void Update()
    {
        BallAI ball = transform.parent.GetComponent <BallAI> ();

        if (eventList[0][0].Count > 0 || eventList[0][1].Count > 0)
        {
            ball.left = upRef(eventList [0] [0], eventList [0] [1]);
        }
        if (eventList[1][0].Count > 0 || eventList[1][1].Count > 0)
        {
            ball.right = upRef(eventList [1] [0], eventList [1] [1]);
        }
        if (eventList[2][0].Count > 0 || eventList[2][1].Count > 0)
        {
            ball.up = upRef(eventList [2] [0], eventList [2] [1]);
        }
        if (eventList[3][0].Count > 0 || eventList[3][1].Count > 0)
        {
            ball.down = upRef(eventList [3] [0], eventList [3] [1]);
        }
        ball.up    = checkactive(ball.up) ? ball.up : null;
        ball.left  = checkactive(ball.left) ? ball.left : null;
        ball.right = checkactive(ball.right) ? ball.right : null;
        ball.down  = checkactive(ball.down) ? ball.down : null;
        ball.anim.SetBool("isGrounded", checkactive(ball.down));
    }
Example #2
0
    private void OnCollisionEnter(Collision other)
    {
        _ball = other.gameObject;
        Ready = true;

        if (Game.Instance.AIGame)
        {
            BallAI ballAI = _ball.GetComponentInChildren <BallAI>();
            ballAI.StartCoroutine(ballAI.Launch(1.3f));
        }

        UIWindowManager.WindowHUD.ShowHideLauncher(true);
    }
Example #3
0
    void OnTriggerEnter2D(Collider2D coll)
    {
        BallAI ball = transform.parent.GetComponent <BallAI> ();

        if (coll.transform.parent == ball.transform)
        {
            return;
        }
        if (ball.name.Contains("Azul") && coll.name.Contains("Azul"))
        {
            Map m = FindObjectOfType <Map>();
            m.won = true;
            //FindObjectOfType<config> ().Won ();
        }

        switch (name)
        {
        case "Left":
            eventList[0][0].Add(coll.transform);
            //ball.left = coll.transform;
            break;

        case "Right":
            eventList[1][0].Add(coll.transform);
            //ball.right = coll.transform;
            break;

        case "Up":
            eventList[2][0].Add(coll.transform);
            //ball.up = coll.transform;
            break;

        case "Down":
            eventList[3][0].Add(coll.transform);
            //ball.down = coll.transform;
            //ball.anim.SetBool("isGrounded", true);
            break;

        default:
            //Debug.LogError ("Nao existe um case para " + name + "?");
            break;
        }
    }
Example #4
0
    public void CreateBall(bool freeBall)
    {
        if (Lives == 0)
        {
            UIWindowManager.WindowGameOver.Show();
            return;
        }

        Ball ball = Instantiate(BallPrefab);

        ball.transform.parent   = Table;
        ball.transform.position = LauncherPoint.position;

        BallAI ballAI = ball.GetComponentInChildren <BallAI>();

        ballAI.AIEnabled = AIGame;

        if (!freeBall)
        {
            Lives--;
        }
    }
Example #5
0
    void OnTriggerExit2D(Collider2D coll)
    {
        BallAI ball = transform.parent.GetComponent <BallAI> ();

        if (coll.transform.parent == ball.transform)
        {
            return;
        }
        //Debug.Log ("Ended Collision.\n Direction: " + name);
        switch (name)
        {
        case "Left":
            eventList[0][1].Add(coll.transform);
            //ball.left = coll.transform;
            break;

        case "Right":
            eventList[1][1].Add(coll.transform);
            //ball.right = coll.transform;
            break;

        case "Up":
            eventList[2][1].Add(coll.transform);
            //ball.up = coll.transform;
            break;

        case "Down":
            eventList[3][1].Add(coll.transform);
            //ball.down = coll.transform;
            //ball.anim.SetBool("isGrounded", true);
            break;

        default:
            //Debug.LogError ("Nao existe um case para " + name + "?");
            break;
        }
    }
Example #6
0
	void OnMouseOver(){
		if(Input.GetMouseButtonDown(0)){
			iterator=(iterator+1)%objList.Length;
			if (current) Destroy(current);
			if(objList[iterator]){
				current = Instantiate(objList[iterator]);
				current.transform.parent=transform;
				current.transform.localPosition=(new Vector3(0,0,0));
				Animator tan = current.GetComponent<Animator>();
				if(tan) tan.enabled=false;
				EnemyAI tai = current.GetComponent<EnemyAI>();
				if(tai) tai.enabled=false;
				BoxCollider2D tco = current.GetComponent<BoxCollider2D>();
				if(tco) tco.enabled=false;
				CircleCollider2D tcc = current.GetComponent<CircleCollider2D>();
				if(tcc) tcc.enabled=false;
				BallAI tba = current.GetComponent<BallAI>();
				if(tba) tba.enabled=false;
				CogumeloAI tca = current.GetComponent<CogumeloAI>();
				if(tca) tca.enabled=false;
			}
			Debug.Log ("Clicked at a object in "+transform.position.x+","+transform.position.y);
		}
	}