Exemple #1
0
 private void Awake()
 {
     //player = GetComponent<GameObject>();
     attack = new MagicAttack(Ammo, player);
     attack.SetSpeed(10);
     anim = new Anim(GetComponent <Animator>());
 }
 void Start()
 {
     magicAttack   = GetComponent <MagicAttack>();
     fireBallTake2 = FindObjectOfType <FireBallTake2>();
     ChangeWeapon(1);
     BowImage.enabled = true;
 }
    /// <summary>
    /// Converts an enum type of <see cref="EnemyMoves"/> to an <see cref="SpecialMove"/> instance
    /// </summary>
    /// <returns>A special move instance</returns>
    /// <param name="moveType">The type of special move to create.</param>
    /// <param name="text">The text to show when the move is used</param>
    /// <param name="magic">The magic it will consume</param>
    /// <param name="value">A number value, used for the calculation of that specific special move</param>
    private SpecialMove createSpecialMove(EnemyMoves moveType, string text, int magic, float value)
    {
        SpecialMove specialMove;

        switch (moveType)
        {
        case EnemyMoves.MagicAttack:
            specialMove = new MagicAttack(text, "", magic, (int)value);
            break;

        case EnemyMoves.RaiseAttack:
            specialMove = new RaiseAttack(text, "", magic, value);
            break;

        case EnemyMoves.RaiseDefence:
            specialMove = new RaiseDefence(text, "", magic, value);
            break;

        case EnemyMoves.LowerDefence:
            specialMove = new LowerDefence(text, "", magic, value);
            break;

        case EnemyMoves.LowerSpeed:
            specialMove = new LowerSpeed(text, "", magic, value);
            break;

        default:
            specialMove = null;
            break;
        }
        return(specialMove);
    }
Exemple #4
0
 void Start()
 {
     // Find magic attack prefab
     magicAttack = Resources.Load <MagicAttack>("Items/Weapons/Projectiles/MagicAttack");
     // Set animator var to be the swords animator
     animator = GetComponent <Animator>();
 }
Exemple #5
0
 void Start()
 {
     magicAttack = Resources.Load <MagicAttack>("Items/Weapons/Projectiles/MagicAttack");
     //playerXform = playerGO.transform;
     //transform.LookAt(playerXform);
     // Create new loot table
     LootTable = new LootTable();
     // Create new list of loot
     LootTable.lootDrops = new List <LootDrop>
     {
         // Populate loot list
         new LootDrop("sword", 1),
     };
     for (int i = 0; i < listOfDrops.Length; i++)
     {
         LootTable.lootDrops.Add(new LootDrop(listOfDrops[i], chancesOfDrops[i]));
     }
     ID         = enemyID;
     Experience = experienceForKilling;
     // Assign nav mesh agent
     navMeshAgent   = GetComponent <NavMeshAgent>();
     combatantStats = new CombatantStats(attackLevel, defenceLevel, attackSpeed);
     // Set health to full
     currentHealth = maxHealth;
 }
Exemple #6
0
    /// <summary>
    /// Performs the turn, updating text display and health and magic bars.
    /// Afterwards, checks to see whether the player has won or lost
    /// </summary>
    /// <returns>Coroutine functions</returns>
    /// <param name="move">The move to  be performed</param>
    private IEnumerator performTurn(CharacterMove move)
    {
        int previousHealth = move.Target.Health;
        int previousMagic  = move.User.Magic;

        move.performMove();
        textBox.text = move.User.Name + " " + move.Text + " " + move.Target.Name;
        if (manager.WasCriticalHit && (move is StandardAttack || move is MagicAttack))
        {
            textBox.text += "\nCritical Hit!";
        }

        //If the player is a Gorilla it has a 50/50 chance of performing its move or attacking a team mate
        // ALL ADDED FOR ASSESSMENT 4
        if (move.User.GetType() == typeof(Player) && ((Player)move.User).IsGorilla)
        {
            SpecialMove damagePlayer = new MagicAttack("attacked a team mate", "Attack Team", 0, 30);
            List <int>  indexes      = new List <int>();

            bool badEffect = (Random.value > 0.5f);

            if (badEffect)
            {
                for (int i = 0; i < PlayerData.instance.data.Players.Length; i++)
                {
                    Player currentPlayer = PlayerData.instance.data.Players[i];
                    if (currentPlayer != null && !currentPlayer.IsGorilla)
                    {
                        indexes.Add(i);
                    }
                }

                int index = Random.Range(0, indexes.Count);
                index = indexes[index];

                Player[] players = PlayerData.instance.data.Players;
                damagePlayer.setUp(manager, move.User, players[index]);
                damagePlayer.performMove();

                textBox.text = move.User.Name + " " + move.Text + " " + move.Target.Name + " but Gorilla goes mad and hits " + damagePlayer.Target.Name + "!";
            }
        }

        //Update bars and data
        if (move is SwitchPlayers)
        {
            updateToNewPlayer();
        }
        yield return(updateBars(move, previousHealth, previousMagic));

        if (move.Target is Enemy)
        {
            StartCoroutine(checkIfPlayerWon());
        }
        else
        {
            StartCoroutine(checkIfPlayerLost());
        }
    }
Exemple #7
0
    public void FireProjectile()
    {
        // Instantiated magic attack spawned as magicAttack prefab on the proj spawn position using that rotation
        MagicAttack magicAttackInstantiated = (MagicAttack)Instantiate(magicAttack, ProjectileSpawnPosition.position, ProjectileSpawnPosition.rotation);

        // Set direction to forward
        magicAttackInstantiated.direction = ProjectileSpawnPosition.forward;
    }
