Пример #1
0
    // Use this for initialization
    void Start()
    {
        /// Base class initialisation
        sprRend = GetComponent <SpriteRenderer>();

        rb   = GetComponent <Rigidbody2D>();
        anim = GetComponent <Animator>();
        //remove this later
        initialColor = sprRend.color;

        health   = 100;
        atkSpeed = 2.0f;

        range = weapon.AtkRange;
        speed = 3;
        atk   = weapon.Atk;

        initialAtk   = atk;
        initialSpeed = speed;
        defense      = 10;

        /// This class initialisation
        player       = GameObject.FindGameObjectWithTag("Player");
        rangedAttack = GetComponent <RangedAttack>();
        originalPos  = transform.position;

        CurrState = InitialState;

        rangedAttack.AtkCooldown = weapon.AtkSpeed;
        colorTime  = 0.2f;
        colorTimer = colorTime;

        ExpValue = 100;
    }
Пример #2
0
        private void GameObject_OnCreate(GameObject gsender)
        {
            var mc = gsender as MissileClient;

            if (mc == null || !mc.IsValid)
            {
                return;
            }

            var sender = mc.SpellCaster;
            var target = mc.Target;

            var targetBase = target as Obj_AI_Base;

            if (sender == null || targetBase == null || !sender.IsValid || !target.IsValid || target.IsDead ||
                sender.IsDead || sender.IsMe || sender.Distance(ObjectManager.GetLocalPlayer()) > 4000)
            {
                return;
            }


            var attack = new RangedAttack(sender, targetBase, mc, 0);

            Attacks.AddAttack(attack);
        }
Пример #3
0
    IEnumerator RangeAtt()
    {
        this.transform.LookAt(Player.transform.position);
        float temp = Time.deltaTime;

        RangedAttack Ranged = MobObj.GetComponent <RangedAttack>();

        Ranged.damage    = DMG;
        Ranged.PlayerPos = Player.transform.position;
        MobObj.SetActive(true);

        while (true)
        {
            if (time >= AttackFrame)
            {
                ani.SetBool("IsAttack", false);
            }
            if (time >= TimeLimit)
            {
                break;
            }
            else
            {
                time += temp;
            }
            yield return(new WaitForSeconds(temp));
        }
    }
Пример #4
0
 public void SetUpRangedAttack()
 {
     rangedAttack = new RangedAttack(GameObject.Find("RangedAttack").transform,
                                     Resources.Load("Prefabs/VFX/WindSlash") as GameObject,
                                     new AbilitiesDatabaseConn("RangedAttack"));
     rangedAttack.SetCharacterAnimationController(characterAnimationController);
 }
Пример #5
0
        /// Creates a [RayAction] radiating from [_from] centered on [_to] (which
        /// may be the same as [_from] if the ray is a full circle. It applies
        /// [_attack] to each touched tile. The rays cover a chord whose width is
        /// [fraction] which varies from 0 (an infinitely narrow line) to 1.0 (a full
        /// circle.
        public RayAction(VectorBase from, VectorBase to, Attack attack, double fraction)
        {
            _from   = from;
            _attack = (RangedAttack)attack;
            _to     = to;

            // Don't hit the creator of the cone.
            _hitTiles.Add(_from);

            // We "fill" the cone by tracing a number of rays. We need enough of them
            // to ensure there are no gaps when the cone is at its maximum extent.
            var circumference = Math.PI * 2 * _attack.Range;
            var numRays       = Math.Ceiling(circumference * fraction);

            // Figure out the center angle of the cone.
            var offset = _to - _from;
            // TODO: Make atan2 getter on VectorBase?
            var centerTheta = 0.0;

            if (_from != _to)
            {
                centerTheta = Math.Atan2(offset.x, offset.y);
            }

            // Create the rays.
            for (var i = 0; i < numRays; i++)
            {
                var range = (i / (numRays - 1)) - 0.5;
                _rays.Add(centerTheta + range * (Math.PI * 2 * fraction));
            }
        }
