コード例 #1
0
    private void ActivateDashSlash(PlayerStats player)
    {
        if (MapManager.map[Targeting.Position.x, Targeting.Position.y].enemy != null || !MapManager.map[Targeting.Position.x, Targeting.Position.y].isWalkable)
        {
            return;
        }

        List <Vector2Int> moveLine = LineAlg.GetPointsOnLine(
            PlayerMovement.playerMovement.position.x,
            PlayerMovement.playerMovement.position.y,
            Targeting.Position.x,
            Targeting.Position.y);

        foreach (var pos in moveLine)
        {
            if (pos != Targeting.Position && pos != PlayerMovement.playerMovement.position)
            {
                if (MapManager.map[pos.x, pos.y].enemy != null)
                {
                    var enemy = MapManager.map[pos.x, pos.y].enemy;
                    var npc   = enemy.GetComponent <RoamingNPC>();
                    int roll  = UnityEngine.Random.Range(1, 101);


                    int calcRoll;
                    calcRoll = CalculateRoll(roll, player.__dexterity, npc.dex, npc.AC, npc.sleeping);

                    if (roll <= 20)
                    {
                        MissEnemyWakeUp(npc);
                        continue;
                    }
                    int damage = 0;
                    if (calcRoll > 60 || roll >= 80) //Do we hit?
                    {
                        damage = CalculateDamage(player._Lhand, player._Rhand, player.__dexterity, player.__strength, npc.AC, npc.dex, 0.5f);
                        DealDamageToEnemy(npc, damage);
                    }
                    else //WE MISSED BUT WE WAKE UP ENEMY
                    {
                        MissEnemyWakeUp(npc);
                    }
                }
            }
        }
        PlayerMovement.playerMovement.Move(new Vector2Int(Targeting.Position.x, Targeting.Position.y));
    }
