Ejemplo n.º 1
0
        public void Fire(Character character, Transform firePosition)
        {
            if (load == null)
            {
                load = Resources.Load <GameObject>("Prefabs/Fireball");
            }

            var ins = GameObject.Instantiate <GameObject>(load);

            ins.transform.position = firePosition.position;
            bool facingRight = character.Move.FacingRight;

            Vector2 force = firePosition.right;

            if (!facingRight)
            {
                var scale = ins.transform.localScale;
                scale.x *= -1;
                ins.transform.localScale = scale;

                force = firePosition.right * -1;
            }

            var rig = ins.GetComponent <Rigidbody2D>();

            rig.AddForce(force * 300, ForceMode2D.Force);

            Rect rect = new Rect(0.1585348f, 0.009190321f, 0.851881f, 0.5521439f);

            rect.x *= character.Move.FacingRight ? 1 : -1;

            DamageTriggerCreater.Attach(character, Damage.Type.General, 20, rect, 100);
        }
Ejemplo n.º 2
0
        private void DetectAttack()
        {
            Vector2 offset = new Vector2(1.139406f, -0.5f);
            Vector2 size   = new Vector2(1.236866f, 1.45f);

            Rect rect = new Rect(offset, size);

            rect.x *= character.Move.FacingRight ? 1 : -1;

            DamageTriggerCreater.Create(character, Damage.Type.General, AttackDamage, rect, 10000);
        }