Beispiel #1
0
    protected float meleeChanceToHit(unitScript unit, unitScript clickedUnit)
    {
        if (unit.getCurrentWeapon().type == WeaponType.ranged)
        {
            return(0);
        }

        // Check outflank bonus
        int     flankBonus    = 0;  // Flank Check
        Vector2 enemyPosition = clickedUnit.GetComponent <GridItem>().getPos();

        foreach (unitScript u in playerUnitList)
        {
            if (u != null)
            {
                Vector2 unitPosition = u.GetComponent <GridItem>().getPos();
                if (u.getOwner() == controllerID && u != unit && Vector2.Distance(unitPosition, enemyPosition) < 2)
                {
                    flankBonus = 2;
                    print("Flanked Bitches");
                }
            }
        }


        // return chance to hit
        return((5.0f + (unit.getSkill() + flankBonus) - clickedUnit.getSkill()) / 10.0f);
    }
    public void loadCharacter(unitScript u, bool ally = true)
    {
        if (ally)
        {
            unit = u;
        }
        Transform characterPanel = transform;
        Transform statPannel     = characterPanel.Find(ally?"StatPanel":"EnemyStatPanel");

        UnityEngine.UI.Text nameText = statPannel.Find("Name").GetComponent <UnityEngine.UI.Text>();
        nameText.text = u.getName();

        statPannel.FindChild("Image").GetComponent <Image>().sprite = u.getPortrait();

        var strengthText = statPannel.Find("Strength").GetComponent <UnityEngine.UI.Text>();

        strengthText.text = u.getStrength().ToString();

        var skillText = statPannel.Find("Skill").GetComponent <UnityEngine.UI.Text>();

        skillText.text = u.getSkill().ToString();

        var speedText = statPannel.Find("Speed").GetComponent <UnityEngine.UI.Text>();

        speedText.text = u.getSpeed().ToString();

        var smartsText = statPannel.Find("Smarts").GetComponent <UnityEngine.UI.Text>();

        smartsText.text = u.getSmarts().ToString();

        loadHealth(u.getHealth(), u.getMaxHealth(), statPannel);

        if (ally)
        {
            if (unit.doorsWithinRange.Count > 0)
            {
                transform.FindChild("CharacterPanel").FindChild("DoorButton").GetComponent <Button>().interactable = true;
            }
            else
            {
                transform.FindChild("CharacterPanel").FindChild("DoorButton").GetComponent <Button>().interactable = false;
            }
        }

        loadWeaponData(u, ally);
    }
Beispiel #3
0
 protected float getBaseHitChance(unitScript unit)
 {
     return(Mathf.Log10(unit.getSkill()));
 }