コード例 #2
0
    public void DrawPreperation()
    {
        switch (Effect)
        {
        case SkillEffect.HeavySwing:
            break;

        case SkillEffect.Thrust:
            break;

        case SkillEffect.Divide:
            break;

        case SkillEffect.Sweep:
            break;

        case SkillEffect.JumpSmash:
            break;

        case SkillEffect.FlatBash:
            break;

        case SkillEffect.Sever:
            break;

        case SkillEffect.DashSlash:
            List <Vector2Int> moveLine = LineAlg.GetPointsOnLine(
                PlayerMovement.playerMovement.position.x,
                PlayerMovement.playerMovement.position.y,
                Targeting.Position.x,
                Targeting.Position.y);
            foreach (var pos in moveLine)
            {
                if (pos != Targeting.Position && pos != PlayerMovement.playerMovement.position)
                {
                    MapManager.map[pos.x, pos.y].decoy = $"<color=red>x</color>";
                }
            }
            break;

        case SkillEffect.ArcEdge:
            Vector2Int targetPos   = new Vector2Int(Targeting.Position.x, Targeting.Position.y);
            Vector2Int playerPos   = PlayerMovement.playerMovement.position;
            Vector2Int targetDelta = targetPos - playerPos;

            int maxSingle = Mathf.Abs(playerPos.x - targetPos.x) + Mathf.Abs(playerPos.y - targetPos.y);
            int maxBoth   = 2;

            // hor and vert
            Vector2Int d1 = new Vector2Int(-1, -1);
            if (
                !(
                    Mathf.Abs(d1.x - targetDelta.x) + Mathf.Abs(d1.y - targetDelta.y) > maxBoth ||
                    Mathf.Abs(d1.x - targetDelta.x) > maxSingle || Mathf.Abs(d1.y - targetDelta.y) > maxSingle))
            {
                if (d1 + playerPos != targetPos)
                {
                    MapManager.map[d1.x + playerPos.x, d1.y + playerPos.y].decoy = $"<color=red>x</color>";
                }
            }
            Vector2Int d2 = new Vector2Int(-1, 0);
            if (
                !(
                    Mathf.Abs(d2.x - targetDelta.x) + Mathf.Abs(d2.y - targetDelta.y) > maxBoth ||
                    Mathf.Abs(d2.x - targetDelta.x) > maxSingle || Mathf.Abs(d2.y - targetDelta.y) > maxSingle))
            {
                if (d2 + playerPos != targetPos)
                {
                    MapManager.map[d2.x + playerPos.x, d2.y + playerPos.y].decoy = $"<color=red>x</color>";
                }
            }
            Vector2Int d3 = new Vector2Int(-1, +1);
            if (
                !(
                    Mathf.Abs(d3.x - targetDelta.x) + Mathf.Abs(d3.y - targetDelta.y) > maxBoth ||
                    Mathf.Abs(d3.x - targetDelta.x) > maxSingle || Mathf.Abs(d3.y - targetDelta.y) > maxSingle))
            {
                if (d3 + playerPos != targetPos)
                {
                    MapManager.map[d3.x + playerPos.x, d3.y + playerPos.y].decoy = $"<color=red>x</color>";
                }
            }

            Vector2Int d4 = new Vector2Int(0, 1);
            if (
                !(
                    Mathf.Abs(d4.x - targetDelta.x) + Mathf.Abs(d4.y - targetDelta.y) > maxBoth ||
                    Mathf.Abs(d4.x - targetDelta.x) > maxSingle || Mathf.Abs(d4.y - targetDelta.y) > maxSingle))
            {
                if (d4 + playerPos != targetPos)
                {
                    MapManager.map[d4.x + playerPos.x, d4.y + playerPos.y].decoy = $"<color=red>x</color>";
                }
            }
            Vector2Int d5 = new Vector2Int(0, -1);
            if (
                !(
                    Mathf.Abs(d5.x - targetDelta.x) + Mathf.Abs(d5.y - targetDelta.y) > maxBoth ||
                    Mathf.Abs(d5.x - targetDelta.x) > maxSingle || Mathf.Abs(d5.y - targetDelta.y) > maxSingle))
            {
                if (d5 + playerPos != targetPos)
                {
                    MapManager.map[d5.x + playerPos.x, d5.y + playerPos.y].decoy = $"<color=red>x</color>";
                }
            }

            Vector2Int d6 = new Vector2Int(1, -1);
            if (
                !(
                    Mathf.Abs(d6.x - targetDelta.x) + Mathf.Abs(d6.y - targetDelta.y) > maxBoth ||
                    Mathf.Abs(d6.x - targetDelta.x) > maxSingle || Mathf.Abs(d6.y - targetDelta.y) > maxSingle))
            {
                if (d6 + playerPos != targetPos)
                {
                    MapManager.map[d6.x + playerPos.x, d6.y + playerPos.y].decoy = $"<color=red>x</color>";
                }
            }
            Vector2Int d7 = new Vector2Int(1, 0);
            if (
                !(
                    Mathf.Abs(d7.x - targetDelta.x) + Mathf.Abs(d7.y - targetDelta.y) > maxBoth ||
                    Mathf.Abs(d7.x - targetDelta.x) > maxSingle || Mathf.Abs(d7.y - targetDelta.y) > maxSingle))
            {
                if (d7 + playerPos != targetPos)
                {
                    MapManager.map[d7.x + playerPos.x, d7.y + playerPos.y].decoy = $"<color=red>x</color>";
                }
            }
            Vector2Int d8 = new Vector2Int(1, 1);
            if (
                !(
                    Mathf.Abs(d8.x - targetDelta.x) + Mathf.Abs(d8.y - targetDelta.y) > maxBoth ||
                    Mathf.Abs(d8.x - targetDelta.x) > maxSingle || Mathf.Abs(d8.y - targetDelta.y) > maxSingle))
            {
                if (d8 + playerPos != targetPos)
                {
                    MapManager.map[d8.x + playerPos.x, d8.y + playerPos.y].decoy = $"<color=red>x</color>";
                }
            }
            break;

        case SkillEffect.ShadowFang:
            break;

        case SkillEffect.VampireBite:
            break;

        case SkillEffect.NutCracker:
            break;

        case SkillEffect.HookSwitch:
            break;

        case SkillEffect.BackingJavelin:
            break;

        case SkillEffect.PoisonCleanse:
            break;

        default:
            break;
        }
    }
