Exemple #1
0
    //when the attack 1 button is pushed, have the monster shoot a sample of the attack
    public void Attack1Btn()
    {
        MonsterAttack attack = monster.info.baseAttack1.attack;

        monster.GetComponent <Tower>().attackNumber = 1;
        monster.monsterMotion.SetBool("isAttacking", true);
        monster.GetComponent <Tower>().isAttacking = true;
        monster.GetComponent <Tower>().boneStructure.GetComponent <MotionControl>().AttackModeCheck(attack.attackMode);
        monster.isAttacking = true;


        ////get a list of all of the animation events on the monster.
        //AnimationClip[] clips = monster.monsterMotion.runtimeAnimatorController.animationClips;
        //for (int i = 0; i < clips.Length; i++)
        //{
        //    //get a list of all animations that have at least 1 event
        //    if (clips[i].events.Length > 0)
        //    {
        //        AnimationEvent[] evt = clips[i].events;
        //        for (int e = 0; e < clips[i].events.Length; e++)
        //        {
        //            //figure out where the "start attack" event is, and delay the attack by this amount, so that the attack spawns when the attack animation tells it to
        //            if (evt[e].functionName == "StartAttack")
        //            {
        //                StartCoroutine(Attack1(evt[e].time));
        //                return;
        //            }
        //        }
        //    }
        //}
    }
 // Start is called before the first frame update
 void Start()
 {
     gsm        = GameObject.FindGameObjectWithTag("GameStateMachine").GetComponent <GameStateMachine>();
     monsterMov = GetComponent <MonsterMovement>();
     mb         = GetComponent <MonsterBrain>();
     ma         = GetComponent <MonsterAttack>();
 }
Exemple #3
0
    void OnTriggerEnter(Collider other)
    {
        Monster m = gameObject.transform.parent.transform.parent.GetComponent <Monster>();

        if (other.gameObject.CompareTag(Game.TAG_BOARD))
        {
        }

        //else if (other.gameObject.CompareTag("CubeMonster"))
        else if (other.gameObject.CompareTag(Game.TAG_MONSTER))
        {
            //Monster enemy = other.transform.parent.transform.parent.GetComponent<Monster>();
            Monster enemy = FindObjScript.GetObjScriptFromCollider <Monster>(other);
        }
        else if (other.gameObject.CompareTag(Game.TAG_BULLET))
        {
            //MonsterAttack bullet = other.transform.parent.transform.parent.GetComponent<MonsterAttack>();
            MonsterAttack bullet = FindObjScript.GetObjScriptFromCollider <MonsterAttack>(other);
            //if (!m.Equals(bullet.Owner))
            if (bullet.Owner != null && !m.Group.Equals(bullet.Owner.Group))
            {
                bullet.ApplyDamage(m);
            }
        }
    }
Exemple #4
0
    private MonsterAttack InstanceMonsterAttack()
    {
        MonsterAttack obj = Instantiate(objectToPool).GetComponent <MonsterAttack>();

        obj.gameObject.SetActive(false);
        pooledObjects.Add(obj);
        return(obj);
    }
Exemple #5
0
    //when the attack 2 button is pushed, have the monster shoot a sample of the attack
    public void Attack2Btn()
    {
        MonsterAttack attack = monster.info.baseAttack2.attack;

        monster.GetComponent <Tower>().attackNumber = 2;
        monster.monsterMotion.SetBool("isAttacking", true);
        monster.GetComponent <Tower>().isAttacking = true;
        monster.GetComponent <Tower>().boneStructure.GetComponent <MotionControl>().AttackModeCheck(attack.attackMode);
        monster.isAttacking = true;
    }
Exemple #6
0
    private void Awake()
    {
        mover    = GetComponent <MonsterMovement>();
        sight    = GetComponent <MonsterSight>();
        attacker = GetComponent <MonsterAttack>();

        maxHealth      = health;
        healthBar      = transform.GetChild(0).gameObject;
        healthBarValue = healthBar.transform.GetChild(0).gameObject;
        healthBar.SetActive(false);
    }
