Exemple #1
0
        private IEnumerator LaunchFireball(GameObject target)
        {
            float   launchDuration = 1f;
            float   elapsedTime    = 0;
            Vector3 origin         = Fireball.transform.position;

            while (elapsedTime < launchDuration)
            {
                Fireball.transform.position = Vector3.Lerp(
                    origin,
                    target.transform.position,
                    elapsedTime / launchDuration);
                elapsedTime += Time.deltaTime;
                yield return(null);
            }

            Fireball.SetActive(false);

            Attack attack = new Attack(CurrentDamage);

            target.GetComponent <Combatant>()
            .Defend(attack);

            CombatSystem.EndTurn(this.GetComponentInParent <Combatant>().gameObject);
        }
        protected override IEnumerator InnerDoGroupAbility(Transform groupTransform)
        {
            ImpGroupAi impGroupAi = groupTransform.GetComponent <ImpGroupAi>();

            CombatSystem hammerCombatSystem = _hammer.GetComponentInChildren <CombatSystem>();

            while (impGroupAi.Target.GetTransformDistanceFromTarget(_hammer.transform) > data.MINDistanceBeforeAttack)
            {
                _hammer.transform.position = groupTransform.position + new Vector3(0f, 1f, 0f) + (_hammer.transform.position - impGroupAi.Target.Target.position).normalized;
                _hammer.transform.rotation = Quaternion.LookRotation((impGroupAi.Target.Target.position - _hammer.transform.position).normalized, Vector3.up);

                yield return(null);
            }

            hammerCombatSystem.StartAttack(data.AssociatedAttack.GetAttack());

            float timer = 0f;

            while (timer <= data.ActivatedDuration)
            {
                _hammer.transform.position = groupTransform.position + new Vector3(0f, 1f, 0f) + (_hammer.transform.position - impGroupAi.Target.Target.position).normalized;
                _hammer.transform.rotation = Quaternion.LookRotation((impGroupAi.Target.Target.position - _hammer.transform.position).normalized, Vector3.up);

                yield return(null);

                timer += Time.deltaTime;
            }

            _hammer.transform.rotation = Quaternion.Euler(0f, 0f, 0f);
        }
Exemple #3
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Space))
     {
         CombatSystem.SlashAttack(5, attackPoint.position, attackRange, enemyLayers);
     }
 }
 protected override void Awake()
 {
     base.Awake();
     lifeSystem     = GetComponent <LifeSystem>();
     combatSystem   = GetComponent <CombatSystem>();
     characterMotor = GetComponent <CharacterMotor>();
 }
Exemple #5
0
    //CODE DEALING WITH PLAYER COMBAT STAGE

    public void HealButton()
    {
        EnemyChange enemyChange = GameObject.FindWithTag("EnemyChange").GetComponent <EnemyChange>();

        if (enemyChange.IsLevel1 == true || enemyChange.IsLevel3 == true)//This code will only run during lvl 1 and 3
        {
            Player     player     = GameObject.FindWithTag("Player").GetComponent <Player>();
            DiceScript diceScript = GameObject.FindWithTag("Dice").GetComponent <DiceScript>();

            player.currentHealth               = 10f;
            playerfillAmountHealth             = player.currentHealth / player.maxHealth;
            diceScript.playerHealth.fillAmount = player.currentHealth / 1;

            PlayerHealGlow.SetActive(true);
            Invoke("PlayerGlowDisappear", 0.5f);

            Invoke("EnemyTurnChange", 2f);
            PlayerCanAttack = false;

            if (0 < player.defenceNumber)
            {
                player.defenceNumber  -= 1;
                playerDefenceText.text = player.defenceNumber.ToString();

                healGlowText.text = player.defenceNumber.ToString();
                healGlow.SetActive(true);
                Invoke("PlayerGlowDisappear", 0.5f);
            }
        }

        CombatSystem combatSystem = GameObject.FindWithTag("CombatSystem").GetComponent <CombatSystem>();

        combatSystem.CanRoll = false;
    }
