예제 #1
0
    public void spawnMob(int ID, int lane)
    {
        if (canSpawn && !isBlocked[lane])
        {
            GameObject mob;

            mob = Instantiate(mobs[ID], spawns[lane].position, Quaternion.identity);

            MobBehaviourNodes enemy = mob.GetComponent <MobBehaviourNodes>();
            if (lane == 0)
            {
                enemy.Nodes = nodes1;
            }
            else if (lane == 1)
            {
                enemy.Nodes = nodes2;
            }
            else
            {
                enemy.Nodes = nodes3;
            }
            enemy.PrintNodes();
            enemy.LaneIndex = lane;
            enemy.ownerId   = 2;
            health         -= enemy.healthCost;

            canSpawn = false;

            StartCoroutine(cooldown(ID, 5f));
        }
    }
    public void spawnMob(int ID)
    {
        if (canSpawn && !isBlocked[flagCount])
        {
            GameObject mob;
            if (queue.Count == 0)
            {
                mob = Instantiate(mobs[ID], spawns[flagCount].position, Quaternion.identity);
                source.PlayOneShot(source.clip);
                //AINode.mobsKinds[flagCount][ID]++;
            }

            else
            {
                mob = Instantiate(mobs[queue[0]], spawns[lanes[0]].position, Quaternion.identity);
                source.PlayOneShot(source.clip);
                //mob.transform.name = "PlayerMob";
                //AINode.mobsKinds[lanes[0]][queue[0]]++;
                queue.RemoveAt(0);
                lanes.RemoveAt(0);
                if (queue.Count < maxQueue)
                {
                    queue.Add(ID);
                    lanes.Add(flagCount);
                }
            }

            MobBehaviourNodes enemy = mob.GetComponent <MobBehaviourNodes>();
            if (flagCount == 0)
            {
                enemy.Nodes = nodes1;
            }
            else if (flagCount == 1)
            {
                enemy.Nodes = nodes2;
            }
            else
            {
                enemy.Nodes = nodes3;
            }
            enemy.LaneIndex = flagCount;
            enemy.ownerId   = 1;
            enemy.TypeIndex = ID;
            health         -= enemy.healthCost;

            canSpawn = false;
            StartCoroutine(cooldown(ID, enemy.GetComponent <MobBehaviourNodes> ().spawnTime));
        }
        else
        {
            if (queue.Count < maxQueue)
            {
                queue.Add(ID);
                lanes.Add(flagCount);
            }
        }
    }
예제 #3
0
    private void OnTriggerExit(Collider other)
    {
        if (other.tag == "MobTag")
        {
            _animator.SetBool("waiting", false);
            MobBehaviourNodes mb = other.GetComponentInParent <MobBehaviourNodes>();
            if (mb.ownerId == ownerId)
            {
                CurrentState = PreviousState;
            }
        }
//        else if (other.CompareTag("Spawn") && ownerId == 1 && Owner.GetComponent<PlayerControllsNodes>().flagCount == LaneIndex) {
//            Owner.GetComponent<PlayerControllsNodes>().Blocked = false;
//        }
    }
예제 #4
0
    private void OnTriggerExit(Collider other)
    {
        if (other.CompareTag("Mob"))
        {
            MobBehaviourNodes mb = other.GetComponent <MobBehaviourNodes>();
            if (mb.ownerId == ownerId)
            {
                switch (ownerId)
                {
                case 1:
                    Owner.GetComponent <PlayerControllsNodes>().isBlocked[selfId] = false;

                    break;

                case 2:
                    Owner.GetComponent <AINode>().isBlocked[selfId] = false;
                    break;
                }
            }
        }
    }
예제 #5
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Mob")
     {
         MobBehaviourNodes mb = other.GetComponent <MobBehaviourNodes>();
         if (mb.ownerId != ownerId && CurrentState != EnemyState.Fighting)
         {
             PreviousState = CurrentState;
             CurrentState  = EnemyState.Fighting;
             Enemy         = mb;
         }
     }
     else if (other.CompareTag("MobTag"))
     {
         MobBehaviourNodes mb = other.GetComponentInParent <MobBehaviourNodes>();
         if (mb.ownerId == ownerId && CurrentState != EnemyState.Waiting)
         {
             _animator.SetBool("waiting", true);
             PreviousState = CurrentState;
             CurrentState  = EnemyState.Waiting;
         }
     }
 }
    IEnumerator cooldown(int ID, float time)
    {
        yield return(new WaitForSeconds(time));

        canSpawn = true;
        if (queue.Count != 0)
        {
            if (!isBlocked[lanes[0]])
            {
                GameObject mob = Instantiate(mobs[queue[0]], spawns[lanes[0]].position, Quaternion.identity);
                source.PlayOneShot(source.clip);
                //AINode.mobsKinds[lanes[0]][queue[0]]++;
                MobBehaviourNodes enemy = mob.GetComponent <MobBehaviourNodes>();
                if (lanes[0] == 0)
                {
                    enemy.Nodes = nodes1;
                }
                else if (lanes[0] == 1)
                {
                    enemy.Nodes = nodes2;
                }
                else
                {
                    enemy.Nodes = nodes3;
                }
                enemy.ownerId   = 1;
                enemy.LaneIndex = lanes[0];
                enemy.TypeIndex = ID;
                health         -= enemy.healthCost;
                queue.RemoveAt(0);
                lanes.RemoveAt(0);
                canSpawn = false;
            }

            StartCoroutine(cooldown(ID, 2f));
        }
    }
예제 #7
0
    private void OnTriggerStay(Collider other)
    {
        /*if (other.CompareTag("Mob"))
         *  other.GetComponent<MobBehaviour>().GetComponent<PlayerControllsNodes>().Blocked = false;
         * else if (other.CompareTag("Mob"))
         *  other.GetComponent<MobBehaviour>().GetComponent<AINode>().Blocked = false;*/

        //Debug.Log("kuuuuurrrwa1");
        if (other.CompareTag("Mob"))
        {
            //Debug.Log("kurrrrrrwa2");


            MobBehaviourNodes mb = other.GetComponent <MobBehaviourNodes>();
            //Debug.Log("OwnerID: " + mb.ownerId + ", id: " + ownerId);
            if (mb.ownerId == ownerId)
            {
                switch (ownerId)
                {
                case 1:

                    Owner.GetComponent <PlayerControllsNodes>().isBlocked[selfId] = true;

                    break;

                case 2:
                    Owner.GetComponent <AINode>().isBlocked[selfId] = true;
                    break;
                }
            }
            else
            {
                mb.HasArrived = true;
            }
        }
    }
예제 #8
0
 private void Start()
 {
     mb = transform.GetComponentInParent <MobBehaviourNodes>();
 }
예제 #9
0
 // Start is called before the first frame update
 void Start()
 {
     mbn = GetComponent <MobBehaviourNodes>();
 }