Exemple #7
0
    void InitialiseAttackColliders() //must be called before disabling colliders
    {
        MonsterAttack rightHand = RightHandCollider.AddComponent <MonsterAttack>();
        MonsterAttack leftHand  = LeftHandCollider.AddComponent <MonsterAttack>();

        rightHand.SetEnemy(this.gameObject);
        rightHand.SetDamage(AttackDamage);

        leftHand.SetEnemy(this.gameObject);
        leftHand.SetDamage(AttackDamage);
    }
Exemple #8
0
        public bool Attack(Point?target)
        {
            var zone = target == null?AttackZone.Select(x => Position + x).ToList() : new List <Point>
            {
                (Point)target
            };
            var attack   = AttackMethods.AttackConstructor(Type, this, zone);
            var isLethal = GetMap().IsLethalAttack(attack, zone);

            MonsterAttack?.Invoke(this, attack);
            return(isLethal);
        }
Exemple #9
0
    public void LoadMonster(Monster m, int atkNumber)
    {
        attackSelector.ClearOptions();


        activeMonster = m;
        attackNumber  = atkNumber;
        string activeAttack = "";

        if (atkNumber == 1)
        {
            activeAttack = activeMonster.info.attack1Name;
        }
        else if (atkNumber == 2)
        {
            activeAttack = activeMonster.info.attack2Name;
        }



        var monsters = GameManager.Instance.monstersData.monstersAllDict;
        var attacks  = GameManager.Instance.baseAttacks.attackDict;
        var type     = GameManager.Instance.monstersData.typeChartDict;


        List <string> attackList = new List <string>();
        List <TMP_Dropdown.OptionData> optionList = new List <TMP_Dropdown.OptionData>();

        //cycle through the monster's attacks that it can learn, then add all of those attacks, except the ones it already knows, to the dropdown list
        foreach (string attackName in monsters[activeMonster.info.species].baseAttacks)
        {
            if (activeMonster.info.attack1Name != attackName && activeMonster.info.attack2Name != attackName)
            {
                MonsterAttack           a          = attacks[attackName];
                TypeInfo                t          = type[a.type];
                TMP_Dropdown.OptionData optionData = new TMP_Dropdown.OptionData(attackName, type[a.type].typeSprite);

                optionList.Add(optionData);
            }
        }

        attackSelector.AddOptions(optionList);

        //for (int i = 0; i < optionList.Count; i++) {
        //    MonsterAttack a = attacks[attackSelector.options[i].text];
        //    TypeInfo t = type[a.type];
        //    //attackSelector.itemImage.
        //}


        DisplayAttackStats();
    }
Exemple #10
0
    public BaseAttack(MonsterAttack Attack, Monster Owner)
    {
        attack = Attack;
        owner  = Owner;

        //var attacks = GameManager.Instance.baseAttacks.attackDict;

        //attack = attacks[Attack.name];

        //Debug.Log(attack.range);

        SetAttack();
    }
Exemple #11
0
    public void RePooledObject(GameObject obj)
    {
        MonsterAttack attack = obj.GetComponent <MonsterAttack>();

        if (attack == null)
        {
            return;
        }
        obj.SetActive(false);
        _lastAvaiable.NextAvaiable = attack;
        attack.NextAvaiable        = null;
        _lastAvaiable = attack;
    }
Exemple #12
0
    // Start is called before the first frame update
    void Start()
    {
        MonsterAttack obj = InstanceMonsterAttack();

        _currentAvaiable = obj;
        for (int i = 1; i < DefaultInit; i++)
        {
            obj = InstanceMonsterAttack();
            _currentAvaiable.NextAvaiable = obj;
            _currentAvaiable = obj;
        }
        _currentAvaiable = pooledObjects[0];
        _lastAvaiable    = pooledObjects[pooledObjects.Count - 1];
    }
Exemple #13
0
    //recieve attacker information from the Tower Template script. holds data about the attack and attacker
    public void FromAttacker(MonsterAttack attack, string atkName, string atkType, float atkStat, int attackPower, int attackerLevel, float critChance, float critMod, Monster attackingMonster)
    {
        AtkPower = attackPower;
        AtkStat = atkStat;
        AttackerLevel = attackerLevel;
        AttackName = atkName;
        AttackType = atkType;
        CritChance = critChance;
        CritMod = critMod;
        attacker = attackingMonster;
        Attack = attack;

        //animator.speed = animator.speed + (animator.speed / Attack.attackTime);
    }
