示例#1
0
    void Start()
    {
        animations       = GetComponent <Animator>();
        spriteController = GetComponent <SpriteRenderer>();

        // initiates stats
        TotalHp     = baseHp;
        TotalAttack = baseAttack;
        CurrentHp   = TotalHp;

        EnableMovement = true;
        EnableAttack   = true;

        // initial positioning
        spawnPoint         = GameObject.Find("GladiatorSpawn").transform;
        transform.position = new Vector2(spawnPoint.position.x, spawnPoint.position.y);
        position           = transform.position;
        newPosition        = position;

        // creates all the skills
        slashSkill    = new Slash(slashButton, slash);
        whirlingSkill = new Whirling(whirlingButton, whirling);
        sonicSkill    = new Sonic(sonicButton, sonic);
        defendSkill   = new Defend(defendButton, defend);
        blindingSkill = new Blinding(blindingButton, blinding);
    }
示例#2
0
 // Use this for initialization
 void Start()
 {
     Attack.init();
     Defend.init();
     Jump.init();
     Skill.init();
 }
示例#3
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        Defend defend = collision.collider.GetComponent <Defend>();

        Debug.Log(defend);
        defend?.TakeDamage(combatStats.Attack);
    }
示例#4
0
 void CheckAllButtonState()
 {
     Attack.CheckButtonState();
     Defend.CheckButtonState();
     Jump.CheckButtonState();
     Skill.CheckButtonState();
 }
示例#5
0
        public void MergeFrom(EncounterInteractCombatStageOptions other)
        {
            if (other == null)
            {
                return;
            }
            switch (other.TypeCase)
            {
            case TypeOneofCase.Attack:
                if (Attack == null)
                {
                    Attack = new global::WUProtos.Data.Encounter.EncounterInteractCombatStageOptions.Types.Attack();
                }
                Attack.MergeFrom(other.Attack);
                break;

            case TypeOneofCase.Defend:
                if (Defend == null)
                {
                    Defend = new global::WUProtos.Data.Encounter.EncounterInteractCombatStageOptions.Types.Defend();
                }
                Defend.MergeFrom(other.Defend);
                break;

            case TypeOneofCase.AutoAdvance:
                if (AutoAdvance == null)
                {
                    AutoAdvance = new global::WUProtos.Data.Encounter.EncounterInteractCombatStageOptions.Types.AutoAdvance();
                }
                AutoAdvance.MergeFrom(other.AutoAdvance);
                break;
            }

            _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
        }
示例#6
0
        /**
         * create the list of action use in the game
         * set the logo for each action
         */
        public List <Action> GetActionList()
        {
            List <Action> actionList = new List <Action>();

            foreach (ACTION_TYPE type in ActionInTimeline)
            {
                switch (type)
                {
                case ACTION_TYPE.ATTACK:
                {
                    Attack attack = new Attack();
                    attack.actionLogo = attackLogo;
                    actionList.Add(attack);
                }
                break;

                case ACTION_TYPE.DEFEND:
                {
                    Defend defend = new Defend();
                    defend.actionLogo = defendLogo;
                    actionList.Add(defend);
                }
                break;

                case ACTION_TYPE.CURSE:
                {
                    Curse curse = new Curse();
                    curse.actionLogo = curseLogo;
                    actionList.Add(curse);
                }
                break;

                case ACTION_TYPE.MOVE_ENEMY:
                {
                    MoveEnemy moveEnemy = new MoveEnemy();
                    moveEnemy.actionLogo = moveEnemyLogo;
                    actionList.Add(moveEnemy);
                }
                break;

                case ACTION_TYPE.SPAWN_ENEMY:
                {
                    SpawnEnemy spawnEnemy = new SpawnEnemy();
                    spawnEnemy.actionLogo = spawnEnemyLogo;
                    actionList.Add(spawnEnemy);
                }
                break;

                case ACTION_TYPE.SPAWN_FOW:
                {
                    SpawnFOW spawnFOW = new SpawnFOW();
                    spawnFOW.actionLogo = spawnFOWLogo;
                    actionList.Add(spawnFOW);
                }
                break;
                }
            }
            return(actionList);
        }