Пример #6
0
    public void ChaseAndBurstAttack()
    {
        //Replace this with pathfinding to the target
        Vector2 dir = (Target.Body.mAABB.Center - (Body.mAABB.Center + attackAnchor)).normalized;

        if (EnemyBehaviour.TargetInRange(this, Target, 124))
        {
            if (!mAttackManager.rangedAttacks[0].OnCooldown())
            {
                RangedAttack attack = mAttackManager.rangedAttacks[0];
                attack.Activate(dir, Position);
                mBossState = BossState.Aggrivated;
            }
        }
        else
        {
            Body.mSpeed = (Target.Position + new Vector2(32, 32) - Position).normalized * GetMovementSpeed();
        }

        if (dir.x < 0)
        {
            mDirection = EntityDirection.Right;
            //Body.mAABB.ScaleX = 1;
        }
        else
        {
            mDirection = EntityDirection.Left;
            //Body.mAABB.ScaleX = -1;
        }
    }
Пример #7
0
        private static void Obj_AI_Base_OnProcessAutoAttack(Obj_AI_Base sender, Obj_AI_BaseMissileClientDataEventArgs e)
        {
            //Ignore auto attacks happening too far away
            if (sender == null || !sender.IsValidTarget(4000, true) || sender is Obj_AI_Hero)
            {
                return;
            }

            //Only process for minion targets
            var targetM = e.Target as Obj_AI_Minion;

            if (targetM == null)
            {
                return;
            }


            AutoAttack attack;

            if (sender.IsMelee)
            {
                attack = new MeleeAttack(sender, targetM, 0);
            }

            else
            {
                attack = new RangedAttack(sender, targetM, 0);
            }

            Attacks.AddAttack(attack);
        }
Пример #8
0
        private void CreateNewData()
        {
            AssetDatabase.CreateAsset(_ability, "Assets/Scriptable Objects/Abilities/Ranged/" + _name + ".asset");
            AssetDatabase.SaveAssets();

            _ability = CreateInstance <RangedAttack>();
        }
Пример #9
0
    //Does a bullet have a reference to an attack?
    //or does a bullet behave like an attack?

    public Projectile(ProjectilePrototype proto, RangedAttack attack, Vector2 direction) : base(proto, attack, direction)
    {
        frameDelay             = proto.frameDelay;
        this.collidesWithTiles = proto.collidesWithTiles;
        this.attack            = attack;
        isAngled = proto.angled;
        //Body.mState = ColliderState.Closed;
        SetOwner(attack.mEntity);
        hitbox        = new Hitbox(this, new CustomAABB(Position, proto.hitboxSize, new Vector2(0, 0)));
        hitbox.mState = ColliderState.Closed;
        Body          = new PhysicsBody(this, new CustomAABB(Position, proto.bodySize, new Vector2(0, 0)));

        Body.mIsKinematic = true;
        //mMovingSpeed = 100;
        Body.mIgnoresOneWay = true;
        pierce   = proto.pierce;
        isBouncy = proto.bouncy;

        Body.mIgnoresGravity = proto.ignoreGravity;

        mMovingSpeed = proto.speed;

        if (SoundManager.instance != null)
        {
            SoundManager.instance.PlaySingle(proto.spawnSFX);
        }
        //AudioSource.PlayClipAtPoint(sfx, Body.mPosition);
    }
Пример #10
0
 void Awake()
 {
     weaponManager = GetComponent <WeaponManager>();
     meleeAttack   = GetComponent <MeleeAttack>();
     rangedAttack  = GetComponent <RangedAttack>();
     animator      = GetComponent <Animator>();
     block         = GetComponent <Block>();
 }
Пример #11
0
    private void Fire()                                                                                                       // Method for firing the bow
    {
        isFiring = true;                                                                                                      // isFiring bool is set to true
        Vector2      temp  = new Vector2(Player.GetFloat("lastMoveX"), Player.GetFloat("lastMoveY"));                         // Store Players last known X,Y position in temp variable
        RangedAttack arrow = Instantiate(ArrowObject, transform.position, Quaternion.identity).GetComponent <RangedAttack>(); // Instantiates the arrow prefab

        arrow.Setup(temp, ArrowDirection());                                                                                  // arrow variable stores Player Postion and calulates position of arrow
        Invoke("SetFiring", fireTime);                                                                                        // Activate the time between firing arrows
    }