Exemple #14
0
    /// <summary>
    /// 实例化下一波作战单位
    /// </summary>
    public void InstUnits()
    {
        HealthUIManager.instance.ResetDepth();
        int[] ids = DungeonManager.enemyWave[wave];
        wave++;
        for (int i = 0; i < ids.Length; i++)
        {
            MonsterData monsterData = monsterDataDic[ids[i]];
            string      modelName   = Util.GetConfigString(monsterData.model);
            GameObject  child       = AssetManager.GetGameObject(modelName, battle_points[i]);
            if (monsterData.direction == 1)
            {
                child.transform.Rotate(new Vector3(0, 180, 0));
            }
            child.layer            = gameObject.layer;
            child.transform.parent = transform.parent;
            MonsterFightUnit unit = child.AddComponent <MonsterFightUnit>();
            fightUnits.Add(unit);
            unit.parentGroup = this;
            unit.orinPoint   = battle_points[i];
            unit.birthPoint  = battle_points [i];
            //父节点坐标不为0
            float x = battle_points[i].localPosition.x + battle_points[i].parent.localPosition.x;
            float y = battle_points[i].localPosition.y + battle_points[i].parent.localPosition.y;
            float z = battle_points[i].localPosition.z + battle_points[i].parent.localPosition.z;

            unit.birthPoint.localPosition = new Vector3(x, y, z);
            unit.birthPoint.localRotation = battle_points[i].localRotation;
            unit.birthPoint.localScale    = Vector3.one;

            //赋值战斗属性
            unit.monsterData = monsterData;
            unit.InitFightAttribute();
            //赋值技能id
            MonsterAttack monsterAttack = child.GetComponent <MonsterAttack>();
            monsterAttack.normalAttackId = (int)monsterData.attackID;
            JsonData data = JsonMapper.ToObject(Util.GetConfigString(monsterData.skill));
            monsterAttack.autoSkillsId = new int[data.Count];
            for (int num = 0; num < monsterAttack.autoSkillsId.Length; num++)
            {
                int id;
                int.TryParse(data[num].ToString(), out id);
                monsterAttack.autoSkillsId[num] = id;
            }
            //血条UI
            Transform healthBarPos = child.transform.Find("blood");
            HealthUIManager.instance.AddNewHealthBar(fightUnits[i], healthBarPos, group == GroupType.Enemy);
        }
    }
Exemple #15
0
    public GameObject GetPooledObject()
    {
        GameObject obj = _currentAvaiable.gameObject;

        _currentAvaiable = _currentAvaiable.NextAvaiable;
        if (_currentAvaiable.NextAvaiable == null)
        {
            MonsterAttack newAttack = InstanceMonsterAttack();
            _currentAvaiable.NextAvaiable = newAttack;
            _lastAvaiable = newAttack;
            Debug.Log("Extend bullet " + pooledObjects.Count);
        }
        obj.SetActive(true);
        return(obj);
    }
Exemple #16
0
        public bool MonsterAttacking(Battler user, Monster attacker, Monster defender, int attackerIndex, int defenderIndex)
        {
            user.HasMoved = true;
            BattleCardEventArgs args = new BattleCardEventArgs(user, GetOpponent(user), attacker, defender, attackerIndex, defenderIndex);

            ShowText(user.Name + "'s " + attacker.Name + " attacked " + GetOpponent(user).Name + "'s " + defender.Name + "!");

            MonsterAttack?.Invoke(this, args);

            if (args.DestroyTriggerer)
            {
                DestroyingMonster(args.TriggeringPlayer, (Monster)args.TriggeringCard, null, args.TriggeringCardIndex, -1);
            }
            if (args.Cancel || args.DestroyTriggerer)
            {
                return(false);
            }

            switch (((Monster)args.TriggeringCard).Battle((Monster)args.TargetedCard))
            {
            case MonsterAttackOutcome.WIN:
                if (DestroyingMonster(args))
                {
                    ChangingMana(args.TriggeringPlayer, args.TargetedCard.Level);
                }
                break;

            case MonsterAttackOutcome.LOSS:
                if (DestroyingMonster(args.NonTriggeringPlayer, args.TargetedCard, (Monster)args.TriggeringCard, args.TargetedCardIndex, args.TriggeringCardIndex))
                {
                    ChangingMana(args.NonTriggeringPlayer, args.TriggeringCard.Level);
                }
                break;

            case MonsterAttackOutcome.TIE:
                ShowText("...but neither claimed victory.");
                break;
            }

            return(true);
        }
