Example #1
0
    void Start()
    {
        currentAction      = null;
        lastFrameDirection = 0;
        if (opcoes == null || opcoes[0] == null)
        {
            opcoes = new List <GameObject>(GameObject.FindGameObjectsWithTag("OpcaoCombate"));
            opcoes.Sort(new HierarchyComparer());
        }
        #region Move List
        if (moves == null || moves[0] == null)
        {
            moves = new List <GameObject>(GameObject.FindGameObjectsWithTag("StandardMove"));
            moves.Sort(new HierarchyComparer());

            foreach (GameObject move in moves)
            {
                move.GetComponent <Image>().material = new Material(moves[0].GetComponent <Image>().material);
            }
        }

        #endregion
        currentlySelected = -1;
        character         = gameObject.GetComponent <CombatCharacter>();

        for (int i = 0; i < opcoes.Count; i++)
        {
            opcoes[i].SendMessage("selected", i == currentlySelected);
        }
    }
Example #2
0
    public void createBuff(CombatCharacter source, CombatCharacter target)
    {
        this.target = target;
        target.buffs.Add(this);
        applyBuff(1);
        target.refreshUI();

        switch (duration)
        {
        case BuffDuration.UntilEndOfTurn: {
            eventName = TurnMaster.getEndTurnTrigger(source.gameObject.GetInstanceID());
            break;
        }

        case BuffDuration.UntilStartOfNextTurn: {
            eventName = TurnMaster.getStartTurnTrigger(source.gameObject.GetInstanceID());
            break;
        }

        case BuffDuration.UntilEndOfTargetsTurn: {
            eventName = TurnMaster.getEndTurnTrigger(target.gameObject.GetInstanceID());
            break;
        }
        }

        EventManager.StartListening(eventName, removeBuff);
    }
Example #3
0
    // Use this for initialization
    void Start()
    {
        CoinCount = CoinCounter.GetInstance();

        CC         = GetComponent <CombatCharacter>();
        CC.OnHurt += CC_OnHurt;
    }
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Return) &&
            lastAbility != null)
        {
            int varX = Int32.Parse(xField.text);
            if (lastAbility.varXResource == ResourceType.Energy)
            {
                if (CombatCharacter.Player().energy >= varX)
                {
                    CombatCharacter.Player().energy -= varX;
                    lastAbility.setVarX(varX);
                    successfulInput(varX);
                }
            }
            else if (lastAbility.varXResource == ResourceType.Focus)
            {
                if (CombatCharacter.Player().focus >= varX)
                {
                    CombatCharacter.Player().focus -= varX;
                    successfulInput(varX);
                }
            }

            xField.text = "";
        }
    }
Example #5
0
    public void execute()
    {
        bool targetDead = false;

        foreach (GameObject t in target)
        {
            CombatCharacter character = t.GetComponent <CombatCharacter>();
            if (!character.isAlive())
            {
                targetDead = true;
                break;
            }
        }
        if (targetDead)
        {
            ActionRetarget retarget = gameObject.GetComponent <ActionRetarget>();
            retarget.retarget(this);
        }

        applyEffects();
        started = true;
        Sender.BroadcastMessage("animateAttack", name);
        hitCounter = 0;
        //ended = true; // placeHolderCode
    }
Example #6
0
 private void Awake()
 {
     character  = GetComponent <CombatCharacter>();
     aiThinking = false;
     //EventManager.StartListening(TurnMaster.getStartPhaseTrigger(Phase.Action, character.gameObject.GetInstanceID()), aiActionPhase);
     character.ai = this;
 }
Example #7
0
 //called in update() if the current stage is the selection stage
 void selectionStage()
 {
     if (!frendlyAttacking)
     {
         //TODO write better enemy combat logic
         int toAttack = CombatCharacter.getFirstAlive(defendChars);
         if (toAttack == -1)
         {
             lose();
         }
         else
         {
             attackTargets = new List <CombatCharacter> ();
             attackTargets.Add(defendChars [toAttack]);
             attack = attacker.basicAttack;
             attacker.updateEntityAnimation("move");
             currentStage = turnStages.moving;
         }
     }
     else
     {
         selectorRen.enabled            = true;
         selectorObj.transform.position = attacker.entity.transform.position;
     }
 }
