Exemple #1
0
    // Start is called before the first frame update
    void Start()
    {
        guardMovement = gameObject.GetComponent <GuardMovement>();

        player           = PlayerSingleton.instance.player.transform;
        playerController = player.GetComponent <PlayerController>();
    }
Exemple #2
0
 void OnTriggerExit2D(Collider2D other)
 {
     if (type.Equals("speed") && other.gameObject.tag.Equals("Guard"))
     {
         GameObject    gm    = other.gameObject;
         GuardMovement guard = (GuardMovement)gm.GetComponent(typeof(GuardMovement));
         guard.speed /= 1.5f;
     }
 }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        GuardMovement chasing = gameObject.GetComponentInParent <GuardMovement>();

        if (collision.gameObject.tag == ("Player"))
        {
            chasing.GuardChasing();
        }
    }
    public GuardMovementSaveData(GuardMovement guardMovement) : base(guardMovement)
    {
        Vector2 lastMoveDirV2 = guardMovement.GetLastMoveDirection();

        lastMoveDir = new float[2] {
            lastMoveDirV2.x, lastMoveDirV2.y
        };
        isFirstMove = guardMovement.CheckIsFirstMove();
    }
    private void OnTriggerExit2D(Collider2D collision)
    {
        GuardMovement stopChasing = gameObject.GetComponentInParent <GuardMovement>();

        if (collision.gameObject.tag == ("Player"))
        {
            stopChasing.StopGuardChasing();
            stopChasing.GuardAlert();
        }
    }
Exemple #6
0
 protected override void Awake()
 {
     currentHealth = maximumHealth;
     spriteRender  = GetComponent <SpriteRenderer> ();
     anim          = GetComponent <Animator> ();
     guardFire     = GetComponent <GuardBulletFiring> ();
     guardMovement = GetComponent <GuardMovement> ();
     guardCollider = GetComponent <BoxCollider2D>();
     playerScore   = GameObject.FindGameObjectWithTag("Score").GetComponent <ScoreManager> ();
 }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        //GuardMovement incapacitated = gameObject.GetComponent<GuardMovement>();
        GuardMovement incapacitated = gameObject.GetComponentInParent <GuardMovement>();

        if (collision.gameObject.tag == ("Player"))
        {
            incapacitated.GuardIncapacitated();
        }
    }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        GuardMovement chasing = gameObject.GetComponentInParent <GuardMovement>();

        if (collision.gameObject.tag == ("Player"))
        {
            chasing.GuardChasing();
            Animator anim = gameObject.GetComponentInParent <Animator>();
            anim.SetBool("Alert", false);
        }
    }
Exemple #9
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        //GuardMovement incapacitated = gameObject.GetComponent<GuardMovement>();
        GuardMovement incapacitated = gameObject.GetComponentInParent <GuardMovement>();

        if (collision.gameObject.tag == ("Player"))
        {
            rb.AddForce(transform.up * 1150);
//            Debug.Log("Guard Incapacitated");
            incapacitated.GuardIncapacitated();
        }
    }
    private void OnSceneGUI()
    {
        GuardMovement gm = (GuardMovement)target;

        Handles.color = Color.white;
        Handles.DrawWireArc(gm.transform.position, Vector3.up, Vector3.forward, 360, gm.viewRadius);
        Vector3 viewAngleA = gm.DirFromAngle(-gm.viewAngle / 2, false);
        Vector3 viewAngleB = gm.DirFromAngle(gm.viewAngle / 2, false);

        Handles.DrawLine(gm.transform.position, gm.transform.position + viewAngleA * gm.viewRadius);
        Handles.DrawLine(gm.transform.position, gm.transform.position + viewAngleB * gm.viewRadius);
    }
Exemple #11
0
 // Use this for initialization
 void Start()
 {
     sight                     = GetComponent <FieldOfView>();
     reaction                  = GetComponent <ReactionLogic>();
     reactionMethod            = GetComponent <ReactionMethod>();
     isActive                  = true;
     movement                  = GetComponent <GuardMovement>();
     animations                = GetComponent <tk2dSpriteAnimator>();
     effects                   = GetComponent <SpriteEffects>();
     gunPosition               = GetComponentInChildren <PositionMarker>().gameObject;
     stunSparks                = GetComponentInChildren <ParticleSystem>();
     stunSparks.enableEmission = false;
 }
 // Update is called once per frame
 void Update()
 {
     // Update guard state
     if (guard != null && player != null)
     {
         //Debug.Log("Both in same room.");
         GuardMovement chasingScript = guard.GetComponent <GuardMovement>();
         if ((chasingScript != null) && chasingScript.chasing)
         {
             //Debug.Log("GOTCHA!");
             FindObjectOfType <AudioManager>().Play("LightOn");
             Destroy(gameObject);
         }
     }
 }
Exemple #13
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (type.Equals("speed") && other.gameObject.tag.Equals("Guard"))
     {
         GameObject    gm    = other.gameObject;
         GuardMovement guard = (GuardMovement)gm.GetComponent(typeof(GuardMovement));
         guard.speed *= 1.5f;
     }
     if (type.Equals("spawn") && other.gameObject.tag.Equals("Player") && !guardSpawned)
     {
         guardSpawned = true;
         GameObject    gm    = Instantiate(guardClone);
         GuardMovement guard = (GuardMovement)gm.GetComponent(typeof(GuardMovement));
         Vector2       tempX = new Vector2();
         guard.transform.position = this.transform.position + new Vector3(0f, -this.coll.radius - 0.1f, 0f);
         guard.path       = "vertical";
         guard.yPathStart = this.transform.position.y;
         guard.yPathEnd   = this.transform.position.y + 1f;
     }
 }
 private void OnTriggerExit2D(Collider2D collision)
 {
     GuardMovement chasing = gameObject.GetComponentInParent <GuardMovement>();
 }
Exemple #15
0
    protected override void Awake()
    {
        base.Awake();

        guardMovement = GetComponent <GuardMovement>();
    }
 void Awake()
 {
     guardMovement  = GetComponent <GuardMovement> ();
     anim           = GetComponent <Animator> ();
     playerMovement = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerMovement> ();
 }