Esempio n. 1
0
        public void CustomCreepUpdate(Creep creep, GameTime gameTime)
        {
            float time = PoisonTimes[creep];
            int value = PoisonValues[creep];
            float counter = PoisonCounterTimes[creep];
            float timer = PoisonTimers[creep];
            if (time > 0)
            {
                time -= (float)gameTime.ElapsedGameTime.TotalMilliseconds;
                if (time <= 0)
                {
                    creep.CustomUpdate -= CustomCreepUpdate;
                    PoisonValues.Remove(creep);
                    PoisonTimes.Remove(creep);
                    PoisonTimers.Remove(creep);
                    PoisonCounterTimes.Remove(creep);
                    return;
                }
                if (timer >= counter)
                {
                    timer = 0;
                    creep.Hit(value);
                }
                else
                {
                    timer += (float)gameTime.ElapsedGameTime.TotalMilliseconds;
                }
                PoisonTimes[creep] = time;
                PoisonTimers[creep] = timer;
            }

        }
Esempio n. 2
0
 // Update is called once per frame. EXCEPT NOT!!!
 protected override void fireAway(Creep curTarget)
 {
     float health = curTarget.getHealth();
     health = health - this.damage;
     curTarget.setHealth(health);
     atkCooldown = 0;
     Debug.Log("Zombie attacked " + curTarget);
 }
Esempio n. 3
0
 public FreezeShot(Game game, Tower parent, Creep target, List<Creep> creeps, Vector2 position,
                   string shotTextName, float speed, float damage, float percentage, float time)
     : base(game, parent, target, creeps, position, shotTextName, speed, damage)
 {
     FreezePercentage = percentage;
     FreezeTime = time;
     Parent = (FreezeTower) parent;
 }
Esempio n. 4
0
        public static float GetAttackBackswing(Creep creep)
        {
            var attackRate = GetAttackRate(creep);

            var attackPoint = GetAttackPoint(creep);

            return attackRate - attackPoint;
        }
Esempio n. 5
0
 private void SetFreezeValue(float value, Creep creep)
 {
     if (!FreezeValues.ContainsKey(creep))
     {
         FreezeValues.Add(creep, 0);
     }
     FreezeValues[creep] = value;
 }
Esempio n. 6
0
    public void DirectToNextNode(Creep creep)
    {

        int nextTargetIndex = GetNextNodeIndex();

        creep.target = children[nextTargetIndex];
        creep.previous = this;
        creep.nodesHit += 1;
    }
Esempio n. 7
0
 public PoisonShot(Game game, Tower parent, Creep target, List<Creep> creeps, 
     Vector2 position, string shotTextName, float speed, float damage,
     float time, int amount, float counterTime) : 
     base(game, parent, target, creeps, position, shotTextName, speed, damage)
 {
     Time = time;
     Amount = amount;
     CounterTime = counterTime;
     Parent = (PoisonTower) parent;
 }
Esempio n. 8
0
        public static float GetAttackPoint(Creep creep)
        {
            var animationPoint = 0f;

            var attackSpeed = GetAttackSpeed(creep);

            if (creep.IsRanged)
            {
                animationPoint = 0.5f;
            }
            else
            {
                animationPoint = 0.467f;
            }

            return animationPoint / (1 + (attackSpeed - 100) / 100);
        }
Esempio n. 9
0
 /// <summary>
 /// Not yet the best shootable creep, right now just any creep
 /// returns true if there's a valid creep, creep is the target
 /// </summary>
 /// <param name="targets"></param>
 /// <param name="towerPosition"></param>
 /// <returns></returns>
 public static bool BestShootableCreep(List<Creep> targets, Vector2 towerPosition, int range, out Creep creep)
 {
     creep = null;
     bool found = false;
     double best = 0;// double.MaxValue;
     double current;
     if (targets.Count > 0)
     {
         foreach (Creep c in targets) //This might be changed to favor the creeps first in the list
         {
             current = GetDistance(c.Position, towerPosition);
             if ((current < range) && c.DistanceTravelled > best && c.DeathForecast < c.Stats[Enumerations.CreepStats.Health])
             {
                 found = true;
                 best = c.DistanceTravelled;
                 creep = c;
             }
         }
     }
     return found;
 }
Esempio n. 10
0
        public void CustomCreepUpdate(Creep creep, GameTime gameTime)
        {
            double freezeTime = FreezeTimes[creep];
            float freezeValue = FreezeValues[creep];

            if (freezeTime > 0)
            {
                if (creep.InitialSpeed * freezeValue < creep.Speed)
                {
                    creep.Speed = creep.InitialSpeed * freezeValue;
                }
                freezeTime -= gameTime.ElapsedGameTime.TotalMilliseconds;
                FreezeTimes[creep] = (float)freezeTime;
                if (freezeTime <= 0)
                {
                    RestoreCreepSpeed(creep);
                    creep.CustomUpdate -= CustomCreepUpdate;
                    FreezeValues.Remove(creep);
                    FreezeTimes.Remove(creep);
                    FrozenCreeps.Remove(creep);
                }
            }
        }
Esempio n. 11
0
 public bool IsInExperienceRange(Creep creep)
 {
     return(creep.IsValid && Hero.IsValid && creep.Team != team && Hero.IsVisible && Hero.IsAlive && Hero.Distance2D(creep) <= 1600);
 }
Esempio n. 12
0
 public static Projectile GetTowerProjectile(Tower tower, Creep target)
 {
     return new Projectile(tower.Fire(), target, tower.Position, tower.Type);
 }
 public void CreateGlassCreep()
 {
     creep = new Creep(CreepType.Glass, Vector3D.Zero);
 }
Esempio n. 14
0
 public SignalCreepDied(Creep creep)
 {
     Creep = creep;
 }
Esempio n. 15
0
 protected override bool validTarget(Creep curTarget)
 {
     bool fly = this.flying || !curTarget.getFlying(); //true unless enemy is flying and tower is not
     bool mag = this.magic && curTarget.getMagicImmune(); //true if enemy is immune and tower is magic
     return fly && !mag;
 }
