Ejemplo n.º 1
0
    public virtual void Close(bool immediate = false)
    {
        if (immediate)
        {
            alpha = 0.0f;
        }

        direction = AnimDirection.BACKWARD;
        StartCoroutine(AnimationCoroutine());
    }
Ejemplo n.º 2
0
    public virtual void Open(bool immediate = false)
    {
        if (immediate)
        {
            alpha = 1.0f;
        }

        direction = AnimDirection.FORWARD;
        StartCoroutine(AnimationCoroutine());
    }
Ejemplo n.º 3
0
 void OnOptionPanelAnimationIsOver(AnimDirection direction)
 {
     if (direction == AnimDirection.FORWARD)
     {
         OptionPanelRight();
     }
     else
     {
         OptionPanelLeft();
     }
 }
Ejemplo n.º 4
0
 void OnViewPanelIsClosed(AnimDirection direction)
 {
     buttonPanelTransform.localScale = Vector3.zero;
 }
 public bool playAnimation(AnimDirection animDir)
 {
     m_eDir = animDir;
     return(playAnimation((int)animDir));
 }
        public void SetDirAnimation(AnimDirection theDir, string sAnimName)
        {
            SpriteAnimation newAnim = Firecracker.animations.getAnimation(sAnimName);

            m_animations[(int)theDir] = newAnim;
        }
 public void SetAnimDir(AnimDirection theDir)
 {
     m_eDir             = theDir;
     m_currentAnimation = (int)m_eDir;
 }
Ejemplo n.º 8
0
        /*
         * public void Repel(Vector2 value) //from landMines
         * {
         *  float distance = (value - Position).Length();
         *  Vector2 direction = (value - Position) * -1;
         *  direction.Normalize();
         *  float difference = (value - goal).Length();
         *  Vector2 newLoc = (direction * (200.0f - distance) * 4.0f) + Position;
         *  if (difference > 10)
         *  {
         *      goal = new Vector2(ai.Next((int)(-distance / 2.0f), (int)(distance / 2.0f)) + newLoc.X, ai.Next((int)(-distance / 2.0f), (int)(distance / 2.0f)) + newLoc.Y);
         *      interest = 100;
         *  }
         * }
         */



        public void BasicMove(GameTime gameTime)
        {
            if (!m_bIsMoving)
            {
                m_fIdleTime += (float)gameTime.ElapsedGameTime.Milliseconds / 1000.0f;
                if (m_fIdleTime >= m_fWaitTime)
                {
                    m_fIdleTime = 0.0f;
                    m_bIsMoving = true;

                    Vector2 targetpos = position;
                    for (int j = 0; j < 5; j++)
                    {
                        //try 5 times to find a legal position
                        targetpos = position + new Vector2((float)Firecracker.random.NextDouble() * 60 - 30, (float)Firecracker.random.NextDouble() * 60 - 30);
                        if (Terrain.Instance == null || Terrain.Instance.isPositionWalkable(targetpos))
                        {
                            break;
                        }
                        targetpos = position;
                    }
                    m_vTargetLocation = targetpos;
                    float vecAngle = Helpers.GetAngle(targetpos - position);
                    vecAngle += 45;
                    if (vecAngle < 0)
                    {
                        vecAngle += 360;
                    }
                    if (vecAngle > 360)
                    {
                        vecAngle -= 360;
                    }
                    AnimDirection theDir = (AnimDirection)(((int)vecAngle) / 90);
                    // Le Cheat Hack!
                    if (theDir == AnimDirection.DIR_N)
                    {
                        theDir = AnimDirection.DIR_S;
                    }
                    else if (theDir == AnimDirection.DIR_S)
                    {
                        theDir = AnimDirection.DIR_N;
                    }
                    playAnimation(theDir);
                }
            }
            else
            {
                Vector2 diffVec = m_vTargetLocation - position;
                if (diffVec.Length() <= 1.0f)
                {
                    m_bIsMoving = false;
                    m_fIdleTime = 0.0f;
                    PauseAnimation();
                }
                else
                {
                    diffVec.Normalize();
                    diffVec *= m_fSpeed;
                    Vector2 newPosition = position + Firecracker.level.getScreenPosition((diffVec * ((float)gameTime.ElapsedGameTime.Milliseconds / 1000.0f)));
                    if (Terrain.Instance == null || Terrain.Instance.isPositionWalkable(newPosition))
                    {
                        position = newPosition;
                    }
                    else
                    {
                        m_vTargetLocation = position;
                    }
                }
            }
        }