Exemple #1
0
    public override void Using(Vector2 location)
    {
        Optional <Cat> theCat = God.GetCat(true);

        if (theCat.IsPresent() && theCat.Get() != null)
        {
            theCat.Get().AddPossibleTarget(this.transform.position, GameConstants.WHISTLE_PRIORITY);
        }
    }
Exemple #2
0
 public void Update()
 {
     if (IsOn)
     {
         Optional <Cat> theCat = God.GetCat(true);
         if (theCat.IsPresent() && theCat.Get() != null)
         {
             theCat.Get().AddPossibleTarget(this.transform.position, GameConstants.BALL_PRIORITY);
         }
     }
 }
Exemple #3
0
    // Update is called once per frame
    void Update()
    {
        Optional <Cat> theCat = God.GetCat(true);

        if (theCat.IsPresent() && theCat.Get() != null)
        {
            theCat.Get().AddPossibleTarget(this.transform.position, GameConstants.LASER_PRIORITY);
        }
        else
        {
            //Debug.Log("No cat");
        }
    }
Exemple #4
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);
//		}
    }
    void TryMoveToNextLevel(Collider2D player)
    {
        Optional <Player> collidedPlayer = Optional <Player> .Of(player.gameObject.GetComponent <Player>());

        Optional <Cat> theCat = God.GetCat(true);

        if (theCat.IsPresent() && collidedPlayer.IsPresent())
        {
            Vector2 dist = theCat.Get().transform.position - collidedPlayer.Get().transform.position;
            if (dist.SqrMagnitude() < GameConstants.MAX_CAT_DIST_FOR_LEVEL_END)
            {
                // I know this is a bandaid, but it fixes a problem that occurs when you carry yarn into a scene that also has yarn in it
                GameObject[] toyBalls = GameObject.FindGameObjectsWithTag("DeleteOnTransition");
                for (int i = 0; i < toyBalls.Length; i++)
                {
//					Debug.Log ("destroy ball");
//					Debug.Log ("length" + (toyBalls [i]).GetComponent<ToyBall>().GetOwner ().Items.Count);
                    if ((toyBalls [i]).GetComponent <ToyBall> ().GetOwner() != null)
                    {
                        (toyBalls [i]).GetComponent <ToyBall> ().GetOwner().Items.Remove(toyBalls [i].GetComponent <ToyBall> ());
                    }
//					Debug.Log ("new length" + (toyBalls [i]).GetComponent<ToyBall>().GetOwner ().Items.Count);
                    Destroy(toyBalls [i]);
                }
                God.GetSavior().TransitionToNewLevel(LevelToLoad, true);
            }
            else
            {
                if (hintToBringCat)
                {
                    God.ShowText(HintsList.HINT_TO_BRING_CAT);
                    hintToBringCat = false;
                }
            }
        }
    }