Exemple #1
0
 /// <summary>
 /// Resumes the target. All queued actions will be resumed.
 /// </summary>
 public void resumeTarget(CCObject target)
 {
     if (m_pTargets.ContainsKey(target))
     {
         m_pTargets[target].paused = false;
     }
 }
Exemple #2
0
 public void setObject(CCObject pObj)
 {
     if (pObj != m_pObject)
     {
         m_pObject = pObj;
     }
 }
Exemple #3
0
        /// <summary>
        /// Gets an action given its tag an a target
        /// </summary>
        /// <returns>
        /// @return the Action the with the given tag
        /// </returns>
        public CCAction getActionByTag(uint tag, CCObject target)
        {
            Debug.Assert((int)tag != (int)ActionTag.kCCActionTagInvalid);

            if (m_pTargets.ContainsKey(target))
            {
                tHashElement element = m_pTargets[target];

                if (element.actions != null)
                {
                    int limit = element.actions.Count;
                    for (int i = 0; i < limit; i++)
                    {
                        CCAction action = element.actions[i];

                        if (action.tag == (int)tag)
                        {
                            return(action);
                        }
                    }
                }
                else
                {
                    CCLog.Log("cocos2d : getActionByTag: Target not found");
                }
            }
            else
            {
                CCLog.Log("cocos2d : getActionByTag: Target not found");
            }

            return(null);
        }
Exemple #4
0
 /// <summary>
 /// Pauses the target: all running actions and newly added actions will be paused.
 /// </summary>
 public void pauseTarget(CCObject target)
 {
     if (m_pTargets.ContainsKey(target))
     {
         m_pTargets[target].paused = true;
     }
 }
Exemple #5
0
        /// <summary>
        /// Removes all actions from a certain target.
        /// All the actions that belongs to the target will be removed.
        /// </summary>
        public void removeAllActionsFromTarget(CCObject target)
        {
            if (target == null)
            {
                return;
            }

            if (m_pTargets.ContainsKey(target))
            {
                tHashElement element = m_pTargets[target];

                if (element.actions.Contains(element.currentAction) && (!element.currentActionSalvaged))
                {
                    element.currentActionSalvaged = true;
                }

                element.actions.Clear();
                if (m_pCurrentTarget == element)
                {
                    m_bCurrentTargetSalvaged = true;
                }
                else
                {
                    deleteHashElement(element);
                }
            }
            else
            {
                CCLog.Log("cocos2d: removeAllActionsFromTarget: Target not found");
            }
        }
Exemple #6
0
 /// <summary>
 /// Removes all actions from all the targets.
 /// </summary>
 public void removeAllActions()
 {
     CCObject[] targets = new CCObject[m_pTargets.Keys.Count];
     m_pTargets.Keys.CopyTo(targets, 0);
     for (int i = 0; i < targets.Length; i++)
     {
         removeAllActionsFromTarget(targets[i]);
     }
 }
Exemple #7
0
        /// <summary>
        /// Returns the numbers of actions that are running in a certain target.
        /// Composable actions are counted as 1 action. Example:
        /// - If you are running 1 Sequence of 7 actions, it will return 1.
        /// - If you are running 7 Sequences of 2 actions, it will return 7.
        /// </summary>
        public uint numberOfRunningActionsInTarget(CCObject target)
        {
            if (m_pTargets.ContainsKey(target))
            {
                tHashElement element = m_pTargets[target];
                return((element.actions != null) ? (uint)element.actions.Count : 0);
            }

            return(0);
        }
