Exemplo n.º 1
0
    public void Init(
        IUnit unit
        )
    {
        // vars
        _unit = unit;

        // sensors
        var lookFor = IAm == IAm.Ally ? IAm.Enemy : IAm.Ally;

        if (gameObject.GetComponent <Rigidbody>() == null)
        {
            Debug.LogError("I have no Rigidbody, I can't be seen by sensors!");
        }

        if (gameObject.GetComponent <CapsuleCollider>() == null)
        {
            Debug.LogError("I have no CapsuleCollider, I can't be seen by sensors!");
        }

        if (ViewSensor == null)
        {
            Debug.LogError("I have no view Sensor !");
        }
        else
        {
            ViewSensor.Init(lookFor.ToString(), true, EnemyInViewRange);
        }
    }
Exemplo n.º 2
0
    public void SetupAtackSensor(AttackController atkController)
    {
        _attackController = atkController;

        if (AtackSensor == null)
        {
            Debug.LogError("I have no attack Sensor !");
        }
        else
        {
            var lookFor = IAm == IAm.Ally ? IAm.Enemy : IAm.Ally;

            AtackSensor.Init(lookFor.ToString(), true, _attackController.EnemyInRange);
            AtackSensor.transform.localScale = new Vector3(_unit.Stats.AttackRange * 2, _unit.Stats.AttackRange * 2, _unit.Stats.AttackRange * 2);
            AtackSensor.gameObject.SetActive(false);
        }
    }