Example #1
0
        public void Animation(GameTime gameTime, SpriteBatch spriteBatch, GameObject gameObject)
        {
            if (currentAnimation == NPCAnimations.IdleShopkeeper)
            {
                currentAnimation = nextAnimation;
            }
            if (currentAnimation == NPCAnimations.WavingShopkeeper)
            {
                if (wavingShopkeeper.getPlayedOnce())
                {
                    if (nextAnimation == NPCAnimations.WavingShopkeeper)
                    {
                        nextAnimation = previousAnimation;
                    }
                    currentAnimation = nextAnimation;

                    wavingShopkeeper.resetPlayedOnce();
                }
            }

            Rectangle tempRec;

            switch (currentAnimation)
            {
            case NPCAnimations.IdleShopkeeper:
                tempRec = idleShopkeeper.Update(gameTime);
                spriteBatch.Draw(idleShopkeeper.texture, gameObject.gameObjectPosition, tempRec, Color.White, 0, Vector2.Zero, new Vector2(1, 1), SpriteEffects.None, 0);
                break;

            case NPCAnimations.WavingShopkeeper:
                tempRec = wavingShopkeeper.Update(gameTime);
                spriteBatch.Draw(wavingShopkeeper.texture, gameObject.gameObjectPosition, tempRec, Color.White, 0, Vector2.Zero, new Vector2(1, 1), SpriteEffects.None, 0);
                break;
            }
        }
Example #2
0
    private void Awake()
    {
        agent        = GetComponent <NavMeshAgent>();
        obstacle     = GetComponent <NavMeshObstacle>();
        animator     = GetComponent <NPCAnimations>();
        stateMachine = GetComponent <StateMachine>();

        GetComponent <StateMachine>().OnStateChanged += FleeTheParty;
    }
Example #3
0
    public AudioClip RetrieveAudioClip(NPCAnimations.AnimationIndex index)
    {
        foreach(SoundFX soundFX in soundFXs)
        {
            if (soundFX.audioIndex == index)
                return soundFX.clip;
        }

        return null;
    }
 void setFriendAnimation(NPCAnimations.AnimationIndex animationType)
 {
     if(anim != null)
     {
         NPCAnimations.AnimationSequence currAnimSeq = anim.GetComponent<NPCAnimations>().RetrieveAnimationSequence(animationType);
         List<Texture> currAnimSeqTextures = currAnimSeq.textures;
         if (currAnimSeqTextures.Count > 0)
         {
             anim.StopAnimation();
             anim.SetAnimationList(currAnimSeqTextures);
             anim.PlayAnimation();
             anim.SetSpeed(currAnimSeq.speed);
         }
     }
 }
    void Start()
    {
        if (animations == null) {
            animations = (NPCAnimations)gameObject.AddComponent (typeof(NPCAnimations));
            animations.animations = new List<NPCAnimations.AnimationSequence> ();
        }

        GameObject animationsPrefab = ResourceManager.LoadObject ("Player/" + ApplicationState.Instance.selectedCharacter + "Animations");
        if (animationsPrefab != null) {
            NPCAnimations playerInstanceAnimations = animationsPrefab.GetComponent<NPCAnimations> ();

            foreach (NPCAnimations.AnimationIndex index in animationIndexes) {
                    NPCAnimations.AnimationSequence sequence;
                    animations.animations.Add (playerInstanceAnimations.RetrieveAnimationSequence (index));
            }

            playerInstanceAnimations = null;
            animationsPrefab = null;
            Resources.UnloadUnusedAssets ();
        }
    }
Example #6
0
    void Awake()
    {
        // Set static instance to this object
        instance = this;
        initialRotation = transform.rotation;

        if (GameManager.WasInitialized () && GameManager.Instance.playerPosition != null) {
            this.transform.position = GameManager.Instance.playerPosition.position;
        }

        // Find the navigation mesh agent in the gameobject (3D)
        playerNavigation = GameObject.FindObjectOfType(typeof(NavMeshAgent)) as NavMeshAgent;
        // Find the main camera (3D)
        sceneCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<Camera>();

        if(!GameObject.Find("FarDistance_Pos")){
            farDistance = Vector3.Distance(sceneCamera.transform.position, transform.position);
        }

        else{
            //Debug.Log("Found Far Distance Pos");
            Vector3 farDistancePos = GameObject.Find("FarDistance_Pos").transform.position;
            farDistance = Vector3.Distance(sceneCamera.transform.position, farDistancePos);
        }
        scaleCameraRatio = farDistance - nearDistance;

        GameObject spritePrefab = ResourceManager.LoadObject ("Player/" + ApplicationState.Instance.selectedCharacter + "Sprite");
        GameObject spriteInstance = Instantiate (spritePrefab) as GameObject;
        spriteInstance.transform.parent = transform;
        spriteInstance.transform.localPosition = new Vector3(0,0.76f,0);

        animationsList = spriteInstance.GetComponent<NPCAnimations> ();
        animationControl = spriteInstance.GetComponent<NPCDialogueAnimation> ();
        animationFlip = spriteInstance.GetComponent<FlipTexture> ();

        animationStretch = GetComponentInChildren<UIStretch>();

        spriteScale = spriteInstance.transform;
        scalePlayerRatio = farScale - nearScale;

        spritePrefab = null;
        Resources.UnloadUnusedAssets ();
    }
