Beispiel #1
0
    public Actors.ACTOR_DIRECTION HauntActor(Actors actor)
    {
        gameObject.GetComponent <AudioSource> ().clip = hauntClip;
        gameObject.GetComponent <AudioSource> ().Play();
        //play haunting animation
        hauntPrefab.SetActive(false);

        //Changed to bitwisw
        if ((hauntedTiles[0].effectsOnTile & Tile.TILE_EFFECTS.HAUNT) == Tile.TILE_EFFECTS.HAUNT)
        {
            hauntedTiles[0].effectsOnTile &= ~Tile.TILE_EFFECTS.HAUNT;
        }
        else
        {
            Debug.LogError("Actor activated haunt but the tile is not the current one");
        }

        actor.AddFear(amountOfFear);

        //TODO NEVER CHANGE MACHINE STATES OUTSIDE OTHER CLASSES
        //actor.state = Actors.ACTOR_STATE.MOVING;

        if (hauntDirection.z > 0)
        {
            //Debug.Log("Haunting up");
            return(Actors.ACTOR_DIRECTION.UP);
        }
        else if (hauntDirection.z < 0)
        {
            //Debug.Log("Haunting down");
            return(Actors.ACTOR_DIRECTION.DOWN);
        }
        if (hauntDirection.x > 0)
        {
            //Debug.Log("Haunting right");
            return(Actors.ACTOR_DIRECTION.RIGHT);
        }
        else if (hauntDirection.x < 0)
        {
            //Debug.Log("Haunting left");
            return(Actors.ACTOR_DIRECTION.LEFT);
        }
        else
        {
            Debug.LogError("HAUNTING ACTOR HAS RETURNED WITH DIRECTION NONE");
            return(Actors.ACTOR_DIRECTION.NONE);
        }
    }
Beispiel #2
0
    public bool Activate(int lockNum)
    {
        if (shoutCooldownTimer > 0)
        {
            return(false);
        }

        shoutCooldownTimer = shoutCooldown;
        castTimer          = castTime;

        gameObject.GetComponent <Animator> ().Play(shoutAnimName);
        gameObject.GetComponent <AudioSource> ().clip = shoutClip;
        gameObject.GetComponent <AudioSource> ().Play();

        Collider[] colliders = Physics.OverlapSphere(this.transform.position, radius);

        for (int i = 0; i < colliders.Length; ++i)
        {
            if (colliders [i].tag == "Actor" && colliders[i].isTrigger == false)
            {
                Actors actor = colliders[i].GetComponent <Actors>();
                actor.AddFear(amountOfFear);

                Vector3 dirDifference = actor.transform.position - this.transform.position;
                dirDifference = dirDifference.normalized;

                Actors.ACTOR_DIRECTION scareDir = new Actors.ACTOR_DIRECTION();

                FillRandomDirection(actor.currentTile);

                Actors.ACTOR_DIRECTION randDir = new Actors.ACTOR_DIRECTION();

                if (possibleDirections.Count != 0)
                {
                    randDir = possibleDirections[Random.Range(0, possibleDirections.Count)];
                }
                else
                {
                    Debug.Log("No possible direction for the scream");
                }

                if (Vector3.SqrMagnitude(dirDifference) < 0.0001f)
                {
                    scareDir = randDir;
                }
                else if (Mathf.Abs(dirDifference.x) > Mathf.Abs(dirDifference.z))
                {
                    if (dirDifference.x > 0)
                    {
                        scareDir = actor.currentTile.right != null ? Actors.ACTOR_DIRECTION.RIGHT : randDir;
                    }
                    else if (dirDifference.x < 0)
                    {
                        scareDir = actor.currentTile.left != null ? Actors.ACTOR_DIRECTION.LEFT : randDir;
                    }
                }
                else
                {
                    if (dirDifference.z > 0)
                    {
                        scareDir = actor.currentTile.up != null ? Actors.ACTOR_DIRECTION.UP : randDir;
                    }
                    else if (dirDifference.z < 0)
                    {
                        scareDir = actor.currentTile.down != null ? Actors.ACTOR_DIRECTION.DOWN : randDir;
                    }
                }
                actor.ScreamedAt(scareDir);
            }
        }
        lockNumber = lockNum;
        return(true);
    }