Exemple #8
0
 /// <summary>
 /// Start this instance.
 /// </summary>
 void Start()
 {
     desiredPlayer      = GameObject.FindGameObjectsWithTag("Player2");
     battle             = desiredPlayer[0].GetComponent <BattleTimeScript>();
     constVar           = GameObject.FindGameObjectWithTag("Constant");
     stored             = constVar.GetComponent <StoredInformation>();
     attacking          = new PlayerAttack();
     attackingWithMagic = new MagicAttack();
 }
Exemple #9
0
        public Attack AttackTarget(ICombatable target, IEventDispatcher eventDispatcher)
        {
            Attack attack = new PhysicalAttack(this, Monster.MinAttack, Monster.MaxAttack, Monster.Hitrate, Monster.GetCriticalHitChance(), 2, 0);

            if (Monster.DamageType == DamageType.Magical)
            {
                attack = new MagicAttack(this, Monster.MaxAttack);
            }

            return(target.ReceiveAttack(attack, eventDispatcher));
        }
Exemple #10
0
        public override string Activate(int itemPos, User user, User target, string channel)
        {
            var damage = target.Level * target.Agility;
            var attack = new MagicAttack(user, damage);

            target.ReceiveAttack(attack, _eventDispatcher);

            _combatService.DealDamage(user, attack, target, channel).Wait();

            return(base.Activate(itemPos, user, target, channel));
        }
Exemple #11
0
        public Attack AttackTarget(ICombatable target, IEventDispatcher eventDispatcher)
        {
            Attack attack = new PhysicalAttack(this, MinAttack, MaxAttack, Hitrate, Luck);

            if (DamageType == DamageType.Magical)
            {
                attack = new MagicAttack(this, Intelligence);
            }

            return(target.ReceiveAttack(attack, eventDispatcher));
        }
        public ActionCoopMagic(SimulatorContext context,
                               List <PlayerCharacter> actors,
                               List <FightingCharacter> monsters)
            : base(context,
                   actors.First(),
                   monsters)
        {
            Attackers       = actors;
            _onlyOneMonster = false;

            _magic = GetCoopMagic();
        }
Exemple #13
0
    public void SpecialMoveSaveLoad()
    {
        SpecialMove testMove = new MagicAttack("testtext", "testdesc", 1, 1.2f);

        SaveData.SpecialMoveSaveData savedItem = PlayerData.instance.data.SpecialMoveToSerializable(testMove);
        SpecialMove restoredMove = PlayerData.instance.data.SerializableToSpecialMove(savedItem);

        Assert.IsInstanceOf <MagicAttack>(restoredMove);
        Assert.AreEqual(testMove.Desc, restoredMove.Desc);
        Assert.AreEqual(testMove.Text, restoredMove.Text);
        Assert.AreEqual(testMove.Magic, restoredMove.Magic);
        Assert.AreEqual(testMove.Special, restoredMove.Special);
    }
    public void DoMagic()
    {
        int selectedType = (int)Save.current.combatData.selectedMagic;

        if (Save.current.combatData.magic[selectedType].amount > 0)
        {
            string attackPath = "error";
            switch ((Save.MagicType)selectedType)
            {
            case Save.MagicType.Fire:
                attackPath = "fireAttack";
                break;

            case Save.MagicType.Lightning:
                attackPath = "lightningAttack";
                break;

            case Save.MagicType.Air:
                attackPath = "airAttack";
                break;

            case Save.MagicType.Water:
                attackPath = "waterAttack";
                break;

            default:
                break;
            }
            GameObject  magicGO       = Instantiate((GameObject)Resources.Load("Attacks/" + attackPath));
            MagicAttack magicAttack   = magicGO.GetComponent <MagicAttack>();
            Vector3     magicPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);

            Save.current.combatData.magic[selectedType].amount -= 1;

            Enemy hoveredEnemy = GetHoveredEnemy();
            if (hoveredEnemy != null && hoveredEnemy.currentElementIndex < hoveredEnemy.info.types.Length)
            {
                Save.MagicType enemyType = hoveredEnemy.info.types[hoveredEnemy.currentElementIndex];
                if (enemyType == (Save.MagicType)selectedType)
                {
                    hoveredEnemy.TakeDamage();
                    magicPosition = hoveredEnemy.transform.position;
                }
            }

            magicPosition.z = 0;
            magicAttack.Init(magicPosition);
        }
        Game.instance.uiManager.UpdateMagicUI();
    }
        /// <summary>
        /// 合击动作
        /// </summary>
        /// <param name="actors"></param>
        /// <param name="monster"></param>
        public ActionCoopMagic(SimulatorContext context,
                               List <PlayerCharacter> actors,
                               FightingCharacter monster)
            : base(context,
                   actors.First(),
                   new List <FightingCharacter>() { monster })
        {
            State = CombatAnimationState.Move;

            Attackers       = actors;
            _onlyOneMonster = true;

            _magic = GetCoopMagic();
        }
Exemple #16
0
    void Awake()
    {
        m_AttackInputWait    = new WaitForSeconds(k_AttackInputDuration);
        MagicAttackInputWait = new WaitForSeconds(30);
        _magicAttack         = GetComponentInChildren <MagicAttack>();
        _canMagicAttack      = true;

        if (s_Instance == null)
        {
            s_Instance = this;
        }
        else if (s_Instance != this)
        {
            throw new UnityException("There cannot be more than one PlayerInput script.  The instances are " + s_Instance.name + " and " + name + ".");
        }
    }
Exemple #17
0
        public override async Task <DougResponse> Activate(User user, ICombatable target, string channel)
        {
            if (!CanActivateSkill(user, out var response))
            {
                return(response);
            }

            var message = string.Format(DougMessages.UserActivatedSkill, _userService.Mention(user), Name);
            await _slack.BroadcastMessage(message, channel);

            var attack = new MagicAttack(user, user.TotalIntelligence());

            target.ReceiveAttack(attack, _eventDispatcher);
            await _combatService.DealDamage(user, attack, target, channel);

            return(new DougResponse());
        }