Пример #12
0
 public Archer(Field location, Player owner) :
     base(
         location: location,
         textureDescriptor: location.World.Resources.Get <GameTilesets>().Units.Archer,
         owner: owner
         )
 {
     rangedAttack = (RangedAttack)GrantAbility(RangedAttack.Factory(this));
 }
Пример #13
0
 protected override void SetAttacks()
 {
     this.melee = new MeleeAttack(
         2,
         actorPosition,
         new MeleeRangeAugment(),
         new DamageAugment(),
         new MeleeCleaveAugment()
         );
     ranged = new RangedAttack(this.actorPosition, projectile);
 }
Пример #14
0
    // Use this for initialization (external)
    void Start()
    {
        rigid    = this.GetComponent <Rigidbody>();
        animator = this.GetComponent <Animator>();
        bow.SetActive(false);

        //Initialize melee script
        melee = this.GetComponentInChildren <MeleeAttack>();
        melee.SetAttackDamage(meleeDamage);

        //Initialize ranged script
        ranged = this.GetComponentInChildren <RangedAttack>();
        ranged.SetAttackDamage(rangedDamage);
    }
Пример #15
0
 // Use this for initialization
 void Start()
 {
     tempBoost      = new Dictionary <Items.Type, float>();
     memoryBoost    = new List <Items.Type>();
     magnitudeBoost = new Dictionary <Items.Type, float>();
     RangedAttack   = gameObject.GetComponent <RangedAttack>();
     health         = gameObject.GetComponentInChildren <Health>();
     myRb           = GetComponent <Rigidbody2D>();
     OrienteProjectileSpawn(270);
     EndPerturbation();
     lastPressedAxisVert = 0;
     lastPressedAxisHori = 0;
     interdictionSprite  = interdictionHUD.GetComponent <Image>();
 }
Пример #16
0
        private void ranged(string name, int level, int price, string foreColour, string noun, int damage, int range,
                            int tossDamage)
        {
            var toss = new RangedAttack(new Noun($"the {name.ToLower()}"),
                                        Log.MakeVerbsAgree(_verb, Pronouns.It), tossDamage, ElementFactory.Instance.None,
                                        _tossRange.HasValue ? _tossRange.Value : 0);

            var localGlyph = _glyph.Clone() as Glyph;

            localGlyph.Fore = foreColour;

            item(name, level, localGlyph, "bow",
                 attack: new RangedAttack(noun, "pierce[s]", damage, ElementFactory.Instance.None, range),
                 tossAttack: toss,
                 price: price);
        }
Пример #17
0
        private void item(string name, int level, object appearance,
                          string equipSlot = null, ItemUse use             = null,
                          Attack attack    = null, RangedAttack tossAttack = null,
                          int armor        = 0, int price = 0,
                          bool treasure    = false)
        {
            // If the appearance isn"t an actual glyph, it should be a color function
            // that will be applied to the current glyph.
            Glyph localGlyph = null;

            if (!(appearance is Glyph) && appearance is string)
            {
                var gylphForColor = appearance as string;
                localGlyph      = _glyph;
                localGlyph.Fore = gylphForColor;
            }
            else
            {
                localGlyph = appearance as Glyph;
            }

            var categories = new List <string>();

            if (_category != null)
            {
                categories = _category.Split('/').ToList();
            }

            if (equipSlot == null)
            {
                equipSlot = _equipSlot;
            }

            if (tossAttack == null && _tossDamage != null)
            {
                tossAttack = new RangedAttack(new Noun($"the {name.ToLower()}"), "hits",
                                              (double)_tossDamage, _tossElement, _tossRange.HasValue ? _tossRange.Value : 0);
            }

            var newItemType = new ItemType(name, localGlyph, level, _sortIndex++,
                                           categories, equipSlot, use, attack, tossAttack, _breakage, armor, price,
                                           treasure);

            ItemTypes.Add(name, newItemType);
        }