Exemple #6
0
    void Update()
    {
        //check if has died
        if (health <= 0)
        {
            //animator.SetTrigger(consts.Die);
        }
        Vector3 movement = MoveTowardsTarget(new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")));

        if (!RotatetowardsMouse)
        {
            RotateTowardsMovementVector(movement);
        }
        else if (Physics.Raycast(camera.ScreenPointToRay(inputMovement = Input.mousePosition), out RaycastHit hitinfo, maxDistance: 300f))
        {
            transform.LookAt(new Vector3(hitinfo.point.x, transform.position.y, hitinfo.point.z));
            if (Input.GetMouseButtonDown(0))
            {
                animator.SetTrigger(consts.Attack1Name);

                CombatSystem.ChooseAttack(consts.Attack1Type, consts.Damage, transform.position + (transform.forward * 1), this.transform.rotation, consts.AttackRange1, LayerMask.GetMask("Enemy"));
            }

            if (Input.GetMouseButtonDown(1))
            {
                animator.SetTrigger(consts.Attack2Name);
                CombatSystem.ChooseAttack(consts.Attack2Type, consts.Damage, transform.position, this.transform.rotation, consts.AttackRange2, LayerMask.GetMask("Enemy"));
            }
        }
    }
    public override void Shoot()
    {
        fxEffect?.SetActive(true);

        List <IDamagable> enemyList = new List <IDamagable>();

        Collider[] enemyCollider = Physics.OverlapSphere(transform.position, weaponData.RangeAttack, LayerMask.GetMask("Avatar"));
        for (int i = 0; i < enemyCollider.Length; i++)
        {
            if (enemyCollider[i].gameObject == avatarOwner.gameObject)
            {
                continue;
            }
            var enemy = enemyCollider[i].GetComponent <IDamagable>();

            RaycastHit raycastHit;

            Physics.Raycast(transform.position, enemyCollider[i].transform.position - transform.position, out raycastHit);
            if (raycastHit.collider == enemyCollider[i])
            {
                var vector3ToEnemy = enemyCollider[i].transform.position - transform.position;
                var angle          = Vector3.Angle(transform.forward, vector3ToEnemy);
                if (angle < weaponData.AttackSector / 2 && enemy != null)
                {
                    enemyList.Add(enemy);

                    CombatSystem.CalculateDamage(enemy, hitData);
                }
            }
        }
    }
Exemple #8
0
        public bool DoAttack(int slot, Vec dir)
        {
            var weapon = _controller.Player.GetOne <Inventory>().Slots[slot].Item;

            if (weapon == null)
            {
                return(false);
            }

            var weaponComponent = weapon.GetOne <IWeapon>();

            if (weaponComponent == null)
            {
                return(false);
            }

            var targets = weaponComponent.Targets(_controller.Player, dir);

            CombatSystem.RollAttack(_controller.Player, targets.ToArray(), (weapon, weaponComponent));

            if (slot == Inventory.SLOT_MAINHAND)
            {
                DoAttack(Inventory.SLOT_OFFHAND, dir);
            }

            return(true);
        }
Exemple #9
0
    public void MoveUnit()
    {
        AttackUnit = null;
        if (path.Count == 0)
        {
            return;
        }
        List <HexCell> move = new List <HexCell>();

        move.Add(path[0]);
        int cellNumber = 1;

        while (movementLeft > 0 && path.Count > 1)
        {
            if (path.Count > cellNumber)
            {
                int movementCost = HexUnit.GetMoveCost(path[cellNumber - 1], path[cellNumber], path[cellNumber - 1].GetNeighborDirection(path[cellNumber]), true);
                if (movementCost == -1 || movementCost > movementLeft)
                {
                    break;
                }
                else
                {
                    move.Add(path[cellNumber]);
                    movementLeft -= movementCost;
                    cellNumber++;
                }
            }
            else
            {
                break;
            }
        }

        if (move.Count > 1)
        {
            AttackUnit = null;
            AttackCity = null;
            City city = move[move.Count - 1].City;
            if (city && hexUnit.HexUnitType == HexUnit.UnitType.COMBAT && GetCityState() != city.GetCityState())
            {
                AttackCity = city;
                CombatSystem.CityFight(this, city);
                SetMovementLeft(0);
            }
            else
            {
                HexUnit unitToFight = move[move.Count - 1].GetFightableUnit(HexUnit);
                if (unitToFight)
                {
                    AttackUnit = unitToFight;
                    CombatSystem.UnitFight(this, unitToFight.GetComponent <Unit>());
                    SetMovementLeft(0);
                }
            }

            path.RemoveRange(0, move.Count - 1);
            HexUnit.Travel(move);
        }
    }
Exemple #10
0
        private bool ActionAttackEnemy(Entity self, Entity enemy)
        {
            if (enemy == null)
            {
                return(false);
            }

            foreach (var weaponPair in ChooseWeapon(self))
            {
                var weaponComponent = weaponPair.Item2;
                var dir             = weaponComponent.Dir(self, enemy);
                if (dir == null)
                {
                    continue;
                }

                var targets = weaponComponent.Targets(self, dir.Value);
                if (!targets.Contains(enemy))
                {
                    continue;
                }

                CombatSystem.RollAttack(self, targets.ToArray(), weaponPair);
                return(true);
            }
            return(false);
        }
Exemple #11
0
    // Use this for initialization
    void Start()
    {
        // EL meu personatge
        pv = GetComponent <PhotonView>();
        rb = GetComponent <Rigidbody>();
        CombatSystem cs = GetComponent <CombatSystem>();


        // Còpia del personatge a la xarxa
        Unidad unidad = this.gameObject.GetComponent <Unidad>();

        unidad.Initialize();

        pdc.playerHealthBar.maxValue = unidad.GetMaxHealth();
        pdc.playerHealthBar.value    = unidad.GetHealth();
        cs.playerHealthBar           = pdc.playerHealthBar;

        // Nom de la unitat
        if (cs.GetTeam() == 0)
        {
            pdc.playerNameText.color = Color.blue;
        }
        else if (cs.GetTeam() == 1)
        {
            pdc.playerNameText.color = Color.red;
        }
        else
        {
            pdc.playerNameText.color = Color.black;
        }
    }
Exemple #12
0
    private void OnDamageHitDealt(Attack attack, CombatSystem c, Vector3 v)
    {
        switch (attack.name)
        {
        case "MidBossSingleAttack":
            Play("singleAttack");
            break;

        case "MidBossGroupAttack":
            Play("groupAttack");
            break;

        case "BossSingleAttack":
            Play("singleAttack");
            break;

        case "BossGroupAttack":
            Play("groupAttack");
            break;

        default:
            //Debug.Log("ATTACK "+ attack.name +" NOT FOUND");
            break;
        }
    }
        public bool Act(Monster monster, CombatSystem combatSystem)
        {
            Microsoft.Xna.Framework.Point pLoc = GameWorld.DungeonScreen.MapConsole.Player.Position;
            FieldOfView monsterFov             = new FieldOfView(GameWorld.DungeonScreen.MapConsole.detailedMap);

            // If the monster has not been alerted, compute a field-of-view
            // Use the monster's Awareness value for the distance in the FoV check
            // If the player is in the monster's FoV then alert it
            // Add a message to the MessageLog regarding this alerted status
            if (!monster.TurnsAlerted.HasValue)
            {
                monsterFov.ComputeFov(monster.Position.X, monster.Position.Y, monster.Awareness, true);
                if (monsterFov.IsInFov(pLoc.X, pLoc.Y))
                {
                    GameWorld.DungeonScreen.MessageConsole.PrintMessage($"{monster.Name} is eager to fight {GameWorld.DungeonScreen.MapConsole.Player.Name}");
                    monster.TurnsAlerted = 1;
                }
            }

            if (monster.TurnsAlerted.HasValue)
            {
                PathFinder pathFinder = new PathFinder(GameWorld.DungeonScreen.MapConsole.detailedMap);
                Path       path       = null;

                try
                {
                    path = pathFinder.ShortestPath(
                        GameWorld.DungeonScreen.MapConsole.detailedMap.GetCell(monster.Position.X, monster.Position.Y),
                        GameWorld.DungeonScreen.MapConsole.detailedMap.GetCell(pLoc.X, pLoc.Y));
                }
                catch (PathNotFoundException)
                {
                    // The monster can see the player, but cannot find a path to him
                    // This could be due to other monsters blocking the way
                    // Add a message to the message log that the monster is waiting
                    GameWorld.DungeonScreen.MessageConsole.PrintMessage($"{monster.Name} waits for a turn");
                }

                // In the case that there was a path, tell the CommandSystem to move the monster
                if (path != null)
                {
                    try
                    {
                        GameWorld.DungeonScreen.MapConsole.MoveMonster(monster, path.StepForward());
                    }
                    catch (NoMoreStepsException)
                    {
                        GameWorld.DungeonScreen.MessageConsole.PrintMessage($"{monster.Name} growls in frustration");
                    }
                }

                monster.TurnsAlerted++;

                if (monster.TurnsAlerted > AlertStatusLength)
                {
                    monster.TurnsAlerted = null;
                }
            }
            return(true);
        }
 protected CombatAction(LunchHourGames lhg, CombatSystem combatSystem, Handler combatActionHandler, ActionType actionType)
 {
     this.lhg                 = lhg;
     this.combatSystem        = combatSystem;
     this.combatActionHandler = combatActionHandler;
     this.actionType          = actionType;
 }
Exemple #15
0
    public void RefreshHudTop(string mort, string assassi)
    {
        GameObject goMort    = GameObject.Find(mort);
        GameObject goAssassi = GameObject.Find(assassi);
        Unidad     unMort    = goMort.GetComponent <Unidad>();
        Unidad     unAssassi = goMort.GetComponent <Unidad>();

        unMort.SetDeaths(unMort.GetDeaths() + 1);
        unAssassi.SetAssassinations(unAssassi.GetAssassinations() + 1);

        GameObject[] playersList = GameObject.FindGameObjectsWithTag("Player");
        AssTeam1 = 0;
        AssTeam2 = 0;

        foreach (GameObject player in playersList)
        {
            CombatSystem cmbtPlayer = player.GetComponent <CombatSystem>();
            Unidad       uPlayer    = player.GetComponent <Unidad>();

            if (cmbtPlayer.GetTeam() == 0)
            {
                AssTeam1 += uPlayer.GetAssassinations();
            }
            else
            {
                AssTeam2 += uPlayer.GetAssassinations();
            }
        }

        netManager.playerHUD.AssMor.text = AssTeam1 + " vs " + AssTeam2;
    }
 private void Awake()
 {
     _combatSystem = GetComponentInChildren <CombatSystem>();
     _animator     = GetComponent <Animator>();
     _rigidbody    = GetComponent <Rigidbody>();
     _stun         = GetComponentInChildren <Stun>();
 }
Exemple #17
0
    public void MeleeButton()
    {
        Enemy enemy = GameObject.FindWithTag("Enemy").GetComponent <Enemy>();

        enemy.currentHealth   -= 0.2f;
        enemyHealth.fillAmount = enemy.currentHealth / 1;

        EnemyHealthGlow.SetActive(true);
        Invoke("EnemyGlowDisappear", 0.5f);

        EnemyDamage.text = "2";
        Invoke("DamageDisappear", 2f);

        ScreenshakeController screenShakeController = GameObject.FindWithTag("MainCamera").GetComponent <ScreenshakeController>();

        StartCoroutine(screenShakeController.CameraShake(0.1f, 0.05f));

        if (enemy.currentHealth < 0.1f || enemy.currentHealth > 1f) //Player Wins
        {
            Debug.Log("Has Won");
            WinUI.SetActive(true);
        }

        CombatSystem combatSystem = GameObject.FindWithTag("CombatSystem").GetComponent <CombatSystem>();

        Invoke("EnemyTurnChange", 0.5f);
        //ConsoleText.text = "Enemy Turn";
        combatSystem.EnemyCanRoll = true;
    }
 private void Start()
 {
     combat    = GetComponent <CombatSystem>();
     weapons   = GetComponent <WeaponSystem>();
     abilities = GetComponent <SpecialAbilities>();
     animator  = GetComponent <Animator>();
     camera    = GetComponent <CameraController>();
 }
Exemple #19
0
 public void SetCombatSystem(CombatSystem _playerCS)
 {
     this.playerCS = _playerCS;
     if (this.coolDownSlider != null)
     {
         this.coolDownSlider.value = 0;
     }
 }
Exemple #20
0
        protected override void EndAbility()
        {
            Debug.Log($"Bonk Damage total: {Damage}");

            CurrentPhase = Phase.Inactive;

            CombatSystem.EndTurn(this.GetComponentInParent <Combatant>().gameObject);
        }
Exemple #21
0
    IEnumerator NoMP()
    {
        trackerText.text = "You don't have any MP left...";
        yield return(new WaitForSeconds(2f));

        combatState = CombatSystem.EnemyTurn;
        StartCoroutine(EnemyTurn());
    }
Exemple #22
0
    protected override void EndAbility()
    {
        Thunder.SetActive(false);

        Animator.SetBool("IsFinishedCasting", true);

        CombatSystem.EndTurn(this.GetComponentInParent <Combatant>().gameObject);
    }
 protected override void InnerDispose(int id, CombatSystem ownerCombatSystem)
 {
     foreach (GameObject g in _attackGameObjects[id])
     {
         PoolersManager.Instance.TryGetPooler(data.AttackPrefab).DeactivatePooledObject(g);
     }
     _attackGameObjects.Remove(id);
 }
    public void EnemyTurnChange()
    {
        CombatSystem combatSystem = GameObject.FindWithTag("CombatSystem").GetComponent <CombatSystem>();

        combatSystem.state        = CombatState.ENEMYTURN;
        ConsoleText.text          = "Enemy Turn";
        combatSystem.EnemyCanRoll = true;
    }
Exemple #25
0
 // Start is called before the first frame update
 void Start()
 {
     //canPress = true;
     targets      = MinigameData.targets;
     m            = MinigameData.m;
     cs           = MinigameData.cs;
     miniGameBody = MinigameData.miniGameBody;
 }
Exemple #26
0
        public IEnumerator DoAttack(int id, CombatSystem ownerCombatSystem, Action <Attack, int> stopAction, Transform target = null)
        {
            Setup(id, ownerCombatSystem, target);

            yield return(InnerDoAttack(id, ownerCombatSystem, target));

            Dispose(id, ownerCombatSystem, stopAction);
        }
Exemple #27
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Player")
     {
         CombatSystem.CalculateDamage(other.GetComponent <IPersonController>(), this);
         Destroy(gameObject);
     }
 }