Exemple #18
0
 protected virtual void Start()
 {
     currentLife = maxLife;
     currentMana = maxMana;
     if (currentCamp == Camp.Player)
     {
         CombatManager.instance.playerEntities.Add(this);
     }
     else if (currentCamp == Camp.Enemy)
     {
         CombatManager.instance.enemyEntities.Add(this);
     }
     physicalAttack = GetComponent <PhysicalAttack>();
     magicalAttack  = GetComponent <MagicAttack>();
     heal           = GetComponent <Heal>();
     gambit         = GetComponent <GambitSystem.Gambit>();
 }
Exemple #19
0
    public void setUp(GameObject localPlayer)
    {
        if (localPlayer == null)
        {
            Debug.LogError("passed null local player");
            return;
        }

        player = localPlayer;
        if (player != null && player.GetComponent <Identifier>().typePrefix != Identifier.magicianType)
        {
            Debug.LogError("Displaying incorrect HUD");
            return;
        }

        health          = player.GetComponent <NetHealth>();
        resourceManager = player.GetComponent <ResourceManager>();
        magic           = player.GetComponent <MagicAttack>();

        setHealth(1);
//        setShield();

        isPaused = false;
    }
    // Update is called once per frame
    /// <summary>
    /// Update this instance.
    /// this handles taking the inputs and sending the correct repsone to the attack script
    /// this is done by button presses to determine the correct response that are depicted by different screens
    /// </summary>
    void Update()
    {
        GameObject[] enemyObjects = GameObject.FindGameObjectsWithTag("Enemy2");
        if(enemyObjects.Length!=0){
            if((battle.timeToAttack>99)&&(counter!=1)){
                counter =1;
            }
            if((battle.timeToAttack<99)&&(counter==1)){
                counter =0;
                optionsToSelect[0] = "Attack";
                optionsToSelect[1] = "Magic";
                optionsToSelect[2] = "Items";
                optionsToSelect[3] = "Run";
                flag=0;
                flagCheck=false;
            }

            if(counter==1){

                if((Input.GetKeyUp("joystick button 0"))&&(flag!=1)&&(!flagCheck)){
                    flag =1;
                    flagCheck=true;
                }
                if((Input.GetKeyUp("joystick button 1"))&&(flag!=2)&&(!flagCheck)){

                    flag=2;
                    flagCheck=true;
                }
                if((Input.GetKeyUp("joystick button 2"))&&(flag!=3)&&(!flagCheck)){
                    flag=3;
                    flagCheck=true;
                }
                if((Input.GetKeyUp("joystick button 3"))&&(flag!=4)&&(!flagCheck)){
                    flag =4;
                    if(buttonPressedCheck==0){

                    }
                    else{
                        buttonPressedCheck=0;
                    }
                }

                if(flag==1){
                    //Attack();
                    GameObject[] game = GameObject.FindGameObjectsWithTag("Enemy2");
                    if(Input.GetKeyUp("joystick button 10")){
                        EnemyNumber--;
                        if(EnemyNumber < 0)
                            EnemyNumber =0;
                    }
                    if(Input.GetKeyUp("joystick button 11")){
                        EnemyNumber++;
                        if(EnemyNumber > game.Length-1){
                            EnemyNumber =game.Length-1;
                        }
                    }

                    for(int cnt =0; cnt < optionsToSelect.Length; cnt ++){
                        if((attackDisplay+cnt)>stored._attack.Length){
                            attackDisplay--;
                        }
                        if((attackDisplay+cnt)<stored._attack.Length){
                            optionsToSelect[cnt] = stored._attack[cnt+attackDisplay];
                        }
                        if(Input.GetKeyUp("joystick button 8")){
                            attackDisplay--;
                            if(attackDisplay < 0)
                                attackDisplay =0;
                        }
                        if(Input.GetKeyUp("joystick button 9")){
                            attackDisplay++;
                        }
                        if(cnt == optionsToSelect.Length-1){
                            optionsToSelect[3] = "Back";
                        }
                        if(Input.GetKeyUp("joystick button 3")){
                            flag =0;
                            optionsToSelect[0] = "Attack";
                            optionsToSelect[1] = "Magic";
                            optionsToSelect[2] = "Items";
                            optionsToSelect[3] = "Run";
                            attackDisplay=0;
                            flagCheck = false;
                        }

                        if((Input.GetKeyUp("joystick button 0"))&&(secondCheck==true)){
                            waitingPeriod+=0.1f;
                            if(waitingPeriod>0.6f){
                                if(optionsToSelect[0]=="Attack"){
                                    attacking = new PlayerAttack();
                                    attackType = "Attack";
                                    attacking.Start();
                                    attacking.retrieveEnemies(EnemyNumber);
                                    attacking.AttackEnemy();
                                    secondCheck = false;
                                    waitingPeriod=0;
                                }
                                if(optionsToSelect[0] =="FireAttack"){
                                    attacking = new PlayerAttack();
                                    attackType = "FireAttack";
                                    attacking.Start();
                                    attacking.retrieveEnemies(EnemyNumber);
                                    attacking.FireAttackEnemy();
                                    secondCheck = false;
                                    waitingPeriod=0;
                                }

                            }
                        }

                        if/*(Input.GetKeyUp("joystick button 2"))*/
                        ((Input.GetKeyUp("joystick button 1"))&&(secondCheck)){
                            waitingPeriod+=0.1f;
                            if(waitingPeriod>0.6f){
                                if(optionsToSelect[1]=="FireAttack"){
                                    attacking = new PlayerAttack();
                                    attackType = "FireAttack";
                                    attacking.Start();
                                    attacking.retrieveEnemies(EnemyNumber);
                                    attacking.FireAttackEnemy();
                                    secondCheck = false;
                                    waitingPeriod=0;
                                }
                                if(optionsToSelect[1] =="IceAttack"){
                                    attacking = new PlayerAttack();
                                    attackType = "IceAttack";
                                    attacking.Start();
                                    attacking.retrieveEnemies(EnemyNumber);
                                    attacking.IceAttackEnemy();
                                    secondCheck = false;
                                    waitingPeriod=0;
                                }

                            }
                        }
                        if(Input.GetKeyUp("joystick button 2"))/*(Input.GetKeyUp("joystick button 3")){*/
                        {
                            waitingPeriod+=0.1f;
                            if(waitingPeriod>0.6f){
                                if(optionsToSelect[2]=="IceAttack"){
                                    attacking = new PlayerAttack();
                                    attackType = "IceAttack";
                                    attacking.Start();
                                    attacking.retrieveEnemies(EnemyNumber);
                                    attacking.IceAttackEnemy();
                                    secondCheck = false;
                                    waitingPeriod=0;
                                }
                                if(optionsToSelect[2] =="LightningAttack"){
                                    attacking = new PlayerAttack();
                                    attackType = "LightningAttack";
                                    attacking.Start();
                                    attacking.retrieveEnemies(EnemyNumber);
                                    attacking.LightningAttackEnemy();
                                    secondCheck = false;
                                    waitingPeriod=0;
                                }

                            }
                        }
                        if(Input.GetKeyUp("joystick button 3"))/*(Input.GetKeyUp("joystick button 1")){*/{

                        }
                    }

                    if((flag==1)&&
                       (((Input.GetKeyUp("joystick button 0")))||
                       ((Input.GetKeyUp("joystick button 1")))||
                       ((Input.GetKeyUp("joystick button 2")))
                       )&&(secondCheck==false)){
                        secondCheck=true;
                    }
                }
                if(flag==2){
                    //Magic();

                    for(int cnt =0; cnt < optionsToSelect.Length; cnt ++){
                        if((attackDisplay+cnt)>stored._mana.Length){
                            attackDisplay--;
                        }
                        if((attackDisplay+cnt)<stored._mana.Length){
                            optionsToSelect[cnt] = stored._mana[cnt+attackDisplay];
                        }
                        if(Input.GetKeyUp("joystick button 8")){
                            attackDisplay--;
                            if(attackDisplay < 0)
                                attackDisplay =0;
                        }
                        if(Input.GetKeyUp("joystick button 9")){
                            attackDisplay++;
                        }
                        if(cnt == optionsToSelect.Length-1){
                            optionsToSelect[3] = "Back";
                        }
                    }
                    GameObject[] game = GameObject.FindGameObjectsWithTag("Enemy2");
                    if(Input.GetKeyUp("joystick button 10")){
                        EnemyNumber--;
                        if(EnemyNumber < 0)
                            EnemyNumber =0;
                    }
                    if(Input.GetKeyUp("joystick button 11")){
                        EnemyNumber++;
                        if(EnemyNumber > game.Length-1){
                            EnemyNumber =game.Length-1;
                        }
                    }
                    if(Input.GetKeyUp("joystick button 3")){/*(Input.GetKeyUp("joystick button 1")){*/
                        flag =0;
                        optionsToSelect[0] = "Attack";
                        optionsToSelect[1] = "Magic";
                        optionsToSelect[2] = "Items";
                        optionsToSelect[3] = "Run";
                        attackDisplay=0;
                        flagCheck=false;
                    }

                    if((Input.GetKeyUp("joystick button 0"))&&(secondCheck==true)){
                        waitingPeriod+=0.3f;
                        Debug.Log(waitingPeriod);
                        if(waitingPeriod>0.7f){
                            if(optionsToSelect[0]=="Fire"){
                                attackingWithMagic = new MagicAttack();
                                attackType = optionsToSelect[0];
                                attackingWithMagic.Start();
                                attackingWithMagic.retrieveEnemies(EnemyNumber);
                                attackingWithMagic.FireAttackEnemy();
                                secondCheck = false;
                            //	flag =0;
                                waitingPeriod=0;
                            }
                            if(optionsToSelect[0] =="Water"){
                                attackingWithMagic = new MagicAttack();
                                attackType = optionsToSelect[0];
                                attackingWithMagic.Start();
                                attackingWithMagic.retrieveEnemies(EnemyNumber);
                                attackingWithMagic.FireAttackEnemy();
                                secondCheck = false;
                                //flag =0;
                                waitingPeriod=0;
                            }

                        }
                    }

                    if/*(Input.GetKeyUp("joystick button 2"))*/
                    ((Input.GetKeyUp("joystick button 1"))&&(secondCheck)){
                        waitingPeriod+=0.3f;

                        Debug.Log(waitingPeriod);
                        if(waitingPeriod>0.7f){
                            if(optionsToSelect[1] =="Wind"){
                                attackingWithMagic = new MagicAttack();
                                attackType = "Wind";
                                attackingWithMagic.Start();
                                attackingWithMagic.retrieveEnemies(EnemyNumber);
                                attackingWithMagic.FireAttackEnemy();
                                secondCheck = false;
                                //flag =0;
                                waitingPeriod=0;
                            }
                            if(optionsToSelect[1] =="Ice"){
                                attackingWithMagic = new MagicAttack();
                                attackType = "Ice";
                                attackingWithMagic.Start();
                                attackingWithMagic.retrieveEnemies(EnemyNumber);
                                attackingWithMagic.IceAttackEnemy();
                                secondCheck = false;
                                //flag =0;
                                waitingPeriod=0;
                            }

                        }
                    }
                    if(Input.GetKeyUp("joystick button 2"))/*(Input.GetKeyUp("joystick button 3")){*/
                    {
                        waitingPeriod+=0.3f;
                        Debug.Log(waitingPeriod);
                        if(waitingPeriod>0.7f){

                            if(optionsToSelect[2] =="Water"){
                                attackingWithMagic = new MagicAttack();
                                attackType = "Water";
                                attackingWithMagic.Start();
                                attackingWithMagic.retrieveEnemies(EnemyNumber);
                                attackingWithMagic.FireAttackEnemy();
                                secondCheck = false;
                                //flag =0;
                                waitingPeriod=0;
                            }
                            if(optionsToSelect[2] =="Lightning"){
                                attackingWithMagic = new MagicAttack();
                                attackType = "Lightning";
                                attackingWithMagic.Start();
                                attackingWithMagic.retrieveEnemies(EnemyNumber);
                                attackingWithMagic.LightningAttackEnemy();
                                secondCheck = false;
                                //flag =0;
                                waitingPeriod=0;
                            }

                        }
                    }
                    if(Input.GetKeyUp("joystick button 3"))/*(Input.GetKeyUp("joystick button 1")){*/{

                    }
                    if((flag==2)&&
                       (((Input.GetKeyUp("joystick button 0")))||
                     ((Input.GetKeyUp("joystick button 1")))||
                     ((Input.GetKeyUp("joystick button 2")))
                     )&&(secondCheck==false)){
                        secondCheck=true;
                        waitingPeriod+=0.1f;
                    }

                }
                if(flag==3){
        //				Items();
                    for(int cnt =0; cnt < optionsToSelect.Length; cnt ++){
                        /*if((attackDisplay+cnt)>stored.items.Length){
                            attackDisplay--;
                        }*/

                        if(((attackDisplay+cnt)<stored.items.Length)
                           &&(cnt < stored.items.Length)){
                            optionsToSelect[cnt] = stored.items[cnt+attackDisplay];
                        }else{
                            optionsToSelect[cnt] = "";
                        }

                        if(Input.GetKeyUp("joystick button 8")){
                            attackDisplay--;
                            if(attackDisplay < 0)
                                attackDisplay =0;
                        }
                        if(Input.GetKeyUp("joystick button 9")){
                            attackDisplay++;
                        }
                        if(cnt == optionsToSelect.Length-1){
                            optionsToSelect[3] = "Back";
                        }
                    }
                    if(Input.GetKeyUp("joystick button 0")){
                    }
                    if/*(Input.GetKeyUp("joystick button 2"))*/
                    (Input.GetKeyUp("joystick button 1")){
                    }
                    if(Input.GetKeyUp("joystick button 2"))/*(Input.GetKeyUp("joystick button 3"))*/
                    {
                    }
                    if(Input.GetKeyUp("joystick button 3")){/*(Input.GetKeyUp("joystick button 1")){*/

                        flag =0;
                        optionsToSelect[0] = "Attack";
                        optionsToSelect[1] = "Magic";
                        optionsToSelect[2] = "Items";
                        optionsToSelect[3] = "Run";
                        attackDisplay=0;
                        flagCheck=false;
                    }
                }
                if(flag==4){
                    Run();
                }

            }
        }
    }