Example #8
0
    public void resolveTargeting(Targetable target)
    {
        this.target = target;
        GameAlertUI.Instance().deactivateText();
        if (targetCategory == TargetCategory.Enemy)
        {
            CombatCharacter targetCharacter = target as CombatCharacter;

            //Debug.Log("Resolve Targeting");
            if ((!undodgeable) && targetCharacter.checkDodge(details.character))
            {
                FloatingDamageTextController.Instance().createDodgeText(targetCharacter.transform);
                this.target = null;
            }
            else
            {
                //Debug.Log("Not dodged");
            }
        }

        if (targetOnResolution)
        {
            abilityResolve = true;
            activateTargetAbility();
        }
        else
        {
            precastResolve = true;
        }
    }
    public static CombatCharacter MakeCharacter(CombatCharacterPresets characterType)
    {
        CombatCharacter newCharacter       = null;
        int             characterMaxHealth = GetCharacterMaxhealth(characterType);
        int             characterMaxEnergy = GetCharacterMaxEnergy(characterType);
        CombatAbility   basicAttack        = getCharacterBasicAttack(characterType);

        switch (characterType)
        {
        case CombatCharacterPresets.BobbyBard:
            newCharacter = new CombatCharacter(characterMaxHealth, characterMaxHealth / 2, characterMaxEnergy, characterMaxEnergy, basicAttack);
            break;

        default:
            newCharacter = new CombatCharacter(characterMaxHealth, characterMaxHealth, characterMaxEnergy, characterMaxEnergy, basicAttack);
            break;
        }

        List <CombatAbility> abilities = GetCharacterAbilities(characterType);

        foreach (CombatAbility ability in abilities)
        {
            newCharacter.AddAbility(ability);
        }
        newCharacter.combatSprites = getCharacterSprites(characterType);

        newCharacter.Name = GetCharacterName(characterType);
        return(newCharacter);
    }
Example #10
0
    /// [NEW FOR ASSESSMENT 4]
    /// <summary>
    /// Sets the attacker.
    ///	also handles actions that need to happen when the attacker changes
    /// </summary>
    void setAttacker(CombatCharacter character)
    {
        if (attacker == character)
        {
            return;
        }
        attacker = character;
        float val = Random.value;

        Debug.Log(val);
        if (val < attacker.attackFriendlyChance)
        {
            //select a random alive friendly character
            List <int> options = new List <int> ();
            for (int i = 0; i < frendlyChars.Count; i++)
            {
                if (frendlyChars [i].health > 0)
                {
                    options.Add(i);
                }
            }
            int toAttack = options [Random.Range(0, options.Count - 1)];
            //attack them
            attackTargets = new List <CombatCharacter> ();
            attackTargets.Add(frendlyChars [toAttack]);
            attack = attacker.basicAttack;
            attacker.updateEntityAnimation("move");
            currentStage = turnStages.moving;
        }
    }
Example #11
0
 void Start()
 {
     currentAction = null;
     controller    = GameObject.FindGameObjectWithTag("CombatController").GetComponent <CombatController>();
     moves         = gameObject.GetComponent <CombatCharacter>().moves;
     character     = gameObject.GetComponent <CombatCharacter>();
 }
Example #12
0
    protected virtual IEnumerator BuffAction(CombatCharacter caster, CombatCharacter[] targets)
    {
        CharacterDefinition def = caster.Definition;

        caster.CharacterUI.AnimateBuff();
        yield return(new WaitForSeconds(1.0f));
    }
Example #13
0
    private void OnSelection(CombatCharacter character)
    {
        List <CombatCharacter> selected = new List <CombatCharacter>();

        if (caster.Value.IsSelectionCharacter)
        {
            selected.Add(character);
        }
        else
        {
            CombatSlotArrayVar selectedVars = character.Definition.Team == CharacterDefinition.TeamType.Player? players : enemies;

            foreach (CombatSlotObserver selectedCharacter in selectedVars.Value)
            {
                if (selectedCharacter.Character != null && selectedCharacter.Character.IsAlive)
                {
                    selected.Add(selectedCharacter.Character);
                }
            }
        }
        CombatAction action = new CombatAction(caster.Value, selected.ToArray());

        actions.Add(action);
        combatAnimator.Value.SetInteger("ActionsCount", actions.Count());
        combatAnimator.Value.SetTrigger("TargetSelected");
        actionUI.Value.AnimateAddAction(actions.Count() - 1);
    }