Example #7
0
    public void PlayAnimation(NPCAnimations.AnimationIndex animationIndex, int fps = -1)
    {
        if (currentAnimation != animationIndex)
        {
            animationControl.StopAnimation();
            NPCAnimations.AnimationSequence sequence = animationsList.RetrieveAnimationSequence(animationIndex);
            animationControl.SetAnimationList(sequence.textures);
            animationControl.SetSpeed(sequence.speed);
            animationControl.PlayAnimation();
            currentAnimation = animationIndex;
        }

        if (fps > 0)
            animationControl.SetFPS(fps);
    }
Example #8
0
    public void UpdatePlayerTexture(NPCAnimations.AnimationIndex animationIndex, float stretch = -1)
    {
        if (dialogue.owner != null)
            playerParentTransform.localScale = Vector3.one * dialogue.owner.playerHeight;

        //if (stretch > 0)
        //	playerTexture.stretch.relativeSize.y = stretch;

        if (animationIndex != NPCAnimations.AnimationIndex.NONE)
        {
            dialogue.owner.conversationTree.playerAnimations.animations.PlayAnimationSequence(animationIndex, playerTexture);

            if(animationIndex == NPCAnimations.AnimationIndex.RECEIVE_TOY)
            {
                received2DToy.spriteName = dialogue.owner.missingToy.name;
                received2DToy.color = dialogue.owner.foundToyColor;
                received2DToy.gameObject.SetActive(true);
                reach2DToy.gameObject.SetActive(false);

                progressBar.PlayStarParticle(received2DToy.transform.position);
            }
            else
            {
                received2DToy.gameObject.SetActive(false);

                if (animationIndex == NPCAnimations.AnimationIndex.REACH_FOR_TOY)
                {
                    reach2DToy.spriteName = dialogue.owner.missingToy.name;
                    reach2DToy.color = dialogue.owner.foundToyColor;
                    reach2DToy.gameObject.SetActive(true);
                }
                else
                {
                    reach2DToy.gameObject.SetActive(false);
                }
            }
        }
    }
Example #9
0
    public void ShowPreDialogueMinigame(NPCAnimations.AnimationIndex playerMinigameTexture, Dialogue firstDialogue)
    {
        npcArrow.gameObject.SetActive(false);
        progressBar.gameObject.SetActive(false);
        GameManager.Instance.mainCamera.enabled = false;
        // Hide the HUD
        HUD.Instance.gameObject.SetActive(false);

        // Clear all elements of the window
        InitializeElements(emotions);
        InitializeElements(imageText);
        InitializeElements(imageTextBox);
        InitializeElements(textOnly);
        singleDialogueElement.transform.parent.gameObject.SetActive(false);

        if (playerMinigameTexture != NPCAnimations.AnimationIndex.NONE)
        {
            DialogueWindow.instance.dialogue = Player.instance.interactingNPC.conversationTree.root;
            playerTexture.animation.StopAnimation();
            UpdatePlayerTexture(playerMinigameTexture);
        }
        npc1.animation.StopAnimation ();
        npc2.animation.StopAnimation ();
        npcSingle.animation.StopAnimation ();
        UpdateNPCPortrait(firstDialogue);

        this.gameObject.SetActive(true);
    }
Example #10
0
 public void PlaySoundFX(NPCAnimations.AnimationIndex soundFX)
 {
     AudioClip audioClip = soundFXLibrary.RetrieveAudioClip(soundFX);
     if (audioClip != null)
         AudioManager.Instance.Play(audioClip, this.transform, 1, false);
 }
Example #11
0
 void PlayAnimation(NPCAnimations.AnimationIndex index)
 {
     NPCAnimations.AnimationSequence anim = animationSet.RetrieveAnimationSequence(index);
     List<Texture> textures = anim.textures;
     if (textures.Count > 0)
     {
         animationController.StopAnimation();
         animationController.SetAnimationList(textures);
         animationController.PlayAnimation();
         animationController.SetSpeed(anim.speed);
     }
 }
 void setCharacterAnimation(NPCAnimations.AnimationIndex animationType, NPCDialogueAnimation anim)
 {
     NPCAnimations.AnimationSequence currAnimSeq = anim.GetComponent<NPCAnimations>().RetrieveAnimationSequence(animationType);
     List<Texture> currAnimSeqTextures = currAnimSeq.textures;
     if (currAnimSeqTextures.Count > 0)
     {
         anim.StopAnimation();
         anim.SetAnimationList(currAnimSeqTextures);
         anim.PlayAnimation();
         anim.SetSpeed(currAnimSeq.speed);
     }
 }
Example #13
0
 void setTeacherAnimation(NPCAnimations.AnimationIndex animationType)
 {
     NPCAnimations.AnimationSequence currAnimSeq = teacher.GetComponent<NPCAnimations>().RetrieveAnimationSequence(animationType);
     List<Texture> currAnimSeqTextures = currAnimSeq.textures;
     if (currAnimSeqTextures.Count > 0)
     {
         teacherAnimation.StopAnimation();
         teacherAnimation.SetAnimationList(currAnimSeqTextures);
         teacherAnimation.PlayAnimation();
         teacherAnimation.SetSpeed(currAnimSeq.speed);
     }
 }