示例#1
0
    public void InitializePassives(Attacks.AtkDefElement mineElement, Attacks.AtkDefElement playerElement, Moveonterrain _player)
    {
        player = _player;
        if (mineElement == (Attacks.AtkDefElement)(((int)playerElement + 1) % 3))
        {
            buff = -1;       //  Debug.Log(source + " Made Bad Attack On " + other);
        }
        else if (playerElement == (Attacks.AtkDefElement)(((int)mineElement + 1) % 3))
        {
            buff = 1;        //Debug.Log(source + " Made Good Attack On " + other);
        }
        else if (playerElement == mineElement)
        {
            buff = 0;     //Debug.Log(source + " Made Neutral Attack On " + other);
        }
        passive = (PassivesList)Random.Range(0, 15);
        if (Random.Range(0, 100) == 27)
        {
            buffAmtPercent = Random.Range(27f, 54f);
        }
        else
        {
            buffAmtPercent = Random.Range(127, 279f);
        }
        buffElement = mineElement;

        text.text = passive.ToString() + "  " + ((int)passive < 15 ? buffElement.ToString():" ");
        switch (buff)
        {
        case -1:
            text.color = Color.red;
            text.text += "-- " + buffAmtPercent.ToString("F0") + "%";
            break;

        case 0:
            text.color = Color.clear;
            break;

        case 1:
            text.color = Color.green;
            text.text += "++ " + buffAmtPercent.ToString("F0") + "%";
            break;
        }
    }
示例#2
0
    public void PerformLevelUp(Moveonterrain player, int mode)
    {
        if (Moveonterrain.levels[(int)attackElement] != 9)
        {
            switch (mode)
            {
            case 0:
                Moveonterrain.levels[(int)attackElement]++;
                player.XPLevelThreshold[(int)attackElement] = 100 + Moveonterrain.levels[(int)attackElement] * 50;
                player.XP[(int)attackElement] = 0;
                break;

            case 1:
                Moveonterrain.levels[(int)attackElement]++;
                player.XPLevelThreshold[(int)attackElement] = 100 + Moveonterrain.levels[(int)attackElement] * 50;
                player.XP[(int)attackElement] = player.XPLevelThreshold[(int)attackElement] / 3;
                break;
            }
        }
        isComplete        = true;
        player.isGrounded = false;
    }
示例#3
0
    void UpdateMining()
    {
        Vector3 tempPlayerCoord = player.transform.position - terr.gameObject.transform.position;
        Vector3 playerCoord;

        playerCoord.x = tempPlayerCoord.x / terr.terrainData.size.x;
        playerCoord.y = tempPlayerCoord.y / terr.terrainData.size.y;
        playerCoord.z = tempPlayerCoord.z / terr.terrainData.size.z;

        int playerX  = (int)(playerCoord.x * terr.terrainData.heightmapWidth);
        int playerY  = (int)(playerCoord.z * terr.terrainData.heightmapHeight);
        int specials = -1;

        for (int i = 1; i < 2; i++)
        {
            for (int j = 1; j < 2; j++)
            {
                Vector2 alphamapPos = new Vector2((playerX + i) * terr.terrainData.alphamapWidth / terr.terrainData.heightmapWidth,
                                                  (playerY + j) * terr.terrainData.alphamapHeight / terr.terrainData.heightmapHeight);
                var newMap = terr.terrainData.GetAlphamaps((int)alphamapPos.x, (int)alphamapPos.y, 1, 1);
                //Debug.Log(alphamapPos.x + "   " + (playerX + i));
                //Debug.Log(terr.terrainData.alphamapWidth + "   " + terr.terrainData.heightmapWidth);
                float height = terr.terrainData.GetHeights(playerX + i, playerY + j, 1, 1)[0, 0];
                if (player.GetComponent <Moveonterrain>().isGrounded)
                {
                    if (newMap[0, 0, 10] == 1)                             // Custom colors I picked on testing
                    {
                        specials = 0;
                        alphaMaps[(int)alphamapPos.x, (int)alphamapPos.y, 10] = 0;
                        alphaMaps[(int)alphamapPos.x, (int)alphamapPos.y, 13] = 1;
                        newMap[0, 0, 10] = 0;
                        newMap[0, 0, 13] = 1;
                        terr.terrainData.SetAlphamaps((int)alphamapPos.x, (int)alphamapPos.y, newMap);
                        break;
                    }
                    else
                    if (newMap[0, 0, 11] == 1)
                    {
                        specials = 1;
                        alphaMaps[(int)alphamapPos.x, (int)alphamapPos.y, 11] = 0;
                        alphaMaps[(int)alphamapPos.x, (int)alphamapPos.y, 13] = 1;
                        newMap[0, 0, 11] = 0;
                        newMap[0, 0, 13] = 1;
                        terr.terrainData.SetAlphamaps((int)alphamapPos.x, (int)alphamapPos.y, newMap);
                        break;
                    }
                    else
                    if (newMap[0, 0, 12] == 1)
                    {
                        specials = 2;
                        alphaMaps[(int)alphamapPos.x, (int)alphamapPos.y, 12] = 0;
                        alphaMaps[(int)alphamapPos.x, (int)alphamapPos.y, 13] = 1;
                        newMap[0, 0, 12] = 0;
                        newMap[0, 0, 13] = 1;
                        terr.terrainData.SetAlphamaps((int)alphamapPos.x, (int)alphamapPos.y, newMap);
                        break;
                    }
                }
            }
        }
        if (specials >= 0)
        {
            Vector3 spawnPos = new Vector3(Random.Range(player.transform.position.x - SpawnBugs.SpawnBox.x / 2, player.transform.position.x + SpawnBugs.SpawnBox.x / 2),
                                           Random.Range(player.transform.position.y - SpawnBugs.SpawnBox.y / 2, player.transform.position.y + SpawnBugs.SpawnBox.y / 2),
                                           Random.Range(player.transform.position.z - SpawnBugs.SpawnBox.z / 2, player.transform.position.z + SpawnBugs.SpawnBox.z / 2));
            Passives      passiveScript;
            Moveonterrain playerscript = player.GetComponent <Moveonterrain>();
            switch (specials)
            {
            case 0:
                passiveScript = Instantiate(rockSpecial, spawnPos, Quaternion.identity).GetComponent <Passives>();
                passiveScript.InitializePassives((Attacks.AtkDefElement) 0, playerscript.attackElement, playerscript);
                break;

            case 1:
                passiveScript = Instantiate(paperSpecial, spawnPos, Quaternion.identity).GetComponent <Passives>();
                passiveScript.InitializePassives((Attacks.AtkDefElement) 1, playerscript.attackElement, playerscript);
                break;

            case 2:
                passiveScript = Instantiate(scissorSpecial, spawnPos, Quaternion.identity).GetComponent <Passives>();
                passiveScript.InitializePassives((Attacks.AtkDefElement) 2, playerscript.attackElement, playerscript);
                break;
            }
        }
    }