示例#7
0
    public void TestInit()
    {
        int defense = 5;
        int bonus   = 5;

        Defend defend = new Defend(null, defense, bonus, null, null);

        Assert.AreEqual(defense, defend.Defense);
    }
    public EnemyDecisionTree(Enemy agent)
    {
        advance   = new Advance(agent);
        breakWall = new BreakWall(agent);
        attack    = new Attack(agent);
        defend    = new Defend(agent);

        wallInWay         = new BooleanDecision(breakWall, advance);
        defenderAttacking = new BooleanDecision(defend, attack);
        defenseInRange    = new BooleanDecision(defenderAttacking, wallInWay);

        start = defenseInRange;
    }
    private void setPlayerObject()
    {
        if(gameObject.CompareTag("PlayerOneUI")) {
            playerAttack = GameObject.FindGameObjectWithTag("PlayerOne").GetComponent<Attack>();
            playerDefend = GameObject.FindGameObjectWithTag("PlayerOne").GetComponent<Defend>();
        } else if(gameObject.CompareTag("PlayerTwoUI")) {
            playerAttack = GameObject.FindGameObjectWithTag("PlayerTwo").GetComponent<Attack>();
            playerDefend = GameObject.FindGameObjectWithTag("PlayerTwo").GetComponent<Defend>();
        }
        else Debug.Log("Could not set player.");

        gameObject.transform.rotation = playerAttack.transform.rotation;
    }
示例#10
0
    Advance advance;     // move towards next target
    #endregion

    /// <param name="agent">the agent to act upon</param>
    public EnemyDecisionTree(BasicEnemy agent)
    {
        advance   = new Advance(agent);
        breakWall = new BreakWall(agent);
        attack    = new Attack(agent);
        defend    = new Defend(agent);

        wallInWay         = new BooleanDecision(breakWall, advance);
        defenderAttacking = new BooleanDecision(defend, attack);
        defenseInRange    = new BooleanDecision(defenderAttacking, wallInWay);

        start = defenseInRange;

        // subscribe update method to game events
    }
示例#11
0
        public async Task Defend(long unitId, string operation)
        {
            var enemy = await this.Context.GeneratedEnemies.FindAsync(unitId);

            var action = new Defend();

            if (operation == "execute")
            {
                action.Execute(enemy);
            }
            else
            {
                action.Stop(enemy);
            }

            await this.SaveAsync();
        }
示例#12
0
    public void TestDefend()
    {
        Character     mockTarget    = new Mock <Character>("name", 100, 1).Object;
        Mock <Weapon> mockWeapon    = new Mock <Weapon>("name", 0, 0, 0, 0, 0, 0, 0);
        int           weaponDefense = 5;
        int           weaponBonus   = 15;

        mockWeapon.Setup(weapon => weapon.Defense).Returns(weaponDefense);
        mockWeapon.Setup(weapon => weapon.BonusDefense).Returns(weaponBonus);
        character.EquipWeapon(mockWeapon.Object);

        Defend defend = character.Defend(mockTarget);

        defend.Use();

        Assert.AreSame(character, defend.Actor);
        Assert.AreSame(mockTarget, defend.Targets[0]);
        Assert.AreEqual(weaponDefense, defend.Defense);
        Assert.AreEqual(weaponBonus, defend.Bonus);
        mockCombatHandler.Verify(handler => handler.OnDefend());
    }
示例#13
0
 public Warrior(string characterType, int level) : base(characterType, level)
 {
     CurrentHealth         = level * level * 10;
     MaxHealth             = level * level * 10;
     Damage                = 1.8;
     MaxDamage             = Damage;
     Defense               = 100;
     MaxDefense            = Defense;
     Energy                = 0;
     EnergyFillRate        = 5;
     CurrentQueueSize      = 0;
     MaxQueueSize          = 3;
     CriticalPercentage    = 15;
     MaxCriticalPercentage = CriticalPercentage;
     MissPercentage        = 10;
     MaxMissPercentage     = MissPercentage;
     ExperienceMultiplier  = 1.0;
     GoldMultiplier        = 1.0;
     attackOne             = new Attack();
     attackTwo             = new PowerAttack();
     attackThree           = new Defend();
     attackFour            = new Crush();
 }
示例#14
0
文件: unit.cs 项目: ciarano84/barony
    public void SetActions()
    {
        //Dash
        Dash da = new Dash();

        da.SetActionButtonData(this);
        actions.Add(da);
        dash = da;

        //Defend
        Defend df = new Defend();

        df.SetActionButtonData(this);
        actions.Add(df);
        defend = df;

        //Prime
        Prime pr = new Prime();

        pr.SetActionButtonData(this);
        actions.Add(pr);
        prime = pr;
    }
