Esempio n. 1
0
    public override void Attack()
    {
        Girl girl = EnemyHandler.GetInstance().GetGirl();

        if (girl == null)
        {
            return;
        }

        if (girl.IsTaken())
        {
            return;
        }

        Stop();
        SetState(State.ATTACKING);
        target = girl.transform;
        Vector3 targetPos = target.position - ray.transform.position;

        SetRayAngle(targetPos);

        girl.SetCaptor(this);
        takingGirl           = true;
        girlStartPos         = target.position;
        girlMovementTimer    = 0f;
        girlMovementDuration = Vector3.Distance(ray.transform.position, girlStartPos) / girlMovementSpeed;
    }
Esempio n. 2
0
    protected virtual void OnAttackApproach()
    {
        Girl girl = EnemyHandler.GetInstance().GetGirl();
        bool exit = true;

        if (state == State.ATTACKING)
        {
            if (girl != null)
            {
                if (!girl.IsTaken())
                {
                    girl.SetCaptor(this);
                    exit = false;

                    Vector3 exitPos = GetNearExitPath();
                    exitPos = NormalizeVector(exitPos);
                    StartMoving(exitPos);
                    SetState(State.KIDNAPPING);
                    SetFinishedListener(OnEscaped);
                }
            }
        }

        if (exit)
        {
            OnStartExit();
        }
    }
Esempio n. 3
0
 protected virtual void ReleaseGirl(bool saved = true)
 {
     if (state == State.KIDNAPPING)
     {
         Girl girl = EnemyHandler.GetInstance().GetGirl();
         if (girl.IsTaken())
         {
             girl.Release(this, saved);
         }
     }
 }
Esempio n. 4
0
    protected override void OnEntered()
    {
        SetState(State.IDLING);
        Attack();

        int level = EnemyHandler.GetInstance().GetLevel();

        if (level > 0)
        {
            hp = data.life * level;
        }
    }
Esempio n. 5
0
    protected void OnAttackApproachDelayed()
    {
        Girl girl = EnemyHandler.GetInstance().GetGirl();
        bool exit = true;

        if (state == State.ATTACKING)
        {
            if (girl != null)
            {
                if (!girl.IsTaken())
                {
                    Vector3 girlPos = girl.transform.position;
                    girlPos.z = this.transform.position.z;
                    float dist = Vector3.Distance(girlPos, transform.position);
                    if (dist < 0.5f)
                    {
                        girl.SetCaptor(this);
                        exit = false;

                        Vector3 exitPos = this.transform.position;
                        if (exitPos.x > 0f)
                        {
                            exitPos.x = 12f;
                        }
                        else
                        {
                            exitPos.x = -12f;
                        }

                        exitPos = NormalizeVector(exitPos);
                        BounceToPosition(exitPos);
                        SetState(State.KIDNAPPING);
                        SetFinishedListener(OnEscaped);
                    }
                    else
                    {
                        BounceToPosition(girlPos);
                        SetFinishedListener(OnAttackApproach);
                    }
                }
            }
        }

        Debug.Log(this.name + " OnAttackApproachDelayed() " + this.transform.position.y);
        if (exit)
        {
            OnStartExit();
        }
    }
Esempio n. 6
0
    public override void Attack()
    {
        if (enemyAnim != null)
        {
            enemyAnim.clip = spawnClip;
            enemyAnim.Play();
            Invoke("PlayIdle", 4f);
        }

        attackTimer = Random.Range(spawnTimes.x, spawnTimes.y);

        // Create attackers
        int enemyId = 1;
        int level   = EnemyHandler.GetInstance().GetLevel();

        if (level > 4)
        {
            level = 4;
        }

        enemyId = Random.Range(enemyId, level);
        Vector3 basePos = this.transform.position;

        basePos.y -= 1.6f;

        List <Vector3> positions = new List <Vector3>();
        float          xSpace    = spawnSpacing;
        float          yPos      = basePos.y - 2f;
        int            count     = attackCounter + 2;

        if (count > 6)
        {
            count = 6;
        }

        float xStart = basePos.x - (count - 1) * 0.5f * xSpace;

        for (int i = 0; i < count; i++)
        {
            positions.Add(new Vector3(xStart + xSpace * i, yPos, 0f));
        }

        EnemyHandler.GetInstance().SpawnEnemies(enemyId, EnemyData.Type.ATTACKER, positions, basePos);

        attackCounter++;
    }
Esempio n. 7
0
    public virtual void Attack()
    {
        Girl girl = EnemyHandler.GetInstance().GetGirl();

        if (girl == null)
        {
            return;
        }

        if (girl.IsTaken())
        {
            return;
        }

        Stop();
        SetState(State.ATTACKING);
        Vector3 targetPos = girl.transform.position;

        targetPos.y -= carryOffset.y;
        StartMoving(targetPos, data.attackSpeed);
        SetFinishedListener(OnAttackApproach);

        target = girl.transform;
    }
Esempio n. 8
0
    public override void Attack()
    {
        Girl girl = EnemyHandler.GetInstance().GetGirl();

        if (girl == null)
        {
            return;
        }

        if (girl.IsTaken())
        {
            return;
        }

        Stop();
        SetState(State.ATTACKING);
        Vector3 targetPos = girl.transform.position;

        targetPos.y = EnemyHandler.GROUND;
        BounceToPosition(targetPos);
        SetFinishedListener(OnAttackApproach);

        target = girl.transform;
    }
Esempio n. 9
0
 private void LostTheGirl()
 {
     SetState(State.LOST);
     EnemyHandler.GetInstance().LostTheGirl();
 }