Пример #1
0
        public override float StartBehavior(EnemyController enemyController, Character character)
        {
            randomPosition = Random.insideUnitCircle * 1f;
            randomPosition.Normalize();
            randomPosition *= new Vector2(Random.Range(sizeMin.x, sizeMax.x), Random.Range(sizeMin.y, sizeMax.y));
            randomPosition  = new Vector2(Mathf.Sign(randomPosition.x) * Mathf.Clamp(randomPosition.x, sizeMin.x, sizeMax.x),
                                          Mathf.Sign(randomPosition.y) * Mathf.Clamp(randomPosition.y, sizeMin.y, sizeMax.y));
            if (nearestSide == true)
            {
                character.LookAt(character.Target.transform);
                randomPosition = new Vector2(Mathf.Abs(randomPosition.x) * -character.GetDirection(), randomPosition.y);
            }
            if (lookAtPosition == true)
            {
                character.LookAtPosition(randomPosition);
            }

            if (targetIsSelf == true)
            {
                movementPosition = new Vector3(character.transform.position.x, character.transform.position.y, 0) + randomPosition;
            }
            else
            {
                movementPosition = new Vector3(character.Target.transform.position.x, character.Target.transform.position.y, 0) + randomPosition;
            }

            return(base.StartBehavior(enemyController, character));
        }
Пример #2
0
        public void CreateAttack(Character cUser, Character lockedTarget)
        {
            user = cUser;
            lockedCharacter = lockedTarget;

            // direction
            //Debug.Log(user.SpriteRenderer.transform.localScale.y);
            // direction
            this.transform.localScale = new Vector3(this.transform.localScale.x * user.SpriteRenderer.transform.localScale.x * cUser.GetDirection(), this.transform.localScale.y * user.SpriteRenderer.transform.localScale.y, user.SpriteRenderer.transform.localScale.z);
            if (attackBehavior.NoDirection == false)
                direction = cUser.GetDirection();

            // hitbox
            hitbox.enabled = attackBehavior.IsActive;

            // Link to user
            if (attackBehavior.LinkToCharacterAerial == true)
            {
                this.transform.SetParent(cUser.SpriteRenderer.transform);
                this.transform.localPosition = Vector3.zero;
                if(hitboxY != null)
                    hitboxY.transform.position = user.transform.position;
            }
            else if (attackBehavior.LinkToCharacter == true)
            {
                this.transform.SetParent(cUser.transform);
            }



            // Tag
            this.tag = cUser.tag;

            if (attackCoroutine != null)
                StopCoroutine(attackCoroutine);
            attackCoroutine = AttackBehaviorCoroutine();
            StartCoroutine(attackCoroutine);
        }