Example #1
0
    /// <summary>
    /// Sets the control binding for a destroyed virus to "not in use"
    /// </summary>
    /// <param name="destroyed">The virus that was destroyed</param>
    public void VirusDestroyed(VirusMovement killedCell)
    {
        int index         = 0;
        int activeViruses = 0;

        for (int i = 0; i < viruses.Count; i++)
        {
            if (viruses[i] == killedCell)
            {
                index = i;
                //i = viruses.Count;
            }
            if (viruses[i].gameObject.activeInHierarchy)
            {
                activeViruses++;
            }
        }

        score -= score / (activeViruses * 2);

        possibleControlSchemes[index].InUse = false;

        viruses[index].gameObject.SetActive(false);
        //removes destroyed viruses
        //viruses.Remove(killedCell);

        //ends game if player is out of viruses
        int activeVirusCount = 0;

        for (int i = 0; i < viruses.Count; i++)
        {
            if (viruses[i].gameObject.activeInHierarchy)
            {
                activeVirusCount++;
            }
        }
        if (activeVirusCount == 0)
        {
            UnityEngine.SceneManagement.SceneManager.LoadScene("MainMenu");
            //*******************************************************************Change to you win screen
            return;
        }

        if (spawners.Count != 0)
        {
            //spawn a new red blood cell
            Instantiate(redBloodCellPrefab, spawners[rand.Next(spawners.Count - 1)]);
        }

        //creates a list of which control schemes are in use
        List <bool> usedControlIndices = new List <bool>();

        for (int i = 0; i < possibleControlSchemes.Count; i++)
        {
            usedControlIndices.Add(viruses[i].gameObject.activeInHierarchy);
        }
        uiManager.UpdateUI(usedControlIndices);
    }
Example #2
0
    void VirusDuplicate(VirusMovement parent, Vector3 pos)
    {
        transform.position = new Vector3(pos.x, pos.y, pos.z);

        mesh     = parent.mesh;
        material = parent.material; //pass material reference

        target = parent.childTarget;


        speed            = parent.speed;
        maxRotationSpeed = parent.maxRotationSpeed;
        twist            = parent.twist;
        //transform.parent = parent.transform; // nests it in parent
    }
    private void OnCollisionEnter2D(Collision2D collision)
    {
        //if not colliding with a virus, do nothing
        if (collision.gameObject.tag != "Virus")
        {
            return;
        }

        //destroy the virus and tell the virus manager about it
        VirusMovement killedCell = collision.gameObject.GetComponent <VirusMovement>();
        VirusManager  manager    = GameObject.FindGameObjectWithTag("VirusManager").GetComponent <VirusManager>();

        manager.VirusDestroyed(killedCell);

        tracking = null;
    }
Example #4
0
    void Start()
    {
        VirusManager     = gameObject.transform.parent.gameObject;
        FightVirusPlayer = VirusManager.GetComponent <VirusManager>().FightVirusPlayer;
        GoTo             = VirusManager.GetComponent <VirusManager>().VirusLocations;
        EnteredZone      = false;

        RandomVirusLocation = Random.Range(0, 4);
        VM = (VirusMovement)Random.Range(0, 8);

        BossCanTakeDamage = false;
        BossMadeLocation  = false;
        BossMovementTimer = 0.0f;

        SpawnSmallVirusTimer = 0.0f;
        AngleSpeed           = 20.0f;
        BossStartHealth      = VirusManager.GetComponent <VirusManager>().BossVirusHealth;
    }
