예제 #1
0
    // Update is called once per frame
    void Update()
    {
        if (show_AIList_count)
        {
            if (AIlist.Count != 0)
            {
                print(AIlist.Count);
            }
            else
            {
                print("AI list is clear");
            }
        }


        foreach (Ai_Enemy AI in AIlist)
        {
            curentAI            = AI;
            AI.DistanceToPlayer = DistanceToPlayer();
            AI.Dot = Dot();
            AI.DirectionToPlayer = DirectionToPlayer();
            var mele     = AI.GetComponent <MeleeEnemy>();
            var shooting = AI.GetComponent <ShootingEnemy>();

            AI.meleeAllow = DistanceToPlayer() <= AI.numberDistanceForMelee && mele;
            AI.shootAllow = DistanceToPlayer() <= AI.numberDistanceForShoot && RayToPlayer() == "Player" && !AI.meleeAllow && shooting;
            AI.moveAllow  = DistanceToPlayer() <= AI.numberDistanceForMove &&//бежать (и прыгать)
                            !AI.shootAllow && !AI.meleeAllow && AI.GetComponent <MoveEnemy>();
        }
    }
예제 #2
0
    private float JumpTime = 0.5f;   //время через которое во время прыжка может снова идти вперёд AI

    //bool contactToPlayer = false;

    void Start()
    {
        StartAllow = false;
        _Ai        = GetComponent <Ai_Enemy>();
        _rigidbody = GetComponent <Rigidbody2D>();
        _animator  = GetComponent <Animator>();

        if (needSpawnAnimation) //данная конструкция нужна если есть анимация спавна
        {
            _animator.Play("Spawn");

            //  StartAllow = false;
            //needSpawnAnimation = false;
            //StartAllow = true;
        }



        //  body = GetComponent<Rigidbody2D>();
        // _animation = GetComponent<Animator>();
    }