Ejemplo n.º 1
0
    private void TrainerScan()
    {
        if (!defeated && !engaged)
        {
            Vector2 checkVector;
            Vector2 size2;
            Vector2 directionVector;
            bool    foundWall = false;
            int     maxRange  = maxSeeDistance;
            if (limitRange)
            {
                maxRange = rangeLimit + 1;
            }
            int foundRange = -1;
            while (!foundWall && foundRange < maxRange)
            {
                foundRange++;
                checkVector = MoveScripts.GetFrontVector2(move, (float)foundRange, true);
                Collider2D[] hit = Physics2D.OverlapAreaAll(checkVector, checkVector);
                //foundWall = MoveScripts.CheckForTag(this.gameObject,hit,TrainerLookStop);
                foundWall = !MoveBegin(hit);

                /*
                 * if (foundRange < maxRange)
                 * {
                 *  foundPlayer = MoveScripts.CheckForTag(this.gameObject,hit,"Player");
                 *  if (foundPlayer && !sr.saveSystemObject.isLoading && !sr.battleSetup.playerDead && !engaged) sr.battleSetup.StartCutscene(new PackedCutscene(GetComponent<Cutscene>()));
                 * }
                 */
                if (foundTrainer)
                {
                    Debug.Log("Found Trainer! FoundWall = " + foundWall);
                }
                if (foundTrainer && !foundWall)
                {
                    if (!sr.saveSystemObject.isLoading && !sr.battleSetup.playerDead && !engaged)
                    {
                        engaged = true;
                        sr.battleSetup.StartCutscene(new PackedCutscene(GetComponent <Cutscene>()));
                    }
                }
            }

            foundRange--;
            checkVector     = MoveScripts.GetFrontVector2(move, (float)foundRange / 2, true);
            size2           = MoveScripts.GetVector2FromDirection(move.lookDirection) * foundRange;
            directionVector = MoveScripts.GetVector2FromDirection(move.lookDirection) * 0.5f;
            if (size2.x == 0)
            {
                size2.x = 1;
            }
            if (size2.y == 0)
            {
                size2.y = 1;
            }
            Size          = new Vector3(size2.x, size2.y, 1);
            StartPosition = new Vector3(checkVector.x + directionVector.x, checkVector.y + directionVector.y, -1);
        }
    }
Ejemplo n.º 2
0
 // Update is called once per frame
 void Update()
 {
     if (sr.battleSetup.PlayerCanMove() && !move.isMoving)
     {
         if (Input.GetButtonDown("Submit"))
         {
             Vector2      faceDirection = MoveScripts.GetVector2FromDirection(MoveScripts.GetOppositeDirection(move.lookDirection));
             Vector2      checkPoint    = MoveScripts.GetFrontVector2(move, 1, true);
             Collider2D[] hit           = Physics2D.OverlapAreaAll(checkPoint, checkPoint);
             InteractBegin(hit);
         }
     }
 }
Ejemplo n.º 3
0
 private void OnDrawGizmos()
 {
     Gizmos.color     = new Color(0, 1, 1, 0.5f);
     frontOfCharacter = MoveScripts.GetFrontVector2(move, 1, true);
     Gizmos.DrawCube(frontOfCharacter, new Vector3(0.5f, 0.5f, 1));
 }