Exemple #17
0
        private void PerformAttack()
        {
            MonsterAttack newAttack = BulletPooler.Instance.GetPooledObject().GetComponent <MonsterAttack>();

            bullets.Add(newAttack);
            newAttack.Owner = Host;
            newAttack.Initialize(new Vector3(
                                     Host.transform.localPosition.x,
                                     Host.transform.localPosition.y + Host.transform.localScale.y * 0.25f,
                                     Host.transform.localPosition.z),
                                 new Vector3(
                                     Host.TargetAttack.transform.localPosition.x,
                                     Host.TargetAttack.transform.localPosition.y + Host.TargetAttack.transform.localScale.y * 0.25f,
                                     Host.TargetAttack.transform.localPosition.z)
                                 , 0.5f);

            Host.OnDestroyNotify.Attach(o =>
            {
                newAttack.Owner = null;
            });
        }
    public static void PerformAction(Creature p, List <Monster> monster, Dungeon d)
    {
        foreach (Monster mon in monster.ToList())
        {
            StatusDamage(p, d, mon, monster);
        }
        foreach (Monster mon in monster.ToList())
        {
            if (mon.stun[0] > 0)
            {
                Console.WriteLine($"The {mon.name} is frozen!");
                break;
            }
            if (mon.stun[1] > 0)
            {
                Console.WriteLine($"The {mon.name} is stunned!");
                break;
            }
            switch (mon.monChoice)
            {
            case 0:
                MonsterAttack.Regular(p, mon, d);
                break;

            case 1:
                MonsterAttack.Special(p, d, mon, monster, 1);
                break;

            case 2:
                MonsterAttack.Special(p, d, mon, monster, 1);
                break;

            case 3:
                MonsterAttack.Special(p, d, mon, monster, 1);
                break;
            }
        }
    }
Exemple #19
0
    void InitMonsterInfo()
    {
        MonsterInfo.MonsterCharInfo monsterCharInfo;
        if (StageDataManager.Inst.nowStage == StageDataManager.StageNameEnum.STAGE_1_1)
        {
            monsterCharInfo.level          = 1;
            monsterCharInfo.maxHp          = 300;
            monsterCharInfo.defensive      = 10;
            monsterCharInfo.attack         = 70;
            monsterCharInfo.attackDistance = 2.5f;
            monsterCharInfo.speed          = 5.0f;
            m_monsterInfo = GetComponent <MonsterInfo>();
            m_monsterInfo.SetInfo(monsterCharInfo);
        }
        else if (StageDataManager.Inst.nowStage == StageDataManager.StageNameEnum.STAGE_1_2)
        {
            monsterCharInfo.level          = 1;
            monsterCharInfo.maxHp          = 700;
            monsterCharInfo.defensive      = 10;
            monsterCharInfo.attack         = 150;
            monsterCharInfo.attackDistance = 2.5f;
            monsterCharInfo.speed          = 5.0f;
            m_monsterInfo = GetComponent <MonsterInfo>();
            m_monsterInfo.SetInfo(monsterCharInfo);
        }
        m_monsterMove   = GetComponent <MonsterMove>();
        m_monsterAttack = GetComponent <MonsterAttack>();
        m_animFunction  = transform.GetComponentInChildren <AnimFuntion>();
        m_receiveDamage = GetComponent <ReceiveDamage>();
        m_monsterHpBar  = GetComponentInChildren <MonsterHpBar>();

        m_monsterPosition = Monster_Position.Monster_Position_Ground;

        m_monsterMove.SetSpeed(m_monsterInfo.speed);
        m_bLive = true;
    }
