示例#1
0
    public int GetCurrentStreet()
    {
        StreetSpriteSort sort = this.GetComponent <StreetSpriteSort>();

        return(sort.street);
        //return CurrentStreet;
    }
示例#2
0
    public void TransitionToStreet(Alley alley)
    {
        var tempsss = alley.GetCurrentStreet().GetComponent <StreetSpriteSort>();

        if (tempsss != null)
        {
            tempsss.spriteColour   = Color.white;
            tempsss.transitionFrac = 1;
            tempsss.layer          = SortLayer.BUILDING_FRONT;
        }
        tempsss = (CurrentStreet = alley.GetTargetAlley().GetCurrentStreet()).GetComponent <StreetSpriteSort>();
        if (tempsss != null)
        {
            tempsss.spriteColour   = Color.black;
            tempsss.transitionFrac = 1;
            tempsss.layer          = SortLayer.BACKGROUND;
        }
        var delta = transform.position.y;

        gameObject.transform.SetParent(CurrentStreet.gameObject.transform);
        Vector3 temp = alley.GetTargetAlley().gameObject.transform.localPosition;

        temp.y     = CurrentStreet.StreetYOffset;
        sss.street = CurrentStreet.streetID;
        if (currentCorpse != null)
        {
            currentCorpse.gameObject.GetComponent <StreetSpriteSort>().street = sss.street;
        }
        gameObject.transform.localPosition = temp;

        delta -= transform.position.y;

        StreetSpriteSort.PlayerStreetSwapp(sss.street);

        AudioManager.Instance.SwitchAtmosphere(CurrentStreet.AtmoType);

        // SmoothCamera.camT.transform.parent = transform.parent;
        if (SmoothCamera.locked = CurrentStreet.lockable)
        {
            SmoothCamera.lockPos  = Vector3.zero;
            SmoothCamera.lockSize = CurrentStreet.size;
            float dy = CurrentStreet.transform.position.y + CurrentStreet.StreetYOffset - (CurrentStreet.GetSuperStreet().transform.position.y + CurrentStreet.GetSuperStreet().StreetYOffset);
            SmoothCamera.lockSize.y += Mathf.Abs(dy);
            SmoothCamera.lockPos.y  -= dy * 0.5f;
            SmoothCamera.Target      = CurrentStreet.transform;
        }
        else
        {
            SmoothCamera.Target  = transform;
            SmoothCamera.lockPos = Vector3.zero;
            // SmoothCamera.targetPosition.x=-transform.position.x/SmoothCamera.Parallax(1,0,delta);
        }

        AudioManager.Instance.PlaySoundOneShot(AudioManager.Instance.ClipEffectTransition, 0.25f);
    }
示例#3
0
 protected void Start()
 {
     for (int i = 0; i < ListActionDefinitions.Count; ++i)
     {
         ActionDefinitions.Add(ListActionDefinitions[i].Action, ListActionDefinitions[i]);
     }
     instance = this;
     sss      = GetComponent <StreetSpriteSort>();
     StreetSpriteSort.PlayerStreetSwapp(sss.street);
     SmoothCamera.Target = transform;
     base.Start();
 }
示例#4
0
    public void TransitionToStreet(Alley alley)
    {
        CurrentStreet = alley.GetTargetAlley().GetCurrentStreet();
        gameObject.transform.SetParent(CurrentStreet.gameObject.transform);
        Vector3 temp = alley.GetTargetAlley().gameObject.transform.localPosition;

        temp.y = CurrentStreet.StreetYOffset;

        StreetSpriteSort sss = GetComponent <StreetSpriteSort>();

        sss.street = CurrentStreet.streetID;
        gameObject.transform.localPosition = temp;
    }
示例#5
0
    public int GetStreetSpriteSortIndex()
    {
        StreetSpriteSort sort = GetComponent <StreetSpriteSort>();

        if (sort != null)
        {
            return(sort.street);
        }
        else
        {
            return(0);
        }
    }
示例#6
0
    public override void Tick()
    {
        base.Tick();

        if (currentCorpse != null)
        {
            currentCorpse.AdvanceDecay();

            if (currentCorpse.DecayLevel == EDecayLevel.WellDone)
            {
                //AudioManager.Instance.PlayVoiceLine(AudioManager.);
                AudioManager.Instance.PlayVoiceLine(AudioManager.Instance.ClipsNonViable[UnityEngine.Random.Range(0, AudioManager.Instance.ClipsNonViable.Count)]);
                DropCorpse();
            }
        }

        StreetSpriteSort sordo = GetComponent <StreetSpriteSort>();

        if (sordo != null)
        {
            IInteractable closestInteractable = EntityManager.Instance.GetClosestInteractableWithinRange(gameObject.transform.position, sordo.street);
            if (CurrentClosestInteractable != closestInteractable)
            {
                CurrentActionProgress = 0.0f;
                HUD.Instance.SetProgressBarProgress(0.0f);
            }
            CurrentClosestInteractable = closestInteractable;
        }
        else
        {
            CurrentClosestInteractable = null;
        }

        if (CurrentClosestInteractable != null)
        {
            TooltipRenderer.sprite = CurrentClosestInteractable.GetInteractIcon();
        }
        else
        {
            TooltipRenderer.sprite = null;
        }


        // if (CurrentClosestInteractable != closestInteractable && closestInteractable != null)
        // {
        //     Debug.Log("Player is near interactable: " + closestInteractable);
        // }
    }