Example #14
0
 public bool isCardTargetingCharacter(CombatCharacter character)
 {
     foreach (BaseAbility ability in abilities)
     {
         if (ability is TargetAbility)
         {
             TargetAbility tarAbility = ability as TargetAbility;
             if (tarAbility.target is CombatCharacter)
             {
                 CombatCharacter tarCharacter = tarAbility.target as CombatCharacter;
                 if (tarCharacter == character)
                 {
                     return(true);
                 }
             }
         }
         else if (ability is MultiTargetAbility)
         {
             MultiTargetAbility tarAbility = ability as MultiTargetAbility;
             foreach (Targetable target in tarAbility.targets)
             {
                 if (target is CombatCharacter)
                 {
                     CombatCharacter tarCharacter = target as CombatCharacter;
                     if (tarCharacter == character)
                     {
                         return(true);
                     }
                 }
             }
         }
     }
     return(false);
 }
Example #15
0
    public void loadSideboard()
    {
        foreach (Transform child in sideboardListTransform)
        {
            GameObject.Destroy(child.gameObject);
        }

        if (PlayerInfo.Instance().sideboard.Count > 0)
        {
            currentPreviewedCard = PlayerInfo.Instance().sideboard[0];
        }
        previewCard(currentPreviewedCard);

        foreach (GameObject card in PlayerInfo.Instance().sideboard)
        {
            GameObject sideboardItemGO = Instantiate(sideboardListItemPrefab, sideboardListTransform);
            sideboardItemGO.GetComponent <SideboardListItem>().setCard(card);
        }

        LayoutRebuilder.ForceRebuildLayoutImmediate(sideboardListTransform as RectTransform);

        if (!CombatCharacter.Player().atleastOneSideboardLearnable())
        {
            gameObject.SetActive(false);
        }
    }
Example #16
0
    public int Compare(GameObject x, GameObject y)
    {
        CombatCharacter charX = x.GetComponent <CombatCharacter>();
        CombatCharacter charY = y.GetComponent <CombatCharacter>();

        if (charX.Priority + charX.PriorityModifier > charY.Priority + charY.PriorityModifier)
        {
            return(1);
        }
        else if (charX.Priority + charX.PriorityModifier < charY.Priority + charY.PriorityModifier)
        {
            return(-1);
        }
        else
        {
            if (charX.Priority == charY.Priority)
            {
                return(0);
            }
            else
            {
                return(charX.Priority > charY.Priority ? 1 : -1);
            }
        }
    }
Example #17
0
    //called in update() if the current stage is the target selection stage
    /// <summary>
    /// [EXTENSION Un-Two] Gorrila check added for target selection to allow randomisation for the gorilla
    void targetSelectionStage()
    {
        selectorRen.enabled = false;
        hideAbilities();
        if (attackTargets == null)
        {
            attackTargets = new List <CombatCharacter> ();
        }
        if (targetsRemaining == 0)
        {
            removeTargetSelectors();
            currentStage = turnStages.moving;
            attacker.updateEntityAnimation("move");
            return;
        }
        if (targetSelectorButtonObjs == null)
        {
            targetSelectorButtonObjs = new List <GameObject> ();
            List <CombatCharacter> selectableCharacters;
            if (attack.isAssist)
            {
                selectableCharacters = attackChars;
            }
            else if (attack.isGorrila)                 //[Un-Two] this statement detects if the attack is from the Gorrila and if it is will randomly select to target players or enemies
            {
                Debug.Log("Gorrila Attack");
                if (Random.Range(0, 10) <= 3)
                {
                    Debug.Log("Hit Players");
                    selectableCharacters = attackChars;
                }
                else
                {
                    Debug.Log("Hit Enemies");
                    selectableCharacters = defendChars;
                }
            }
            else
            {
                selectableCharacters = defendChars;
            }

            foreach (CombatCharacter character in selectableCharacters)
            {
                if (character.isAlive())
                {
                    GameObject newButtonObj = Instantiate(canvasObj.transform.Find("ReferenceTargetButton").gameObject, canvasObj.transform);
                    newButtonObj.transform.position = character.entity.transform.position;
                    newButtonObj.SetActive(true);
                    targetSelectorButtonObjs.Add(newButtonObj);
                    UnityEngine.UI.Button newButton = newButtonObj.GetComponent <UnityEngine.UI.Button> ();
                    CombatCharacter       tempValue = character;               // necessary to deal with weird scoping
                    newButton.onClick.AddListener(delegate {
                        selectTarget(tempValue);
                    });
                }
            }
        }
    }
