public override void onEnter() { base.onEnter(); centerSprites(3); CCFiniteTimeAction action = CCSequence.actions( CCMoveBy.actionWithDuration(2, new CCPoint(200, 0)), CCCallFunc.actionWithTarget(this, new SEL_CallFunc(callback1))); CCFiniteTimeAction action2 = CCSequence.actions( CCScaleBy.actionWithDuration(2, 2), CCFadeOut.actionWithDuration(2), CCCallFuncN.actionWithTarget(this, new SEL_CallFuncN(callback2))); CCFiniteTimeAction action3 = CCSequence.actions( CCRotateBy.actionWithDuration(3, 360), CCFadeOut.actionWithDuration(2), CCCallFuncND.actionWithTarget(this, new SEL_CallFuncND(callback3), (object)0xbebabeba)); m_grossini.runAction(action); m_tamara.runAction(action2); m_kathia.runAction(action3); }
private void AddMonster(float time) { var selectedMonster = new Random().Next() % _monsters.Count; var monster = _monsters[selectedMonster]; var m = monster.Movement; //!IMPORTANT -- Every Sprite in Screen must be an new CCSprite! Each Sprite can only be one time on screen var spriteMonster = new CCSprite(monster.MonsterSprite); spriteMonster.Scale = _appScale; spriteMonster.Tag = monster.Tag; //BLOCK 1 - Determine where to spawn the monster along the Y axis var winSize = Window.WindowSizeInPixels; var minX = (spriteMonster.ContentSize.Width / 2); var maxX = winSize.Width - spriteMonster.ContentSize.Width / 2; var rangeX = maxX - minX; var actualY = (new Random().Next() % rangeX) + minX; //BLOCK 2 - Determine speed of the monster var minDuration = monster.MinVelocity; var maxDuration = monster.MaxVelocity; var rangeDuration = maxDuration - minDuration; var actualDuration = (new Random().Next() % rangeDuration) + minDuration; if (m == 1) { spriteMonster.Position = new CCPoint(actualY, winSize.Height + spriteMonster.ContentSize.Height / 2); AddChild(spriteMonster); var actionMove = new CCMoveTo(actualDuration, new CCPoint(actualY, -spriteMonster.ContentSize.Height / 2)); var actionMoveComplete = new CCCallFuncN(node => { _monstersOnScreen.Remove(node); node.RemoveFromParent(); _lives--; var index = _hearths.Count - 1; RemoveChild(_hearths[index]); _hearths.RemoveAt(index); if (_lives == 0) { Window.DefaultDirector.ReplaceScene(GameStartLayer.GameStartLayerScene(Window)); } }); spriteMonster.RunActions(actionMove, actionMoveComplete); _monstersOnScreen.Add(spriteMonster); } else if (m == 2) { spriteMonster.Position = new CCPoint(actualY, winSize.Height + spriteMonster.ContentSize.Height / 2); AddChild(spriteMonster); var actionMoveComplete = new CCCallFuncN(node => { _monstersOnScreen.Remove(node); node.RemoveFromParent(); _lives--; var index = _hearths.Count - 1; RemoveChild(_hearths[index]); _hearths.RemoveAt(index); if (_lives == 0) { Window.DefaultDirector.ReplaceScene(GameStartLayer.GameStartLayerScene(Window)); } }); var bezierList = new List <CCFiniteTimeAction>(); var bezier = new CCBezierConfig(); var splitDuration = actualDuration / 6.0f; CCBezierTo bezierAction; for (int i = 0; i < 6; i++) { if (i % 2 == 0) { bezier.ControlPoint1 = new CCPoint(actualY + 100, winSize.Height - (100 + (i * 200))); bezier.ControlPoint2 = new CCPoint(actualY + 100, winSize.Height - (100 + (i * 200))); bezier.EndPosition = new CCPoint(actualY, winSize.Height - (200 + (i * 200))); bezierAction = new CCBezierTo(splitDuration, bezier); } else { bezier.ControlPoint1 = new CCPoint(actualY - 100, winSize.Height - (100 + (i * 200))); bezier.ControlPoint2 = new CCPoint(actualY - 100, winSize.Height - (100 + (i * 200))); bezier.EndPosition = new CCPoint(actualY, winSize.Height - (200 + (i * 200))); bezierAction = new CCBezierTo(splitDuration, bezier); } bezierList.Add(bezierAction); } bezierList.Add(actionMoveComplete); var seq = new CCSequence(bezierList.ToArray()); spriteMonster.RunAction(seq); _monstersOnScreen.Add(spriteMonster); } }
public CCCallFuncN (CCCallFuncN callFuncN) : base (callFuncN) { InitWithTarget(callFuncN.m_pCallFuncN); }
void OnTouchesEnded(CCTouch touch, CCEvent touchEvent) { endTime = DateTime.Now; var timeDiff = endTime - startTime; if (CurrentSpriteTouched != null) { if (touchType == Tags.Tag.Icon) { var target = (CCSprite)touchEvent.CurrentTarget; CCRect rect = target.BoundingBoxTransformedToWorld; List <IconReference> mFolders = iconList2.Where(t => t.Sprite.Tag == SpriteTypes.FolderTag).ToList(); var mIntersect = mFolders.Where(t => t.Sprite.BoundingBoxTransformedToParent.IntersectsRect(rect)).ToList(); if (mIntersect.Count == 1) { string mContentTag = SpriteHasLabel(mIntersect[0].Sprite); if (mContentTag != "") { List <StoredIconReference> mInFolder = storedList.Where(t => t.FolderName == mContentTag).ToList(); if (mInFolder.Count < 9) { var mCloneCopy = iconList2.Where(t => t.Sprite.GetHashCode() == target.GetHashCode()).FirstOrDefault(); var spriteLabel = mCloneCopy.Sprite.GetChildByTag(SpriteTypes.ContentTag) as CCLabel; if (spriteLabel == null) { return; } var newItem = new StoredIconReference(mCloneCopy.Sprite, mCloneCopy.Base64, mContentTag, mCloneCopy.Sprite.ScaleX, spriteLabel.ScaleX, spriteLabel.Visible); var savedScale = (float)mCloneCopy.Sprite.ScaleX; CurrentSpriteTouched = null; ScheduleOnce((dt) => { var moveAction = new CCMoveTo(0.2f, mIntersect[0].Sprite.Position); var scaleAction = new CCScaleTo(0.2f, 0.1f); var clearColor = new CCCallFuncN(node => node.Color = White); var setInvisible = new CCCallFuncN(node => node.Visible = false); var scaleAction2 = new CCScaleTo(0.01f, savedScale); var endAction = new CCCallFuncN(node => node.RemoveFromParent(true)); target.AddActions(false, moveAction, scaleAction, clearColor, setInvisible, scaleAction2, endAction); }, 0); iconList2.Remove(mCloneCopy); //newItem.Item1.Scale = savedScale; storedList.Add(newItem); //storedList.Add(trueClone); return; } } } if (deleteFrame.BoundingBoxTransformedToParent.IntersectsRect(rect) && inEditMode) { var mSprite = iconList2.Where(t => t.Sprite.GetHashCode() == target.GetHashCode()).FirstOrDefault(); ScheduleOnce((dt) => { RemoveChild(target); }, 0); iconList2.Remove(mSprite); } else if (inEditMode && timeDiff.TotalSeconds < 0.25) { var mSprite = iconList2.Where(t => t.Sprite.GetHashCode() == target.GetHashCode()).FirstOrDefault(); var mCounter = iconList2.IndexOf(mSprite); GamePageParent.CallActionSheet(mCounter); } } else if (touchType == Tags.Tag.FolderIcon && inEditMode && timeDiff.TotalSeconds < 0.25) { var target = (CCSprite)touchEvent.CurrentTarget; var mSprite = iconList2.Where(t => t.Sprite.GetHashCode() == target.GetHashCode()).FirstOrDefault(); var mCounter = iconList2.IndexOf(mSprite); GamePageParent.CallActionSheet(mCounter); } else if (touchType == Tags.Tag.FolderIcon && !inEditMode) { string contentTag = SpriteHasLabel(CurrentSpriteTouched); if (contentTag != "") { ShowWindow(CurrentSpriteTouched, contentTag); } } else if (touchType == Tags.Tag.Add && inEditMode) { GamePageParent.CallImagePicker(); } else if (touchType == Tags.Tag.TakePhoto && inEditMode) { GamePageParent.CallImageTaker(); } else if (touchType == Tags.Tag.Folder && inEditMode) { var mList = iconList2.Where(t => t.Sprite.Tag == SpriteTypes.FolderTag).ToList(); var nameList = new List <string>(); mList.ForEach(p => { var returnedString = SpriteHasLabel(p.Sprite); if (returnedString != "") { nameList.Add(returnedString.ToLower()); } }); lock (nameList) { GamePageParent.GetFolderSetup(nameList); } } else if (touchType == Tags.Tag.FolderIcon && inEditMode) { var target = (CCSprite)touchEvent.CurrentTarget; CCRect rect = target.BoundingBoxTransformedToWorld; if (deleteFrame.BoundingBoxTransformedToParent.IntersectsRect(rect) && inEditMode) { var mSprite = iconList2.Where(t => t.Sprite.GetHashCode() == target.GetHashCode()).FirstOrDefault(); ScheduleOnce((dt) => { RemoveChild(target); }, 0); iconList2.Remove(mSprite); } else if (timeDiff.TotalSeconds < 0.25f) { var mSprite = iconList2.Where(t => t.Sprite.GetHashCode() == target.GetHashCode()).FirstOrDefault(); var mCounter = iconList2.IndexOf(mSprite); GamePageParent.CallActionSheet(mCounter); } } else if (touchType == Tags.Tag.Speak && timeDiff.TotalSeconds < 5.0f) { List <IconReference> mList = null; if (!inSingleMode) { mList = iconList2.Where(t => sentenceFrame.BoundingBoxTransformedToParent.IntersectsRect(t.Sprite.BoundingBoxTransformedToParent) == true).ToList(); } else { mList = iconList2.Where(t => t.Sprite.Color == Green).ToList(); } if (mList.Count > 1) { mList = mList.OrderBy(i => i.Sprite.PositionX).ToList(); } List <string> labelList = new List <string>(); foreach (IconReference mIcon in mList) { string contentTag = SpriteHasLabel(mIcon.Sprite); if (contentTag != "") { labelList.Add(contentTag); } } var outputString = string.Join(" ", labelList.ToArray()); DependencyService.Get <ITextToSpeech>().Speak(outputString); } else if (touchType == Tags.Tag.Speak && timeDiff.TotalSeconds >= 5.0f) { SetEditMode(!inEditMode); } else if (touchType == Tags.Tag.SingleMode && inEditMode) { SetSingleMode(true); } else if (touchType == Tags.Tag.MultiMode && inEditMode) { SetSingleMode(false); } CurrentSpriteTouched = null; CCSprite caller = touchEvent.CurrentTarget as CCSprite; caller.Opacity = 255; } }
public CCCallFuncN(CCCallFuncN callFuncN) : base(callFuncN) { InitWithTarget(callFuncN.m_pCallFuncN); }