Exemple #20
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.transform.tag == "Player")
        {
            MonsterAttack attackAction = GetCurrentAction() as MonsterAttack;
            if (attackAction != null)
            {
                attackAction.OnHit();
            }
        }

        if (other.transform.tag == "Weapon")
        {
            MonsterState monsterDamegeState = GetCurrentState() as MonsterDamegeState;

            if (monsterDamegeState == null)
            {
                setState(MonsterStates.Damege);
                setAction(MonsterActions.Damage);
                monsterDamegeState = GetCurrentState() as MonsterDamegeState;
                monsterDamegeState.TakeDamege();
            }
        }
    }
Exemple #21
0
    //when the attack animation hits the enemy, deal the damage. this method is invoked from the AttackEffects script. Also gives information about the attacking monster, so if an enemy is destroyed, it can tell which monster destroyed it
    public void DealDamage(TypeChart atk, float damageMod, Monster attacker, float critChance, float critMod, MonsterAttack attack)
    {
        var statuses = GameManager.Instance.GetComponent <AllStatusEffects>().allStatusDict;

        float damageTaken = Mathf.Round(atk.totalDamage * damageMod);

        if (damageTaken <= 0)
        {
            damageTaken = 1;
        }

        float critRand   = Random.Range(0f, 100f);
        float rand       = Random.Range(0f, 100f);
        float statusRand = Random.Range(0f, 100f);


        //check to see if the attack misses by comparing the enemies' dodge stat with a number from 1-100. if the enemy dodges, deal 0 damage and spawn the word DODGE instead of a damage value
        if (rand >= monster.info.evasionBase)
        {
            monster.monsterMotion.SetBool("isHit", true);
            monster.monsterMotion.GetComponent <MotionControl>().IsHit(attack);



            //check and see if the attack is a critical hit, and if so, change the damage output and color of the font to indicate a crit
            if (critRand <= critChance)
            {
                damageTaken = damageTaken * (1 + critMod);
                //spawn the box to display damage done and change the properties
                var damage = Instantiate(damageText, transform.position, Quaternion.identity);
                damage.transform.SetParent(enemyCanvas.transform, false);
                damage.transform.position = new Vector3(transform.position.x, transform.position.y, 1f);
                damage.GetComponentInChildren <TMP_Text>().text  = "-" + damageTaken + "!";
                damage.GetComponentInChildren <TMP_Text>().color = Color.yellow;
                Destroy(damage, damage.GetComponent <Animator>().GetCurrentAnimatorStateInfo(0).length);
            }
            else
            {
                //spawn the box to display damage done and change the properties to signify a critical hit
                var damage = Instantiate(damageText, transform.position, Quaternion.identity);
                damage.transform.SetParent(enemyCanvas.transform, false);
                damage.transform.position = new Vector3(transform.position.x, transform.position.y, 1f);
                damage.GetComponentInChildren <TMP_Text>().text = "-" + damageTaken.ToString();
                Destroy(damage, damage.GetComponent <Animator>().GetCurrentAnimatorStateInfo(0).length);
            }


            //if the attack hits and it has a chance to inflict a secondary status, that is calculated here
            if (attack.effectName != "none")
            {
                if (statusRand <= attack.effectChance * 100)
                {
                    //checks if the monster is already inflicted with this status. if they are not, then the monster is now inflicted.
                    if (statuses.ContainsKey(attack.effectName))
                    {
                        if (monster.statuses.Contains(statuses[attack.effectName]))
                        {
                            //
                        }
                        else
                        {
                            monster.AddStatus(statuses[attack.effectName]);
                        }
                    }
                }
            }
        }
        else
        {
            monster.monsterMotion.SetBool("isDodge", true);

            //spawn the box to display damage done and change the properties to "DODGE" if the enemy succesfully evades
            var damage = Instantiate(damageText, transform.position, Quaternion.identity);
            damage.transform.SetParent(enemyCanvas.transform, false);
            damage.transform.position = new Vector3(transform.position.x, transform.position.y, 1f);
            damage.GetComponentInChildren <TMP_Text>().text = "Dodge!";
            Destroy(damage, damage.GetComponent <Animator>().GetCurrentAnimatorStateInfo(0).length);
            damageTaken = 0;
        }



        //call this to actually deal the damage afer its been calculated
        TakeDamage(damageTaken, attacker);
    }