Пример #18
0
    public override void OnDamagedTrigger(Attack attack)
    {
        base.OnDamagedTrigger(attack);

        if (Random.Range(0, 100) > procChance)
        {
            return;
        }

        rangedAttack = new RangedAttack(owner, attackPrototype);
        Vector2 tempDir = Vector2.up;

        if (attack.mEntity != null)
        {
            tempDir = attack.mEntity.Position - owner.Position;
        }

        rangedAttack.Activate(tempDir, owner.Position);
    }
Пример #19
0
 public ItemType(string name, Glyph glyph, int level, int sortIndex, List <string> categories, string equipSlot, ItemUse use, Attack attack, RangedAttack tossAttack,
                 int?breakage, int armor, int price, bool treasure, int id = 0, string description = null, string slug = null, bool stackable = false)
 {
     this.name        = name;
     this.glyph       = glyph;
     this.level       = level;
     this.sortIndex   = sortIndex;
     this.categories  = categories;
     this.equipSlot   = equipSlot;
     this.use         = use;
     this.attack      = attack;
     this.tossAttack  = tossAttack;
     this.breakage    = breakage;
     this.armor       = armor;
     this.price       = price;
     isTreasure       = treasure;
     this.id          = id;
     this.description = description;
     this.slug        = slug;
     this.stackable   = stackable;
 }
Пример #20
0
    /// <summary>
    ///
    /// here we set up the enemy attack action types based on the enemy type
    ///
    /// </summary>
    public void Start()
    {
        switch (owner.EnemyType)
        {
        case e_EnemyType.Ghost:
            meleeAttackActions = (owner as Ghost).meleeAttack;
            break;

        case e_EnemyType.Witch:
            rangedAttackActions = (owner as Witch).rangedAttack;
            break;

        case e_EnemyType.Phoenix:
            meleeAttackActions  = (owner as Phoenix).meleeAttack;
            rangedAttackActions = (owner as Phoenix).rangedAttack;
            break;

        default:
            break;
        }
    }
Пример #21
0
    public void Pickup(GearController controller)
    {
        switch (powerupType)
        {
        case PowerupType.money:
            controller.GetComponent <MoneyController>().AddMoney(value);
            controller.GetComponent <AudioSource>().PlayOneShot(pickupSound);
            Destroy(gameObject);
            break;

        case PowerupType.key:
            if (!controller.GetComponent <MoneyController>().HasKey())
            {
                controller.GetComponent <MoneyController>().SetKey(true);
                controller.GetComponent <AudioSource>().PlayOneShot(pickupSound);
                Destroy(gameObject);
            }
            break;

        case PowerupType.health:
            if (controller.GetComponent <HealthController>().currHealth < controller.GetComponent <HealthController>().maxHealth)
            {
                controller.GetComponent <HealthController>().Heal(value);
                controller.GetComponent <AudioSource>().PlayOneShot(pickupSound);
                Destroy(gameObject);
            }
            break;

        case PowerupType.ammo:
            //TODO move ShouldPickup to IAttackable and check that instance on the weapon as it is guaranteed to be on a weapon
            RangedAttack attack = controller.weapon.GetComponent <RangedAttack>();
            if (attack != null && attack.ShouldPickup())
            {
                attack.GetAmmo(attack.maxAmmo / 4);
                controller.GetComponent <AudioSource>().PlayOneShot(pickupSound);
                Destroy(gameObject);
            }
            break;
        }
    }
    public void SetAttackList()
    {
        if (attackTypes != null)
        {
            for (int x = 0; x < attackTypes.Count; x++)
            {
                Attack newAttack;
                switch (attackTypes[x])
                {
                case AttackType.basic:
                {
                    newAttack = new BasicAttack();
                    attackList.Add(newAttack);
                    break;
                }

                case AttackType.bow:
                {
                    newAttack = new RangedAttack();
                    attackList.Add(newAttack);
                    break;
                }

                case AttackType.spear:
                {
                    newAttack = new SpearAttack();
                    attackList.Add(newAttack);
                    break;
                }

                case AttackType.hatchets:
                {
                    newAttack = new HatchetsAttack();
                    attackList.Add(newAttack);
                    break;
                }
                }
            }
        }
    }
