Пример #1
0
    public override State Update()
    {
        IceSlimeBossAI iceSlimeBossAI = (IceSlimeBossAI)GetAI();
        IceSlimeBoss   iceSlimeBoss   = (IceSlimeBoss)iceSlimeBossAI.getCharacter();
        GameObject     myBody         = iceSlimeBoss.GetGameObject();

        if (currentLastTime < lastTime)
        {
            if (count < 0.5f)
            {
                count += Time.deltaTime;
            }
            else
            {
                float angle = (360 / iceBulletCount) * i;
                float r     = (Mathf.PI / 180) * angle;

                Vector2    pre       = myBody.transform.up;
                Vector3    d         = new Vector2(pre.x * Mathf.Cos(r) + pre.y * Mathf.Sin(r), -pre.x * Mathf.Sin(r) + pre.y * Mathf.Cos(r)).normalized;
                GameObject iceBullet = GameObject.Instantiate(iceBulletSkill2, myBody.transform.position, Quaternion.identity);
                iceBullet.transform.position = d * range + iceBullet.transform.position;
                iceBullet.GetComponent <Skill2IceBullet_IceSlimeBoss>().owner = iceSlimeBoss;
                count = 0;
                i++;
            }
            currentLastTime += Time.deltaTime;
        }
        else
        {
            return(State.SUCESSED);
        }
        return(State.RUNNING);
    }
Пример #2
0
 // Update is called once per frame
 void Update()
 {
     if (owner.GetGameObject() == null)
     {
         return;
     }
     if (currentLifeTime < lifeTime)
     {
         transform.RotateAround(owner.GetGameObject().transform.position, owner.GetGameObject().transform.forward, rotateSpeed * Time.deltaTime);
         currentLifeTime += Time.deltaTime;
     }
     else
     {
         Destroy(gameObject);
     }
 }
Пример #3
0
    // Update is called once per frame
    void Update()
    {
        if (isEnd)
        {
            IceSlimeGameLoop._instance.SetOver(true);
            return;
        }

        if (iceSlimeBoss.GetGameObject() == null)
        {
            Debug.Log("图");
            isEnd = true;
            return;
        }
        DoorsUpdate();

        if (isStart)
        {
            if (currentStartTime < startTime)
            {
                currentStartTime += Time.deltaTime;
                GameObject.Find("CM vcam1").GetComponent <Cinemachine.CinemachineVirtualCamera>().Follow = iceSlimeBossBody.transform;
            }
            else
            {
                GameObject.Find("CM vcam1").GetComponent <Cinemachine.CinemachineVirtualCamera>().Follow = GameObject.Find("Player").transform;
                Running = true;
            }
        }
        if (Running)
        {
            iceSlimeBoss.Update();
            iceSlimeBossBody.GetComponent <SkillUnit>().SetStart(true);
        }
    }
Пример #4
0
    public override State Update()
    {
        IceSlimeBossAI iceSlimeBossAI = (IceSlimeBossAI)GetAI();
        IceSlimeBoss   iceSlimeBoss   = (IceSlimeBoss)iceSlimeBossAI.getCharacter();
        GameObject     myBody         = iceSlimeBoss.GetGameObject();

        if (currentPrepareTime < prepareTime)
        {
            currentPrepareTime += Time.deltaTime;
            if (count < 0.2f)
            {
                count += Time.deltaTime;
            }
            else
            {
                count = 0;
                CreateParticalIce();
            }
        }
        else
        {
            for (int i = 0; i < IceBullets.Count; i++)
            {
                if (IceBullets[i] == null)
                {
                    break;
                }
                Vector2 dir = -(myBody.transform.position - IceBullets[i].transform.position).normalized;
                IceBullets[i].GetComponent <Rigidbody2D>().velocity = dir * outSpeed * Time.deltaTime;
            }
            return(State.SUCESSED);
        }
        return(State.RUNNING);
    }
Пример #5
0
    public override void Enter()
    {
        base.Enter();
        IceSlimeBossAI iceSlimeBossAI = (IceSlimeBossAI)GetAI();
        IceSlimeBoss   iceSlimeBoss   = (IceSlimeBoss)iceSlimeBossAI.getCharacter();
        GameObject     myBody         = iceSlimeBoss.GetGameObject();

        iceBulletSkill4    = iceSlimeBoss.IceBulletSkill4;
        currentRecoverTime = 0;
        currentLastTime    = 0;
        havaFired          = false;
    }