Exemple #22
0
    protected override void Init()
    {
        base.Init();
        root = new BTPrioritySelector();   // 根节点首先是一个选择器

        // 转移条件
        MonsterCheckPlayerInRange playerInRange    = new MonsterCheckPlayerInRange(checkPlayerRange, PLAYER_NAME);
        MonsterCheckPlayerInRange playerNotInRange = new MonsterCheckPlayerInRange(checkPlayerRange, PLAYER_NAME, true);

        // 行为节点
        move = new MonsterMove(DESTINATION, moveSpeed);
        MonsterFindToTargetDestination findToTargetDestination = new MonsterFindToTargetDestination(PLAYER_NAME, PLAYERLOCATION, DESTINATION, ATKdistance);
        MonsterWait monsterWait = new MonsterWait();

        // 怪兽攻击
        MonsterAttack monsterAttack;

        if (myMonsterType == MonsterType.LongDistanceAttack)
        {
            monsterAttack = new MonsterLongDistanceAttacks(longDistanceATK);
        }
        else if (myMonsterType == MonsterType.MeleeAttack)
        {
            monsterAttack = new MonsterMeleeAttack(meleeATK);
        }
        else
        {
            monsterAttack = new MonsterAttack(meleeATK);     // 先暂时为近战的攻击力
        }
        MonsterRandomMoveDistance randomMoveDistance = new MonsterRandomMoveDistance(DESTINATION, moveX, moveZ);
        MonsterRotateToTarget     monsterMoveRotate  = new MonsterRotateToTarget(DESTINATION);
        MonsterRotateToTarget     attackRotate       = new MonsterRotateToTarget(PLAYERLOCATION);

        // 攻击
        BTSequence attack = new BTSequence(playerInRange);

        {
            BTParallel parallel = new BTParallel(BTParallel.ParallelFunction.Or);
            {
                parallel.AddChild(findToTargetDestination);    // 先找到走到攻击目标的目的地
                BTSequence rotateAndMove = new BTSequence();
                {
                    rotateAndMove.AddChild(monsterMoveRotate);
                    rotateAndMove.AddChild(move);
                }
                parallel.AddChild(rotateAndMove);             // 怪物朝着目的地移动
            }
            attack.AddChild(parallel);
            attack.AddChild(attackRotate);                // 怪物朝向玩家
            attack.AddChild(monsterAttack);               // 进行攻击
        }
        root.AddChild(attack);

        // 随机巡逻
        BTSequence randomMove = new BTSequence(playerNotInRange);

        {
            randomMove.AddChild(monsterWait);                  // 怪物静止几秒

            BTParallel parallel = new BTParallel(BTParallel.ParallelFunction.And);
            {
                parallel.AddChild(randomMoveDistance);         // 随机找一个移动地点
                BTSequence rotateAndMove = new BTSequence();
                {
                    rotateAndMove.AddChild(monsterMoveRotate);
                    rotateAndMove.AddChild(move);
                }
                parallel.AddChild(rotateAndMove);             // 怪物朝着目的地移动
            }
            randomMove.AddChild(parallel);
        }
        root.AddChild(randomMove);
    }
Exemple #23
0
 public static void monsterAttack(int s)
 {
     MonsterAttack?.Invoke(s);
 }