Esempio n. 16
0
	/// <summary>
	/// Es llamado cuando un creep muere
	/// </summary>
	public void CreepDead(Creep creep){
		numberCreeps--;
		//Si no es tier 0 se elimina de la lista de creeps de tier
		if (creep.tier > 0)
			creepsTier.Remove (creep);
	}
    //I MUST set a specific reference to whatever defender this creep IS IN combat with. So that this creep can return to walking if that defender dies or is
    //moved

    private void Awake()
    {
        thisCreep = GetComponent<Creep>(); //Get the creep instance on this game object
        creepAnimationEventHandler = GetComponentInChildren<scrAnimationEventHandler>(); //Gets the reference
    }
Esempio n. 18
0
 /// <summary>
 /// Called when colliding with a creep.
 /// </summary>
 /// <param name="c"></param>
 public virtual void OnHit(Creep c)
 {
 }
Esempio n. 19
0
        public void CheckGoldRewardForCreeps()
        {
            var creep = new Creep(CreepType.Cloth, Vector2D.Zero);

            Assert.AreEqual(13, creep.GetStatValue("Gold"));
        }
Esempio n. 20
0
    private IEnumerator FireAfterAnimation(Creep enemy, float damage)
    {
        yield return(new WaitForSeconds(Constants.ANIM_ATTACK_TIME));

        Fire(enemy, damage);
    }
Esempio n. 21
0
 public void walkTowardsTarget(Creep touchedCreep)
 {
     NewPosition       = touchedCreep.transform.position - offsetY;
     isWalkingToTarget = true;
 }
Esempio n. 22
0
 public void GetClosestCreep()
 {
     targetCreep = ec.GetClosestCreep(this);
     print("Update enemy");
 }
Esempio n. 23
0
 public void removeCreep(Creep creep)
 {
     creeps.Remove(creep);
 }
Esempio n. 24
0
 public int getCreep(Creep creep)
 {
     return(creeps.IndexOf(creep));
 }
Esempio n. 25
0
	/// <summary>
	/// Rellenamos la pool del creep
	/// </summary>
	/// <param name="tempCreep">Prefab del creep</param>
	/// <param name="creepTempScript">Script perteneciente al prefab</param>
	/// <param name="cuantity">Cantidad de creeps a meter en la pool</param>
	/// <param name="creepArray">Pool donde se van a meter los creeps</param>
	void FillPoolCreep(GameObject tempCreep,Creep creepTempScript, int cuantity, CreepScript[] creepPool){
		GameObject clone;
		for(int i = 0;i < cuantity;i++){
			clone = Instantiate(tempCreep,Vector3.zero,Quaternion.identity) as GameObject;
			clone.transform.parent = transform;
			clone.name = "Creep"+creepTempScript.tier+"_"+i;
			CreepScript tempScript = new CreepScript(clone,clone.GetComponent<Creep>());
			creepPool[i] = tempScript;
		}
	}
Esempio n. 26
0
    public override void ClickUpdate()
    {
        bool RMB = Input.GetMouseButton(1);

        if (RMB && canMove)
        {
            stopAbilityIndication();
            EndAttack();
            autoNum = 1;
            RaycastHit hit;
            Ray        raymond = Camera.main.ScreenPointToRay(Input.mousePosition);
            if (Physics.Raycast(raymond, out hit, layerMask))
            {
                NewPosition   = hit.point;
                NewPosition.y = 0.5f;
            }
            if (Physics.Raycast(raymond, out hit) && hit.transform.tag == "Creep")
            {
                Creep touchedCreep = hit.transform.gameObject.GetComponent <Creep>();
                creepSelected = touchedCreep;
                if (achecker.EnemiesInRadius.Contains(touchedCreep) && canAttack)
                {
                    if (isTony)
                    {
                        NewPosition = transform.position;
                        stopMoving();
                        transform.LookAt(touchedCreep.transform.position);
                        transform.eulerAngles = new Vector3(0, transform.eulerAngles.y, 0);
                        Anim.SetTrigger("TonyAuto");
                        Anim.SetBool("isAttacking", true);
                        Anim.SetBool("isIdle", false);
                    }
                    else
                    {
                        NewPosition = transform.position;
                        stopMoving();
                        transform.LookAt(touchedCreep.transform.position);
                        transform.eulerAngles = new Vector3(0, transform.eulerAngles.y, 0);
                        Anim.SetTrigger("Attack");
                        Anim.SetBool("isAttacking", true);
                        Anim.SetBool("isIdle", false);
                    }
                }
                else
                {
                    walkTowardsTarget(touchedCreep);
                }
            }
        }
        if (Vector3.Distance(NewPosition, transform.position) > walkRange)
        {
            if (isTony)
            {
                isMoving = true;
                Anim.SetBool("isIdle", false);
                Anim.SetBool("isWalkingTony", true);
                Vector3 lookPos = NewPosition - transform.position;
                lookPos.y          = 0;
                transform.position = Vector3.MoveTowards(transform.position, NewPosition, speed * Time.deltaTime);
                Quaternion transRot = Quaternion.LookRotation(lookPos, Vector3.up);
                graphics.transform.rotation = Quaternion.Slerp(transRot, graphics.transform.rotation, 0.2f);
            }
            else
            {
                isMoving = true;
                Anim.SetBool("isIdle", false);
                Anim.SetBool("isWalkingTony", false);
                Anim.SetBool("isWalking", true);
                Vector3 lookPos = NewPosition - transform.position;
                lookPos.y          = 0;
                transform.position = Vector3.MoveTowards(transform.position, NewPosition, speed * Time.deltaTime);
                Quaternion transRot = Quaternion.LookRotation(lookPos, Vector3.up);
                graphics.transform.rotation = Quaternion.Slerp(transRot, graphics.transform.rotation, 0.2f);
            }
        }
        else
        {
            stopMoving();
        }
    }
