コード例 #1
0
    // Fire a projectile
    private void Fire()
    {
        // Count for analytics
        if (fireTarget && fireTarget.GetComponentInParent <Virus>() && IsHeavyWeaponSelected())
        {
            antibioticUseOnVirus++;
        }

        // Spawn the projectile
        SpawnProjectile();

        // Apply a drawback force
        ApplyFireDrawback(heavyWeaponSelected? fireDrawbackP2 : fireDrawbackP1);

        // Increase mutation proba if heavy projectile is fired
        if (heavyWeaponSelected)
        {
            if (fireTarget && fireTarget.GetOrgMutation())
            {
                fireTarget.GetOrgMutation().ShineShields();
            }
            gameController.IncreaseAllMutationProba();
            if (audioManager)
            {
                audioManager.Play("FireHeavy");
            }
        }
        else
        {
            if (audioManager)
            {
                audioManager.Play("FireLight");
            }
        }
    }
コード例 #2
0
    /***** SPAWN DUPLICATE FUNCTIONS *****/

    //Spawn a new organism around the current one and return a bool if did so
    private bool SpawnDuplicatedOrganism()
    {
        //Check if there is no object at position before spawing, if yes find a new position
        Vector2 randomPos = new Vector2();
        int     nbTry     = 0;

        while (nbTry < 3) // Arbitrary
        {
            nbTry++;
            randomPos = ComputeRandomSpawnPosAround();
            Collider2D[] hitColliders = TestPosition(randomPos);

            // If touch something doesn't duplicate (avoid organism spawning on top of each other)
            if (hitColliders.Length > 0)
            {
                continue;
            }

            Organism spawnedOrganism = selfOrganism.InstantiateOrganism(randomPos);

            // Copy shield health if organism has shield
            if (spawnedOrganism && spawnedOrganism.GetOrgMutation())
            {
                spawnedOrganism.GetOrgMutation().SetShieldHealth(selfOrganism.GetOrgMutation().GetShieldHealth());
            }

            return(true);
        }
        return(false);
    }