Beispiel #1
0
        public void Play(MonsterAnimation type, WrapMode mode)
        {
            string name = "";

            m_animation.wrapMode = mode;

            if (type == MonsterAnimation.IDEL)
            {
                name = "idle";
            }
            else if (type == MonsterAnimation.ATTACK)
            {
                name = "attack";
            }
            else if (type == MonsterAnimation.DEATH)
            {
                name = "death";
            }
            else if (type == MonsterAnimation.INJURT)
            {
                name = "injurt";
            }
            else if (type == MonsterAnimation.RUN)
            {
                name = "run";
            }

            m_animation.Play(name);
        }
 void Start()
 {
     pm = PlayerMovement.me;
     ms = MonsterScript.me;
     ma = MonsterAnimation.me;
     gm = GameManager.me;
     cc = CameraController.me;
 }
Beispiel #3
0
 public Monster(ContentManager content, string textureName, Point startLoc, int speed, int winHeight, int winWidth)
     : base(content, textureName, startLoc, speed, winHeight, winWidth)
 {
     animation = new MonsterAnimation(content, textureName, new Rectangle(0, 0, startLoc.X, startLoc.Y),
                                      _frameWaiteTime: 100,
                                      _frameWidth: 60, _frameHeight: 60,
                                      _rows: 4, _culloms: 4,
                                      _rotation: 0
                                      );
 }
    public static void SetAnimationState(MonsterAnimation index)
    {
        List <AnimationState> states;
        Animation             anim = GetAnimation();

        states = new List <AnimationState>(anim.Cast <AnimationState>());

        anim.Stop();
        anim.clip = states[(int)index].clip;
        anim.Play();
    }
        public Monster(IndexPair startPoint, IndexPair endPoint)
        {
            increasing = true;
            counter    = 0;
            AnimationFactory factory = new AnimationFactory();
            PathFinder       myPath  = new PathFinder(new RouteInformation(startPoint, endPoint));

            monsterPath = myPath.FindPath();

            makeStepTimer.Elapsed += Timer_Elapsed;
            makeStepTimer.Enabled  = true;
            makeStepTimer.Interval = 250;

            Alive = true;

            monsterAnimation = (MonsterAnimation)factory.CreateAnimation(AnimationType.MonsterAnimation, monsterPath[0]);
            monsterAnimation.AnimationPosition = startPoint.IndexesToCoordinates();

            // TODO set Monster start position at game start. TODO set Monster Direction at game start.
            monsterAnimation.Collider.Collided += Monster_Collided;
        }
Beispiel #6
0
        public Monster(IndexPair startPoint, IndexPair endPoint)
        {
            increasing = true;
            counter    = 0;
            AnimationFactory factory = new AnimationFactory();
            IndexPair        temp    = startPoint;

            myPath         = new PathFinder(new RouteInformation(startPoint, endPoint));
            tempPath       = myPath.FindPath();
            timer.Elapsed += Timer_Elapsed;
            timer.Enabled  = true;
            timer.Interval = 250;

            //MapLoader.MonsterStartLocation;
            //monsterAnimation.AnimationTileIndex = new IndexPair(1, 1);//temp.TileIndecies;

            monsterAnimation = (MonsterAnimation)factory.CreateAnimation(AnimationType.MonsterAnimation, tempPath[0]);
            monsterAnimation.AnimationPosition = temp.IndexesToCorrdinates();

            // TODO set Monster start position at game start. TODO set Monster Direction at game start.
            monsterAnimation.Collider.Collided += Monster_Collided;
        }
Beispiel #7
0
    private IEnumerator TransitionIEnum(MonsterAnimation animState)
    {
        float tweenTime = 1f;

        isTransitioning = true;
        monsterBody.GetComponentInChildren <Animator>().speed = 0;
        lifeController.Show();

        if (currentMicro != null)          //Transition in
        {
            currentMicro.gameObject.SetActive(false);
        }

        yield return(InTransitionHelper(tweenTime));

        monsterBody.GetComponentInChildren <Animator>().speed = 1;
        petAnim.animator.speed = 1;
        switch (animState)
        {
        case MonsterAnimation.INTRO:
            int index = Random.Range(0, petAnim.happyIdleAnimations.Count - 1);
            petAnim.animator.Play(petAnim.happyIdleAnimations[index], 0, 0);
            monsterBody.GetComponentInChildren <Animator>().Play("PlayerIntro", 0, 0);
            break;

        case MonsterAnimation.WIN:
            petAnim.animator.speed = 2;
            petAnim.StartFireBlow();
            monsterBody.GetComponentInChildren <Animator>().Play("PlayerWin", 0, 0);
            break;

        case MonsterAnimation.LOSE_FINAL:                 //Just fall through cause we don't have anything special
        case MonsterAnimation.LOSE:
            petAnim.animator.Play(petAnim.sadIdleAnimations[Random.Range(0, petAnim.sadIdleAnimations.Count)], 0, 0);
            monsterBody.GetComponentInChildren <Animator>().Play("PlayerLose", 0, 0);
            break;

        case MonsterAnimation.WIN_FINAL:
            petAnim.Flipping();
            monsterBody.GetComponentInChildren <Animator>().Play("PlayerWinFinal", 0, 0);
            break;

        default:
            Debug.LogWarning("Invalid anim state");
            break;
        }
        if (animState == MonsterAnimation.WIN)
        {
            yield return(WaitSecondsPause(.7f));

            petAnim.FinishFireBlow();
            yield return(WaitSecondsPause(1.3f));
        }
        else
        {
            yield return(WaitSecondsPause(2f));
        }
        if (animState == MonsterAnimation.WIN_FINAL)
        {
            GameOver();             //We have finally won
        }
        else if (animState == MonsterAnimation.LOSE_FINAL)
        {
            GameOver();             //We have finally lost
        }
        else
        {
            ChangeMicro();
            petAnim.animator.Play(petAnim.happyIdleAnimations[1], 0, 0);
            yield return(OutTransitionHelper());

            isTransitioning = false;
            lifeController.Hide();
            StartMicro();
        }
    }
Beispiel #8
0
 void Awake()
 {
     me = this;
 }