Пример #6
0
    public override State Update()
    {
        IceSlimeBossAI iceSlimeBossAI = (IceSlimeBossAI)GetAI();
        IceSlimeBoss   iceSlimeBoss   = (IceSlimeBoss)iceSlimeBossAI.getCharacter();
        GameObject     myBody         = iceSlimeBoss.GetGameObject();
        Vector3        dir            = (iceSlimeBoss.currentTarget.transform.position - myBody.transform.position).normalized;
        GameObject     iIceBullet     = Object.Instantiate(IceBullet, myBody.transform.position, Quaternion.identity);

        iIceBullet.transform.localScale = new Vector3(2, 2, 0);
        iIceBullet.GetComponent <Rigidbody2D>().velocity = dir * IceBulletSpeed * Time.deltaTime;
        return(State.SUCESSED);
    }
Пример #7
0
    public override State Update()
    {
        IceSlimeBossAI iceSlimeBossAI = (IceSlimeBossAI)GetAI();
        IceSlimeBoss   iceSlimeBoss   = (IceSlimeBoss)iceSlimeBossAI.getCharacter();
        GameObject     myBody         = iceSlimeBoss.GetGameObject();

        if (!havaFired)
        {
            List <GameObject> iceBullets = new List <GameObject>();
            GameObject        iceBullet  = GameObject.Instantiate(iceBulletSkill4, myBody.transform.position + myBody.transform.up, Quaternion.identity);
            GameObject        iceBullet1 = GameObject.Instantiate(iceBulletSkill4, myBody.transform.position + myBody.transform.right, Quaternion.identity);
            GameObject        iceBullet2 = GameObject.Instantiate(iceBulletSkill4, myBody.transform.position - myBody.transform.up, Quaternion.identity);
            GameObject        iceBullet3 = GameObject.Instantiate(iceBulletSkill4, myBody.transform.position - myBody.transform.right, Quaternion.identity);
            iceBullets.Add(iceBullet);
            iceBullets.Add(iceBullet1);
            iceBullets.Add(iceBullet2);
            iceBullets.Add(iceBullet3);

            GameObject iceBullet4 = GameObject.Instantiate(iceBulletSkill4, myBody.transform.position + new Vector3(1, 1).normalized, Quaternion.identity);
            GameObject iceBullet5 = GameObject.Instantiate(iceBulletSkill4, myBody.transform.position + new Vector3(-1, 1).normalized, Quaternion.identity);
            GameObject iceBullet6 = GameObject.Instantiate(iceBulletSkill4, myBody.transform.position + new Vector3(1, -1).normalized, Quaternion.identity);
            GameObject iceBullet7 = GameObject.Instantiate(iceBulletSkill4, myBody.transform.position + new Vector3(-1, -1).normalized, Quaternion.identity);
            iceBullets.Add(iceBullet4);
            iceBullets.Add(iceBullet5);
            iceBullets.Add(iceBullet6);
            iceBullets.Add(iceBullet7);

            Vector2 dir;
            for (int i = 0; i < iceBullets.Count; i++)
            {
                dir = (myBody.transform.position - iceBullets[i].transform.position).normalized;
                iceBullets[i].GetComponent <Rigidbody2D>().velocity = dir * iceBulletSpeed * Time.deltaTime;
                Debug.Log(iceBullets[i].GetComponent <Rigidbody2D>().velocity + " " + i);
            }
            havaFired = true;
        }
        else
        {
            if (currentRecoverTime < recoverTime)
            {
                currentRecoverTime += Time.deltaTime;
            }
            else
            {
                return(State.SUCESSED);
            }
        }
        return(State.RUNNING);
    }
Пример #8
0
    public override State Update()
    {
        IceSlimeBossAI iceSlimeBossAI = (IceSlimeBossAI)GetAI();
        IceSlimeBoss   iceSlimeBoss   = (IceSlimeBoss)iceSlimeBossAI.getCharacter();
        GameObject     myBody         = iceSlimeBoss.GetGameObject();

        float distance = Vector3.Distance(myBody.transform.position, iceSlimeBoss.currentTarget.transform.position);

        if (distance < iceSlimeBoss.getAttr().getAttackRange())
        {
            Debug.Log("距离足够");
            return(State.SUCESSED);
        }
        Debug.Log("距离不够");
        return(State.FAILED);
    }
