Exemple #1
0
    void PickUp(GameObject newWeapon)
    {
        if (!Arachnid.Math.LayerMaskContainsLayer(layersCanPickUp, newWeapon.layer))
        {
            return;
        }

        FlingSword newWeaponSword = newWeapon.GetComponent <FlingSword>();

        if (!newWeaponSword)
        {
            Debug.LogError(name + " tried to pickup weapon but it has no fling sword component.", newWeapon);
            return;
        }

        Hauntable hauntable = newWeaponSword.GetComponent <Hauntable>();

        if (hauntable)
        {
            hauntable.EndHaunt();
        }

        wieldedObject = newWeaponSword;
        wieldedObject.gameObject.SetActive(false);
        wieldedObject.transform.parent        = transform;
        wieldedObject.transform.localPosition = wieldedObjectOffset;
        wieldedObjectFSM = wieldedObject.GetComponent <PlayMakerFSM>();

        onWeaponPickedUp.Invoke();

        Debug.Log("Picked up " + newWeapon.name);
    }
Exemple #2
0
    public void Init(Hauntable newHauntable, int hauntCost)
    {
        hauntable = newHauntable;
        cost      = Mathf.Clamp(hauntCost, 0, 500);

        PlayFullSequence();
    }
Exemple #3
0
    Haunter GetHaunter()
    {
        Hauntable myHauntable = GetComponent <Hauntable>();

        if (!myHauntable)
        {
            return(null);
        }
        return(myHauntable.haunter);
    }
Exemple #4
0
    public void StartHauntInRoom(Room room)
    {
        Hauntable hauntable = room.GetComponent <Hauntable>();

        if (CanHaunt && hauntable != null && !_catchingInProgress)
        {
            _activeHauntable = hauntable;
            _activeHauntable.StartHaunting();
            _hauntChargeTimer.Stop();
            _hauntChargeTimer.Reset();
            _hauntProgressTimer.Start();
            _hauntedRoom = room;
            Events.g.Raise(new HauntEvent(succeeded: true, starting: true, duration: _hauntDuration, room: room));
        }
        else
        {
            Events.g.Raise(new HauntEvent(succeeded: false, starting: true, duration: _hauntDuration, room: room));
        }
    }
Exemple #5
0
    void MergeWith(Matchable other)
    {
        if (AmMaxLevel())
        {
            return;
        }

        // get the next level prefab
        int        evolution       = level + 1;
        GameObject evolutionPrefab = matchableInfo.evolutions[evolution];

        // instantiate the next level prefab
        GameObject evolutionInstance = Instantiate(evolutionPrefab, transform.position, transform.rotation);

        // Check if the haunter should be migrated to the next level evolution. Check both matchers for a haunter
        Haunter haunter = GetHaunter();

        if (!haunter)
        {
            haunter = other.GetHaunter();
        }
        if (haunter)
        {
            Hauntable evolutionHauntable = evolutionInstance.GetComponent <Hauntable>();
            if (evolutionHauntable)
            {
                haunter.MigrateHaunt(evolutionHauntable);
            }

            else
            {
                haunter.EndHaunt(evolutionInstance);
            }
        }

        // destroy
        Destroy(other.gameObject);
        Destroy(gameObject);
    }
Exemple #6
0
    void Update()
    {
        if (GameDirector.Instance.CurrentPhase == Phase.Play)
        {
            if (!childMesh.IsInAnim)
            {
                if (curExorcising != null)
                {
                    curExorcising.PreviouslyInteracted = true;
                    curExorcising.IsPossessed          = false;
                    curExorcising = null;
                }
                if (Input.GetButtonUp("Fire1"))
                {
                    bool shouldAnim = false;
                    bool hasGhost   = false;
                    if (lookDir == LookDirection.Background)
                    {
                        if (proxHaunts[1] != null && !proxHaunts[1].PreviouslyInteracted)
                        {
                            // TODO: Animation based on IsPossessed state BEFORE change
                            if (proxHaunts[1].IsPossessed)
                            {
                                curExorcising = proxHaunts[1];
                                hasGhost      = true;
                            }
                            proxHaunts[1].PreviouslyInteracted = true;
                            shouldAnim = true;
                        }
                    }
                    else if (lookDir == LookDirection.Foreground)
                    {
                        if (proxHaunts[0] != null && !proxHaunts[0].PreviouslyInteracted)
                        {
                            if (proxHaunts[0].IsPossessed)
                            {
                                hasGhost      = true;
                                curExorcising = proxHaunts[0];
                            }
                            proxHaunts[0].PreviouslyInteracted = true;
                            shouldAnim = true;
                        }
                    }

                    if (shouldAnim)
                    {
                        childMesh.PlayScare();
                        asrc.PlayOneShot(scareGhostClip);
                    }

                    if (hasGhost)
                    {
                        childMesh.ShowScaredGhost();
                    }
                }
                else
                {
                    float speed = body.velocity.magnitude;
                    if (speed > 0f)
                    {
                        childMesh.SetSpeed(speed > HorizontalDeadzone ? speed : 0f);
                    }
                }
            }
        }
    }
Exemple #7
0
 public void RegisterHauntable(Hauntable haunt)
 {
     haunts.Add(haunt);
 }