Example #5
0
    void FixedUpdate()
    {
        if (GlobalVariables.tutorial == false)
        {
            if (transform.tag == "Virus")
            {
                //Virus form up at special postion
                if (BossSpawnSmallVirus == false)
                {
                    transform.position = Vector3.MoveTowards(transform.position, GoTo.GetComponent <VirusLocations>().VirusLocationList[RandomVirusLocation].Pos.transform.position, Speed);
                }

                else
                {
                    transform.position -= transform.forward * Speed;
                }
            }

            else if (transform.tag == "BigVirus")
            {
                //Temporaily Fixed
                transform.LookAt(FightVirusPlayer.transform.position);
                transform.position -= transform.forward * Speed;

                //Have the big virus move around
                //transform.position = new Vector3(Mathf.PingPong(Speed, 2), transform.position.y, transform.position.z);
                //transform.position = new Vector3(transform.position.x, transform.position.y, Mathf.PingPong(Speed, 2));
            }

            //For Boss
            else if (transform.tag == "Boss")
            {
                if (BossMadeLocation == false)
                {
                    float Distance1 = Vector3.Distance(transform.position, FightVirusPlayer.transform.position);
                    if (Distance1 >= 4.5f)
                    {
                        transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(FightVirusPlayer.transform.position - transform.position), 20 * Time.deltaTime);
                        transform.position = Vector3.MoveTowards(transform.position, FightVirusPlayer.transform.position, Speed);
                    }

                    else
                    {
                        //Basically the Boss made it to its destination
                        BossMadeLocation  = true;
                        BossCanTakeDamage = true;
                    }
                }

                else
                {
                    if (Health <= BossStartHealth * .85f)
                    {
                        SpawnSmallVirusTimer += Time.deltaTime;
                    }

                    if (BossSmallVirusCount > 0)
                    {
                        if (SpawnSmallVirusTimer >= 4.0f)
                        {
                            SpawnSmallVirusTimer = 0.0f;
                            SpawnSmallViruses();
                            BossSmallVirusCount -= 1;
                        }
                    }

                    transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(FightVirusPlayer.transform.position - transform.position), 2.5f * Time.deltaTime);

                    //The boss moves unpredicatble and rotate
                    BossMovementTimer += Time.deltaTime;
                    if (BossMovementTimer > 6.5f)
                    {
                        BossMovementTimer = 0.0f;
                        VM = (VirusMovement)Random.Range(0, 8);
                    }

                    switch (VM)
                    {
                    case VirusMovement.UP:
                        transform.RotateAround(FightVirusPlayer.transform.position, Vector3.up, AngleSpeed * Time.deltaTime);
                        break;

                    case VirusMovement.DOWN:
                        transform.RotateAround(FightVirusPlayer.transform.position, Vector3.down, AngleSpeed * Time.deltaTime);
                        break;

                    case VirusMovement.LEFT:
                        transform.RotateAround(FightVirusPlayer.transform.position, Vector3.left, AngleSpeed * Time.deltaTime);
                        break;

                    case VirusMovement.RIGHT:
                        transform.RotateAround(FightVirusPlayer.transform.position, Vector3.right, AngleSpeed * Time.deltaTime);
                        break;

                    case VirusMovement.UPLEFT:
                        transform.RotateAround(FightVirusPlayer.transform.position, Vector3.up, AngleSpeed * Time.deltaTime);
                        transform.RotateAround(FightVirusPlayer.transform.position, Vector3.left, AngleSpeed * Time.deltaTime);
                        break;

                    case VirusMovement.UPRIGHT:
                        transform.RotateAround(FightVirusPlayer.transform.position, Vector3.up, AngleSpeed * Time.deltaTime);
                        transform.RotateAround(FightVirusPlayer.transform.position, Vector3.right, AngleSpeed * Time.deltaTime);
                        break;

                    case VirusMovement.DOWNLEFT:
                        transform.RotateAround(FightVirusPlayer.transform.position, Vector3.down, AngleSpeed * Time.deltaTime);
                        transform.RotateAround(FightVirusPlayer.transform.position, Vector3.left, AngleSpeed * Time.deltaTime);
                        break;

                    case VirusMovement.DOWNRIGHT:
                        transform.RotateAround(FightVirusPlayer.transform.position, Vector3.down, AngleSpeed * Time.deltaTime);
                        transform.RotateAround(FightVirusPlayer.transform.position, Vector3.right, AngleSpeed * Time.deltaTime);
                        break;

                    default:
                        break;
                    }
                }
            }

            if (FightVirusPlayer.GetComponent <Player>().isGameOver == true)
            {
                Destroy(this.gameObject);
            }
        }

        else if (GlobalVariables.tutorial == true)
        {
            if (transform.tag == "Virus")
            {
                transform.position = Vector3.MoveTowards(transform.position, GoTo.GetComponent <VirusLocations>().VirusLocationList[0].Pos.transform.position, Speed * 2.0f);
            }

            else if (transform.tag == "BigVirus")
            {
                transform.LookAt(FightVirusPlayer.transform.position);
                transform.position -= transform.forward * Speed * 2.0f;
            }
        }
    }