示例#15
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (typeCase_ == TypeOneofCase.Attack)
            {
                hash ^= Attack.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.Defend)
            {
                hash ^= Defend.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.AutoAdvance)
            {
                hash ^= AutoAdvance.GetHashCode();
            }
            hash ^= (int)typeCase_;
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
示例#16
0
        public void Handle(Selector selector, Player p1, Player p2, Field p1Field, Field p2Field,
                           KeyboardState state, KeyboardState previousState)
        {
            if (state.IsKeyDown(Keys.Right) && previousState.IsKeyUp(Keys.Right))
            {
                selector.action          = SelectedAction.DEFEND;
                selector.defaultPosition = selectorPositions[1];
            }
            else if (state.IsKeyDown(Keys.Left) && previousState.IsKeyUp(Keys.Left))
            {
                selector.action          = SelectedAction.ATTACK;
                selector.defaultPosition = selectorPositions[0];
            }
            else if (state.IsKeyDown(Keys.Up) && previousState.IsKeyUp(Keys.Up)) // same as left
            {
                selector.action          = SelectedAction.ATTACK;
                selector.defaultPosition = selectorPositions[0];
            }
            else if (state.IsKeyDown(Keys.Down) && previousState.IsKeyUp(Keys.Down))
            {
                selector.action          = SelectedAction.SACRIFICE;
                selector.defaultPosition = selectorPositions[2];
            }

            // Select Action
            if (state.IsKeyDown(Keys.Enter) && previousState.IsKeyUp(Keys.Enter))
            {
                if (selector.action.Equals(SelectedAction.ATTACK))
                {
                    if (selector.selected is MonsterCard)
                    {
                        selector.attacking = (MonsterCard)selector.selected;
                        if (selector.attacking.canAttack && (p1.currentPhase.Equals(Phase.BATTLE) || p1.currentPhase.Equals(Phase.MAIN)))
                        {
                            selector.attacking.mode = MonsterPosition.ATTACK;
                            selector.state          = SelectedState.ATTACKING;
                        }
                        else
                        {
                            selector.attacking = null;
                            selector.state     = SelectedState.P1_MONSTER_ZONE;
                        }
                    }
                }
                else if (selector.action.Equals(SelectedAction.DEFEND))
                {
                    Defend.Apply(p1, p1Field, (MonsterCard)selector.selected);
                    selector.state = SelectedState.P1_MONSTER_ZONE;
                }
                else if (selector.action.Equals(SelectedAction.SACRIFICE))
                {
                    Sacrifice.Apply(p1, p1Field, (MonsterCard)selector.selected, selector.index);
                    selector.state = SelectedState.P1_MONSTER_ZONE;
                }
                selector.selected        = p1Field.monsterZone[selector.index];
                selector.defaultPosition = p1Field.monsterPositions[selector.index];
            }
            else if (state.IsKeyDown(Keys.Back) && previousState.IsKeyUp(Keys.Back))
            {
                selector.state  = SelectedState.P1_MONSTER_ZONE;
                selector.action = SelectedAction.NONE;
            }
        }
示例#17
0
 /// <summary>
 /// CreatBoard - Reseta a Board Attack e Defesa do Jogador
 /// </summary>
 public void CreatBoard()
 {
     Attack.ResetBoard();
     Defend.ResetBoard();
 }