Esempio n. 27
0
        private void AttackCreep(Creep _creep)
        {
            // pythagorean to find hypoteneus distance
            double hypDistance = GetDistanceToCreep(_creep);

            // is in range to attack?
            if (hypDistance <= MyWeapon.Range)
            {
                // attack!
                _creep.Hurt(MyWeapon.Damage);

                // check for kill condition
                if (_creep.HitPoints <= 0)
                {
                    //System.Diagnostics.Debug.Print("Creep hitpoints: " + _creep.HitPoints);
                    MyCanvas.Dispatcher.Invoke(_creep.Killed);
                }

                // trigger cooldown state
                MyWeapon.Reload();

                // switch image to 'attack'
                Thread t1 = new Thread(new ThreadStart(
                delegate()
                {
                    MyCanvas.Dispatcher.BeginInvoke(DispatcherPriority.Normal,
                        new Action(delegate()
                        {
                            MyCanvas.Dispatcher.Invoke(new Action(() => DrawTower(pathImage_attack)));

                        }));
                    Thread.Sleep(TimeSpan.FromMilliseconds(attackAnimationLength));
                    MyCanvas.Dispatcher.BeginInvoke(DispatcherPriority.Normal,
                        new Action(delegate()
                        {
                            MyCanvas.Dispatcher.Invoke(new Action(() => DrawTower(pathImage)));
                        }));
                }));
                t1.Start();
            }
        }
Esempio n. 28
0
    public override void ClickUpdate()
    {
        bool RMB = Input.GetMouseButton(1);

        if (RMB && canMove)
        {
            stopAbilityIndication();
            EndAttack();
            autoNum = 1;
            RaycastHit hit;
            RaycastHit yeet;
            bool       cant    = false;
            Ray        raymond = Camera.main.ScreenPointToRay(Input.mousePosition);
            if (Physics.Raycast(raymond, out hit, Mathf.Infinity, groundOnly))
            {
                if (Physics.Linecast(transform.position + rayOffset, hit.point + rayOffset, out yeet, wallMask))
                {
                    if (yeet.collider.transform != null)
                    {
                        cant = true;
                    }
                }
                if (!canAttackAfterAuto && !cant)
                {
                    bufferedPosition   = hit.point;
                    bufferedPosition.y = 1.15f;
                    StartCoroutine(waitToMove());
                    isBuffering = true;
                }
                else if (!cant)
                {
                    canAttackAfterAuto = true;
                    NewPosition        = hit.point;
                    NewPosition.y      = 1.15f;
                    EndAttack();
                }
            }
            cant = false;
            if (Physics.Raycast(raymond, out hit, Mathf.Infinity, creepsOnly) && hit.transform.tag == "Creep")
            {
                Creep touchedCreep = hit.transform.gameObject.GetComponent <Creep>();
                creepSelected = touchedCreep;
                if (achecker.EnemiesInRadius.Contains(touchedCreep) && canAttack)
                {
                    NewPosition = transform.position;
                    stopMoving();
                    transform.LookAt(touchedCreep.transform.position);
                    transform.eulerAngles = new Vector3(0, transform.eulerAngles.y, 0);
                    if (CooldownW && WActive && IndW.levelNum > 0)
                    {
                        if (numW <= 3)
                        {
                            audManager.audioList[numW].Play();
                            Anim.SetTrigger("W");
                            Anim.SetBool("isAttacking", true);
                            Anim.SetBool("isIdle", false);
                        }
                        else
                        {
                            audManager.audioList[numW].Play();
                            Anim.SetBool("isAttacking", true);
                            Anim.SetBool("isIdle", false);
                            Anim.SetTrigger("W2");
                        }
                    }
                    else if (autoOn <= 3)
                    {
                        Anim.SetTrigger("Attack" + autoOn);
                        Anim.SetBool("isAttacking", true);
                        Anim.SetBool("isIdle", false);
                    }
                    else
                    {
                        autoOn = 1;
                        Anim.SetTrigger("Attack" + autoOn);
                        Anim.SetBool("isAttacking", true);
                        Anim.SetBool("isIdle", false);
                    }
                }
                else
                {
                    walkTowardsTarget(touchedCreep);
                }
            }
        }

        if (Vector3.Distance(NewPosition, transform.position) > walkRange)
        {
            isMoving = true;
            Anim.SetBool("isIdle", false);
            Anim.SetBool("isWalking", true);
            Vector3 lookPos = NewPosition - transform.position;
            lookPos.y          = 0;
            transform.position = Vector3.MoveTowards(transform.position, NewPosition, speed * Time.deltaTime);
            Quaternion transRot = Quaternion.LookRotation(lookPos, Vector3.up);
            graphics.transform.rotation = Quaternion.Slerp(transRot, graphics.transform.rotation, 0.2f);
        }
        else
        {
            stopMoving();
        }
    }
Esempio n. 29
0
 private void _createCreep(Creep.Property[] props, string name)
 {
 }
Esempio n. 30
0
 private void RestoreCreepSpeed(Creep creep)
 {
     creep.Speed = creep.InitialSpeed;
 }
Esempio n. 31
0
 private void Awake()
 {
     creep    = GetComponent <Creep> ();
     animator = GetComponent <Animator> ();
 }