示例#7
0
    public override void Tick()
    {
        base.Tick();

        if (bIsDying || IntroManager.instance == null || !IntroManager.instance.bIntroDone)
        {
            return;
        }

        if (CurrentStatus != ENPCStatus.Sleeping)
        {
            currentSleepiness += (SleepinessIncrease * Time.deltaTime);
        }

        //CurrentAction = EAction.Idle;
        CurrentTaskDuration -= Time.deltaTime;

        Log("state: " + CurrentStatus + "" +
            "CurrentTaskDuration: " + CurrentTaskDuration.ToString("##.##") + " - " +
            currentSleepiness.ToString("#.###"));

        float distance   = 0;
        bool  isInVision = CheckPlayerIsInVision(out distance);


        if (CurrentStatus == ENPCStatus.Alarmed || CurrentStatus == ENPCStatus.Alert || CurrentStatus == ENPCStatus.Aggressive)
        {
            if (!lastKnownPosition.HasValue && lastKnownFleeAlley == null)
            {
                //lost all tracks, where is she ?
                Debug.LogWarning("Inconsistent State: no last knownPosition. setting NPC Status back to Neutral.");
                SetStatus(ENPCStatus.Neutral);
                return;
            }

            if (isInVision)
            {
                lastKnownPosition  = CharacterPlayer.instance.transform.position;
                lastKnownFleeAlley = null; // we saw the player, we don't need to remember potential fleeAlley.

                //we see here, don't give up.
                this.CurrentTaskDuration = this.AlarmedDuration;

                //EntityManager.Instance.npcCorpseDetectionDistance
                MoveToTargetPos(lastKnownPosition.Value);
                //check gameover instance here ?!

                //Second winning condition:
                // if the NPC saw you already wtih the corpse,
                // he will chase you to dead even if you don't wear the corpse anymore.
                CheckForCatchDistance(distance);
            }
            else if (lastKnownFleeAlley != null)
            {
                var distanceAlley = Vector3.Distance(lastKnownFleeAlley.transform.position, transform.position);
                if (distanceAlley < EntityManager.Instance.interactableRadius)
                {
                    //Alley targetAlley =  lastKnownFleeAlley.GetTargetAlley();
                    LogWarn("Warping!");
                    TransitionToStreet(lastKnownFleeAlley);

                    //this.transform.position = targetAlley.GetPosition();
                    lastKnownFleeAlley = null;
                    lastKnownPosition  = null;
                }
                else
                {
                    //abbroach further to this alley.
                    //because of parallax scrolling the allay moves - so we update the move to every frame.
                    MoveToTargetPos(lastKnownFleeAlley.GetPosition());
                }
            }
            else
            {
                if (CurrentTaskDuration <= 0)
                {
                    Log("Calming down from State.");
                    //maybe we chased long enought and can calm down.
                    SetStatus(ENPCStatus.Neutral);
                    return;
                }

                //we don't see the player anymore. maybe he used an interactable ?!
                StreetSpriteSort sort = this.GetComponent <StreetSpriteSort>();
                if (sort == null)
                {
                    Debug.LogError("This NPC does not have a StreetSpriteSort", this);
                    return;
                }
                int streetID = 1;
                if (sort == null)
                {
                    Debug.LogWarning("Unable to determine Street ID of NPC ", this);
                }
                else
                {
                    streetID = sort.street;
                }

                var interactable = EntityManager.Instance.GetClosestInteractableWithinRange(lastKnownPosition.Value, streetID);

                if (interactable != null)
                {
                    if (interactable is Alley)
                    {
                        lastKnownPosition  = null;
                        lastKnownFleeAlley = interactable as Alley;
                    }
                    else
                    {
                        LogWarn("Wheres the Player  ? " + interactable.ToString());
                    }
                }



                // we are moving to the last known position.
                //maybe there is an interactable there ?
                //MoveToTargetPos(lastKnownPosition.Value);
            }
            //if ()
            //is player still in sight ?!
            //GetClosestInteractableWithinRange
        }
        else if (CurrentTaskDuration >= 0.0f)
        {
            //just finish current action.
            //Debug.Log("current Action: " + CurrentAction);
        }
        else
        {
            CurrentThinkCooldown -= Time.deltaTime;
            if (CurrentThinkCooldown <= 0.0f)
            {
                Think();
            }
        }

        // START: Stuff from EntityManager
        bool foundACorpse = false;
        bool foundPlayerCarryingCorpse = false;

        if (isInVision)
        {
            if (CharacterPlayer.instance.GetCurrentCorpse() != null && !CharacterPlayer.instance.IsHiding())
            {
                FollowCharacter(CharacterPlayer.instance);
            }

            /*else if (CharacterPlayer.instance.IsHiding())
             * {
             *  SetStatus(ENPCStatus.Neutral);
             * }*/

            foundPlayerCarryingCorpse = true;
            ActivateFoundCorpseText(foundACorpse);

            if (AudioManager.Instance != null)
            {
                if (foundPlayerCarryingCorpse)
                {
                    AudioManager.Instance.SwitchMusic(AudioManager.Instance.ClipMusicChase);
                    //Debug.Log("Player is seen carrying corpse by: " + npc);
                }
                else
                {
                    AudioManager.Instance.SwitchMusic(AudioManager.Instance.ClipMusicWander);
                }
            }
            Log("Corpse detected!! Distance: " + distance);
        }
        // END: Stuff from EntityManager
    }