Esempio n. 1
0
 // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
 override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     //if enemy at their destination, move to next destination
     if (patrol.AtDestination())
     {
         moveToPoint.MoveTo(patrol.GetDestination());
     }
 }
Esempio n. 2
0
    private void Update()
    {
        lastFire += Time.deltaTime;
        try
        {
            GameObject target = FindTarget();
            if (target != null && lastFire > timeReload)
            {
                if (turret != null)
                {
                    //Quaternion quaternion = Quaternion.AngleAxis(1, Vec)
                    //float yRotate = Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg;
                    //turret.transform.localRotation = new Vector3(turret.transform.localRotation.x, , turret.transform.localRotation.z);
                    turret.transform.LookAt(target.transform.position, Vector3.up);
                }

                GameObject newBullet = poolManager.Spawn(bullet, pointGeneratorBullet.transform.position, pointGeneratorBullet.transform.rotation);//Instantiate(bullet, this.transform);

                Debug.Log(gameObject.name + " create bullet");
                MoveToPoint moveToPointBullet = newBullet.GetComponent <MoveToPoint>();
                if (moveToPointBullet != null)
                {
                    moveToPointBullet.MoveTo(pointGeneratorBullet.transform.position, target);
                }

                DealingDamage dealingDamageBullet = newBullet.GetComponent <DealingDamage>();
                if (dealingDamageBullet != null)
                {
                    UnitData unitData = gameObject.GetComponent <UnitData>();
                    if (unitData != null)
                    {
                        dealingDamageBullet.SetTeam(unitData.team);
                    }
                    else
                    {
                        Debug.LogWarning("Try get UnitData is faled (" + gameObject.name + ")");
                    }
                }
                else
                {
                    Debug.LogWarning("Try get DealingDamage is faled (" + gameObject.name + ")");
                }
                lastFire = 0;
            }
        }
        catch
        {
            Debug.LogError("Error in target " + targets[0].name);
        }
    }
Esempio n. 3
0
    // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (distract.SliotorPosition() != null)
        {
            moveToPoint.MoveTo(distract.SliotorPosition());
            Debug.Log("GOING TO SLIOTOR");
        }

        Debug.Log(Vector3.Distance(animator.gameObject.transform.position, distract.SliotorPosition()));

        if (Vector3.Distance(animator.gameObject.transform.position, distract.SliotorPosition()) < 1)
        {
            animator.SetBool("AtSliotorPosition", true);
        }
    }
Esempio n. 4
0
 // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
 override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     moveToPoint.MoveTo(enemy.GetLastKnownPosition());
 }