コード例 #1
0
    public bool canActuallyChangePath()
    {
        foreach (GameObject enemyClose in closeOtherEnemies)
        {
            if (enemyClose != null)
            {
                WalkOnMultiplePaths womp = enemyClose.GetComponent <WalkOnMultiplePaths>();
                if ((womp.isFrontPath != isFrontPath) && !takesBothPathways)
                {
                    //IF they walk on different paths we check if they are gonna collide
                    Vector3 distanceBetweenObjects = transform.position - enemyClose.transform.position;
                    //We discard the z component
                    float distance = new Vector2(distanceBetweenObjects.x, distanceBetweenObjects.y).magnitude;

                    if (distance < (centerToExtremesDistance + womp.centerToExtremesDistance))
                    {
                        //It's not gonna fit!!! , you Shall not change path
                        return(false);
                    }
                }
            }
        }
        //Nothing went wrong, so you can actually change path
        return(true);
    }
コード例 #2
0
    public float getClosestEnemyInFront()
    {
        float closestEnemyDistance = float.PositiveInfinity;

        foreach (GameObject enemyClose in closeOtherEnemies)
        {
            if (((ia.getIsLookingRight()) && Util.isARightToB(enemyClose, gameObject)) ||
                (!ia.getIsLookingRight() && !Util.isARightToB(enemyClose, gameObject)))
            {
                if (enemyClose != null)
                {
                    WalkOnMultiplePaths womp = enemyClose.GetComponent <WalkOnMultiplePaths>();
                    if ((womp.isFrontPath == isFrontPath) || (takesBothPathways || womp.takesBothPathways))
                    {
                        float distance = Vector3.Distance(transform.position, enemyClose.transform.position) - centerToExtremesDistance - womp.centerToExtremesDistance;
                        if (distance < closestEnemyDistance)
                        {
                            closestEnemyDistance = distance;
                        }
                    }
                }
            }
        }
        return(closestEnemyDistance);
    }
コード例 #3
0
    // Use this for initialization
    void Start()
    {
        if (!isForCinematic)
        {
            GameManager.iaManager.registerIA(this);
        }
        despawned            = false;
        attackController     = GetComponent <CharacterAttackController> ();
        isOnGuard            = false;
        iaAnimator           = GetComponentInChildren <Animator> ();
        player               = GameManager.player;
        characterController  = GetComponent <CharacterController> ();
        transform.forward    = new Vector3(1f, 0f, 0f);
        minimumDistanceFront = ((Random.value) * 0.2f) + 0.2f;

        isDead = false;
        walkOnMultiplePaths = GetComponent <WalkOnMultiplePaths> ();

        enemyOnHitParticlesController = GetComponent <EnemyOnHitParticlesController> ();
        //Particle Inicialization
        //hitParticles = new GameObject[3];

        //hitParticles[0] = GameObject.Instantiate (onHitEffect) as GameObject;
        //hitParticles[1] = GameObject.Instantiate (secondOnHitEffect) as GameObject;
        //hitParticles[2] = GameObject.Instantiate (thirdOnHitEffect) as GameObject;
        flyParticles = GameObject.Instantiate(flySmokeParticles) as GameObject;
        flyParticles.transform.parent   = transform;
        flyParticles.transform.position = GetComponent <Rigidbody> ().worldCenterOfMass;
        hitGroundParticles = GameObject.Instantiate(onHitGroundParticles) as GameObject;
        hitGroundParticles.transform.parent   = transform;
        hitGroundParticles.transform.position = GetComponent <Rigidbody> ().worldCenterOfMass;

        /*foreach (GameObject particles in hitParticles) {
         *      particles.transform.parent = gameObject.transform;
         * }*/
    }
コード例 #4
0
    public int ammountOfEnemiesInFront(bool isFrontPath, int jumps)
    {
        float playerAngle = Util.getPlanetaryAngleFromAToB(gameObject, GameManager.player);

        int enemiesBetweenPlayerAndMe = 0;

        foreach (GameObject enemyClose in closeOtherEnemies)
        {
            if (enemyClose != null)
            {
                WalkOnMultiplePaths womp = enemyClose.GetComponent <WalkOnMultiplePaths>();

                if (womp.isFrontPath == isFrontPath || (womp.takesBothPathways || takesBothPathways))
                {
                    float enemyAngle = Util.getPlanetaryAngleFromAToB(gameObject, enemyClose);
                    if (playerAngle < 0f && enemyAngle < 0f)
                    {
                        //if they're both negative
                        if (playerAngle < enemyAngle)
                        {
                            enemiesBetweenPlayerAndMe++;
                        }
                    }
                    else if (playerAngle > 0f && enemyAngle > 0f)
                    {
                        if (playerAngle > enemyAngle)
                        {
                            enemiesBetweenPlayerAndMe++;
                        }
                    }
                }
            }
        }

        return(enemiesBetweenPlayerAndMe);
    }
コード例 #5
0
    // Use this for initialization
    void Start()
    {
        if(!isForCinematic){
            GameManager.iaManager.registerIA (this);
        }
        despawned = false;
        attackController = GetComponent<CharacterAttackController> ();
        isOnGuard = false;
        iaAnimator = GetComponentInChildren<Animator> ();
        player = GameManager.player;
        characterController = GetComponent<CharacterController> ();
        transform.forward = new Vector3(1f,0f,0f);
        minimumDistanceFront = ((Random.value)*0.2f) + 0.2f;

        isDead = false;
        walkOnMultiplePaths = GetComponent<WalkOnMultiplePaths> ();

        enemyOnHitParticlesController = GetComponent<EnemyOnHitParticlesController> ();
        //Particle Inicialization
        //hitParticles = new GameObject[3];

        //hitParticles[0] = GameObject.Instantiate (onHitEffect) as GameObject;
        //hitParticles[1] = GameObject.Instantiate (secondOnHitEffect) as GameObject;
        //hitParticles[2] = GameObject.Instantiate (thirdOnHitEffect) as GameObject;
        flyParticles = GameObject.Instantiate (flySmokeParticles) as GameObject;
        flyParticles.transform.parent = transform;
        flyParticles.transform.position = GetComponent<Rigidbody> ().worldCenterOfMass;
        hitGroundParticles = GameObject.Instantiate (onHitGroundParticles) as GameObject;
        hitGroundParticles.transform.parent = transform;
        hitGroundParticles.transform.position = GetComponent<Rigidbody> ().worldCenterOfMass;

        /*foreach (GameObject particles in hitParticles) {
            particles.transform.parent = gameObject.transform;
        }*/
    }