Esempio n. 32
0
    private void updateCurrentSelection(int menuInput)
    {
        // need to test if this is null somehow
        selectMenu.SetActive(false);
        if (menuInput == -1 || menuInput >= selectableObs.Length)
        {
            DetailsScrollView.SetActive(false);
            currentSelection = null;
            return;
        }
        DetailsScrollView.SetActive(true);
        SelectedDetailsText.text = "";
        currentSelection         = selectableObs[menuInput];
        string selectedUser = GetUserName(currentSelection);

        if (selectedUser == "")
        {
            Debug.Log("no user found for : " + objectLoader.users.Count);
        }
        SelectedDetailsText.text =
            "Type : " + selectableObs[menuInput].Type() + System.Environment.NewLine +
            "Id : " + selectableObs[menuInput].Id() + System.Environment.NewLine;

        if (selectedUser != "")
        {
            SelectedDetailsText.text += "Owner: " + selectedUser + System.Environment.NewLine;
        }

        if (currentSelection.hits > 0)
        {
            SelectedDetailsText.text += "Hits: " + PrintShorterInt(currentSelection.Hits()) + "/" + PrintShorterInt(currentSelection.MaxHits()) + System.Environment.NewLine;
        }

        if (selectableObs[menuInput].Type() == "creep")
        {
            Creep selectedCreep = objectLoader.GetSelectedCreep(currentSelection._id);
            if (selectedCreep.name != null)
            {
                SelectedDetailsText.text += "Name: " + selectedCreep.name + System.Environment.NewLine;
            }
            //if (selectedCreep.hits != 0)
            //    SelectedDetailsText.text += "Hits: "+selectedCreep.hits + "/" + selectedCreep.creepBody.parts.Length * 100 + System.Environment.NewLine;
            int counter = 1;
            SelectedDetailsText.text += "Body:" + "<indent=65%>" + selectedCreep.creepBody.parts.Length + " Parts" + System.Environment.NewLine;
            SelectedDetailsText.text += "<indent=15%>";
            foreach (string b in selectedCreep.creepBody.parts)
            {
                SelectedDetailsText.text += "<sprite name=\"" + b + "\"> ";
                counter++;
                if (counter > 10)
                {
                    counter = 1;
                    SelectedDetailsText.text += System.Environment.NewLine + "<indent=15%>";
                }
            }
            SelectedDetailsText.text += System.Environment.NewLine;
            //SelectedDetailsText.text = selectableObs[menuInput].type + "<sprite index=2><sprite index=2><sprite index=2><sprite index=2><sprite index=2><sprite index=2><sprite index=2><sprite index=2>";
        }
        if (selectableObs[menuInput].Type() == "controller")
        {
            if (currentSelection.downgradeTime > 0)
            {
                SelectedDetailsText.text += "Downgrade Time: " + currentSelection.downgradeTime + System.Environment.NewLine;
            }
            if (currentSelection.reservationUser != null)
            {
                SelectedDetailsText.text += "Reserved by: " + GetUserName(currentSelection.reservationUser) + System.Environment.NewLine;
            }
            if (currentSelection.reservationTime > 0)
            {
                SelectedDetailsText.text += "Reservation: " + Mathf.Abs(ObjectsLoader.gameTime - currentSelection.reservationTime).ToString() + System.Environment.NewLine;
            }
            if (currentSelection.sign != null)
            {
                SelectedDetailsText.text += "Sign: User: "******"      Time: " + currentSelection.sign.time + System.Environment.NewLine;
                SelectedDetailsText.text += "      Sign: " + currentSelection.sign.text + System.Environment.NewLine;
            }
        }
        if (currentSelection._store != null && currentSelection.storeCapacity > 0)
        {
            SelectedDetailsText.text += "<indent=0%>Store: " + PrintShorterInt(currentSelection.storeTotal) + "/" + PrintShorterInt(currentSelection.storeCapacity) + System.Environment.NewLine;
            //GameObject selectedObject = objectLoader.GetSelectedGameObject(currentSelection);
            int counter = 1;
            foreach (KeyValuePair <string, int> kvp in currentSelection.Store())
            {
                SelectedDetailsText.text += "<indent=5%><sprite name=\"" + kvp.Key + "\"><indent=20%>" + kvp.Value + System.Environment.NewLine;
                counter++;
            }
        }
        if (DetailsScrollViewBar.gameObject.activeSelf)
        {
            DetailsScrollViewBar.value = lastMenuPos;
        }
    }
 private void EarnCoins(Creep creep) //Triggers when enemies are killed
 {
     AddCoins(1);
 }
Esempio n. 34
0
        public static float GetAttackRate(Creep creep)
        {
            var attackSpeed = GetAttackSpeed(creep);

            return 1 / (1 + (attackSpeed - 100) / 100);
        }
 public void CreateClothCreep()
 {
     creep = new Creep(CreepType.Cloth, Vector3D.Zero);
 }
Esempio n. 36
0
 private void AddCreep(Creep creep)
 {
     creep.GridChanged(null);
     CreepList.Add(creep);
     ChangeInformation();
 }
Esempio n. 37
0
        public static Entity ParseEntity(string[] inputs)
        {
            EntityType entityType;
            Entity     entity = null;

            int unitId           = int.Parse(inputs[0]);
            int x                = int.Parse(inputs[3]);
            int y                = int.Parse(inputs[4]);
            int attackRange      = int.Parse(inputs[5]);
            int health           = int.Parse(inputs[6]);
            int maxHealth        = int.Parse(inputs[7]);
            int shield           = int.Parse(inputs[8]); // useful in bronze
            int attackDamage     = int.Parse(inputs[9]);
            int movementSpeed    = int.Parse(inputs[10]);
            int stunDuration     = int.Parse(inputs[11]); // useful in bronze
            int goldValue        = int.Parse(inputs[12]);
            int countDown1       = int.Parse(inputs[13]); // all countDown and mana variables are useful starting in bronze
            int countDown2       = int.Parse(inputs[14]);
            int countDown3       = int.Parse(inputs[15]);
            int mana             = int.Parse(inputs[16]);
            int maxMana          = int.Parse(inputs[17]);
            int manaRegeneration = int.Parse(inputs[18]);
            int isVisible        = int.Parse(inputs[20]); // 0 if it isn't
            int itemsOwned       = int.Parse(inputs[21]); // useful from wood1

            //entity = new Entity(x, y, unitId, attackRange, health, maxHealth, shield, attackDamage, movementSpeed, stunDuration, goldValue);

            string unitType = inputs[2]; // UNIT, HERO, TOWER, can also be GROOT from wood1

            if (Enum.TryParse(unitType, out entityType))
            {
                switch (entityType)
                {
                case EntityType.UNIT:
                    //entity = UnBoxingHelper.ToDerived<Entity, Creep>(entity);
                    entity = new Creep(x, y, unitId, attackRange, health, maxHealth, shield, attackDamage, movementSpeed, stunDuration, goldValue);
                    break;

                case EntityType.HERO:
                    HeroType heroType;
                    string   tmpHeroType = inputs[19];   // DEADPOOL, VALKYRIE, DOCTOR_STRANGE, HULK, IRONMAN

                    // TODO: refactoring
                    if (Enum.TryParse(tmpHeroType, out heroType))
                    {
                        /*entity = UnBoxingHelper.ToDerived<Entity, Hero>(entity);
                         * (entity as Hero).HeroType = heroType;*/

                        entity = new Hero(x, y, unitId, attackRange, health, maxHealth, shield, attackDamage, movementSpeed, stunDuration, goldValue, countDown1, countDown2, countDown3, mana, maxMana, manaRegeneration, isVisible, itemsOwned, heroType);
                    }
                    break;

                case EntityType.TOWER:
                    //entity = UnBoxingHelper.ToDerived<Entity, Tower>(entity);
                    entity = new Tower(x, y, unitId, attackRange, health, maxHealth, shield, attackDamage, movementSpeed, stunDuration, goldValue);
                    break;

                case EntityType.GROOT:
                    //entity = UnBoxingHelper.ToDerived<Entity, Groot>(entity);
                    entity = new Groot(x, y, unitId, attackRange, health, maxHealth, shield, attackDamage, movementSpeed, stunDuration, goldValue);
                    break;
                }
            }


            return(entity);
        }