Пример #23
0
    public bool Turn()
    {
        int      CurrentDamage       = 0;
        bool     CurrentCrit         = false;
        Creature CurrentCreature     = list[turn].Creature;
        int      CurrentDodgeBuff    = 0;
        bool     CurrentRun          = false;
        bool     CurrentDodgeSuccess = false;
        string   CurrentCMD          = list[turn].Cmd;
        Defense  CurrentDefense      = CurrentCreature.Defense;

        //check spells

        // save log

        if (CurrentCMD.Equals("attack"))
        {
            MeleeAttack MA = CurrentCreature.Melee;
            CurrentDamage = MA.Dmg;
            CurrentCrit   = MA.IsCritical();
        }

        else if (CurrentCMD.Equals("ranged attack"))
        {
            RangedAttack RA = CurrentCreature.Ranged;
            CurrentDamage = RA.Dmg;
            CurrentCrit   = RA.IsCritical();
        }

        else if (CurrentCMD.Equals("spell"))
        {
            // spell mechanics
        }

        else if (CurrentCMD.Equals("dodge"))
        {
            CurrentDodgeBuff = 20;
        }

        else if (CurrentCMD.Equals("run"))
        {
            CurrentRun = true;
        }

        int      Next             = (turn + 1) % 2;
        int      NextDamage       = 0;
        bool     NextCrit         = false;
        Creature NextCreature     = list[Next].Creature;
        int      NextDodgeBuff    = 0;
        bool     NextRun          = false;
        bool     NextDodgeSuccess = false;
        string   NextCMD          = list[Next].Cmd;
        Defense  NextDefense      = NextCreature.Defense;

        if (NextCMD.Equals("attack"))
        {
            MeleeAttack MA = NextCreature.Melee;
            NextDamage = MA.Dmg;
            NextCrit   = MA.IsCritical();
        }

        else if (NextCMD.Equals("ranged attack"))
        {
            RangedAttack RA = NextCreature.Ranged;
            NextDamage = RA.Dmg;
            NextCrit   = RA.IsCritical();
        }

        else if (NextCMD.Equals("spell"))
        {
            // spell mechanics
        }

        else if (NextCMD.Equals("dodge"))
        {
            NextDodgeBuff = 20;
        }

        else if (NextCMD.Equals("run"))
        {
            NextRun = true;
        }

        if (this.DodgeAttempt(CurrentDodgeBuff))
        {
            CurrentDodgeSuccess = true;
            NextDamage          = 0;
        }

        if (this.DodgeAttempt(NextDodgeBuff))
        {
            NextDodgeSuccess = true;
            CurrentDamage    = 0;
        }

        CurrentDamage = (CurrentDamage - NextDefense.Def < 0 ? 0 :
                         CurrentDamage - NextDefense.Def);

        NextCreature.Damage = CurrentDamage;

        this.BL.TurnLog = "";

        this.BL.SaveTurnLog(CurrentCreature, list[turn].IsPlayer(),
                            CurrentCMD, CurrentDamage, CurrentCrit, NextDodgeSuccess);

        if (NextCreature.HP == 0)
        {
            this.BL.CombatLog += TurnLog;
            this.Ended         = true;
            return(false);
        }

        NextDamage = (NextDamage - CurrentDefense.Def < 0 ? 0 :
                      NextDamage - CurrentDefense.Def);

        CurrentCreature.Damage = NextDamage;

        this.BL.SaveTurnLog(NextCreature, list[Next].IsPlayer(), NextCMD,
                            NextDamage, NextCrit, CurrentDodgeSuccess);

        this.BL.CombatLog += TurnLog;

        if (CurrentCreature.HP == 0)
        {
            this.Ended = true;
            return(false);
        }

        if (CurrentRun)
        {
            bool RunSuccess = this.CheckRun(list[turn]);
            this.SaveRunLog(RunSuccess);
            if (RunSuccess)
            {
                this._RunEnded = true;
                return(false);
            }
            else
            {
                return(true);
            }
        }
        if (NextRun)
        {
            bool RunSuccess = this.CheckRun(list[Next]);
            this.SaveRunLog(RunSuccess);
            if (RunSuccess)
            {
                this._RunEnded = true;
                return(false);
            }
            else
            {
                return(true);
            }
        }

        if (CurrentCreature.HP == 0 || NextCreature.HP == 0)
        {
            this.Ended = true;
        }

        list[turn].PostTurn();
        list[Next].PostTurn();

        return(true);
    }