示例#4
0
    public static IEnumerator PerformAttack(AttackType attackType, int attackElement, GameObject attackObject, GameObject attackingObject, float cooldownTimer, Moveonterrain player = null)
    {
        float timer = 0;

        attackObject.SetActive(true);
        int     playerX = -2799, playerY = -2799;
        float   speedMult = 1, rangeMult = 1, difficultyMult = -1;
        Vector3 dir = attackObject.transform.forward;

        if (player != null)
        {
            playerX        = (int)attackType;
            playerY        = attackElement;
            cooldownTimer *= player.AttackTimers[playerX, playerY];
            speedMult      = player.AttackSpeeds[playerX, playerY];
            rangeMult      = player.AttackRanges[playerX, playerY];
            dir            = -(Camera.main.transform.position - (player.transform.position + player.transform.up));
            if (Physics.SphereCast(player.transform.position + player.transform.up, 27, dir, out RaycastHit hit, float.MaxValue, 1 << LayerMask.NameToLayer("Enemy")))
            {
                dir = (hit.transform.position - (player.transform.position + player.transform.up));
                Debug.Log(hit.transform.name);
            }
        }

        else
        {
            difficultyMult = Moveonterrain.levels[(int)attackElement] + 1;
        }
        AudioManager.Instance.CreateAudio(attackObject.transform.position, AudioClipManager.attackClips[0, (int)attackType], attackObject.transform);
        while (timer < cooldownTimer)
        {
            switch (attackType)
            {
            case AttackType.Melee:
                Vector3 scale = attackObject.transform.localScale;
                scale.x = Mathf.Lerp(0f, 9f * rangeMult, timer / (cooldownTimer)) * speedMult * (difficultyMult >= 0 ? 6 * difficultyMult / 10 : 1);
                scale.z = Mathf.Lerp(0f, 9f * rangeMult, timer / (cooldownTimer)) * speedMult * (difficultyMult >= 0 ? 6 * difficultyMult / 10 : 1);
                attackObject.transform.localScale = scale;
                break;

            case AttackType.Ranged:
                //     attackObject.transform.Translate(dir.normalized * Time.deltaTime * 90 * speedMult * rangeMult,Space.World);    //pos.z = Mathf.Lerp(1, 80 * rangeMult, timer / Mathf.Pow(cooldownTimer,.2f)) * speedMult;
                attackObject.transform.Translate(dir.normalized * 1.5f * /*(timer>cooldownTimer/2?-1: 1) * */ timer * ((speedMult / cooldownTimer) + (rangeMult) /
                                                                                                                       Mathf.Pow(cooldownTimer, 2)) * (difficultyMult >= 0 ? 12 * difficultyMult / 10 : 1), Space.World);

                //attackObject.transform.localPosition = pos;
                attackObject.transform.localScale = new Vector3(2.5f, 1.25f, 4f);
                break;

            case AttackType.AoE:
                attackObject.transform.localScale = Vector3.Lerp(new Vector3(0f, 0f, 0f), new Vector3(27, 13.5f, 27) * rangeMult, timer / (cooldownTimer / 1.5f)) * speedMult * (difficultyMult >= 0 ? 2 * difficultyMult / 10 : 1);
                break;
            }
            timer += Time.deltaTime;
            yield return(new WaitForEndOfFrame());
        }


        attackObject.transform.localPosition = Vector3.zero + Vector3.up * 0.375f;
        attackObject.transform.localScale    = new Vector3(1, 0.5f, 1);
        attackObject.SetActive(false);
    }
示例#5
0
    public void DoDamage(float dmg, Attacks.AttackType atkType, Attacks.AtkDefElement playerElement, Moveonterrain player = null)
    {
        int   atkMultiplier = 0;
        float playerMult    = 1;

        if (player != null)
        {
            playerMult = player.AttackDmgMults[(int)atkType, (int)playerElement];
        }
        switch (atkType)
        {
        case Attacks.AttackType.AoE:
            atkMultiplier = 1;
            break;

        case Attacks.AttackType.Ranged:
            atkMultiplier = 3;
            break;

        case Attacks.AttackType.Melee:
            atkMultiplier = 5;
            break;
        }
        hp -= dmg * atkMultiplier * playerMult;

        if (hp < 1)
        {
            isAlive = false;
        }
    }
示例#6
0
 // Start is called before the first frame update
 void Start()
 {
     player = GameObject.FindGameObjectWithTag("Player").GetComponent <Moveonterrain>();
 }