Ejemplo n.º 1
0
	public void Start() {
		Floor floor = Helper.Find<Floor>("Floor");
		gridManager = floor.GridManager;
		unit = GetComponent<BaseUnit>();

		soundEffectPLayer = GetComponentInChildren<SoundEffectPlayer>();

        LeaveSound = unit.GetComponent<BaseUnit>().LeaveSound;
        ArriveSound = unit.GetComponent<BaseUnit>().ArriveSound;

        if (LeaveSound.Any() || ArriveSound.Any())
	    {
            AudioSource audioSrc = gameObject.AddComponent<AudioSource>();
            LeaveArriveEffectPlayer = gameObject.GetComponent<AudioSource>();
	    }
        
	    if (unit is AvatarUnit)
	    {
	        isAvatarMover = true;
            currentAvatarUnit = (AvatarUnit)unit;
	    }
	    else
	    {
	        isAvatarMover = false;
	    }
	}
Ejemplo n.º 2
0
    public override void AddUnitOnTile(BaseUnit unitToAdd)
    {
        base.AddUnitOnTile(unitToAdd);

        if (IsExplotionExecutingOnTile())
        {
            if (unitToAdd.GetComponent <IDamage>() != null)
            {
                unitToAdd.GetComponent <IDamage>().TakeDamage(AmountDamage);
            }
        }
    }
Ejemplo n.º 3
0
 public static void SetActivePlayerUnit(BaseUnit b)
 {
     if (b is PlayerUnit)
     {
         SetActivePlayerUnit(b.GetComponent <PlayerUnit>());
     }
 }
Ejemplo n.º 4
0
    protected virtual void Attack()
    {
        if (anim != null)
        {
            anim.SetInteger("AnimState", 2);
        }

        if (attackCooldown <= 0)
        {
            attackCooldown = 1;

            if (target != null)
            {
                IHealth targetHp = target.GetComponent <IHealth>();
                targetHp.TakeDamage(Atk);
                damageDealt += atk;

                if (meleeSound != null)
                {
                    audioSource.PlayOneShot(meleeSound, 0.1f);
                }
            }
            else
            {
                ChangeState(Move);
            }
        }
        else
        {
            attackCooldown -= Time.deltaTime;
        }
    }
    public void HighlightAvailableTiles(BaseUnit unit)
    {
        CanWalk w = unit.GetComponent <CanWalk>();

        foreach (Vector2Int tilePos in _mapManager.GetAvailableTilesInRangeForMovemntType(unit.Position.x, unit.Position.y, w.Settings.MovemntType, w.Settings.Range))
        {
            HighlightTile(tilePos);
        }
    }
Ejemplo n.º 6
0
    void OnMinionDied(BaseUnit minionUnit)
    {
        var minion = minionUnit.GetComponent <Minion>();

        if (!minion)
        {
            Debug.LogError("Unexpected unit");
            return;
        }
        RemoveMinion(minion);
    }
Ejemplo n.º 7
0
    void AttackPlayer(BaseUnit player)
    {
        int damage = Attack - player.Defense;

        damage           = Mathf.Clamp(damage, 0, Attack);
        player.Health   -= damage;
        player.moveState = MoveState.KnockedBack;

        StartCoroutine(player.ResetMoveState(BasicAttackStunTime));
        player.GetComponent <Rigidbody>().AddForce(_rb.velocity.normalized * BasicAttackKnockback);
    }
Ejemplo n.º 8
0
 protected virtual void Attack()
 {
     if (targetEnemy != null)
     {
         IDamagable damagable = targetEnemy.GetComponent <IDamagable>();
         if (damagable != null)
         {
             damagable.GetDamage(attackDamage);
         }
     }
 }
Ejemplo n.º 9
0
 private void OnUnitDestroy(BaseUnit p_unit)
 {
     if (p_unit.baseStat.controllable)
     {
         Debug.Log("Game over you lose");
     }
     else
     {
         _aiDirector.RemoveAgent(p_unit.GetComponent <AIAgent>());
     }
 }
Ejemplo n.º 10
0
    public override IEnumerator DoEffectCoroutine(BaseUnit target, GameObject source, Vector3 attackPosition)
    {
        var cc = target.GetComponent<CharacterController>();
        var direction = (target.transform.position - attackPosition).normalized;
        for (int i = 0; i < _framesToKnockbackOver; i++) {
            yield return new WaitForFixedUpdate();
            if (target.dead)
                break;

            float move = EasedMove(i/(float)_framesToKnockbackOver);
            cc.Move(direction * (move * (knockbackPower/_framesToKnockbackOver)));
        }
        yield return null;
    }
    private void UpdateUnitsInfo()
    {
        BaseUnit unit = _mapEntetieManager.GetEntitieOfType <BaseUnit>(_selection.Position) as BaseUnit;

        if (unit)
        {
            if (_infoGroupsForEnteties.Count < 2)
            {
                _infoGroupsForEnteties.Add(_tileInfoGroupFactory.Create());
                _infoGroupsForEnteties[1].transform.SetAsFirstSibling();
            }
            _infoGroupsForEnteties[1].gameObject.SetActive(true);
            _infoGroupsForEnteties[1].UpdateInfo(unit.GetComponent <SpriteRenderer>().sprite, unit.name);
            AddUnitFields(_infoGroupsForEnteties[1], unit);
        }
        else
        {
            if (_infoGroupsForEnteties.Count > 1)
            {
                _infoGroupsForEnteties[1].gameObject.SetActive(false);
            }
        }
    }
Ejemplo n.º 12
0
    public HashSet <Vector2Int> GetAvailableTilesForUnit(BaseUnit unit)
    {
        CanWalk w = unit.GetComponent <CanWalk>();

        return(GetAvailableTilesInRangeForMovemntType(unit.Position.x, unit.Position.y, w.Settings.MovemntType, w.Settings.Range));
    }