Пример #24
0
    // Update is called once per frame
    void Update()
    {
        if (currentHpRegen < hpRegenTime)
        {
            currentHpRegen += Time.deltaTime;
        }
        else if (hpRegen && currentHp < hp)
        {
            currentHpRegen = 0;
            currentHp++;
            updateHP();
        }

        if (currentTeleportCoolDown < teleportCoolDown)
        {
            currentTeleportCoolDown += Time.deltaTime;
        }

        rb.velocity = new Vector2(0, 0);

        if (Input.GetKeyDown(KeyCode.E))
        {
            GameObject temp  = attack;
            GameObject temp2 = swapAttack2;

            attack      = swapAttack;
            swapAttack2 = temp;
            swapAttack  = temp2;


            if (attack.tag.Equals("Melee"))
            {
                MeleeAttack mA = attack.GetComponent <MeleeAttack>();
                anim.SetInteger("weapon", mA.weaponId);
            }
            else
            {
                anim.SetInteger("weapon", 2);
            }
        }

        if (Input.GetKeyDown(KeyCode.Q))
        {
            if (spellSelected == 0)
            {
                spellSelected = 1;
            }
            else
            {
                spellSelected = 0;
            }
        }

        Vector3 mouseScreenPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);

        Vector3 lookAt = mouseScreenPosition;

        float AngleRad = Mathf.Atan2(lookAt.y - this.transform.position.y, lookAt.x - this.transform.position.x);

        float AngleDeg = (180 / Mathf.PI) * AngleRad;

        transform.rotation = Quaternion.Euler(0, 0, 0);


        if (AngleDeg >= -45 && AngleDeg < 45)
        {
            //  Debug.Log("Right");
            //       transform.rotation = Quaternion.Euler(0, 0, 0);

            transform.localScale = new Vector3(-1 * transform.localScale.y, transform.localScale.y, transform.localScale.z);
        }

        // if (AngleDeg >= 45 && AngleDeg < 135)
        // {
        //     //Debug.Log("Up");

        //     transform.rotation = Quaternion.Euler(0, 0, 90);
        // }


        if (AngleDeg >= 135 || AngleDeg < -135)
        {
            ///  Debug.Log("Left");
            transform.localScale = new Vector3(transform.localScale.y, transform.localScale.y, transform.localScale.z);
            // transform.rotation = Quaternion.Euler(0, 0, 180);
        }


        // if (AngleDeg >= -135 && AngleDeg < -45)
        // {
        //     //    Debug.Log("Down");

        //     transform.rotation = Quaternion.Euler(0, 0, 270);
        // }

        float yMove = Input.GetAxis("Vertical");
        float xMove = Input.GetAxis("Horizontal");

        yMove       = Time.deltaTime * moveSpeed * 50.0f * slowDown * yMove * speedMod;
        xMove       = Time.deltaTime * moveSpeed * 50.0f * slowDown * xMove * speedMod;
        rb.velocity = new Vector2(xMove, yMove);


        if (Input.GetButton("Fire1") && attack != null)
        {
            if (attack.tag.Equals("Melee"))
            {
                MeleeAttack mASpec = attack.GetComponent <MeleeAttack>();
                if (mASpec.Attack(transform.position, AngleDeg))
                {
                    anim.SetTrigger("attacking");
                }
            }
            else if (attack.tag.Equals("Ranged"))
            {
                RangedAttack rASpec = attack.GetComponent <RangedAttack>();

                //rASpec.Shoot(transform.position, AngleDeg);
                rASpec.DrawBow();

                //    Debug.Log("Drawing Arrow " + rASpec.drawAmount);
                slowDown = 0.2f;

                anim.SetBool("bowDrawn", true);
            }
        }

        if (Input.GetButtonDown("Fire2") && spellSelected == 0 && currentTeleportCoolDown > teleportCoolDown && activeSpells[0] == 1)
        {
            mouseScreenPosition.z   = 0;
            transform.position      = mouseScreenPosition;
            currentTeleportCoolDown = 0;
        }

        if (flamethrowerCurrentTotalCoolDown < flamethrowerTotalCoolDown)
        {
            flamethrowerCurrentTotalCoolDown += Time.deltaTime;
        }

        if (flamethrowerCurrentPartCoolDown < flamethrowerPartCoolDown)
        {
            flamethrowerCurrentPartCoolDown += Time.deltaTime;
        }



        if (Input.GetButton("Fire2") && spellSelected == 1 && flamethrowerCurrentTotalCoolDown > flamethrowerTotalCoolDown && activeSpells[1] == 1)
        {
            flamethrowerCurrentTotalCoolDown -= Time.deltaTime * 50;

            GameObject pObj = Instantiate(firePeice, transform.position, Quaternion.Euler(0, 0, AngleDeg + Random.Range(-20.0f, 20.0f)));
            Projectile p    = pObj.GetComponent <Projectile>();
            p.baddieProjectile = false;

            pObj = Instantiate(firePeice, transform.position, Quaternion.Euler(0, 0, AngleDeg + Random.Range(-20.0f, 20.0f)));
            p    = pObj.GetComponent <Projectile>();
            p.baddieProjectile = false;

            pObj = Instantiate(firePeice, transform.position, Quaternion.Euler(0, 0, AngleDeg + Random.Range(-20.0f, 20.0f)));
            p    = pObj.GetComponent <Projectile>();
            p.baddieProjectile = false;


            pObj = Instantiate(firePeice, transform.position, Quaternion.Euler(0, 0, AngleDeg + Random.Range(-20.0f, 20.0f)));
            p    = pObj.GetComponent <Projectile>();
            p.baddieProjectile = false;

            pObj = Instantiate(firePeice, transform.position, Quaternion.Euler(0, 0, AngleDeg + Random.Range(-20.0f, 20.0f)));
            p    = pObj.GetComponent <Projectile>();
            p.baddieProjectile = false;

            pObj = Instantiate(firePeice, transform.position, Quaternion.Euler(0, 0, AngleDeg + Random.Range(-20.0f, 20.0f)));
            p    = pObj.GetComponent <Projectile>();
            p.baddieProjectile = false;

            pObj = Instantiate(firePeice, transform.position, Quaternion.Euler(0, 0, AngleDeg + Random.Range(-20.0f, 20.0f)));
            p    = pObj.GetComponent <Projectile>();
            p.baddieProjectile = false;
        }

        if (Input.GetButtonUp("Fire1") && attack != null)
        {
            //anim.SetInteger("attacking", 0);
            if (attack.tag.Equals("Ranged"))
            {
                anim.SetBool("bowDrawn", false);
                //    Debug.Log("Firing Arrow");
                RangedAttack rASpec = attack.GetComponent <RangedAttack>();
                rASpec.Shoot(transform.position, AngleDeg);
                slowDown = 1f;
            }
        }

        if (timeSinceLastHit < damageInvulTime)
        {
            //     if (!partySys.isPlaying)
            //   {
            //       partySys.Play();
            //   }
            timeSinceLastHit += Time.deltaTime;
        }
        else
        {
            //        if (partySys.isPlaying)
            //       {
            //           partySys.Stop();
            //       }
        }
    }