Exemple #28
0
        public override CombatAttack getCombatAttack(CombatSystem combatSystem)
        {
            if (combatAttack == null)
            {
                combatAttack = new LinearAttack(lhg, combatSystem, this);
            }

            return(combatAttack);
        }
Exemple #29
0
        private void Dispose(int id, CombatSystem ownerCombatSystem, Action <Attack, int> stopAction)
        {
            InnerDispose(id, ownerCombatSystem);

            AnimationStates.Remove(id);
            HasHit.Remove(id);

            stopAction(this, id);
        }
Exemple #30
0
        public ZombieAttack getCombatAttack(CombatSystem combatSystem)
        {
            if (zombieAttack == null)
            {
                zombieAttack = new ZombieAttack(lhg, combatSystem);
            }

            return(zombieAttack);
        }
    void Awake()
    {
        _fsm = new FSM<CombatStates>();
        AddState();
        AddTransitions();
        Instance = this;
        Players[] allies = FindObjectsOfType<Players>();
        Enemy[] enemies = FindObjectsOfType<Enemy>();
        foreach (Players ally in allies)
        {
            AllyTeam.Add(ally);
        }

        foreach (Enemy en in enemies)
        {
            EnemyTeam.Add(en);
        }

        test = true;
        StartCoroutine(transition());
        Subscribe("GUI","Attacked", AttackOrder);
        Subscribe("GUI", "Quit", CloseApp);
    }
 void Awake()
 {
     if (Instance == null) {
         Instance = this;
     }
     else {
         Destroy(this.gameObject);
     }
 }