Exemple #1
0
    void Start()
    {
        isScaredFlag = Animator.StringToHash("IsScared");
        beginTrigger = Animator.StringToHash("Begin");
        approveAnim  = Animator.StringToHash("Happy");
        scaredAnim   = Animator.StringToHash("Scared");
        inspectAnim  = Animator.StringToHash("buyer_inspect");

        var randIdx = (int)(UnityEngine.Random.value * buyerPrefabs.Count);

        randIdx = Math.Min(randIdx, buyerPrefabs.Count - 1);
        var childGameObject = GameObject.Instantiate(buyerPrefabs[randIdx], Vector3.zero, Quaternion.identity);

        childGameObject.transform.parent        = transform;
        childGameObject.transform.localPosition = Vector3.zero;
        ChildMesh = childGameObject.GetComponent <Animator>();

        ghost                         = GameObject.Instantiate(ghostPrefab, Vector3.zero, Quaternion.identity);
        ghostBrain                    = ghost.GetComponent <GhostSpawnBrain>();
        ghostBrain.type               = GhostType.Spooker;
        ghost.name                    = "SpookGhost";
        ghost.transform.parent        = transform;
        ghost.transform.localPosition = new Vector3(0, 0, 1);
        ghost.transform.localRotation = Quaternion.Euler(0, 165, 0);
        ghost.SetActive(false);
    }
Exemple #2
0
    private void BeginHaunt()
    {
        if (haunts.Count == 0)
        {
            return; // Keep spinning until we have some haunts
        }
        CurrentPhase = Phase.Haunt;

        RemainingHaunts  = config.NumGhosts;
        SecondsRemaining = config.TimeLimit;
        sinceLastHint    = 0f;
        hintsEnabled     = config.EnableHints;

        int toRemove = haunts.Count - RemainingHaunts;

        if (toRemove > 0)
        {
            // Remove some random haunt locations until we have enough
            for (int i = 0; i < toRemove; i++)
            {
                int idx = (int)(UnityEngine.Random.Range(0f, (float)(haunts.Count - 1)));
                haunts.RemoveAt(idx);
            }
        }

        foreach (var h in haunts)
        {
            h.IsPossessed = true;
            Vector3 dest     = h.gameObject.transform.position;
            float   yOff     = UnityEngine.Random.Range(-2f, 2f);
            float   xOff     = UnityEngine.Random.Range(-2f, 2f);
            var     spawnPos = GhostSpawnLocation;
            spawnPos.x += xOff;
            spawnPos.y += yOff;
            GameObject      ghost = GameObject.Instantiate(GhostPrefab, spawnPos, Quaternion.identity);
            GhostSpawnBrain brain = ghost.GetComponent <GhostSpawnBrain>();
            if (brain == null)
            {
                Debug.LogError("Invalid prefab, ghost needs brain!");
                GameObject.Destroy(ghost);
            }
            brain.Destination = dest;
            brain.Speed       = (dest - spawnPos).magnitude / HauntDuration;
        }

        hauntTimeRemaining = HauntDuration;

        asrc.PlayOneShot(hauntClip);
    }
Exemple #3
0
    void Start()
    {
        moveBlendHash    = Animator.StringToHash("MoveSpeed");
        scareAnimHash    = Animator.StringToHash("DoScare");
        stairClimbHash   = Animator.StringToHash("DoStairClimb");
        stairDescendHash = Animator.StringToHash("DoStairDescend");
        anim             = GetComponent <Animator>();

        ghost                         = GameObject.Instantiate(ghostPrefab, Vector3.zero, Quaternion.identity);
        ghostBrain                    = ghost.GetComponent <GhostSpawnBrain>();
        ghostBrain.type               = GhostType.Scared;
        ghost.name                    = "ScaredGhost";
        ghost.transform.parent        = transform;
        ghost.transform.localPosition = new Vector3(0, .25f, 1);
        ghost.transform.localRotation = Quaternion.Euler(0, 165, 0);
        ghost.SetActive(false);
    }