Ejemplo n.º 1
0
 void OnTriggerEnter2D(Collider2D player)
 {
     Debug.Log("collide");
     Debug.Log(player.gameObject.tag);
     if ((transform.position - God.GetPlayer().transform.position).sqrMagnitude < 3)
     {
         if (!HintsList.CANT_GO_BACK_SAID)
         {
             God.ShowText(HintsList.CANT_GO_BACK);
             HintsList.CANT_GO_BACK_SAID = true;
         }
     }
 }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (!initialized)
        {
            this.GetComponent <SpriteChanger> ().SetDirectedSprite(baseDirection);
            initialized = true;
        }
        List <Vector2> emissionResults = this.transform.EmitLight(LightType.GUARD_VISION, GameConstants.GUARD_SIGHT_RANGE, currentDirection);
        Bounds         playerBounds    = God.GetPlayer().GetComponentInChildren <CapsuleCollider2D> ().bounds;

        if (SeeObjectInBounds(playerBounds, emissionResults).IsPresent())
        {
            God.ShowText(HintsList.GUARD_SEES_PLAYER);
            StartCoroutine(ResetLevel());
        }
        if (!moving)
        {
            Optional <Cat> cat = God.GetCat(true);
            if (cat.Get() != null)
            {
                Bounds             catBounds = God.GetCat().Get().GetComponentInChildren <CapsuleCollider2D> ().bounds;
                Optional <Vector2> catLoc    = SeeObjectInBounds(catBounds, emissionResults);
                if (catLoc.IsPresent())
                {
                    currentTarget = catLoc;
                    moving        = true;
//						Debug.Log ("guard sees cat");
                }
            }
        }
        else
        {
            if (canTurn)
            {
                rb.velocity = guardSpeed * currentDirection;
            }
            if (AtTarget() && canTurn)
            {
                rb.velocity = Vector2.zero;
                canTurn     = false;
                StartCoroutine(Turn());
            }
        }
        rb.rotation = 0;


//		if (!moving)
//		{
//			List<Vector2> emissionResults = this.transform.EmitLight (LightType.KITTY_VISION, GameConstants.GUARD_SIGHT_RANGE, baseDirection);
//		}
    }
Ejemplo n.º 3
0
    public override void BeginUse(Vector2 location)
    {
        this.IsOn = true;
        StartCoroutine(AllowCatPickup());

        // ballSoumd.Play();
        Vector2 direction = location - (Vector2)transform.position;

        this.rb.simulated = true;
        this.rb.velocity  = direction.normalized * GameConstants.BALL_SPEED;
        God.GetPlayer().Bag.Drop(this);
        God.GetPlayer().currentlyEquipped = null;

        // God.GetStats().incrementStat("whistle_uses", 1);
        God.GetStats().SendData();
    }