Esempio n. 38
0
 protected abstract void fireAway(Creep curTarget);
Esempio n. 39
0
    // Update is called once per frame
    void Update()
    {
        cleanupTargetList(); //checks current target for being alive, updates target otherwise

        this.atkCooldown = this.atkCooldown + Time.deltaTime;
        if (this.atkCooldown >= this.fireRate)
        {
            if (this.targetList.Count > 0)
            {
                curTarget = this.targetList[0];
                this.fireAway(curTarget);
            }

        }
    }
Esempio n. 40
0
    //
    void Start ()
    {
        creep = GetComponent<Creep>();

        originalSpeed = creep.speed;
	}
Esempio n. 41
0
 void Start()
 {
     creep    = GetComponent <Creep>();
     creepNav = GetComponent <CreepNav>();
 }
Esempio n. 42
0
 public SignalCreepSpawned(Creep creep)
 {
     Creep = creep;
 }
Esempio n. 43
0
        public static float GetAttackSpeed(Creep creep)
        {
            var attackSpeed = Math.Min(creep.AttacksPerSecond * 1 / 0.01, 600);

            return (float)attackSpeed;
        }
Esempio n. 44
0
        public override void Execute()
        {
            if (Core.TempestHero != null && Core.TempestHero.Hero.IsAlive)
            {
                if (_sleeper.Sleeping)
                {
                    return;
                }
                if (Core.TempestHero.Orbwalker.GetTarget() == null || Core.TempestHero.Orbwalker.GetTarget().Position.IsZero)
                {
                    ClosestLane = GetClosestLane(Core.TempestHero.Hero);
                    var lastPoint = ClosestLane.Points[ClosestLane.Points.Count - 1];
                    ClosestLane.ClosestPosition =
                        ClosestLane.Points.Where(
                            x =>
                            x.Distance2D(lastPoint) < Core.TempestHero.Hero.Position.Distance2D(lastPoint) - 300)
                        .OrderBy(pos => CheckForDist(pos, Core.TempestHero.Hero))
                        .FirstOrDefault();

                    if (ClosestLane.ClosestPosition != null && !ClosestLane.ClosestPosition.IsZero)
                    {
                        if (MenuManager.UseTravels)
                        {
                            var travels = Core.TempestHero.Hero.GetItemById(AbilityId.item_travel_boots) ??
                                          Core.TempestHero.Hero.GetItemById(AbilityId.item_travel_boots_2);
                            if (travels != null && travels.CanBeCasted() && !_sleeper.Sleeping)
                            {
                                var temp = ClosestLane.Points.ToList();
                                temp.Reverse();
                                var enemyCreeps =
                                    EntityManager <Creep> .Entities.Where(x => x.IsValid && x.IsVisible && x.IsAlive && x.Team != ObjectManager.LocalHero.Team);

                                Creep creepForTravels = null;

                                foreach (var point in temp)
                                {
                                    creepForTravels = EntityManager <Creep> .Entities.FirstOrDefault(
                                        allyCreep =>
                                        allyCreep.IsValid && allyCreep.IsAlive && allyCreep.Team == ObjectManager.LocalHero.Team &&
                                        allyCreep.HealthPercent() > 0.75 &&
                                        point.IsInRange(allyCreep.Position, 1500) &&
                                        enemyCreeps.Any(z => z.IsInRange(allyCreep, 1500)));

                                    if (creepForTravels != null)
                                    {
                                        break;
                                    }
                                }
                                if (creepForTravels != null && creepForTravels.Distance2D(Core.TempestHero.Hero) > 1500)
                                {
                                    travels.UseAbility(creepForTravels);
                                    _sleeper.Sleep(500);
                                }
                            }
                        }


                        Core.TempestHero.Hero.Move(ClosestLane.ClosestPosition);
                        try
                        {
                            foreach (var illusion in IllusionManager.GetIllusions)
                            {
                                illusion.Hero.Move(ClosestLane.ClosestPosition);
                            }
                            foreach (var necro in NecronomiconManager.GetNecronomicons)
                            {
                                necro.Necr.Move(ClosestLane.ClosestPosition);
                            }
                        }
                        catch (Exception e)
                        {
                            Printer.Both("kek " + e.Message);
                        }
                        ClosestPosition = ClosestLane.ClosestPosition;
                    }
                }
                else if (!_sleeper.Sleeping)
                {
                    if (Core.TempestHero.Spark.CanBeCasted())
                    {
                        var target = Core.TempestHero.Orbwalker.GetTarget();
                        if (target != null)
                        {
                            Printer.Log($"[AutoPushing][Spark][{target.Name}]->{target.Position.PrintVector()}", true);
                            Core.TempestHero.Spark.UseAbility(target.Position);
                            _sleeper.Sleep(500);
                        }
                    }

                    var itemForPushing = Core.TempestHero.Hero.GetItemById(ItemId.item_mjollnir);
                    if (itemForPushing != null && itemForPushing.CanBeCasted())
                    {
                        var allyCreep =
                            EntityManager <Creep> .Entities
                            .FirstOrDefault(
                                x =>
                                x.IsAlive && x.Team == ObjectManager.LocalHero.Team &&
                                x.IsInRange(Core.TempestHero.Hero, 500) && x.HealthPercent() <= 0.92 &&
                                x.IsMelee);

                        if (allyCreep != null)
                        {
                            itemForPushing.UseAbility(allyCreep);
                            _sleeper.Sleep(500);
                        }
                    }
                    itemForPushing = Core.TempestHero.Hero.GetItemById(ItemId.item_manta);

                    if (itemForPushing != null && itemForPushing.CanBeCasted())
                    {
                        itemForPushing.UseAbility();
                        _sleeper.Sleep(500);
                    }

                    itemForPushing = Core.TempestHero.Hero.GetItemById(ItemId.item_necronomicon) ??
                                     Core.TempestHero.Hero.GetItemById(ItemId.item_necronomicon_2) ??
                                     Core.TempestHero.Hero.GetItemById(ItemId.item_necronomicon_3);
                    if (itemForPushing != null && itemForPushing.CanBeCasted())
                    {
                        itemForPushing.UseAbility();
                        _sleeper.Sleep(500);
                    }
                    if (Core.TempestHero.Orbwalker.GetTarget() is Tower)
                    {
                        var field = Core.TempestHero.MagneticField;
                        if (field.CanBeCasted())
                        {
                            var pos =
                                (Core.TempestHero.Orbwalker.GetTarget().NetworkPosition -
                                 Core.TempestHero.Hero.NetworkPosition).Normalized();
                            pos *= (280 + 150);
                            pos  = Core.TempestHero.Orbwalker.GetTarget().NetworkPosition - pos;
                            field.UseAbility(pos);
                            _sleeper.Sleep(1000);
                        }
                    }
                }
                if (MenuManager.AutoPushingTargetting)
                {
                    var enemyHero =
                        Heroes.GetByTeam(ObjectManager.LocalHero.GetEnemyTeam())
                        .FirstOrDefault(x => Core.TempestHero.Hero.IsValidOrbwalkingTarget(x));
                    if (enemyHero != null)
                    {
                        //OrderManager.ChangeOrder(OrderManager.Orders.SparkSpamTempest);
                        Core.Target = enemyHero;
                        MenuManager.TempestCombo.SetValue(new KeyBind(MenuManager.TempestCombo.GetValue <KeyBind>().Key,
                                                                      KeyBindType.Toggle, true));
                        Core.Target = enemyHero;
                    }
                }
                _sleeper.Sleep(250);
            }
            else
            {
                if (_sleeper.Sleeping)
                {
                    return;
                }
                _sleeper.Sleep(400);
                foreach (var illusion in IllusionManager.GetIllusions.Where(x => x.Orbwalker.GetTarget() == null))
                {
                    ClosestLane = GetClosestLane(illusion.Hero);
                    var pushPos = ClosestLane.Points.LastOrDefault();
                    illusion.Hero.Move(pushPos);
                }
                foreach (var necro in NecronomiconManager.GetNecronomicons.Where(x => x.Orbwalker.GetTarget() == null))
                {
                    ClosestLane = GetClosestLane(necro.Necr);
                    var pushPos = ClosestLane.Points.LastOrDefault();
                    necro.Necr.Move(pushPos);
                }
            }
        }