Exemple #24
0
    //gets the attacker information from the attack sprite that hits the enemy, and then calculate the damage. method invoked from the Attack Effects script
    public void OutputDamage(string atkName, string atkType, int atkPower, float atkStat, int attackerLevel, float critChance, float criMod, Monster attacker, MonsterAttack monsterAttack)
    {
        if (monster.info.type2 == "none" || monster.info.type2 == null || monster.info.type2 == "")
        {
            if (GameManager.Instance.monstersData.typeChartDict.ContainsKey(atkType) && GameManager.Instance.monstersData.typeChartDict.ContainsKey(monster.info.type1))
            {
                float force = (((attackerLevel * 2) / 2) + 2) * atkPower * (atkStat / monster.info.Defense.Value);
                //float force = (((attackerLevel * 2) / 5) + 2) * atkPower * (atkStat / stats.def);
                //float resistance = 38 * (stats.def / atkStat);
                float resistance = 38 * (monster.info.Defense.Value / atkStat);

                TypeInfo  attacking = GameManager.Instance.monstersData.typeChartDict[atkType];
                TypeInfo  defending = GameManager.Instance.monstersData.typeChartDict[monster.info.type1];
                TypeChart attack    = new TypeChart(attacking, defending, force, resistance);

                DealDamage(attack, attack.typeModifier, attacker, critChance, criMod, monsterAttack);
            }
        }
        else
        {
            if (GameManager.Instance.monstersData.typeChartDict.ContainsKey(atkType) && GameManager.Instance.monstersData.typeChartDict.ContainsKey(monster.info.type1) && GameManager.Instance.monstersData.typeChartDict.ContainsKey(monster.info.type2))
            {
                float force = (((attackerLevel * 2) / 2) + 2) * atkPower * (atkStat / monster.info.Defense.Value);
                //float force = (((attackerLevel * 2) / 5) + 2) * atkPower * (atkStat / stats.def);
                //float resistance = 38 * (stats.def / atkStat);
                float resistance = 38 * (monster.info.Defense.Value / atkStat);
                float damageMod  = new float();


                for (int i = 0; i < 2; i++)
                {
                    if (i == 0)
                    {
                        TypeInfo  attacking = GameManager.Instance.monstersData.typeChartDict[atkType];
                        TypeInfo  defending = GameManager.Instance.monstersData.typeChartDict[monster.info.type1];
                        TypeChart attack    = new TypeChart(attacking, defending, force, resistance);
                        damageMod = attack.typeModifier;
                    }
                    else
                    {
                        TypeInfo  attacking = GameManager.Instance.monstersData.typeChartDict[atkType];
                        TypeInfo  defending = GameManager.Instance.monstersData.typeChartDict[monster.info.type2];
                        TypeChart attack    = new TypeChart(attacking, defending, force, resistance);
                        damageMod *= attack.typeModifier;
                        DealDamage(attack, damageMod, attacker, critChance, criMod, monsterAttack);
                    }
                }
            }
        }
    }
Exemple #25
0
        public static void EveryTick(object sender, EventArgs e)
        {
            StatsCustomControl.TimePlayedLblUpdate(.001);

            MonsterXp = Logger.LetterPoints;

            switch (MonsterLvl)
            {
            case 0:
                _newXpGate = 2;
                break;

            case 1:
                _newXpGate = 10;
                break;

            default:
            {
                if (MonsterLvl <= 6)
                {
                    _newXpGate = Math.Round(Math.Pow(2, MonsterLvl - 1)) * 5;
                }
                else if (MonsterLvl <= 10)
                {
                    _newXpGate = Math.Round(Math.Pow(2, MonsterLvl - 1) * 2);
                }
                else
                {
                    _newXpGate = Math.Round(Math.Pow(2, MonsterLvl - 1) + 2);
                }
                break;
            }
            }

            StatsCustomControl.XpLblUpdate(MonsterXp.ToString(), _newXpGate.ToString());


            if (MonsterXp < _newXpGate)
            {
                return;
            }

            MonsterLvl++; //LEVEL UP!
            MainCustomControl.LvlLabel1Update(MonsterLvl.ToString());
            StatsCustomControl.LvlLabel2Update(MonsterLvl.ToString());

            MonsterHealth    += 5;
            MonsterMaxHealth += 5;
            StatsCustomControl.HealthLblUpdate(MonsterHealth, MonsterMaxHealth);

            if (MonsterLvl % 5 == 0)
            {
                MonsterAttack += 5;
                StatsCustomControl.AttackLblUpdate(MonsterAttack.ToString());
            }

            using (var soundPlayer = new SoundPlayer(Application.StartupPath + @"\LevelUp.wav"))
            {
                soundPlayer.Play();
            }

            Logger.LetterPoints = 0;
            MonsterXp           = 0; //reset points and xp
            MainForm.SaveSettings();
        }