Exemple #21
0
    public void pickup()
    {
        var isMagician = id.typePrefix == Identifier.magicianType;

        Debug.Log("Starting pickup");

        // Working out what was hit
        RaycastHit hit;

        if (!Physics.Raycast(cam.transform.position, cam.transform.forward, out hit, pickupDistance,
                             attackScript.getLayerMask()))
        {
            return;
        }

        PickUpItem item = hit.transform.gameObject.GetComponentInChildren <PickUpItem>(); // Pickup item lives on parent

        if (item == null)
        {
            return;                                                    // If we hit an item
        }
        if (item.itemClass == PickUpItem.Class.MAGICIAN && isMagician) // Artifacts
        {
            MagicAttack magic = (MagicAttack)attackScript;

            // Downgrade artifacts before picking up new one. Downgrade method only downgrades if you own an artifact.
            if (item.itemType != PickUpItem.ItemType.LESSER_ARTIFACT)
            {
                if (magic.shieldManager.hasArtifact)
                {
                    magic.shieldManager.downgrade();
                }

                foreach (var spell in magic.spells)
                {
                    if (spell.hasArtifact)
                    {
                        spell.downgrade();
                    }
                }
            }

            // Upgrade relevant artifact. Only upgrades if the artifact is the correct type
            foreach (var spell in magic.spells)
            {
                spell.upgrade(item.itemType);
            }

            magic.shieldManager.upgrade(item.itemType);

            item.pickedUp();
        }
        else if (item.itemClass == PickUpItem.Class.GUNNER && !isMagician) // Special weapons
        {
            WeaponAttack gunner = (WeaponAttack)attackScript;

            var xbow = gunner.weapons[5];
            gunner.weaponWheel.onRecieveSpecialWeapon(xbow);
            gunner.equippedWeapons[3] = xbow;

            item.pickedUp();
        }
    }