Esempio n. 45
0
 public void CreepOut(Creep creep)
 {
     if (creep.CreepState == CreepState.Out)
         LiveManager.CreepOut(creep.Health);
     if (creep.CreepState == CreepState.Killed)
     {
         double money = Math.Sqrt(creep.InitialHealth * creep.InitialSpeed);
         MoneyManager.AddMoney(money);
         PointsManager.AddPoints(creep.Points);
     }
     CreepDeleteList.Add(creep);
     ChangeInformation();
 }
Esempio n. 46
0
 public void ReturnPosition(Creep creep) //Is fired from... Check the reference above this method! :) (from the scrCreepAnimations)
 {
     creep.DistanceTravelled = 0f;       //Reset the travel distance variable, also necessary so that they don`t "teleport" back into the goal
 }
Esempio n. 47
0
 protected abstract bool validTarget(Creep curTarget);
Esempio n. 48
0
 private static ICreepSender GetSentCreep(Creep creep)
 {
     return(creep.GetComponent <ICreepSender>());
 }
Esempio n. 49
0
 public void setCurTarget(Creep curTarget)
 {
     this.curTarget = curTarget;
 }
Esempio n. 50
0
 public PercentageShot(Game game, Tower parent, Creep target, List <Creep> creeps, Vector2 position, string shotTextName, float speed, float percentage)
     : base(game, parent, target, creeps, position, shotTextName, speed, 0)
 {
     Percentage = percentage;
 }
Esempio n. 51
0
		public List<Creep> GetNextWaveCreeps() {
			var result = new List<Creep>();
			var waveNode = WavesNode.Element("Wave" + Wave);
			if (waveNode != null) {
				Queue<int> positions = GenerateRandomList(100);
				foreach (var creep in waveNode.Elements()) {
					int health = int.Parse(creep.Attribute("Health").Value) + healthNiveau;
					LastHealth = health;
					int speed = int.Parse(creep.Attribute("Speed").Value);
					string texture = creep.Attribute("Texture").Value;
					var tmpCreep = new Creep(CurrGame, GamePlayScreen, texture, health, speed, new Vector2(0, positions.Dequeue()));
					tmpCreep.Initialize();
					result.Add(tmpCreep);
				}
				Wave++;
				RealWave++;
				GetWaitingTime();
			} else {
				healthNiveau = LastHealth;
				LastHealth = 0;
				Wave = 0;
				result = GetNextWaveCreeps();
				WaveWatch = Stopwatch.StartNew();
				return result;
			}
			WaveWatch = Stopwatch.StartNew();
			return result;
		}
Esempio n. 52
0
 public override void OnHit(Creep c)
 {
     base.OnHit(c);
     //
     Sounder.Instance().PlaySound("pellet_hit_creep");
 }
Esempio n. 53
0
 private double GetDistanceToCreep(Creep c)
 {
     if (c != null)
     {
         return Math.Sqrt(Math.Pow(Math.Abs(c.PosX - this.PosX), 2)
                 + Math.Pow(Math.Abs(c.PosY - this.PosY), 2));
     }
     else
     {
         return 0;
     }
 }