コード例 #3
0
ファイル: PlayerStats.cs プロジェクト: MCR2601/Bloody-Tower
    public void Update()
    {
        Targeting.UpdateTargeting();

        if (usingWand)
        {
            if (usedWand._spellType == WandSO.spellType.ray)
            {
                if (!usedWand.AllowTargetingMove())
                {
                    Targeting.Revert();
                }

                wand_path = LineAlg.GetPointsOnLine(
                    MapManager.playerPos.x, MapManager.playerPos.y,
                    Targeting.Position.x, Targeting.Position.y);

                foreach (var cell in wand_path)
                {
                    MapManager.map[cell.x, cell.y].decoy = $"<color=yellow>\u205C</color>";
                }
            }
            else if (usedWand._spellType == WandSO.spellType.point)
            {
                if (!usedWand.AllowTargetingMove())
                {
                    Targeting.Revert();
                }

                wand_path = LineAlg.GetPointsOnLine(
                    MapManager.playerPos.x, MapManager.playerPos.y,
                    Targeting.Position.x, Targeting.Position.y);

                foreach (var cell in wand_path)
                {
                    MapManager.map[cell.x, cell.y].decoy = $"<color=yellow>\u205C</color>";
                }
            } //todo
            else
            {
                if (usedWand.IsValidTarget())
                {
                    usingWand             = false;
                    Targeting.IsTargeting = false;
                    usedWand.UseWandSpell();
                    usedWand = null;
                    PlayerMovement.playerMovement.canMove = true;
                }
                else
                {
                    // you cannot target that guys
                    Debug.Log("not the right target");
                }
            }

            if (Controls.GetKeyDown(Controls.Inputs.Use))
            {
                if (usedWand.IsValidTarget())
                {
                    usingWand             = false;
                    Targeting.IsTargeting = false;
                    usedWand.UseWandSpell();
                    usedWand = null;
                    gameManager.ApplyChangesInInventory(null);
                    PlayerMovement.playerMovement.canMove = true;
                }
                else
                {
                    // you cannot target that guys
                    Debug.Log("not the right target");
                }
            }
            DungeonGenerator.dungeonGenerator.DrawMap(MapManager.map);
        }

        if (usingSpellScroll)
        {
            if (PlayerMovement.playerMovement.canMove)
            {
                Debug.Log(MapManager.playerPos + " " + Targeting.Position);
                PlayerMovement.playerMovement.canMove = false;
                gameManager.UpdateMessages("Choose target of your spell. <color=pink>(Numpad 8 4 6 2, Enter/Space to confirm, Escape to cancel)</color>");
            }
            if (usedScrollOrBook is IRestrictTargeting check)
            {
                if (check.IsValidTarget())
                {
                    MapManager.map[Targeting.Position.x, Targeting.Position.y].decoy = $"<color=yellow>\u205C</color>";
                }
                else
                {
                    MapManager.map[Targeting.Position.x, Targeting.Position.y].decoy = $"<color={ColorUtility.ToHtmlStringRGB(Color.gray)}>\u205C</color>";
                }
            }
            else
            {
                MapManager.map[Targeting.Position.x, Targeting.Position.y].decoy = $"<color=yellow>\u205C</color>";
            }


            DungeonGenerator.dungeonGenerator.DrawMap(MapManager.map);

            if (Controls.GetKeyDown(Controls.Inputs.Use))
            {
                if (usedScrollOrBook is IRestrictTargeting target)
                {
                    if (target.IsValidTarget())
                    {
                        PlayerMovement.playerMovement.canMove = true;
                        Targeting.IsTargeting = false;
                        usingSpellScroll      = false;
                        if (usedScrollOrBook is ScrollSO scroll)
                        {
                            scroll.UseSpell(this);
                        }
                        else if (usedScrollOrBook is SpellbookSO book)
                        {
                            book.UseSpell(this);
                        }
                        usedScrollOrBook = null;
                        gameManager.ApplyChangesInInventory(null);
                    }
                }
                DungeonGenerator.dungeonGenerator.DrawMap(MapManager.map);
            }
            if (Controls.GetKeyDown(Controls.Inputs.CancelButton))
            {
                PlayerMovement.playerMovement.canMove = true;
                Targeting.IsTargeting = false;
                usingSpellScroll      = false;
                usedScrollOrBook      = null;
                DungeonGenerator.dungeonGenerator.DrawMap(MapManager.map);
            }
        }

        if (dialogue)
        {
            if (PlayerMovement.playerMovement.canMove)
            {
                GameManager.manager.player.StopAllCoroutines();

                PlayerMovement.playerMovement.canMove = false;

                gameManager.UpdateMessages("<b><color=red>???</color></b>: <i>Ahh, you're no jailer are you? No, no, you're from far away...</i>");

                gameManager.UpdateMessages("<color=red><b>???</b></color>: <i>These bastards locked me here. I'm not asking for much, just cut the knots on my wrists, I'll be fine somehow, but in return I can give you something that I took from the priests.</i>");

                gameManager.UpdateMessages("<color=red><b>???</b></color>: <i>We are alike, we should support each other.</i>");

                gameManager.UpdateMessages("\n <i>[1. Help] [2. Refuse] [3. Cancel]</i>");
            }

            if (Controls.GetKeyDown(Controls.Inputs.InventoryChoice1))
            {
                gameManager.UpdateMessages("\n <b><color=red>Grim</color></b>: <i>Very well. I am Grim, I am grateful for your help. As I promised, in return for your help...</i>");

                GameObject rewardObject = Instantiate(gameManager.itemSpawner.itemPrefab);

                rewardObject.GetComponent <Item>().iso = npcDialogue.enemySO.rewardItem;

                rewardObject.transform.SetParent(MapManager.CurrentFloor.GO.transform);

                Pickup(rewardObject, rewardObject.GetComponent <Item>().iso, new Vector2Int(100, 100));

                dialogue = false;
                PlayerMovement.playerMovement.canMove = true;
                npcDialogue.enemySO.finishedDialogue  = true;
                npcDialogue = null;
            }
            if (Controls.GetKeyDown(Controls.Inputs.InventoryChoice2))
            {
                gameManager.UpdateMessages("\n <b><color=red>???</color></b>: <i>Yes, well, why should you? But if you change your mind, give me a shout, eh?</i>");
                dialogue = false;
                PlayerMovement.playerMovement.canMove = true;
                npcDialogue = null;
            }
            if (Controls.GetKeyDown(Controls.Inputs.InventoryChoice3))
            {
                PlayerMovement.playerMovement.canMove = true;
                gameManager.UpdateMessages("\n <b><color=red>???</color></b>: <i>I will wait...</i>");
                dialogue    = false;
                npcDialogue = null;
            }
        }
    }