public override IEnumerator OnActivateSync(Hero sourceHero, Hero otherHero, bool secondSync = true)
    {
        //Debug.Log("Activating" + this.GetType() + " SYNC POWER!");

        if (!secondSync)
        {
            //Pay for activation
            sourceHero.ChangeSpiritAmount(-costActivateSync);
            otherHero.ChangeSpiritAmount(-costActivateSync);

            //Stop other Heros effect
            otherHero.SwitchToSyncPower();
        }

        //Find enemies to do effect on
        GameObject[] enemies = GameObject.FindGameObjectsWithTag("Enemy");
        enemiesToSlow = new BaseUnit[enemies.Length];

        for (int i = 0; i < enemies.Length; i++)
        {
            enemiesToSlow[i] = enemies[i].GetComponent<BaseUnit>();
            enemiesToSlow[i].SetMovementSpeedBuff(-spiritSyncSlow);
        }
        StartCoroutine(OnDeactivateSync(sourceHero, otherHero));

        return null;
    }
示例#2
0
    void OnGUI()
    {
        if(Input.GetButtonDown("Fire1"))
        {

            _initialPosition = new Vector2(Input.mousePosition.x, Screen.height - Input.mousePosition.y);

        }

        if(Input.GetButton("Fire1"))
        {

            _finalPosition = new Vector2(Input.mousePosition.x, Screen.height - Input.mousePosition.y);
            GUI.DrawTexture(new Rect(_initialPosition.x, _initialPosition.y, _finalPosition.x - _initialPosition.x, _finalPosition.y - _initialPosition.y), RectangleTexture);

        }

        if(Input.GetButtonUp("Fire1"))
        {

            foreach(BaseUnit unit in _selectedUnits)
            {

                unit.IsSelected = false;

            }

            float xMin = Mathf.Min(_initialPosition.x, _finalPosition.x);
            float yMin = Mathf.Min(_initialPosition.y, _finalPosition.y);
            float width = Mathf.Abs(_initialPosition.x - _finalPosition.x);
            float height = Mathf.Abs(_initialPosition.y - _finalPosition.y);

            _selectedUnits = GetUnitsUnderRectangle(new Rect(xMin, yMin, width, height));

            foreach(BaseUnit unit in _selectedUnits)
            {

                unit.IsSelected = true;

            }
        }
    }
示例#3
0
 void Awake()
 {
     _unitsInScene = new List<BaseUnit>();
     _selectedUnits = new BaseUnit[0];
 }
    IEnumerator DeathRay(Hero sourceHero, Hero otherHero)
    {
        //Find enemies
        var enemies = GameObject.FindGameObjectsWithTag("Enemy");

        enemiesToKill = new BaseUnit[enemies.Length];
        for (int i = 0; i < enemies.Length; i++) {
            enemiesToKill[i] = enemies[i].GetComponent<BaseUnit>();
        }

        syncTimer = 0f;
        circleActive = true;
        CreateCircleLink(sourceHero, otherHero, "SpiritLinkRay", 16);
        srcHero = sourceHero;
        othHero = otherHero;
        yield return new WaitForSeconds(syncDuration);
        DestroyCircleLink (0f);
    }
    private void DealDamageWithCircleLink(Vector3 center, float radius, float width)
    {
        //Find enemies
        var enemies = GameObject.FindGameObjectsWithTag("Enemy");
        enemiesToKill = new BaseUnit[enemies.Length];
        for (int i = 0; i < enemies.Length; i++) {
            enemiesToKill[i] = enemies[i].GetComponent<BaseUnit>();
        }

        float hitRangeSqr = (width*2f)*(width*2f);
        foreach (var enemy in enemiesToKill) {
            if (enemy != null && !enemy.dead) {
                //Is enemy in the DANGER ZONE?!
                Vector3 circleOrigin = GetVectorWithYSet(center, 0f);
                Vector3 hitDirection = GetVectorWithYSet(enemy.transform.position, 0f) - circleOrigin;
                Vector3 hitPointOnCircle = GetVectorWithYSet(circleOrigin + hitDirection.normalized * radius, enemy.transform.position.y);

                float enemyDistanceSqr = (hitPointOnCircle - enemy.collider.ClosestPointOnBounds(hitPointOnCircle)).sqrMagnitude;
                if (enemyDistanceSqr < hitRangeSqr) {
                    enemy.TakeDamage(damagePerInterval, gameObject);
                    StartCoroutine(CreateCircleDamageParticle(enemy.gameObject));
                }
            }
        }
    }
示例#6
0
		public CombatData(BaseUnit attacker, BaseUnit[] targets)
		{
			this.attacker = attacker;
			this.targets = targets;
		}
示例#7
0
		public CombatData(BaseUnit attacker, BaseUnit target)
		{
			this.attacker = attacker;
			this.targets = new BaseUnit[] { target };
		}