示例#18
0
    private IEnumerator Turn(Character attacker, Character defender)
    {
        // Initialization
        state    = BattleState.InGame;
        atkIndex = -1;
        defIndex = -1;

        // Updata attacker's pool and generate attack choices randomly
        UpdatePool(attacker);
        List <Attack> attackChoices = GenerateAttackChoices(attacker);

        // - If the attacker is player
        // 1. Enable buttons and update their texts
        // 2. Block until player selects
        // 3. After player selects, disable buttons
        // - Else
        // 1. Defender randomly selects one attack
        if (attacker.isPlayer)
        {
            int i = 0;
            for (; i < attackChoices.Count; i += 1)
            {
                uim.RemoveEventBtnListeners(i);
                int index = i;
                uim.AddEventBtnListener(i, delegate { OnSelect(index); });
                uim.SetEventBtnText(i, attackChoices[i].choice);
            }
            for (; i < uim.GetEventBtnsNumber(); i += 1)
            {
                uim.RemoveEventBtnListeners(i);
            }
            // uim.SetEventInfo("你想要如何进攻:\n", true);

            atkIndex = -1;
            yield return(new WaitWhile(() => atkIndex == -1));
        }
        else
        {
            atkIndex = Random.Range(0, attackChoices.Count);
        }

        // Get attack choice and show text
        Attack atkChoice = attackChoices[atkIndex];

        uim.SetEventInfo(atkChoice.description.ToBattleString(attacker, defender) + "\n", true);

        // Updata defender's pool and generate defend choices randomly
        UpdatePool(defender);
        List <Defend> defendChoices = GenerateDefendChoices(defender, atkChoice.types);

        // - If the attacker is player
        // 1. Enable buttons and update their texts
        // 2. Block until player selects
        // 3. After player selects, disable buttons
        // - Else
        // 1. Defender randomly selects one attack
        if (defender.isPlayer)
        {
            int i = 0;
            for (; i < defendChoices.Count; i += 1)
            {
                uim.RemoveEventBtnListeners(i);
                int index = i;
                uim.AddEventBtnListener(i, delegate { OnSelect(index); });
                uim.SetEventBtnText(i, defendChoices[i].description.ToBattleString(attacker, defender));
            }
            for (; i < uim.GetEventBtnsNumber(); i += 1)
            {
                uim.RemoveEventBtnListeners(i);
            }
            // uim.SetEventInfo("你想要如何防御:\n", true);

            defIndex = -1;
            yield return(new WaitWhile(() => defIndex == -1));
        }
        else
        {
            defIndex = Random.Range(0, defendChoices.Count);
        }

        // Get defend choice
        Defend defChoice = defendChoices[defIndex];

        // Calculate result
        float totalProb = 0f;

        foreach (int resultID in defChoice.results)
        {
            totalProb += Data.AllResults[resultID].param;
        }
        float  randProb = Random.Range(0f, totalProb);
        Result result   = new Result(-1);

        foreach (int resultID in defChoice.results)
        {
            result    = Data.AllResults[resultID];
            randProb -= result.param;
            if (randProb <= 0f)
            {
                break;
            }
        }

        // Process result
        defender.GetDamage(result.atkFactor * atkChoice.pDamage, result.atkFactor * atkChoice.mDamage);

        // Show result's text
        uim.SetEventInfo(result.description.ToBattleString(attacker, defender) + "\n", true);
        // Show enemy's hp (only in demo)
        // string hpStr = defender.currentProperty.hp.ToString() + " / " + defender.originalProperty.hp.ToString();
        // uim.SetEventInfo(defender.name + "的血量 : " + hpStr + "\n", true);

        // Add sepration text
        uim.SetEventInfo("--------------------\n", true);
    }
示例#19
0
    private void ChooseAction()
    {
        actionSelectionEffectController.ActivateSpriteObjects();

        if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            if (actionChoice == 0)
            {
                actionChoice = 0;
            }
            else
            {
                actionChoice -= 1;
            }
        }
        else if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            if (actionChoice == 3)
            {
                actionChoice = 3;
            }
            else
            {
                actionChoice += 1;
            }
        }

        actionSelectionEffectController.ChangeSprite(actionChoice);

        if (Input.GetKeyDown(KeyCode.Z))
        {
            if (actionChoice == 0)
            {
                // Normal Attack
                myAction[indexOfAction] = new Attack(selectedAlly);
            }
            else if (actionChoice == 1)
            {
                // Normal Defend
                myAction[indexOfAction] = new Defend(selectedAlly);

                // if not the end of ally action, continue to another ally
                currentState = SelectionState.ALLY;

                // after chose action, check if current ally list is zero => means no more available ally to choose
                // if correct, end the phase and disable self
                if (currentAllyList.Count <= 0)
                {
                    GameStateManager.Instance.SetGameState(GameState.BATTLE_PHASE);
                    this.enabled = false;
                }

                // quit running rest of the code since no need to choose target
                return;
            }
            else if (actionChoice == 2)
            {
                currentState = SelectionState.SKILL_SELECTION;

                return;
            }
            else if (actionChoice == 3)
            {
                // Run
                myAction[indexOfAction] = new Run(selectedAlly);
                // Deactivate this script as battle ends
                this.enabled = false;

                // quit running rest of the code since girl runs away
                // change to battle phase for run action
                GameStateManager.Instance.SetGameState(GameState.BATTLE_PHASE);
            }

            actionSelectionEffectController.DeactivateSpriteObjects();

            currentState = SelectionState.TARGET;

            // debug
            Debug.Log("Selected Action: " + myAction[indexOfAction]);
        }
    }