Exemple #22
0
 private void Start()
 {
     magic       = GetComponent <MagicAttack>();
     telekinesis = magic.telekin;
 }
    private void UpdateAttacks()
    {
        if (this.attack1Timer <= 0)
        {
            if (Input.GetButtonDown("Action1"))
            {
                MagicAttack attack         = Instantiate(MagicAttackPrefab, this.transform.position, Quaternion.AngleAxis(Random.Range(0, 360), Vector3.forward));
                float       damageModifier = Mathf.Max(0.5F, this.stats.Attack1Strength / 5F);
                float       sizeModifier   = Mathf.Max(0.5F, this.stats.Attack1Size / 10F);
                attack.Initialise(damageModifier, sizeModifier);

                // Play audio
                this.audioPlayer.PlayClipRandom(this.blastAttackAudio);

                // Reset attack timer
                this.attack1Timer = 1.0F / this.attack1RateOfFire;
            }
        }
        else
        {
            // Count down attack timer
            this.attack1Timer -= Time.deltaTime;
        }

        if (this.attack2Timer <= 0)
        {
            if (Input.GetButtonDown("Action2"))
            {
                // Find direction based on player's current facing direction
                float     projectileSpeed     = 15F;
                Direction projectileDirection = (Direction)this.spriteAnimator.GetInteger("Direction");
                Vector2   baseVelocity        = Vector2.zero;
                if (projectileDirection == Direction.Right)
                {
                    baseVelocity = Vector2.right * projectileSpeed;
                }
                else if (projectileDirection == Direction.Down)
                {
                    baseVelocity = Vector2.down * projectileSpeed;
                }
                else if (projectileDirection == Direction.Left)
                {
                    baseVelocity = Vector2.left * projectileSpeed;
                }
                else if (projectileDirection == Direction.Up)
                {
                    baseVelocity = Vector2.up * projectileSpeed;
                }

                // Create N projectiles scattered across a range
                float damageModifier = Mathf.Max(0.5F, this.stats.Attack2Strength / 5F);
                int   numProjectiles = this.stats.Attack2NumberOfProjectiles;

                // Scatter range is wider for more projectiles
                float scatterAngle = Mathf.Min(90, 9F * numProjectiles);

                for (int i = 0; i < numProjectiles; i++)
                {
                    MagicProjectile projectile = Container.InstantiatePrefab(MagicProjectilePrefab).GetComponent <MagicProjectile>();
                    projectile.transform.position = this.transform.position;
                    projectile.transform.rotation = Quaternion.AngleAxis(Random.Range(0, 360), Vector3.forward);

                    float angle = Random.Range(-scatterAngle / 2, scatterAngle / 2);
                    projectile.Initialise(Quaternion.AngleAxis(angle, Vector3.forward) * baseVelocity, damageModifier);
                }

                // Play audio
                this.audioPlayer.PlayClipRandom(this.orbAttackAudio, 0.15F);

                // Reset attack timer
                this.attack2Timer = 1.0F / this.attack2RateOfFire;
            }
        }
        else
        {
            // Count down attack timer
            this.attack2Timer -= Time.deltaTime;
        }
    }
 public ActionMagicAttackAll(SimulatorContext context, FightingCharacter attacker, List <FightingCharacter> targets, MagicAttack magic) : base(context, attacker, targets)
 {
     _magic = magic;
 }
 /// <summary>
 /// Start this instance.
 /// </summary>
 void Start()
 {
     desiredPlayer  =GameObject.FindGameObjectsWithTag("Player2");
     battle = desiredPlayer[0].GetComponent<BattleTimeScript>();
     constVar  =GameObject.FindGameObjectWithTag("Constant");
     stored = constVar.GetComponent<StoredInformation>();
     attacking = new PlayerAttack();
     attackingWithMagic = new MagicAttack();
 }
