Esempio n. 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);
            }
        }
    }
Esempio n. 2
0
    private void FixedUpdate()
    {
        if (EnemyTarget != null)
        {
            if (((Vector2)EnemyTarget.transform.position - (Vector2)transform.position).magnitude <= _atackDistensConst)
            {
                if (IMoveMain.IsGo())
                {
                    IMoveMain.StopMoveTarget();
                }

                if (!IsAttack)
                {
                    StartCoroutine(Atack());
                }
            }
        }
    }
Esempio n. 3
0
    private void FixedUpdate()
    {
        if (_wayList.Count <= 0)
        {
            _isMove = false;
        }

        if (StaticLevelManager.IsGameFlove)
        {
            if (_isMove)
            {
                _targetHexagon = _wayList[0];

                if (_targetHexagon.TypeHexagon == 2 && gameObject.layer == 8)
                {
                    gameObject.layer = 11;
                }
                else if (_targetHexagon.TypeHexagon == 0 && gameObject.layer == 11)
                {
                    gameObject.layer = 8;
                }

                transform.position = Vector2.MoveTowards(transform.position, _targetHexagon.transform.position, _speedMove);

                Vector2 NextPos = (Vector2)transform.position + (Vector2)(_targetHexagon.transform.position - transform.position).normalized * 1.8f;

                Control.Collision(NextPos);

                if (_wayList.Count > 0)
                {
                    if (((Vector2)transform.position - (Vector2)_wayList[0].transform.position).magnitude <= 0.01f)
                    {
                        _wayList.Remove(_wayList[0]);
                    }
                }
            }
            else
            {
                if (((Vector2)transform.position - Control.HexagonMain().position).magnitude >= 0.01f)
                {
                    transform.position = Vector2.MoveTowards(transform.position, Control.HexagonMain().position, _speed);
                }

                if (_isBypass)
                {
                    if (_wayList.Count > 0)
                    {
                        IMove move = _currentPos.ObjAbove;
                        if ((move == null))
                        {
                            if (_currentPos.IsFree)
                            {
                                _isMove = true;
                            }
                        }
                        else if (!move.IsGo())
                        {
                            IMove enemy = Control.Target() != null?Control.Target() : null;

                            WayBypass(_wayList[_wayList.Count - 1], enemy, _currentPos.ObjAbove);
                        }
                    }
                }
            }
        }
        else
        {
            if (((Vector2)transform.position - Control.HexagonMain().position).magnitude >= 0.01f)
            {
                transform.position = Vector2.MoveTowards(transform.position, Control.HexagonMain().position, _speed);
            }
        }
    }