Пример #25
0
    public override void EntityUpdate()
    {
        //This is just a test, probably dont need to do it this way

        EnemyBehaviour.CheckForTargets(this);


        switch (mEnemyState)
        {
        case EnemyState.Idle:

            break;

        case EnemyState.Moving:

            if (Target != null)
            {
                Renderer.SetAnimState("Eye_Fly");

                //Replace this with pathfinding to the target
                Vector2 dir = (Target.Body.mAABB.Center - (Body.mAABB.Center)).normalized;

                if (!mAttackManager.rangedAttacks[0].OnCooldown())
                {
                    RangedAttack attack = mAttackManager.rangedAttacks[0];
                    attack.Activate(dir, Position);
                }

                Body.mSpeed = ((Vector2)Target.Position - Position).normalized * GetMovementSpeed();

                if (Body.mPS.pushesLeftTile || Body.mPS.pushesRightTile)
                {
                    if (Target.Position.y < Position.y)
                    {
                        Body.mSpeed.y = -GetMovementSpeed();
                    }
                    else
                    {
                        Body.mSpeed.y = GetMovementSpeed();
                    }
                }
                else if (Body.mPS.pushesBottomTile || Body.mPS.pushesTopTile)
                {
                    if (Target.Position.x < Position.x)
                    {
                        Body.mSpeed.x = -GetMovementSpeed();
                    }
                    else
                    {
                        Body.mSpeed.x = GetMovementSpeed();
                    }
                }
            }
            else
            {
                if (!Body.mPS.pushesTop)
                {
                    Renderer.SetAnimState("Eye_Fly");
                    Body.mSpeed.y = GetMovementSpeed();
                }
                else
                {
                    Renderer.SetAnimState("Eye_Sleep");
                    Body.mSpeed.y = 0;
                }

                Body.mSpeed.x = 0;
            }

            break;
        }

        base.EntityUpdate();


        //HurtBox.mCollisions.Clear();
        //UpdatePhysics();

        //make sure the hitbox follows the object
    }