Exemple #26
0
    // Update is called once per frame
    /// <summary>
    /// Update this instance.
    /// this handles taking the inputs and sending the correct repsone to the attack script
    /// this is done by button presses to determine the correct response that are depicted by different screens
    /// </summary>
    void Update()
    {
        GameObject[] enemyObjects = GameObject.FindGameObjectsWithTag("Enemy2");
        if (enemyObjects.Length != 0)
        {
            if ((battle.timeToAttack > 99) && (counter != 1))
            {
                counter = 1;
            }
            if ((battle.timeToAttack < 99) && (counter == 1))
            {
                counter            = 0;
                optionsToSelect[0] = "Attack";
                optionsToSelect[1] = "Magic";
                optionsToSelect[2] = "Items";
                optionsToSelect[3] = "Run";
                flag      = 0;
                flagCheck = false;
            }

            if (counter == 1)
            {
                if ((Input.GetKeyUp("joystick button 0")) && (flag != 1) && (!flagCheck))
                {
                    flag      = 1;
                    flagCheck = true;
                }
                if ((Input.GetKeyUp("joystick button 1")) && (flag != 2) && (!flagCheck))
                {
                    flag      = 2;
                    flagCheck = true;
                }
                if ((Input.GetKeyUp("joystick button 2")) && (flag != 3) && (!flagCheck))
                {
                    flag      = 3;
                    flagCheck = true;
                }
                if ((Input.GetKeyUp("joystick button 3")) && (flag != 4) && (!flagCheck))
                {
                    flag = 4;
                    if (buttonPressedCheck == 0)
                    {
                    }
                    else
                    {
                        buttonPressedCheck = 0;
                    }
                }

                if (flag == 1)
                {
                    //Attack();
                    GameObject[] game = GameObject.FindGameObjectsWithTag("Enemy2");
                    if (Input.GetKeyUp("joystick button 10"))
                    {
                        EnemyNumber--;
                        if (EnemyNumber < 0)
                        {
                            EnemyNumber = 0;
                        }
                    }
                    if (Input.GetKeyUp("joystick button 11"))
                    {
                        EnemyNumber++;
                        if (EnemyNumber > game.Length - 1)
                        {
                            EnemyNumber = game.Length - 1;
                        }
                    }

                    for (int cnt = 0; cnt < optionsToSelect.Length; cnt++)
                    {
                        if ((attackDisplay + cnt) > stored._attack.Length)
                        {
                            attackDisplay--;
                        }
                        if ((attackDisplay + cnt) < stored._attack.Length)
                        {
                            optionsToSelect[cnt] = stored._attack[cnt + attackDisplay];
                        }
                        if (Input.GetKeyUp("joystick button 8"))
                        {
                            attackDisplay--;
                            if (attackDisplay < 0)
                            {
                                attackDisplay = 0;
                            }
                        }
                        if (Input.GetKeyUp("joystick button 9"))
                        {
                            attackDisplay++;
                        }
                        if (cnt == optionsToSelect.Length - 1)
                        {
                            optionsToSelect[3] = "Back";
                        }
                        if (Input.GetKeyUp("joystick button 3"))
                        {
                            flag = 0;
                            optionsToSelect[0] = "Attack";
                            optionsToSelect[1] = "Magic";
                            optionsToSelect[2] = "Items";
                            optionsToSelect[3] = "Run";
                            attackDisplay      = 0;
                            flagCheck          = false;
                        }

                        if ((Input.GetKeyUp("joystick button 0")) && (secondCheck == true))
                        {
                            waitingPeriod += 0.1f;
                            if (waitingPeriod > 0.6f)
                            {
                                if (optionsToSelect[0] == "Attack")
                                {
                                    attacking  = new PlayerAttack();
                                    attackType = "Attack";
                                    attacking.Start();
                                    attacking.retrieveEnemies(EnemyNumber);
                                    attacking.AttackEnemy();
                                    secondCheck   = false;
                                    waitingPeriod = 0;
                                }
                                if (optionsToSelect[0] == "FireAttack")
                                {
                                    attacking  = new PlayerAttack();
                                    attackType = "FireAttack";
                                    attacking.Start();
                                    attacking.retrieveEnemies(EnemyNumber);
                                    attacking.FireAttackEnemy();
                                    secondCheck   = false;
                                    waitingPeriod = 0;
                                }
                            }
                        }

                        if                        /*(Input.GetKeyUp("joystick button 2"))*/
                        ((Input.GetKeyUp("joystick button 1")) && (secondCheck))
                        {
                            waitingPeriod += 0.1f;
                            if (waitingPeriod > 0.6f)
                            {
                                if (optionsToSelect[1] == "FireAttack")
                                {
                                    attacking  = new PlayerAttack();
                                    attackType = "FireAttack";
                                    attacking.Start();
                                    attacking.retrieveEnemies(EnemyNumber);
                                    attacking.FireAttackEnemy();
                                    secondCheck   = false;
                                    waitingPeriod = 0;
                                }
                                if (optionsToSelect[1] == "IceAttack")
                                {
                                    attacking  = new PlayerAttack();
                                    attackType = "IceAttack";
                                    attacking.Start();
                                    attacking.retrieveEnemies(EnemyNumber);
                                    attacking.IceAttackEnemy();
                                    secondCheck   = false;
                                    waitingPeriod = 0;
                                }
                            }
                        }
                        if (Input.GetKeyUp("joystick button 2"))                       /*(Input.GetKeyUp("joystick button 3")){*/
                        {
                            waitingPeriod += 0.1f;
                            if (waitingPeriod > 0.6f)
                            {
                                if (optionsToSelect[2] == "IceAttack")
                                {
                                    attacking  = new PlayerAttack();
                                    attackType = "IceAttack";
                                    attacking.Start();
                                    attacking.retrieveEnemies(EnemyNumber);
                                    attacking.IceAttackEnemy();
                                    secondCheck   = false;
                                    waitingPeriod = 0;
                                }
                                if (optionsToSelect[2] == "LightningAttack")
                                {
                                    attacking  = new PlayerAttack();
                                    attackType = "LightningAttack";
                                    attacking.Start();
                                    attacking.retrieveEnemies(EnemyNumber);
                                    attacking.LightningAttackEnemy();
                                    secondCheck   = false;
                                    waitingPeriod = 0;
                                }
                            }
                        }
                        if (Input.GetKeyUp("joystick button 3"))                       /*(Input.GetKeyUp("joystick button 1")){*/
                        {
                        }
                    }


                    if ((flag == 1) &&
                        (((Input.GetKeyUp("joystick button 0"))) ||
                         ((Input.GetKeyUp("joystick button 1"))) ||
                         ((Input.GetKeyUp("joystick button 2")))
                        ) && (secondCheck == false))
                    {
                        secondCheck = true;
                    }
                }
                if (flag == 2)
                {
                    //Magic();

                    for (int cnt = 0; cnt < optionsToSelect.Length; cnt++)
                    {
                        if ((attackDisplay + cnt) > stored._mana.Length)
                        {
                            attackDisplay--;
                        }
                        if ((attackDisplay + cnt) < stored._mana.Length)
                        {
                            optionsToSelect[cnt] = stored._mana[cnt + attackDisplay];
                        }
                        if (Input.GetKeyUp("joystick button 8"))
                        {
                            attackDisplay--;
                            if (attackDisplay < 0)
                            {
                                attackDisplay = 0;
                            }
                        }
                        if (Input.GetKeyUp("joystick button 9"))
                        {
                            attackDisplay++;
                        }
                        if (cnt == optionsToSelect.Length - 1)
                        {
                            optionsToSelect[3] = "Back";
                        }
                    }
                    GameObject[] game = GameObject.FindGameObjectsWithTag("Enemy2");
                    if (Input.GetKeyUp("joystick button 10"))
                    {
                        EnemyNumber--;
                        if (EnemyNumber < 0)
                        {
                            EnemyNumber = 0;
                        }
                    }
                    if (Input.GetKeyUp("joystick button 11"))
                    {
                        EnemyNumber++;
                        if (EnemyNumber > game.Length - 1)
                        {
                            EnemyNumber = game.Length - 1;
                        }
                    }
                    if (Input.GetKeyUp("joystick button 3"))                    /*(Input.GetKeyUp("joystick button 1")){*/
                    {
                        flag = 0;
                        optionsToSelect[0] = "Attack";
                        optionsToSelect[1] = "Magic";
                        optionsToSelect[2] = "Items";
                        optionsToSelect[3] = "Run";
                        attackDisplay      = 0;
                        flagCheck          = false;
                    }

                    if ((Input.GetKeyUp("joystick button 0")) && (secondCheck == true))
                    {
                        waitingPeriod += 0.3f;
                        Debug.Log(waitingPeriod);
                        if (waitingPeriod > 0.7f)
                        {
                            if (optionsToSelect[0] == "Fire")
                            {
                                attackingWithMagic = new MagicAttack();
                                attackType         = optionsToSelect[0];
                                attackingWithMagic.Start();
                                attackingWithMagic.retrieveEnemies(EnemyNumber);
                                attackingWithMagic.FireAttackEnemy();
                                secondCheck = false;
                                //	flag =0;
                                waitingPeriod = 0;
                            }
                            if (optionsToSelect[0] == "Water")
                            {
                                attackingWithMagic = new MagicAttack();
                                attackType         = optionsToSelect[0];
                                attackingWithMagic.Start();
                                attackingWithMagic.retrieveEnemies(EnemyNumber);
                                attackingWithMagic.FireAttackEnemy();
                                secondCheck = false;
                                //flag =0;
                                waitingPeriod = 0;
                            }
                        }
                    }

                    if                    /*(Input.GetKeyUp("joystick button 2"))*/
                    ((Input.GetKeyUp("joystick button 1")) && (secondCheck))
                    {
                        waitingPeriod += 0.3f;

                        Debug.Log(waitingPeriod);
                        if (waitingPeriod > 0.7f)
                        {
                            if (optionsToSelect[1] == "Wind")
                            {
                                attackingWithMagic = new MagicAttack();
                                attackType         = "Wind";
                                attackingWithMagic.Start();
                                attackingWithMagic.retrieveEnemies(EnemyNumber);
                                attackingWithMagic.FireAttackEnemy();
                                secondCheck = false;
                                //flag =0;
                                waitingPeriod = 0;
                            }
                            if (optionsToSelect[1] == "Ice")
                            {
                                attackingWithMagic = new MagicAttack();
                                attackType         = "Ice";
                                attackingWithMagic.Start();
                                attackingWithMagic.retrieveEnemies(EnemyNumber);
                                attackingWithMagic.IceAttackEnemy();
                                secondCheck = false;
                                //flag =0;
                                waitingPeriod = 0;
                            }
                        }
                    }
                    if (Input.GetKeyUp("joystick button 2"))                   /*(Input.GetKeyUp("joystick button 3")){*/
                    {
                        waitingPeriod += 0.3f;
                        Debug.Log(waitingPeriod);
                        if (waitingPeriod > 0.7f)
                        {
                            if (optionsToSelect[2] == "Water")
                            {
                                attackingWithMagic = new MagicAttack();
                                attackType         = "Water";
                                attackingWithMagic.Start();
                                attackingWithMagic.retrieveEnemies(EnemyNumber);
                                attackingWithMagic.FireAttackEnemy();
                                secondCheck = false;
                                //flag =0;
                                waitingPeriod = 0;
                            }
                            if (optionsToSelect[2] == "Lightning")
                            {
                                attackingWithMagic = new MagicAttack();
                                attackType         = "Lightning";
                                attackingWithMagic.Start();
                                attackingWithMagic.retrieveEnemies(EnemyNumber);
                                attackingWithMagic.LightningAttackEnemy();
                                secondCheck = false;
                                //flag =0;
                                waitingPeriod = 0;
                            }
                        }
                    }
                    if (Input.GetKeyUp("joystick button 3"))                   /*(Input.GetKeyUp("joystick button 1")){*/
                    {
                    }
                    if ((flag == 2) &&
                        (((Input.GetKeyUp("joystick button 0"))) ||
                         ((Input.GetKeyUp("joystick button 1"))) ||
                         ((Input.GetKeyUp("joystick button 2")))
                        ) && (secondCheck == false))
                    {
                        secondCheck    = true;
                        waitingPeriod += 0.1f;
                    }
                }
                if (flag == 3)
                {
                    //				Items();
                    for (int cnt = 0; cnt < optionsToSelect.Length; cnt++)
                    {
                        /*if((attackDisplay+cnt)>stored.items.Length){
                         *      attackDisplay--;
                         * }*/

                        if (((attackDisplay + cnt) < stored.items.Length) &&
                            (cnt < stored.items.Length))
                        {
                            optionsToSelect[cnt] = stored.items[cnt + attackDisplay];
                        }
                        else
                        {
                            optionsToSelect[cnt] = "";
                        }

                        if (Input.GetKeyUp("joystick button 8"))
                        {
                            attackDisplay--;
                            if (attackDisplay < 0)
                            {
                                attackDisplay = 0;
                            }
                        }
                        if (Input.GetKeyUp("joystick button 9"))
                        {
                            attackDisplay++;
                        }
                        if (cnt == optionsToSelect.Length - 1)
                        {
                            optionsToSelect[3] = "Back";
                        }
                    }
                    if (Input.GetKeyUp("joystick button 0"))
                    {
                    }
                    if                    /*(Input.GetKeyUp("joystick button 2"))*/
                    (Input.GetKeyUp("joystick button 1"))
                    {
                    }
                    if (Input.GetKeyUp("joystick button 2"))                   /*(Input.GetKeyUp("joystick button 3"))*/
                    {
                    }
                    if (Input.GetKeyUp("joystick button 3"))                    /*(Input.GetKeyUp("joystick button 1")){*/

                    {
                        flag = 0;
                        optionsToSelect[0] = "Attack";
                        optionsToSelect[1] = "Magic";
                        optionsToSelect[2] = "Items";
                        optionsToSelect[3] = "Run";
                        attackDisplay      = 0;
                        flagCheck          = false;
                    }
                }
                if (flag == 4)
                {
                    Run();
                }
            }
        }
    }
Exemple #27
0
 private void Start()
 {
     magic = GetComponent <MagicAttack>();
 }