Exemple #8
0
        public void update(float dt)
        {
            CCObject[] keys = new CCObject[m_pTargets.Keys.Count];
            m_pTargets.Keys.CopyTo(keys, 0);

            for (int i = 0; i < keys.Length; i++)
            {
                if (!m_pTargets.ContainsKey(keys[i]))
                {
                    // http://www.cocos2d-x.org/boards/17/topics/11072
                    continue;
                }
                tHashElement elt = m_pTargets[keys[i]];
                m_pCurrentTarget         = elt;
                m_bCurrentTargetSalvaged = false;

                if (!m_pCurrentTarget.paused)
                {
                    // The 'actions' may change while inside this loop.
                    for (m_pCurrentTarget.actionIndex = 0; m_pCurrentTarget.actionIndex < m_pCurrentTarget.actions.Count;
                         m_pCurrentTarget.actionIndex++)
                    {
                        m_pCurrentTarget.currentAction = m_pCurrentTarget.actions[m_pCurrentTarget.actionIndex];
                        if (m_pCurrentTarget.currentAction == null)
                        {
                            continue;
                        }

                        m_pCurrentTarget.currentActionSalvaged = false;

                        m_pCurrentTarget.currentAction.step(dt);

                        if (m_pCurrentTarget.currentAction.isDone())
                        {
                            m_pCurrentTarget.currentAction.stop();

                            CCAction action = m_pCurrentTarget.currentAction;
                            // Make currentAction nil to prevent removeAction from salvaging it.
                            m_pCurrentTarget.currentAction = null;
                            removeAction(action);
                        }

                        m_pCurrentTarget.currentAction = null;
                    }
                }

                // only delete currentTarget if no actions were scheduled during the cycle (issue #481)
                if (m_bCurrentTargetSalvaged && m_pCurrentTarget.actions.Count == 0)
                {
                    deleteHashElement(m_pCurrentTarget);
                }
            }

            m_pCurrentTarget = null;
        }
Exemple #9
0
        // todo
        //public static CCCallFuncO actionWithScriptFuncName(string pszFuncName)
        //{
        //    CCCallFuncO pRet = new CCCallFuncO();

        //    if (pRet != null && pRet.initWithScriptFuncName(pszFuncName)) {
        //        return pRet;
        //    }

        //    return null;
        //}

        public bool initWithTarget(SelectorProtocol pSelectorTarget, SEL_CallFuncO selector, CCObject pObject)
        {
            if (base.initWithTarget(pSelectorTarget))
            {
                m_pObject    = pObject;
                m_pCallFuncO = selector;
                return(true);
            }

            return(false);
        }
Exemple #10
0
        public static CCCallFuncO actionWithTarget(SelectorProtocol pSelectorTarget,
                                                   SEL_CallFuncO selector, CCObject pObject)
        {
            CCCallFuncO pRet = new CCCallFuncO();

            if (pRet != null && pRet.initWithTarget(pSelectorTarget, selector, pObject))
            {
                return(pRet);
            }

            return(null);
        }
Exemple #11
0
        protected void deleteHashElement(tHashElement element)
        {
            element.actions.Clear();
            element.target = null;
            CCObject keyToDelete = null;

            foreach (KeyValuePair <CCObject, tHashElement> kvp in m_pTargets)
            {
                if (element == kvp.Value)
                {
                    keyToDelete = kvp.Key;
                    break;
                }
            }

            if (keyToDelete != null)
            {
                m_pTargets.Remove(keyToDelete);
            }
        }
Exemple #12
0
        /// <summary>
        /// Removes an action given its tag and the target
        /// </summary>
        public void removeActionByTag(int tag, CCObject target)
        {
            Debug.Assert((tag != (int)ActionTag.kCCActionTagInvalid));
            Debug.Assert(target != null);

            if (m_pTargets.ContainsKey(target))
            {
                tHashElement element = m_pTargets[target];

                int limit = element.actions.Count;
                for (int i = 0; i < limit; i++)
                {
                    CCAction action = element.actions[i];

                    if (action.tag == (int)tag && action.originalTarget == target)
                    {
                        removeActionAtIndex(i, element);
                        break;
                    }
                }
            }
        }
Exemple #13
0
        /// <summary>
        /// Removes an action given an action reference.
        /// </summary>
        public void removeAction(CCAction action)
        {
            if (action == null)
            {
                return;
            }

            CCObject target = action.originalTarget;

            if (m_pTargets.ContainsKey(target))
            {
                tHashElement element = m_pTargets[target];
                int          i       = element.actions.IndexOf(action);

                if (i != -1)
                {
                    removeActionAtIndex(i, element);
                }
            }
            else
            {
                CCLog.Log("cocos2d: removeAction: Target not found");
            }
        }
 public virtual bool executeCallFunc0(string pszFuncName, CCObject pObject)
 {
     return false;
 }