Example #1
0
 // Use this for initialization
 void Start()
 {
     mySpriteRenderer = this.GetComponent <SpriteRenderer>();
     updateCol        = this.GetComponent <UpdateColliders>();
     onCol            = updateCol.bmCol;
     target           = GameObject.Find("Player");
 }
Example #2
0
        public void ChooseSprite()
        {
            player           = GameObject.Find("Player").transform;
            mySpriteRenderer = this.gameObject.GetComponent <SpriteRenderer>();
            updateCol        = this.GetComponent <UpdateColliders>();

            playerLoc   = player.position;
            bulletLoc   = this.gameObject.transform.position;
            dirToTarget = playerLoc - bulletLoc;

            onCol = updateCol.bmCol;

            float absx = Mathf.Abs(dirToTarget.x);
            float absy = Mathf.Abs(dirToTarget.y);
            float x    = dirToTarget.x;
            float y    = dirToTarget.y;

            if (absx > absy)
            {
                if (x > 0)
                {
                    mySpriteRenderer.flipX  = false;
                    mySpriteRenderer.sprite = right;


                    onCol.SetActive(false);
                    onCol = updateCol.rtCol;
                    onCol.SetActive(true);
                }
                else
                {
                    mySpriteRenderer.flipX  = true;
                    mySpriteRenderer.sprite = right;

                    onCol.SetActive(false);
                    onCol = updateCol.ltCol;
                    onCol.SetActive(true);
                }
            }
            else
            {
                if (y > 0)
                {
                    mySpriteRenderer.sprite = up;

                    onCol.SetActive(false);
                    onCol = updateCol.tpCol;
                    onCol.SetActive(true);
                }
                else
                {
                    mySpriteRenderer.sprite = down;

                    onCol.SetActive(false);
                    onCol = updateCol.bmCol;
                    onCol.SetActive(true);
                }
            }
        }
Example #3
0
 // Use this for initialization
 void Start()
 {
     mySpriteRenderer = this.GetComponent <SpriteRenderer>();
     updateCol        = this.GetComponent <UpdateColliders>();
     onCol            = ltColCharge.gameObject;
     manager          = this.GetComponent <GoatDemonAttackManager>();
     currentCone      = rtCone;
     currentCone.SetActive(false);
     //target = GameObject.Find("Player");
 }
Example #4
0
        private void Start()
        {
            player         = GameObject.Find("Player").transform;
            playerLoc      = player.position;
            bulletLoc      = gameObject.transform.position;
            dirToTarget    = playerLoc - bulletLoc;
            targetDistance = dirToTarget.magnitude;

            mySpriteRenderer = this.gameObject.GetComponent <SpriteRenderer>();
            updateCol        = this.GetComponent <UpdateColliders>();
            onCol            = updateCol.bmCol;
            ChooseSprite();
        }