Пример #26
0
    public override void EntityUpdate()
    {
        mSummonTimer += Time.deltaTime;
        CheckForTargets();


        switch (mBossState)
        {
        case BossState.Idle:


            break;

        case BossState.Aggrivated:

            int random = Random.Range(0, 100);
            switch (random)
            {
            case int n when(n <= 50):
                mBossState = BossState.Attack1;

                break;

            case int n when(n > 50 && n <= 80):
                mBossState = BossState.Attack2;

                break;

            case int n when(n > 80):
                mBossState = BossState.Attack3;

                shotcount = 0;
                break;
            }

            if (Target != null)
            {
                Vector2 dir = ((Vector2)Target.Position - Position).normalized;

                if (!mAttackManager.rangedAttacks[0].OnCooldown())
                {
                    RangedAttack attack = mAttackManager.rangedAttacks[0];
                    attack.Activate(dir, Position);
                }

                Body.mSpeed = dir * GetMovementSpeed();
            }

            break;

        case BossState.Attack1:

            ShootLaser();
            break;

        case BossState.Attack2:

            SummonEyebat();
            break;

        case BossState.Attack3:

            BeamPillar();
            break;
        }

        if (Body.mSpeed.x > 0)
        {
            mDirection = EntityDirection.Right;
            //Body.mAABB.ScaleX = 1;
        }
        else
        {
            mDirection = EntityDirection.Left;
            //Body.mAABB.ScaleX = -1;
        }

        base.EntityUpdate();



        //HurtBox.mCollisions.Clear();
        //UpdatePhysics();

        //make sure the hitbox follows the object
    }
Пример #27
0
 public BoltAction(VectorBase target, RangedAttack attack, bool canMiss = false) : base(target)
 {
     _canMiss = canMiss;
     _attack  = attack;
 }
Пример #28
0
 public BoltMove(double rate, RangedAttack attack) : base(rate)
 {
     this.attack = attack;
 }
Пример #29
0
 protected override void SetAttacks()
 {
     melee  = new MeleeAttack(this.actorPosition, 2);
     ranged = new RangedAttack(this.actorPosition, projectile);
     thrown = new RangedAttack(this.actorPosition, thrownProjectile);
 }
Пример #30
0
 void Awake()
 {
     rangedAttack = GetComponent <RangedAttack>();
     damageBuff   = (int)(rangedAttack.baseDamage * percentageBoost / 100);
 }