// Update is called once per frame void Update() { if (player == null) { player = GeneralController.DefaultController().getPlayer(); } npcs = GameObject.FindGameObjectsWithTag("TalkingNpc"); if (npcs != null) { float aux = 1000f; min = DISTANCE * 2f; foreach (GameObject i in npcs) { aux = Vector3.Distance(i.transform.position, player.transform.position); if (aux < min) { min = aux; npc = i; } } if (min <= DISTANCE) { renderer.enabled = true; transform.position = new Vector3(npc.transform.position.x, npc.transform.position.y + 0.32f, npc.transform.position.z); } else { renderer.enabled = false; npc = null; } } }
// Use this for initialization void Start() { cameraX = cameraY = 0; mapaBase = GameObject.Find(Variables.mapName); player = GeneralController.DefaultController().getPlayer(); cam = Camera.main; height = 2f * cam.orthographicSize; width = height * cam.aspect; mapChange = false; animTime = 0.5f; NotificationCenter.DefaultCenter().AddObserver(this, "sceneChanged"); NotificationCenter.DefaultCenter().AddObserver(this, "mapChanged"); }
// Use this for initialization void Start() { speed = 2f; player = GeneralController.DefaultController().getPlayer(); float b = Mathf.Rad2Deg * Mathf.Atan(Mathf.Abs(player.transform.position.y - transform.position.y) / Mathf.Abs(player.transform.position.x - transform.position.x)); float c = 90f - b; //print(c); if ((player.transform.position.y - transform.position.y) < 0) { c = 180 - c; } if (player.transform.position.x - transform.position.x > 0) { c *= -1; } transform.rotation = Quaternion.Euler(new Vector3(0, 0, c)); }
// Use this for initialization void Start() { NotificationCenter.DefaultCenter().AddObserver(this, "hideText"); NotificationCenter.DefaultCenter().AddObserver(this, "BossDestroyed"); player = GeneralController.DefaultController().getPlayer(); playerAnim = player.GetComponent <Animator>(); playerController = player.GetComponent <PlayerController>(); lady = GameObject.Find("Ladyuvita"); ladyAnim = lady.GetComponent <Animator>(); ladyController = lady.GetComponent <NpcController>(); canvas = GameObject.Find("Canvas"); canvasAnim = canvas.GetComponent <Animator>(); shine = GameObject.Find("Shine"); shineAnim = shine.GetComponent <Animator>(); stopCinematic = true; //ladyAnim.SetBool("startAnim", true); // playerAnim.SetBool("startAnim", true); canvasAnim.SetBool("startAnim", true); playerFrom = new Vector3(0, -2.3f, 0); playerTo = new Vector3(0, -0.05f, 0); ladyFrom = new Vector3(0, 1.56f, 0); ladyTo = new Vector3(0, 0.25f, 0); time = Time.time; playerController.animated = true; playerAnim.SetInteger("direction", 1); playerAnim.SetBool("moving", true); ladyController.animated = true; ladyAnim.SetBool("moving", true); ladyAnim.SetInteger("direction", 3); lady.tag = "Npc"; bShine = false; isFinished = false; }
// Update is called once per frame void Update() { if (player == null) { player = GeneralController.DefaultController().getPlayer(); } if (!dead) { if (!hitted) { int h = 0; int v = 0; float xDistance = player.transform.position.x - transform.position.x; float yDistance = player.transform.position.y - transform.position.y; if (Vector3.Distance(transform.position, player.transform.position) <= ATTACKDISTANCE) { if (Vector3.Distance(transform.position, player.transform.position) <= SHOOTDISTANCE) { movement = Vector2.zero; ManageMovement(movement * speed); if (shootTime == 0) { GameObject fireball = null; switch (animator.GetInteger("direction")) { case 1: fireball = GameObject.Instantiate(Resources.Load("prefabs/FireBall"), new Vector3(transform.position.x, transform.position.y + 0.126f, 0), Quaternion.identity) as GameObject; break; case 2: fireball = GameObject.Instantiate(Resources.Load("prefabs/FireBall"), new Vector3(transform.position.x + 0.15f, transform.position.y + 0.025f, 0), Quaternion.identity) as GameObject; break; case 3: fireball = GameObject.Instantiate(Resources.Load("prefabs/FireBall"), new Vector3(transform.position.x, transform.position.y, 0), Quaternion.identity) as GameObject; break; case 4: fireball = GameObject.Instantiate(Resources.Load("prefabs/FireBall"), new Vector3(transform.position.x - 0.15f, transform.position.y - 0.025f, 0), Quaternion.identity) as GameObject; break; } fireball.name = "Fireball"; } shootTime += Time.deltaTime; if (shootTime > 1f) { shootTime = 0; } } else { speed = 1f; if (xDistance > 0.1f) { h = 1; } else if (xDistance < -0.1f) { h = -1; } if (yDistance > 0.1f) { v = 1; } else if (yDistance < -0.1f) { v = -1; } movement = new Vector2(h, v); ManageMovement(movement * speed); } } else { speed = 0.75f; move(); } } else { if (Time.time - timeHit > HITTIME) { hitted = false; } else { rigid.velocity = attackDir * speed; ; } } } else if (Time.time - timeDead > DEATHTIME) { collider2D.enabled = true; renderer.enabled = true; dead = false; gameObject.transform.position = initPos; } else { rigid.velocity = Vector2.zero; } }
// Update is called once per frame void Update() { if (player == null) { player = GeneralController.DefaultController().getPlayer(); } //rigidbody2D.mass = 999999f; //transform.position +=0*new Vector3 (Random.Range(-1,2), Random.Range(-1,2), 0) * Time.deltaTime * direccion; if (!dead) { if (!hitted) { int h = 0; int v = 0; float xDistance = player.transform.position.x - transform.position.x; float yDistance = player.transform.position.y - transform.position.y; if (Vector3.Distance(transform.position, player.transform.position) <= ATTACKDISTANCE) { speed = 1f; if (xDistance > 0.1f) { h = 1; } else if (xDistance < -0.1f) { h = -1; } if (yDistance > 0.1f) { v = 1; } else if (yDistance < -0.1f) { v = -1; } movement = new Vector2(h, v); ManageMovement(movement * speed); } else { speed = 0.75f; move(); } } else { if (Time.time - timeHit > HITTIME) { hitted = false; } else { rigid.velocity = attackDir * speed; } } } else if (Time.time - timeDead > DEATHTIME) { collider2D.enabled = true; renderer.enabled = true; dead = false; gameObject.transform.position = initPos; } else { rigid.velocity = Vector2.zero; } }
void lifeTaken(Notification notification) { slider.value = GeneralController.DefaultController().getPlayer().GetComponent <PlayerController>().getLives(); }