Example #18
0
    public override void Use(Battle battle)
    {
        CombatCharacter currentPawn = battle.GetCharacter();

        currentPawn.Health.Heal(info.PrimaryValue);

        base.Use(battle);
    }
Example #19
0
    public override void Use(Battle battle)
    {
        CombatCharacter enemy = battle.GetCharacter(false);

        enemy.StunnedTime = info.PrimaryValue;

        base.Use(battle);
    }
Example #20
0
 // Use this for initialization
 void Start()
 {
     Tooltip[] children = (CombatCharacter.Player() as AnimagusCharacter).animagusTrack.GetComponentsInChildren <Tooltip>();
     for (int i = 0; i < children.Length; i++)
     {
         setTooltip(children[i], i);
     }
 }
Example #21
0
    public bool checkDodge(CombatCharacter source)
    {
        float rng = Random.Range(0, 100);

        float hitChance = rng + source.accuracy - this.avoidance;

        return(hitChance < 100);
    }
Example #22
0
 public void doEffect(CombatCharacter character)
 {
     if (type == effectType.abilityPerTurn)
     {
         List <CombatCharacter> characterList = new List <CombatCharacter> ();
         characterList.Add(character);
         ability.doAbility(characterList, character);
     }
 }
Example #23
0
 // function called when a target is clicked during the target selection phase
 void selectTarget(CombatCharacter target)
 {
     if (attackTargets == null)
     {
         attackTargets = new List <CombatCharacter> ();
     }
     attackTargets.Add(target);
     targetsRemaining -= 1;
 }
Example #24
0
 public void handleEnemyDeath(CombatCharacter enemy)
 {
     charactersInCombat.Remove(enemy);
     if (charactersInCombat.Count == 1)
     {
         gameStarted = false;
         AdventureController.Instance().victoryAnimation();
     }
 }
Example #25
0
    public void incrementPhase()
    {
        EventManager.TriggerEvent(getEndPhaseTrigger(currentPhase, activeCharacter().gameObject.GetInstanceID()));
        bool grabNextPhase = false;

        foreach (Phase phase in Enum.GetValues(typeof(Phase)))
        {
            if (grabNextPhase)
            {
                currentPhase  = phase;
                grabNextPhase = false;
                break;
            }
            else if (phase == currentPhase)
            {
                grabNextPhase = true;
            }
        }

        if (grabNextPhase)
        {
            while (true)
            {
                currentCharacterTurnIndex++;
                if (currentCharacterTurnIndex >= charactersInCombat.Count)
                {
                    currentCharacterTurnIndex = 0;
                }
                if (activeCharacter() != null)
                {
                    break;
                }
            }
            currentPhase = startPhase;
            turnNumber++;
        }

        setContinueButton(false);
        if (activeCharacter().playerCharacter)
        {
            if (currentPhase == Phase.Action)
            {
                setContinueButton(true);
            }
        }
        else if (!activeCharacter().playerCharacter)
        {
            if (currentPhase == Phase.End &&
                CombatCharacter.Player().hasFastCard())
            {
                setContinueButton(true);
            }
        }
        phaseText.text = currentPhase.ToString();
        EventManager.TriggerEvent(getGenericStartPhaseTrigger());
        EventManager.TriggerEvent(getStartPhaseTrigger(currentPhase, activeCharacter().gameObject.GetInstanceID()));
    }
Example #26
0
    public void loadPlayerInfo()
    {
        CombatCharacter player = GameObject.FindGameObjectWithTag("Player").GetComponent <CombatCharacter>();

        player.health = currentHealth;
        player.equipItem(weapon);
        player.equipItem(armor);
        player.deck = deck;
    }
Example #27
0
 private void Update()
 {
     if (!targetSource.character.playerCharacter)
     {
         if (targetCatgeory == TargetCategory.Enemy)
         {
             TurnMaster.Instance().checkTargetListener(CombatCharacter.Player());
         }
     }
 }
Example #28
0
 public void doEffect(CombatCharacter character)
 {
     if (type == effectType.abilityPerTurn)
     {
         this.modifier = modifier * character.GetLevel(character.Name);
         List <CombatCharacter> characterList = new List <CombatCharacter> ();
         characterList.Add(character);
         ability.doAbility(characterList, character);
     }
 }