Esempio n. 54
0
 public bool IsInExperienceRange(Creep creep)
 {
     return(creep != null && creep.IsValid && Hero.IsVisible && Hero.IsAlive && Hero.Distance2D(creep) <= 1300);
 }
Esempio n. 55
0
        // scan for and attack creep, goes with creep 'Move' method
        public void Scan(TimeSpan timeSpan)
        {
            // generate "creeps in range" list and acquire target
            List<Creep> creepsInRange = CreepsInRange(MainWindow.myCreeps.AllCreeps);
            //System.Diagnostics.Debug.Print("Creeps in Range are: " + creepsInRange.Count);
            if (creepsInRange.Count > 0)
            {
                TargetCreep = GetTargetNearest(creepsInRange);

                // attack target if "cooled down"
                if (TargetCreep != null && MyWeapon.IsReady())
                {
                    AttackCreep(TargetCreep);
                }
            }

            if (!MyWeapon.IsReady())
            {
                MyWeapon.CooldownTick(timeSpan);
            }
        }
Esempio n. 56
0
        public override void Execute()
        {
            if (Core.TempestHero != null && Core.TempestHero.Hero.IsAlive)
            {
                if (Ensage.SDK.Extensions.UnitExtensions.HasModifier(Core.TempestHero.Hero, "modifier_teleporting"))
                {
                    return;
                }
                if (Ensage.SDK.Extensions.UnitExtensions.IsChanneling(Core.TempestHero.Hero))
                {
                    return;
                }
                if (_sleeper.Sleeping)
                {
                    return;
                }
                _sleeper.Sleep(150);
                var currentLane = GetLane(Core.TempestHero.Hero);
                CurrentLane = currentLane;
                var target = Core.TempestHero.Orbwalker.GetTarget();
                if (target == null || target.Position.IsZero || !target.IsAlive)
                {
                    var path      = FindOrGetNeededPath(Core.TempestHero.Hero);
                    var lastPoint = path[path.Count - 1];
                    var closest   = path.Where(
                        x =>
                        x.Distance2D(lastPoint) < Core.TempestHero.Hero.Position.Distance2D(lastPoint) - 300)
                                    .OrderBy(pos => CheckForDist(pos, Core.TempestHero.Hero))
                                    .FirstOrDefault();
                    Core.TempestHero.Hero.Move(closest);
                    if (MenuManager.UseTravels)
                    {
                        var travels = Core.TempestHero.Hero.GetItemById(AbilityId.item_travel_boots) ??
                                      Core.TempestHero.Hero.GetItemById(AbilityId.item_travel_boots_2);
                        if (travels != null && travels.CanBeCasted())
                        {
                            var temp = path.ToList();
                            temp.Reverse();
                            if (MenuManager.CheckForCreeps)
                            {
                                var enemyCreeps =
                                    EntityManager <Creep> .Entities.Where(
                                        x =>
                                        x.IsValid && x.IsVisible && x.IsAlive &&
                                        x.Team != ObjectManager.LocalHero.Team &&
                                        Map.GetLane(x) == currentLane);

                                Creep creepForTravels = null;

                                var allyCreeps =
                                    EntityManager <Creep> .Entities.Where(
                                        allyCreep => allyCreep.IsValid && allyCreep.IsAlive &&
                                        allyCreep.Team == ObjectManager.LocalHero.Team &&
                                        Map.GetLane(allyCreep) == currentLane &&
                                        allyCreep.HealthPercent() > 0.75).ToList();

                                foreach (var point in temp)
                                {
                                    creepForTravels = allyCreeps.FirstOrDefault(
                                        allyCreep =>
                                        point.IsInRange(allyCreep.Position, 1500) &&
                                        enemyCreeps.Any(z => z.IsInRange(allyCreep, 1500)));
                                    if (creepForTravels != null)
                                    {
                                        break;
                                    }
                                }
                                if (creepForTravels != null && creepForTravels.Distance2D(Core.TempestHero.Hero) > 1500)
                                {
                                    var point     = path[path.Count - 1];
                                    var distance1 = point.Distance2D(creepForTravels);
                                    var distance2 = point.Distance2D(Core.TempestHero.Hero);

                                    if (distance1 < distance2)
                                    {
                                        travels.UseAbility(creepForTravels);
                                        _sleeper.Sleep(1000);
                                        return;
                                    }
                                }
                            }
                            else
                            {
                                var finalPos = temp.First();
                                var ally     =
                                    EntityManager <Creep> .Entities.Where(
                                        allyCreep => allyCreep.IsValid && allyCreep.IsAlive &&
                                        allyCreep.Team == ObjectManager.LocalHero.Team &&
                                        Map.GetLane(allyCreep) == currentLane &&
                                        allyCreep.HealthPercent() > 0.75)
                                    .OrderBy(y => Ensage.SDK.Extensions.EntityExtensions.Distance2D(y, finalPos))
                                    .FirstOrDefault();

                                var allyTwr =
                                    EntityManager <Tower> .Entities.Where(
                                        allyCreep => allyCreep.IsValid && allyCreep.IsAlive &&
                                        allyCreep.Team == ObjectManager.LocalHero.Team &&
                                        Map.GetLane(allyCreep) == currentLane &&
                                        allyCreep.HealthPercent() > 0.1)
                                    .OrderBy(y => Ensage.SDK.Extensions.EntityExtensions.Distance2D(y, finalPos))
                                    .FirstOrDefault();

                                Unit tpTarget = null;
                                if (ally != null && allyTwr != null)
                                {
                                    var dist1 = finalPos.Distance2D(ally);
                                    var dist2 = finalPos.Distance2D(allyTwr);

                                    if (dist1 > dist2)
                                    {
                                        tpTarget = allyTwr;
                                    }
                                    else
                                    {
                                        tpTarget = ally;
                                    }
                                }

                                if (tpTarget != null && tpTarget.Distance2D(Core.TempestHero.Hero) > 1500)
                                {
                                    var point     = path[path.Count - 1];
                                    var distance1 = point.Distance2D(tpTarget);
                                    var distance2 = point.Distance2D(Core.TempestHero.Hero);

                                    if (distance1 < distance2)
                                    {
                                        travels.UseAbility(tpTarget.Position);
                                        _sleeper.Sleep(1000);
                                        return;
                                    }
                                }
                            }
                        }
                    }

                    try
                    {
                        foreach (var illusion in IllusionManager.GetIllusions)
                        {
                            illusion.Hero.Move(closest);
                        }
                        foreach (var necro in NecronomiconManager.GetNecronomicons)
                        {
                            necro.Necr.Move(closest);
                        }
                    }
                    catch (Exception e)
                    {
                        Printer.Both("kek " + e.Message);
                    }
                }
                else
                {
                    if (Core.TempestHero.Spark.CanBeCasted())
                    {
                        Printer.Log($"[AutoPushing][Spark][{target.Name}]->{target.Position.PrintVector()}", true);
                        if (!target.Position.IsZero)
                        {
                            Core.TempestHero.Spark.UseAbility(target.Position);
                            _sleeper.Sleep(500);
                        }
                    }

                    var itemForPushing = Core.TempestHero.Hero.GetItemById(ItemId.item_mjollnir);
                    if (itemForPushing != null && itemForPushing.CanBeCasted())
                    {
                        var allyCreep =
                            EntityManager <Creep> .Entities
                            .FirstOrDefault(
                                x =>
                                x.IsAlive && x.Team == ObjectManager.LocalHero.Team &&
                                x.IsInRange(Core.TempestHero.Hero, 500) && x.HealthPercent() <= 0.92 &&
                                x.IsMelee);

                        if (allyCreep != null)
                        {
                            itemForPushing.UseAbility(allyCreep);
                            _sleeper.Sleep(500);
                        }
                    }
                    itemForPushing = Core.TempestHero.Hero.GetItemById(ItemId.item_manta);

                    if (itemForPushing != null && itemForPushing.CanBeCasted())
                    {
                        itemForPushing.UseAbility();
                        _sleeper.Sleep(500);
                    }

                    itemForPushing = Core.TempestHero.Hero.GetItemById(ItemId.item_necronomicon) ??
                                     Core.TempestHero.Hero.GetItemById(ItemId.item_necronomicon_2) ??
                                     Core.TempestHero.Hero.GetItemById(ItemId.item_necronomicon_3);
                    if (itemForPushing != null && itemForPushing.CanBeCasted())
                    {
                        itemForPushing.UseAbility();
                        _sleeper.Sleep(500);
                    }
                    if (Core.TempestHero.Orbwalker.GetTarget() is Tower)
                    {
                        var field = Core.TempestHero.MagneticField;
                        if (field.CanBeCasted())
                        {
                            var pos =
                                (Core.TempestHero.Orbwalker.GetTarget().NetworkPosition -
                                 Core.TempestHero.Hero.NetworkPosition).Normalized();
                            pos *= (280 + 150);
                            pos  = Core.TempestHero.Orbwalker.GetTarget().NetworkPosition - pos;
                            field.UseAbility(pos);
                            _sleeper.Sleep(1000);
                        }
                    }
                }
                if (MenuManager.AutoPushingTargetting)
                {
                    var enemyHero =
                        Heroes.GetByTeam(ObjectManager.LocalHero.GetEnemyTeam())
                        .FirstOrDefault(x => Core.TempestHero.Hero.IsValidOrbwalkingTarget(x));
                    if (enemyHero != null)
                    {
                        //OrderManager.ChangeOrder(OrderManager.Orders.SparkSpamTempest);
                        Core.Target = enemyHero;
                        MenuManager.TempestCombo.SetValue(new KeyBind(MenuManager.TempestCombo.GetValue <KeyBind>().Key,
                                                                      KeyBindType.Toggle, true));
                        Core.Target = enemyHero;
                    }
                }
            }
            else
            {
                var illusions = IllusionManager.GetIllusions.Where(x => x.Orbwalker.GetTarget() == null).ToList();
                var necros    = NecronomiconManager.GetNecronomicons.Where(x => x.Orbwalker.GetTarget() == null).ToList();
                var any       = illusions.Any() || necros.Any();
                if (any)
                {
                    foreach (var illusion in illusions)
                    {
                        var path      = FindOrGetNeededPath(illusion.Hero);
                        var lastPoint = path[path.Count - 1];
                        var closest   = path.Where(
                            x =>
                            x.Distance2D(lastPoint) < Core.TempestHero.Hero.Position.Distance2D(lastPoint) - 300)
                                        .OrderBy(pos => CheckForDist(pos, Core.TempestHero.Hero))
                                        .FirstOrDefault();
                        illusion.Hero.Move(closest);
                    }
                    foreach (var necro in necros)
                    {
                        var path      = FindOrGetNeededPath(necro.Necr);
                        var lastPoint = path[path.Count - 1];
                        var closest   = path.Where(
                            x =>
                            x.Distance2D(lastPoint) < Core.TempestHero.Hero.Position.Distance2D(lastPoint) - 300)
                                        .OrderBy(pos => CheckForDist(pos, Core.TempestHero.Hero))
                                        .FirstOrDefault();
                        necro.Necr.Move(closest);
                    }
                    _sleeper.Sleep(500);
                }
            }
        }
Esempio n. 57
0
 public void createCreep(Creep.Spec spec, string name)
 {
     _createCreep(spec.ToArray(),name);
 }
Esempio n. 58
0
    public void creepDied(Creep creep)
    {
        int index = creeps.FindIndex(x => x == creep);

        creeps.RemoveAt(index);
    }
 public void SpawnCreeps(Creep.CreepType type, int[] info)
 {
     for (int j = 0; j < info[0]; j++)
     {
         Creep newCreep = new Creep(type, Pathing.GetPath(NextLevel), TDMCanvas, this);
         myCreeps.AllCreeps.Add(newCreep);
         System.Threading.Thread.Sleep(TimeSpan.FromMilliseconds(info[1]));                
     }
 }
Esempio n. 60
0
 public void SeekEnemy(Creep creep, float _damage)
 {
     target = creep.creepTransform;
     damage = _damage;
     victim = creep;
 }