Beispiel #1
0
    void skillUseBossState()
    {
        int rand = Random.Range(0, 2);

        if (rand <= 1)
        {
            for (int i = 0; i < 3; i++)
            {
                Vector3 pos = Vector3.zero;;
                if (i == 0)
                {
                    pos = new Vector3(this.transform.position.x - (transform.lossyScale.x * 5), this.transform.position.y, this.transform.position.z);
                }
                if (i == 1)
                {
                    pos = new Vector3(this.transform.position.x + (transform.lossyScale.x * 5), this.transform.position.y, this.transform.position.z);
                }
                if (i == 2)
                {
                    pos = new Vector3(this.transform.position.x, this.transform.position.y, this.transform.position.z + (this.transform.lossyScale.z * 5));
                }
                Server.spawnMonster(10000, pos);
                Server.spawnObject(e_Objects.PARTICLE_DEATH, pos);
                this.bossTimer = 10;
                this.bossState = e_BossStates.TARGET;
            }
        }
    }
Beispiel #2
0
    void Update()
    {
        //Klienten får inte acessa AI koden
        if (!isServer)
        {
            return;
        }
        if (timer != null)
        {
            timer.update();
            //if(timer.isFinished()) timer = null;
        }

        if (!isBoss)
        {
            switch (state)
            {
            case e_States.IDLE:
                idleState();
                break;

            case e_States.CHASE:
                chaseState();
                break;

            case e_States.ATTACK:
                attackState();
                break;

            case e_States.DIE:
                dieState();
                break;
            }
        }
        else
        {
            Collider[] col = Physics.OverlapSphere(this.transform.position, 40);
            foreach (Collider c in col)
            {
                if (c.CompareTag("Player"))
                {
                    startBossFight = true;
                }
            }

            if (startBossFight)
            {
                bossTimer -= 1 * Time.deltaTime;
                if (bossTimer <= 0)
                {
                    bossState = e_BossStates.SKILL_USE;
                }
                switch (bossState)
                {
                case e_BossStates.SKILL_USE:
                    skillUseBossState();
                    break;

                case e_BossStates.TARGET:
                    chaseBossState();
                    break;
                }
            }
        }

        if (newPos != null && state != e_States.DIE && !isBoss)
        {
            this.GetComponent <NavMeshAgent>().destination = newPos;
        }
    }