Example #29
0
 public override void TakeDamage(CombatCharacter attacker)
 {
     if (!Invincible)
     {
         _gameManager.AudioManager.PlayerAudioSource.clip = hurt;
         _gameManager.AudioManager.PlayerAudioSource.Play();
         base.TakeDamage(attacker);
         StartCoroutine(Hurt());
     }
 }
Example #30
0
 public void changeEquipStatus(CombatCharacter character, int multi)
 {
     character.avoidance += avoidanceMod * multi;
     character.armor     += armorMod * multi;
     character.accuracy  += accuracyMod * multi;
     character.otherSourcesActionTurnAmountValue   += actionMod * multi;
     character.otherSourcesEnergyTurnAmountValue   += energyMod * multi;
     character.otherSourcesCardDrawTurnAmountValue += cardsMod * multi;
     character.otherSourcesFocusTurnAmountValue    += focusMod * multi;
     changeUniqueStatus(character, multi);
 }
Example #31
0
    public void highlightAttackSquares(CombatCharacter fighter, int range)
    {
        int[,] squareDistances = new int[height, width];
        for(int i = 0; i < height; i++) {
            for(int j = 0; j < width; j++)
                squareDistances[i, j] = -1;
        }

        SquareIcon curSquare = board[fighter.row, fighter.col];
        Queue<SquareIcon> sqQueue = new Queue<SquareIcon>();
        sqQueue.Enqueue(curSquare);
        List<SquareIcon> neighborList;
        squareDistances[curSquare.row, curSquare.col] = 0;
        while(sqQueue.Count != 0) {
            curSquare = sqQueue.Dequeue();

            neighborList = getNeighbors(curSquare);
            foreach(SquareIcon sqIcon in neighborList) {
                if ((squareDistances[sqIcon.row, sqIcon.col] == -1) && (squareDistances[curSquare.row, curSquare.col] < range)) {
                    squareDistances[sqIcon.row, sqIcon.col] = squareDistances[curSquare.row, curSquare.col] + 1;
                    sqQueue.Enqueue (sqIcon);
                }
            }
        }

        for(int i = 0; i < height; i++) {
            for(int j = 0; j < width; j++)
                if ((squareDistances[i,j] != -1) && squareDistances[i,j] <= range){
                    if(board[i, j].curChar != null){
                        board[i, j].highlightForTarget();
                    }
                    else{
                        board[i, j].highlightForAttack();
                    }
                }
        }
        board[fighter.row, fighter.col].highlightForActive();
    }
Example #32
0
 public virtual void executeAbility(CombatBoard board, CombatCharacter currentFighter, SquareIcon targetSquare)
 {
 }
Example #33
0
    public void highlightMoveSquares(CombatCharacter fighter)
    {
        int[,] squareDistances = new int[height, width];
        for(int i = 0; i < height; i++) {
            for(int j = 0; j < width; j++)
                squareDistances[i, j] = -1;
        }

        SquareIcon curSquare = board[fighter.row, fighter.col];
        Queue<SquareIcon> sqQueue = new Queue<SquareIcon>();
        sqQueue.Enqueue(curSquare);
        List<SquareIcon> neighborList;
        squareDistances[curSquare.row, curSquare.col] = 0;
        while(sqQueue.Count != 0) {
            curSquare = sqQueue.Dequeue();

            neighborList = getNeighbors(curSquare);
            foreach(SquareIcon sqIcon in neighborList) {
                if ((squareDistances[sqIcon.row, sqIcon.col] == -1) && (squareDistances[curSquare.row, curSquare.col] < fighter.speed) && (sqIcon.canPass ())) {
                    squareDistances[sqIcon.row, sqIcon.col] = squareDistances[curSquare.row, curSquare.col] + 1;
                    sqQueue.Enqueue (sqIcon);
                }
            }
        }

        for(int i = 0; i < height; i++) {
            for(int j = 0; j < width; j++)
                if ((squareDistances[i,j] != -1) && squareDistances[i,j] <= fighter.speed)
                    board[i, j].highlightForMove();
        }
        board[fighter.row, fighter.col].highlightForActive();
    }
Example #34
0
 public virtual string abilitySummary(CombatCharacter curFighter)
 {
     return null;
 }
Example #35
0
 public void setFighterLocation(CombatCharacter fighter, int r, int c)
 {
     board[fighter.row, fighter.col].curChar = null;
     fighter.row = r;
     fighter.col = c;
     board[r, c].curChar = fighter;
     fighter.transform.position = board[r, c].transform.position;
 }