예제 #1
0
    private void FixedUpdate()
    {
        if (StaticLevelManager.IsGameFlove)
        {
            if (HeroTarget != null)
            {
                if (IMoveMain.IsFlight())
                {
                    Vector2 differenceHero = Vector2.zero;
                    Vector2 differenceMain = Vector2.zero;

                    if (gameObject.layer == 8 && HeroTarget.gameObject.layer == 11)
                    {
                        differenceHero = new Vector2(MapControl.X, MapControl.Y);
                    }

                    if (gameObject.layer == 11 && HeroTarget.gameObject.layer == 8)
                    {
                        differenceMain = new Vector2(MapControl.X, MapControl.Y);
                    }

                    if ((((Vector2)HeroTarget.transform.position - differenceHero) - ((Vector2)transform.position - differenceMain)).magnitude <= _atackDistensConst)
                    {
                        if (IMoveMain.IsGo())
                        {
                            IMoveMain.StopMoveTarget();
                        }

                        if (!IsAttack)
                        {
                            StartCoroutine(Atack());
                        }
                    }
                }
                else
                {
                    if (((Vector2)HeroTarget.transform.position - (Vector2)transform.position).magnitude <= _atackDistensConst)
                    {
                        if (IMoveMain.IsGo())
                        {
                            IMoveMain.StopMoveTarget();
                        }

                        if (!IsAttack)
                        {
                            StartCoroutine(Atack());
                        }
                    }
                }
            }
            else
            {
                _enemyManager.GoalSelection(this, name);
            }
        }
    }