示例#20
0
        public override void GenerateAbstractQuests(int maxDepth)
        {
            this.Quests.questgiver = this.questgiver;
            Random r = new Random();

            switch (r.Next(7))
            {
            case 0:
                //Attack threatening entities
                this.sqName = "Attack threatening entities";
                this.AddQuest(new GoTo(0, maxDepth));
                this.AddQuest(new Damage());
                this.AddQuest(new GoTo(2, maxDepth));
                Quest q = new Report();
                q.QuestText.Add("We need to make sure we're safe.");
                this.AddQuest(q);
                break;

            case 1:
                //Treat or Repair 1
                this.sqName = "Treat";
                this.AddQuest(new Get(0, maxDepth));
                this.AddQuest(new GoTo(2, maxDepth));
                Quest report = new Use();
                report.QuestText.Add(" to treat his wounds.");
                this.AddQuest(report);
                break;

            case 2:
                //Treat or Repair 2
                this.sqName = "Repair";
                this.AddQuest(new GoTo(0, maxDepth));
                Quest give = new Repair();
                give.QuestText.Add("Once it's repaired, everyone should feel safer.");
                this.AddQuest(give);
                break;

            case 3:
                //Create Diversion
                this.sqName = "Create Diversion";
                this.AddQuest(new Get(0, maxDepth));
                this.AddQuest(new GoTo(1, maxDepth));
                Quest use = new Use();
                use.QuestText.Add(" create a diversion.");
                this.AddQuest(use);
                break;

            case 4:
                //Create Diversion 2
                this.sqName = "Create Diversion 2";
                this.AddQuest(new GoTo(1, maxDepth));
                Quest damage = new Damage();
                damage.QuestText.Add(" to create a diversion.");
                this.AddQuest(damage);
                break;

            case 5:
                //Guard Entity
                this.sqName = "Guard entity";
                this.AddQuest(new GoTo(0, maxDepth));
                Quest def = new Defend();
                this.AddQuest(def);
                break;

            case 6:
                //Assemble Fortification
                this.sqName = "Assemble fortification";
                this.AddQuest(new GoTo(0, maxDepth));
                Quest rep = new Repair();
                rep.QuestText.Add("I hope we can use it to defend ourselves.");
                this.AddQuest(rep);
                break;
            }
        }
示例#21
0
 protected virtual void OnDefend(GameActionEventArgs a, GameLogEventArgs l)
 {
     Defend?.Invoke(this, a);
     DefendLog?.Invoke(this, l);
 }
示例#22
0
 // Start is called before the first frame update
 void Start()
 {
     defend       = GetComponent <Defend>();
     lineRenderer = GetComponentInChildren <LineRenderer>();
 }
示例#23
0
    public static Effect GetEffect(string param)
    {
        if (effects.ContainsKey(param))
        {
            return(effects[param]);
        }
        string[] p = param.Split(' ');
        switch (p[0])
        {
        case "Bleed":
            effects[param] = new Bleed(int.Parse(p[1]), int.Parse(p[2]));
            break;

        case "Counter":
            effects[param] = new Counter(float.Parse(p[1]), int.Parse(p[2]));
            break;

        case "Heal":
            effects[param] = new Heal(int.Parse(p[1]));
            break;

        case "Defend":
        case "Defense":
            effects[param] = new Defend(int.Parse(p[1]));
            break;

        case "Mark":
            effects[param] = new Mark(int.Parse(p[1]));
            break;

        case "Push":
        case "Pull":
            effects[param] = new PushPull(int.Parse(p[1]));
            break;

        case "Move":
            effects[param] = new Move();
            break;

        case "MoveSelf":
            effects[param] = new MoveSelf();
            break;

        case "Dodge":
        case "Damage":
        case "Crit":
        case "Acc":
        case "Speed":
        case "StressResist":
            effects[param] = new StatBuff(p[0], float.Parse(p[1]), int.Parse(p[2]));
            break;

        case "Block":
            effects[param] = new Block(int.Parse(p[1]), int.Parse(p[2]));
            break;

        case "Stun":
            effects[param] = new Stun();
            break;

        case "Suprise":
            effects[param] = new Suprise();
            break;

        case "Stress":
        case "StressHeal":
            effects[param] = new Stress(int.Parse(p[1]));
            break;

        case "Cleanse":
            effects[param] = new Cleanse();
            break;

        case "Guard":
            return(new Guard(int.Parse(p[1])));

        case "Metal":
            return(new Metal(int.Parse(p[1])));

        default:
            Debug.Log(param);
            break;
        }
        return(effects[param]);
    }
示例#24
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        Defend defend = collision.GetComponent <Defend>();

        defend?.TakeDamage(combatStats.Attack);
    }