Пример #9
0
    public override State Update()
    {
        IceSlimeBossAI iceSlimeBossAI = (IceSlimeBossAI)GetAI();
        IceSlimeBoss   iceSlimeBoss   = (IceSlimeBoss)iceSlimeBossAI.getCharacter();
        GameObject     myBody         = iceSlimeBoss.GetGameObject();

        for (int i = 0; i < iceBlockNumber; i++)
        {
            GameObject iIceBlock = Object.Instantiate(iceBlock, myBody.transform.position + myBody.transform.up * 3, Quaternion.identity);
            iIceBlock.transform.localRotation = iceBlock.transform.localRotation * Quaternion.Euler(0, 0, i * (360f / iceBlockNumber));
            Vector2 a     = myBody.transform.up;
            float   angle = 360 / iceBlockNumber;
            Vector3 b     = new Vector2(a.x * Mathf.Cos(i * angle) + a.y * Mathf.Sin(i * angle), -a.x * Mathf.Sin(angle) + a.y * Mathf.Cos(angle));
            iIceBlock.transform.position += b * 3;

            iIceBlock.GetComponent <Rigidbody2D>().velocity = iIceBlock.transform.up * iceBlockSpeed * Time.deltaTime;
        }
        return(State.SUCESSED);
    }
Пример #10
0
    public override State Update()
    {
        IceSlimeBossAI iceSlimeBossAI = (IceSlimeBossAI)GetAI();
        IceSlimeBoss   iceSlimeBoss   = (IceSlimeBoss)iceSlimeBossAI.getCharacter();
        GameObject     myBody         = iceSlimeBoss.GetGameObject();

        if (iceSlimeBoss.currentTarget != null)
        {
            return(State.SUCESSED);
        }

        iceSlimeBoss.targets = Physics2D.OverlapCircleAll(myBody.transform.position, eyeViewDistance, LayerMask.GetMask("Player"));
        Collider2D[] targets = iceSlimeBoss.targets;
        if (targets != null && targets.Length > 0)
        {
            iceSlimeBoss.currentTarget = targets[0];
            return(State.SUCESSED);
        }
        return(State.FAILED);
    }
Пример #11
0
    public override State Update()
    {
        IceSlimeBossAI iceSlimeBossAI = (IceSlimeBossAI)GetAI();
        IceSlimeBoss   iceSlimeBoss   = (IceSlimeBoss)iceSlimeBossAI.getCharacter();
        GameObject     myBody         = iceSlimeBoss.GetGameObject();

        attackRange = iceSlimeBoss.getAttr().getAttackRange();
        speed       = iceSlimeBoss.getAttr().getSpeed();

        float distance = Vector3.Distance(myBody.transform.position, iceSlimeBoss.currentTarget.transform.position);

        if (distance < attackRange)
        {
            myBody.GetComponent <Rigidbody2D>().velocity = Vector3.zero;
            return(State.SUCESSED);
        }
        Vector3 dir = (iceSlimeBoss.currentTarget.transform.position - myBody.transform.position).normalized;

        myBody.GetComponent <Rigidbody2D>().velocity = dir * GetAI().getCharacter().getAttr().getSpeed() * Time.deltaTime;
        return(State.RUNNING);
    }
Пример #12
0
    private void CreateParticalIce()
    {
        IceSlimeBossAI iceSlimeBossAI = (IceSlimeBossAI)GetAI();
        IceSlimeBoss   iceSlimeBoss   = (IceSlimeBoss)iceSlimeBossAI.getCharacter();
        GameObject     myBody         = iceSlimeBoss.GetGameObject();

        float      x   = Random.Range(-range, range);
        float      y   = Random.Range(-Mathf.Pow(range * range - x * x, 0.5f), Mathf.Pow(range * range - x * x, 0.5f));
        Vector3    dir = new Vector3(x, y);
        GameObject iIceBullet;

        while (dir.magnitude < 3)
        {
            x   = Random.Range(-range, range);
            y   = Random.Range(-Mathf.Pow(range * range - x * x, 0.5f), Mathf.Pow(range * range - x * x, 0.5f));
            dir = new Vector3(x, y);
        }
        iIceBullet = Object.Instantiate(IceBullet, myBody.transform.position + dir, Quaternion.identity);
        //iIceBullet.GetComponent<IceBullet_IceSlimeBoss>().isBig = false;
        //iIceBullet.GetComponent<IceBullet_IceSlimeBoss>().lifeTime = prepareTime + 5;
        IceBullets.Add(iIceBullet);
    }