예제 #1
0
        public void initialized(ContentManager content, int widthMapPos, int heightMapPos, string texturePath, string texturePathDead, int x, int y, int h, int w, int hCut, int wCut)
        {
            //Set Position
            m_catPos    = new Rectangle(x, y, w, h);
            m_catAnim   = CatAnim.Frame1;
            m_catState  = CatState.Life;
            m_animStart = false;

            m_mapPosX = widthMapPos;
            m_mapPosY = heightMapPos;

            //Set Rectangle
            m_catRectangle = new Rectangle(0, 0, wCut, hCut);

            //Load Texture
            m_catTexture = content.Load <Texture2D>(texturePath);
            m_catDead    = content.Load <Texture2D>(texturePathDead);
        }
예제 #2
0
        //Methods
        public bool TouchInputKill(Vector2 screenScale, TouchCollection touchPanelState)
        {
            if (m_animStart)
            {
                //Collision
                foreach (TouchLocation tl in touchPanelState)
                {
                    if (tl.State == TouchLocationState.Pressed)
                    {
                        if (tl.Position.X > m_catPos.X / screenScale.X && tl.Position.X < m_catPos.X / screenScale.X + m_catRectangle.Width / screenScale.X && /* X */
                            tl.Position.Y > m_catPos.Y / screenScale.Y && tl.Position.Y < m_catPos.Y / screenScale.Y + m_catRectangle.Height / screenScale.Y /* Y */)
                        {
                            if (m_catState == CatState.Life)
                            {
                                m_catState = CatState.DeadAnim;
                                m_catAnim  = CatAnim.Frame1;

                                return(true);
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            else
            {
                return(false);
            }

            return(false);
        }
예제 #3
0
        //UPDATE
        public void Update(GameTime gameTime, TouchCollection touchPanelState, Vector2 screenScale)
        {
            //Animation
            if (m_animStart)
            {
                m_elapsed = (float)gameTime.ElapsedGameTime.TotalMilliseconds; //Timer
                m_timer  -= (int)m_elapsed;

                if (m_timer <= -70) //Duration
                {
                    if (m_catAnim == CatAnim.Frame1)
                    {
                        m_catAnim = CatAnim.Frame2; //Frame 2
                    }
                    else if (m_catAnim == CatAnim.Frame2)
                    {
                        m_catAnim = CatAnim.Frame3; //Frame 3
                    }
                    else if (m_catAnim == CatAnim.Frame3)
                    {
                        m_catAnim = CatAnim.Frame4; //Frame 4
                    }
                    else if (m_catAnim == CatAnim.Frame4)
                    {
                        m_catAnim = CatAnim.Frame5; //Frame 5
                    }
                    else if (m_catAnim == CatAnim.Frame5)
                    {
                        m_catAnim = CatAnim.Frame6; //Frame 6
                    }
                    else if (m_catAnim == CatAnim.Frame6 && m_catState == CatState.DeadAnim)
                    {
                        m_catState = CatState.Dead;
                    }

                    m_timer = 0; //Reset Timer
                }
            }
        }