Exemple #26
0
    public static MonsterAttack SpawnMonsterAttack()
    {
        MonsterAttack attack = instance.warFactory.AnAttack;

        return(attack);
    }
Exemple #27
0
    // Use this for initialization
    void Start()
    {
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }

        if (LevelEnd == null)
        {
            LevelEnd = new UnityEvent();
        }

        if (GameOver == null)
        {
            GameOver = new UnityEvent();
        }

        if (uiManager == null)
        {
            uiManager = GetComponent <UIManager>();
        }

        LevelEnd.AddListener(uiManager.OnLevelEnd);
        LevelEnd.AddListener(AddLevelCount);
        player   = GameObject.FindGameObjectWithTag("Player");
        endLight = GameObject.Find("End Light");
        GameObject[] monsterObjects = GameObject.FindGameObjectsWithTag("Monster");
        for (int i = 0; i < monsterObjects.Length; i++)
        {
            WanderingAI   aiScript     = monsterObjects[i].GetComponent <WanderingAI>();
            MonsterAttack attackScript = monsterObjects[i].GetComponent <MonsterAttack>();
            GameOver.AddListener(aiScript.PlayerIsDead);
            GameOver.AddListener(attackScript.PlayerIsDead);
            LevelEnd.AddListener(aiScript.PlayerIsDead);
            LevelEnd.AddListener(attackScript.PlayerIsDead);
        }
        GameObject[] skullObjects = GameObject.FindGameObjectsWithTag("Skull");
        for (int i = 0; i < skullObjects.Length; i++)
        {
            SkullMove   aiScript     = skullObjects[i].GetComponent <SkullMove>();
            SkullAttack attackScript = skullObjects[i].GetComponent <SkullAttack>();
            GameOver.AddListener(aiScript.PlayerIsDead);
            GameOver.AddListener(attackScript.PlayerIsDead);
            LevelEnd.AddListener(aiScript.PlayerIsDead);
            LevelEnd.AddListener(attackScript.PlayerIsDead);
        }
        GameObject[] ratObjects = GameObject.FindGameObjectsWithTag("Rat");
        for (int i = 0; i < ratObjects.Length; i++)
        {
            RatMove   aiScript     = ratObjects[i].GetComponent <RatMove>();
            RatAttack attackScript = ratObjects[i].GetComponent <RatAttack>();
            GameOver.AddListener(aiScript.PlayerIsDead);
            GameOver.AddListener(attackScript.PlayerIsDead);
            LevelEnd.AddListener(aiScript.PlayerIsDead);
            LevelEnd.AddListener(attackScript.PlayerIsDead);
        }

        GameOver.AddListener(uiManager.OnGameOver);
        GameOver.AddListener(GetComponent <ScreenFader>().OnGameOver);
    }
Exemple #28
0
 // Use this for initialization
 void Start()
 {
     attackScript = transform.GetComponentInParent <MonsterAttack>();
     wanderScript = transform.GetComponentInParent <WanderingAI>();
     rb           = GetComponent <Rigidbody>();
 }
Exemple #29
0
 //this is called from the enemy script when an emey is hit with an attack
 public void IsHit(MonsterAttack attack)
 {
     //hitTime =
     isHit = true;
 }
	void Awake() {
		monster = GetComponent<Monster>();
		monsterAttack = GetComponent<MonsterAttack>();

		anim = GetComponentInChildren<Animator>();
	}
Exemple #31
0
    /////////////////////////////////////////////////////////

    private void Start()
    {
        StartObject = GameObject.FindWithTag("Start").GetComponent <EnemySummon>();
        MKList      = GameObject.Find("Culling").GetComponent <MonsterAttack>();
        Count       = EnemySummon.Instance.iCountingMonster;
    }