protected void OnClickSceneItem(SceneItem _sceneItem) { if (_sceneItem == null || target == null) { return; } if (target.CurFSMState == MainPlayer.EventType.AI_FIGHT_CTRL) //应策划要求,自动战斗时的点击,不能直接跳转到普通,而只是临时执行。 { target.BreakAutoFight(); } else { target.GoNormal(); } target.CancelCommands(); Command_MoveTo cmdMoveTo = new Command_MoveTo(); cmdMoveTo.destPos = _sceneItem.gameObject.transform.position; cmdMoveTo.maxDistance = 0f; target.commandMng.PushCommand(cmdMoveTo); switch (_sceneItem.IsTouchType) { case TouchType.TOUCH: GameCenter.curMainPlayer.CurTarget = _sceneItem; CommandTriggerTarget trigCmd = new CommandTriggerTarget(); trigCmd.target = _sceneItem; target.commandMng.PushCommand(trigCmd); break; default: break; } }
private void treeViewSceneItems_AfterSelect(object sender, TreeViewEventArgs e) { bool enableStatus = false; if (e.Node.Tag != null && e.Node.Tag is SceneItem) { SceneItem sceneItem = e.Node.Tag as SceneItem; sceneItemPreviewControl.SceneItem = sceneItem; textBoxPivot.Text = sceneItem.Pivot.X.ToString(CultureInfo.InvariantCulture) + ", " + sceneItem.Pivot.Y.ToString(CultureInfo.InvariantCulture); if (sceneItem.IsPivotRelative == true) { comboBoxIsPivotRelative.SelectedIndex = 0; } else { comboBoxIsPivotRelative.SelectedIndex = 1; } enableStatus = true; } toolStripButtonDeleteSceneItem.Enabled = enableStatus; toolStripButtonNewBoneFromItem.Enabled = enableStatus; toolStripSplitButtonCopySceneItem.Enabled = enableStatus; groupBoxSceneItemProperties.Enabled = enableStatus; }
/// <summary> /// Update the sun - a simple slow rotation /// </summary> /// <param name="time">Current game time</param> /// <param name="elapsedTime">Elapsed time since last update</param> public override void Update(TimeSpan time, TimeSpan elapsedTime, SceneItem writeTarget) { Sun target = writeTarget as Sun; target.rotation.Z += (float)(elapsedTime.TotalSeconds / 10.0f); base.Update(time, elapsedTime, target); }
public void ISaveableStoreScene(string sceneName) { // Remove old scene save for gameObject if exists GameObjectSave.sceneData.Remove(sceneName); // Get all items in the scene List <SceneItem> sceneItemList = new List <SceneItem>(); Item[] itemsInScene = FindObjectsOfType <Item>(); // Loop through all scene items foreach (Item item in itemsInScene) { SceneItem sceneItem = new SceneItem(); sceneItem.itemCode = item.ItemCode; sceneItem.position = new Vector3Serializable(item.transform.position.x, item.transform.position.y, item.transform.position.z); sceneItem.itemName = item.name; // Add scene item to list sceneItemList.Add(sceneItem); } // Create list scene items in scene save and set to scene item list SceneSave sceneSave = new SceneSave(); sceneSave.listSceneItem = sceneItemList; // Add scene save to gameobject GameObjectSave.sceneData.Add(sceneName, sceneSave); }
//otrzymuje przedmiot do uzycia w prawej rece public void StartUsingItem(SceneItem anItem) { if (anItem != UsedItem && (UsedItem == null || anItem == null || UsedItem.Type != anItem.Type)) { if (UsedItem != null) { PrefabPool.Instance.ReleasePrefab(UsedItem.gameObject); } if (anItem == null) { ActivateHands(null); } else if (anItem.GetComponent <SceneWeapon>() != null) { ActivateHands((string)anItem.GetComponent <SceneWeapon>().WeaponData["fppHands"]); } if (anItem != null) { anItem.transform.parent = _internalPivot.transform; anItem.transform.localPosition = Vector3.zero; anItem.transform.localRotation = Quaternion.identity; anItem.transform.localScale = Vector3.one; } UsedItem = anItem; } }
/// <summary> /// Creates a group of projectiles /// </summary> /// <param name="player">Which player shot the bullet</param> /// <param name="position">Start position of projectile</param> /// <param name="velocity">Initial velocity of projectile</param> /// <param name="angle">Direction projectile is facing</param> /// <param name="time">Game time that this projectile was shot</param> /// <param name="particles">The particles to add to for effects</param> public virtual void Add(PlayerIndex player, Vector3 position, Vector3 velocity, float angle, TimeSpan time, Particles particles, SceneItem readSource) { ProjectileType projectileType = SpacewarGame.Players[(int)player].ProjectileType; Vector3 offset = Vector3.Zero; if (SpacewarGame.Players[(int)player].ProjectileType == ProjectileType.DoubleMachineGun) { //Get a perpendicular vector to the direction of fire to offset the double shot offset.X = -velocity.Y; offset.Y = velocity.X; offset.Normalize(); offset *= 10.0f; } for (int i = 0; i < SpacewarGame.Settings.Weapons[(int)projectileType].Burst; i++) { //If we are not up to max then we can add bullets if (Projectile.ProjectileCount[(int)player] < SpacewarGame.Settings.Weapons[(int)projectileType].Max) { Add(new Projectile(GameInstance, player, position + velocity * i * .1f + offset, velocity, angle, time, particles), readSource); if (offset != Vector3.Zero) { Add(new Projectile(GameInstance, player, position + velocity * i * .1f - offset, velocity, angle, time, particles), readSource); } } } }
/// <summary> /// Store items in the scene /// </summary> /// <param name="name"></param> public void ISaveableStoreScene(string name) { // If we already have an entry for this scene's name in the SceneData dictionary, remove it as we're going to be replacing it. GameObjectSave.SceneData.Remove(name); // Create a list of all items in the scene List <SceneItem> sceneItems = new List <SceneItem>(); Item[] itemsInScene = FindObjectsOfType <Item>(); // Populate the list foreach (Item item in itemsInScene) { SceneItem sceneItem = new SceneItem(); sceneItem.itemCode = item.ItemCode; sceneItem.location = new Vector3Serializable(item.transform.position.x, item.transform.position.y, item.transform.position.z); sceneItem.itemName = item.name; sceneItems.Add(sceneItem); } // Save our scene item list to our sceneItemDict dictionary SceneSave sceneSave = new SceneSave(); sceneSave.ListSceneItem = sceneItems; // Add our data to the SceneData dictionary GameObjectSave.SceneData.Add(name, sceneSave); }
/// <summary> /// 第一次进场景的时候没有移动的时候,不会显示神圣晶石界面 /// </summary> void RefreshHolyFirstLogin() { if(GameCenter.activityMng.GetActivityState(ActivityType.HOLYSPAR) == ActivityState.ONGOING) { FDictionary itemList = GameCenter.sceneMng.SceneItemInfoDictionary; SceneItem holyStone = null; foreach(int key in itemList.Keys) { SceneItemInfo itemInfo = itemList[key] as SceneItemInfo; if(itemInfo.FunctionType == SceneFunctionType.HOLYSTONE) { holyStone = GameCenter.curGameStage.GetSceneItem(itemInfo.ServerInstanceID); break; } } if(holyStone != null) { int distance = (int)((GameCenter.curMainPlayer.transform.position - holyStone.transform.position).sqrMagnitude); if(distance < 144) { if(GameCenter.taskMng.CurSelectToggle != ToggleType.HOLYSTONE) { GameCenter.activityMng.C2S_ReqHolyInfo(); GameCenter.uIMng.CloseGUI(GUIType.TASK); GameCenter.taskMng.SetCurSelectToggle(ToggleType.HOLYSTONE); GameCenter.uIMng.GenGUI(GUIType.TASK,true); } } } } }
/// <summary> /// Make some items pickable /// </summary> /// <returns>return list of pickalbe items</returns> private List <SceneItem> MakeSomeSceneItemsPickable(List <SceneItem> visibleItemList, BuildParams buildParams) { List <SceneItem> pickableItemList = new List <SceneItem>(); int maxPickableItemCount = Math.Min(buildParams.PickableItemCount, visibleItemList.Count); for (int i = 0; i < maxPickableItemCount; i++) { SceneItem item = visibleItemList[i]; var spriteRenderer = item.gameObject.GetComponent <SpriteRenderer>(); if (spriteRenderer != null) { var boxCollider = item.gameObject.GetComponent <BoxCollider2D>(); if (boxCollider == null) { var size = spriteRenderer.sprite.bounds.size; boxCollider = item.gameObject.AddComponent <BoxCollider2D>(); boxCollider.size = new Vector2(size.x, size.y); } } PickableItem component = item.gameObject.AddComponent <PickableItem>(); component.Controller = buildParams.Controller; pickableItemList.Add(item); } return(pickableItemList); }
public IceFarseerEntity(SceneItem item) { //this.Offset = offset; //this.Geom.OnCollision this.SceneItem = item; _isBodyRemoved = true; }
public static void CreateUseItemAction(GameObject target, SceneItem itemObj) { var action = CreateAction <UseItemAction> (target, Example.MapEventAction.Type.SHOW_USEITEM, itemObj.itemId); action.itemObj = itemObj; Selection.activeGameObject = action.gameObject; }
private void treeViewBones_AfterSelect(object sender, TreeViewEventArgs e) { bool enabledState = false; CompositeBone selectedBone = null; if (treeViewBones.SelectedNode != null) { enabledState = true; selectedBone = e.Node.Tag as CompositeBone; if (String.IsNullOrEmpty(selectedBone.SceneItem) == false && CompositeEntity.SceneItemBank.ContainsKey(selectedBone.SceneItem)) { SceneItem sceneItem = CompositeEntity.SceneItemBank[selectedBone.SceneItem]; if (sceneItem != null && sceneItem is ISubItemCollection) { SubItemRefConverter.SubItemsRefs = ((ISubItemCollection)sceneItem).GetSubItemsList(); } } propertyGridBoneProperties.SelectedObject = selectedBone; } else { propertyGridBoneProperties.SelectedObject = null; } toolStripButtonAddChildBone.Enabled = enabledState; toolStripButtonDeleteBone.Enabled = enabledState && treeViewBones.SelectedNode != treeViewBones.Nodes[0]; groupBoxBoneProps.Enabled = enabledState; toolStripButtonLevelUpBone.Enabled = enabledState && selectedBone != CompositeEntity.RootBone && selectedBone != CompositeEntity.RootBone.ChildBones[0]; toolStripButtonLevelDownBone.Enabled = enabledState && selectedBone != CompositeEntity.RootBone; }
public bool Body_OnCollision(Fixture fixtureA, Fixture fixtureB, FarseerPhysics.Dynamics.Contacts.Contact contact) { SceneItem dataA = ((SceneItem)fixtureA.Body.UserData); SceneItem dataB = ((SceneItem)fixtureB.Body.UserData); if (HaveTheseCollided(dataA, dataB)) { return(false); } CollisionComponent collisionComponentA = dataA.GetComponent <CollisionComponent>(); CollisionComponent collisionComponentB = dataB.GetComponent <CollisionComponent>(); if (collisionComponentA != null) { CollisionEventArgs eventArgs = new CollisionEventArgs(); eventArgs.CollidedSceneItemA = dataB; eventArgs.CollidedSceneItemB = dataA; collisionComponentA.OnCollision(eventArgs); } if (collisionComponentB != null) { CollisionEventArgs eventArgs = new CollisionEventArgs(); eventArgs.CollidedSceneItemA = dataA; eventArgs.CollidedSceneItemB = dataB; collisionComponentB.OnCollision(eventArgs); } OnScreenStats.AddStat(string.Format("BODY! {0} {1}", dataA.Name, dataB.Name)); return(false); }
public override void CopyValuesTo(SceneItem target) { base.CopyValuesTo(target); AnimatedSprite animatedSprite = target as AnimatedSprite; // copy animations for (int i = 0; i < this.Animations.Count; i++) { // if no animation is available if (animatedSprite.Animations.Count <= i) { animatedSprite.AddAnimation(new AnimationInfo(String.Empty)); } this.Animations[i].CopyValuesTo(animatedSprite.Animations[i], animatedSprite); animatedSprite.Animations[i].Parent = animatedSprite; } // Remove remaining animations (can cause garbage!) for (int i = animatedSprite.Animations.Count; i > this.Animations.Count; i--) { animatedSprite.Animations.RemoveAt(i - 1); } animatedSprite.AutoPlay = this.AutoPlay; animatedSprite.DefaultAnimation = this.DefaultAnimation; animatedSprite.UpdateBoundingRectSize(); }
/// <summary> /// Creates a new SpacewarScreen /// </summary> public EvolvedScreen(Game game) : base(game) { backdrop = new SceneItem(game, new EvolvedBackdrop(game)); const float factor = 46; backdrop.Center = new Vector3(.5f, .5f, 0); backdrop.Scale = new Vector3(16f * factor, 9f * factor, 1f); backdrop.Position = new Vector3(-.5f, -.5f, 0); nextScene.Add(backdrop, drawScene); bullets = new Projectiles(game); particles = new Particles(game); ship1 = new Ship(game, PlayerIndex.One, SpacewarGame.Players[0].ShipClass, SpacewarGame.Players[0].Skin, new Vector3(SpacewarGame.Settings.Ships[0].StartPosition, 0.0f), bullets, particles); ship1.Paused = true; ship1.Radius = 15f; if (SpacewarGame.Players[0].ShipClass == ShipClass.Pencil) { ship1.ExtendedExtent[0] = new Vector3(0.0f, 25.0f, 0.0f); ship1.ExtendedExtent[1] = new Vector3(0.0f, -25.0f, 0.0f); } ship2 = new Ship(game, PlayerIndex.Two, SpacewarGame.Players[1].ShipClass, SpacewarGame.Players[1].Skin, new Vector3(SpacewarGame.Settings.Ships[1].StartPosition, 0.0f), bullets, particles); ship2.Paused = true; ship2.Radius = 15f; if (SpacewarGame.Players[1].ShipClass == ShipClass.Pencil) { ship2.ExtendedExtent[0] = new Vector3(0.0f, 25f, 0.0f); ship2.ExtendedExtent[1] = new Vector3(0.0f, -25f, 0.0f); } nextScene.Add(bullets, drawScene); asteroids = new Asteroid[SpacewarGame.GameLevel + 2]; for (int i = 0; i < SpacewarGame.GameLevel + 2; i++) { asteroids[i] = new Asteroid(game, random.NextDouble() > .5 ? AsteroidType.Large : AsteroidType.Small, asteroidStarts[i]); asteroids[i].Scale = new Vector3(SpacewarGame.Settings.AsteroidScale, SpacewarGame.Settings.AsteroidScale, SpacewarGame.Settings.AsteroidScale); asteroids[i].Paused = true; asteroids[i].Velocity = (float)random.Next(100) * Vector3.Normalize(new Vector3((float)(random.NextDouble() - .5), (float)(random.NextDouble() - .5), 0)); nextScene.Add(asteroids[i], drawScene); } nextScene.Add(ship1, drawScene); nextScene.Add(ship2, drawScene); //Added after other objects so they draw over the top nextScene.Add(particles, drawScene); //Sun last so its on top sun = new Sun(game, new EvolvedSun(game), new Vector3(-.5f, -.5f, 0)); nextScene.Add(sun, drawScene); //Reset health meters. SpacewarGame.Players[0].Health = 5; SpacewarGame.Players[1].Health = 5; }
void Start() { #if !UNITY_EDITOR Application.targetFrameRate = 60; #endif // show menu OpenMenu(); // create scene list sceneList = new ObservableList <SceneItem>(); foreach (var sceneName in sceneNames) { var item = new SceneItem(); item.SceneName = sceneName; item.LoadCommand = new DelegateCommand(() => LoadScene(item)); // add to list sceneList.Add(item); } // create commands openMenuCommand = new DelegateCommand(OpenMenu); closeMenuCommand = new DelegateCommand(CloseMenu); #if UNITY_5_4_OR_NEWER SceneManager.sceneLoaded += OnSceneLoaded; #endif UpdateSceneName(); BindingManager.Instance.AddSource(this, typeof(MenuController).Name); // do not destroy controller GameObject.DontDestroyOnLoad(gameObject); }
public void LoadScene(SceneItem sceneItem) { // hide menu IsMenuVisible = false; // set selected foreach (var item in sceneList) { if (item == sceneItem) { item.IsSelected = true; } else { item.IsSelected = false; } } if (sceneItem.SceneName == "Start" || sceneItem.SceneName == "NGUI Start") { // destroy current menu controller Destroy(gameObject); } // load scene #if UNITY_5_3_OR_NEWER SceneManager.LoadScene(sceneItem.SceneName); #else Application.LoadLevel(sceneItem.SceneName); #endif }
private SceneItem CreateNewInstaceCopyOf(SceneItem item) { SceneItem copy = (SceneItem)item.GetType().Assembly.CreateInstance(item.GetType().FullName); item.CopyValuesTo(copy); return(copy); }
public TargetItem(SceneItem item, Rectangle rectangle) : this(item) { X = rectangle.X; Y = rectangle.Y; Width = rectangle.Width; Height = rectangle.Height; }
private void tableBoneTransforms_SelectionChanged(object sender, XPTable.Events.SelectionEventArgs e) { bool enabledState = false; if (tableBoneTransforms.SelectedIndicies.Length > 0) { SceneItem sceneItem = SelectedCompositeBoneTransform.GetSceneItem(); if (sceneItem != null && sceneItem is ISubItemCollection) { SubItemRefConverter.SubItemsRefs = ((ISubItemCollection)sceneItem).GetSubItemsList(); } propertyGridCompositeBoneTransform.SelectedObject = SelectedCompositeBoneTransform; _lastSelectedBone = SelectedCompositeBoneTransform.BoneReference; enabledState = true; } if (this.IgnoreBoneTransformSelectionEvent == false) { IgnoreBoneTransformSelectionEvent = true; SelectBoneTransformsOnSceneFromTree(); IgnoreBoneTransformSelectionEvent = false; } groupBoxCompositeBoneProperties.Enabled = enabledState; toolStripButtonLevelDownBoneTransform.Enabled = enabledState && tableBoneTransforms.SelectedIndicies.Length > 0 && tableBoneTransforms.SelectedIndicies[0] != (SelectedCompositeKeyFrame.BoneTransforms.Count - 1); toolStripButtonLevelUpBoneTransform.Enabled = enabledState && tableBoneTransforms.SelectedIndicies.Length > 0 && tableBoneTransforms.SelectedIndicies[0] != 0; }
private void sceneDot_MouseMove(object sender, MouseEventArgs e) { if (!isRectDragInProg) { return; } Border border = sender as Border; if (border != null) { var canvas = VisualTreeHelpers.FindAncestor <Canvas>(border); var mousePos = e.GetPosition(canvas); double left = mousePos.X - (border.ActualWidth / 2); double top = mousePos.Y - (border.ActualHeight / 2); border.Margin = new Thickness(left, top, 0, 0); var imageWidth = sceneImage.ActualWidth; var imageHeight = sceneImage.ActualHeight; SceneItem selectedItem = border.DataContext as SceneItem; selectedItem.XPos = ((border.Margin.Left + (border.Width / 2)) * 100) / imageWidth; selectedItem.YPos = ((border.Margin.Top + (border.Height / 2)) * 100) / imageHeight; ChangedItems.Add(selectedItem); } }
private bool EnterBranchPassImp(int passId) { int branchPassCount = m_Data.branchPass.Count; if (branchPassCount > 0 && m_Data.branchPass.Remove(passId)) { m_EnterBranchPassId = passId; PassItem passItem = GetPassItem(); if (passItem != null) { SceneItem sceneItem = Global.gApp.gGameData.SceneDate.Get(passItem.sceneID); if (branchPassCount == sceneItem.missionLimit) { m_Data.recordTime = DateTimeUtil.GetMills(DateTime.Now); } SaveData(); return(true); } else { return(false); } } return(false); }
// One of the core methods, which will store all of the scene data, executed for every item in the SaveableObject list public void ISaveableStoreScene(string sceneName) { // Remove old scene save (dictionary keyed by scene name) for the gameObject if it exists GameObjectSave.sceneData.Remove(sceneName); // Get all of the items currently in the scene List <SceneItem> sceneItemList = new List <SceneItem>(); Item[] itemsInScene = FindObjectsOfType <Item>(); // Loop through all of the scene items, populate them, and add them to the sceneItemList foreach (Item item in itemsInScene) { // Populate each sceneItem with their proper variables: item code, position, name SceneItem sceneItem = new SceneItem(); sceneItem.itemCode = item.ItemCode; sceneItem.position = new Vector3Serializable(item.transform.position.x, item.transform.position.y, item.transform.position.z); sceneItem.itemName = item.name; // Add the new scene item to the sceneItemList sceneItemList.Add(sceneItem); } // Create the list of scene items in the scene save and add to it to the sceneItemsList SceneSave sceneSave = new SceneSave(); // Add this sceneItemList with all saveable items in the scene to the Item list sceneSave.listSceneItem = sceneItemList; // Add scene save to gameObjectSave a dictionary of sceneName: dict"sceneItemList" : list of saveable items) GameObjectSave.sceneData.Add(sceneName, sceneSave); }
public static void CreateDropItemAction(GameObject target, SceneItem itemObj, int count) { var action = CreateAction <DropItemAction> (target, Example.MapEventAction.Type.DROP_ITEM, itemObj.itemId); action.itemObj = itemObj; action.dropCount = count; Selection.activeGameObject = action.gameObject; }
private void OnCollisionEnter(Collision other) { if (other.gameObject.tag == "Item") { sceneItem = other.gameObject.GetComponent <SceneItem>(); SetWeaponType(); } }
private void StoreInitialValues(SceneItem item) { _itemInitialPosition = item.Position; _itemInitialPivot = item.Pivot; _initialVisibility = item.Visible; _itemInitialRotation = item.Rotation; _itemInitialScale = item.Scale; }
public override void CopyValuesTo(SceneItem target) { base.CopyValuesTo(target); CompositeEntity compositeEntity = target as CompositeEntity; if (this.RootBone == null) { compositeEntity.RootBone = null; } else { this.RootBone.CopyValuesTo(compositeEntity.RootBone, null, compositeEntity); } // copy animations for (int i = 0; i < this._animations.Count; i++) { // if no animation is available if (compositeEntity.Animations.Count <= i) { compositeEntity.Animations.Add(new CompositeAnimation(compositeEntity)); } this.Animations[i].CopyValuesTo(compositeEntity.Animations[i], compositeEntity); compositeEntity.Animations[i].Parent = compositeEntity; } // Remove remaining animations (can cause garbage!) for (int i = compositeEntity.Animations.Count; i > this.Animations.Count; i--) { compositeEntity.Animations.RemoveAt(i - 1); } // copy bank foreach (String key in this.SceneItemBank.Keys) { // if the entry is not available, create it if (compositeEntity.SceneItemBank.ContainsKey(key) == false || this.SceneItemBank[key].GetType() != compositeEntity.SceneItemBank[key].GetType()) { //Can't just create a blank sceneitem. it won't create a new instance of AnimatedSprite for instance SceneItem newItem = CreateNewInstaceCopyOf(this.SceneItemBank[key]); compositeEntity.SceneItemBank[key] = newItem; } this.SceneItemBank[key].CopyValuesTo(compositeEntity.SceneItemBank[key]); } // Remove remaining unused key (can cause garbage!) List <String> keysToRemove = new List <string>(); foreach (String key in compositeEntity.SceneItemBank.Keys) { if (this.SceneItemBank.ContainsKey(key) == false) { keysToRemove.Add(key); } } foreach (String key in keysToRemove) { compositeEntity.SceneItemBank.Remove(key); } }
private MeshItem GetMesh(SceneItem item) { if (item.Tags != null && item.Tags.Any(tag => !patchVisibility.IsTagVisible(tag))) { return(null); } if (item is BackItem) { var back = (BackItem)item; if (back.IsFront ? patchVisibility.FrontVisible : patchVisibility.BackVisible) { return(GetMeshBack(back)); } } else if (item is ObjItem) { if (patchVisibility.ObjVisible) { return(GetMeshObj((ObjItem)item)); } } else if (item is TileItem) { if (patchVisibility.TileVisible) { return(GetMeshTile((TileItem)item)); } } else if (item is LifeItem) { var life = (LifeItem)item; if ((life.Type == LifeItem.LifeType.Mob && patchVisibility.MobVisible) || (life.Type == LifeItem.LifeType.Npc && patchVisibility.NpcVisible)) { return(GetMeshLife(life)); } } else if (item is PortalItem) { if (patchVisibility.PortalVisible) { return(GetMeshPortal((PortalItem)item)); } } else if (item is ReactorItem) { if (patchVisibility.ReactorVisible) { return(GetMeshReactor((ReactorItem)item)); } } else if (item is ParticleItem) { return(GetMeshParticle((ParticleItem)item)); } return(null); }
private void Commit_Scene(object sender, RoutedEventArgs e) { string sceneName = SceneNameTextBox.Text; string ImageSource = SceneImageSourceText.Text; SceneItem newScene = new SceneItem(sceneName, ImageSource, currentSceneConfig.ToList()); availableScenes.Add(newScene); currentSceneConfig.Clear(); }
/// <summary> /// this method initializes the content that is to be drawn by the scene. /// This content is static FOR NOW! This has to be dynamically at some point /// </summary> /// /// public void initContent() { if (SettingsManager.Instance.Settings.SettingsTable.ShowDemoAnimation) { //m_DemoRect = new DemoRectScene(m_CurrentScene); m_DemoRect = new SceneRect(150, 150, 150, 150, Color.FromRgb(255, 0, 0)); m_CurrentScene.Add(m_DemoRect); } }
private void StoreCopyOfSceneItem(SceneItem item) { _sceneItemCopy = (SceneItem)item.GetType().Assembly.CreateInstance( item.GetType().FullName, true); _sceneItemBackup = (SceneItem)item.GetType().Assembly.CreateInstance( item.GetType().FullName, true); item.CopyValuesTo(_sceneItemCopy); item.CopyValuesTo(_sceneItemBackup); }
private void treeViewSceneItems_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { if (e.Node.Tag != null && e.Node.Tag is SceneItem) { SceneItem item = e.Node.Tag as SceneItem; SquidEditorForm.Instance.OpenSceneItemInEditor(item, this.ItemIsLocal); } }
public async Task <int> DeleteSceneItem(SceneItem sceneItem) { if (sceneItem.Phrase != null) { await DeletePhrase(sceneItem.Phrase); } return(await Db.SqLiteAsyncConnection.DeleteAsync(sceneItem)); }
public Screen(Game game) { this.game = game; this.scene = new SceneItem(game); if (game != null) { IGraphicsDeviceService graphicsService = (IGraphicsDeviceService)game.Services.GetService(typeof(IGraphicsDeviceService)); batch = new SpriteBatch(graphicsService.GraphicsDevice); } }
public override void Update(TimeSpan time, TimeSpan elapsedTime, SceneItem writeTarget) { Asteroid target = writeTarget as Asteroid; //Random rotation target.roll += rollIncrement * (float)elapsedTime.TotalSeconds; target.yaw += yawIncrement * (float)elapsedTime.TotalSeconds; target.pitch += pitchIncrement * (float)elapsedTime.TotalSeconds; target.rotation = new Vector3(roll, pitch, yaw); base.Update(time, elapsedTime, target); }
/// <summary> /// Creates the ShipUpgradeScreen /// </summary> public ShipUpgradeScreen(Game game) : base(game) { //Play the menu music menuMusic = Sound.Play(Sounds.MenuMusic); weapons[0] = new SceneItem(game, new EvolvedShape(game, EvolvedShapes.Weapon, PlayerIndex.One, (int)ProjectileType.Peashooter, LightingType.Menu), new Vector3(-170, -30, 0)); weapons[0].Scale = new Vector3(.06f, .06f, .06f); nextScene.Add(weapons[0], drawScene); weapons[1] = new SceneItem(game, new EvolvedShape(game, EvolvedShapes.Weapon, PlayerIndex.Two, (int)ProjectileType.Peashooter, LightingType.Menu), new Vector3(170, -30, 0)); weapons[1].Scale = new Vector3(.06f, .06f, .06f); nextScene.Add(weapons[1], drawScene); }
public Screen(Game game) { this.game = game; this.nextScene = new SceneItem(game); this.drawScene = new SceneItem(game); this.batch = (game as SpacewarGame).SpriteBatch; /*if (game != null) { IGraphicsDeviceService graphicsService = (IGraphicsDeviceService)game.Services.GetService(typeof(IGraphicsDeviceService)); batch = new SpriteBatch(graphicsService.GraphicsDevice); }*/ }
/// <summary> /// Creates a new selection screen. Plays the music and initializes the models /// </summary> public SelectionScreen(Game game) : base(game) { //Start menu music menuMusic = Sound.Play(Sounds.MenuMusic); ships[0] = new SceneItem(game, new EvolvedShape(game, EvolvedShapes.Ship, PlayerIndex.One, selectedShip[0], selectedSkin[0], LightingType.Menu), new Vector3(-120, 0, 0)); ships[0].Scale = new Vector3(.05f, .05f, .05f); scene.Add(ships[0]); ships[1] = new SceneItem(game, new EvolvedShape(game, EvolvedShapes.Ship, PlayerIndex.Two, selectedShip[1], selectedSkin[1], LightingType.Menu), new Vector3(120, 0, 0)); ships[1].Scale = new Vector3(.05f, .05f, .05f); scene.Add(ships[1]); }
/// <summary> /// Makes a new splash screen with the right texture, no timeout and will move to the logo screen /// </summary> public VictoryScreen(Game game, bool playMusic) : base(game, victoryScreen, TimeSpan.Zero, GameState.LogoSplash) { if(playMusic) Sound.PlayCue(Sounds.TitleMusic); //Whoever won we need to render their ship. winningPlayerNumber = (SpacewarGame.Players[0].Score > SpacewarGame.Players[1].Score) ? 0 : 1; Player winningPlayer = SpacewarGame.Players[winningPlayerNumber]; ship = new SceneItem(game, new EvolvedShape(game, EvolvedShapes.Ship, (winningPlayerNumber == 0) ? PlayerIndex.One : PlayerIndex.Two, (int)winningPlayer.ShipClass, winningPlayer.Skin, LightingType.Menu), new Vector3(-90, -30, 0)); ship.Scale = new Vector3(.07f, .07f, .07f); scene.Add(ship); }
public void CreateNewDotAndPlace(SceneItem sceneItem) { var width = sceneImage.ActualWidth; var height = sceneImage.ActualHeight; Border border = new Border() { HorizontalAlignment = System.Windows.HorizontalAlignment.Left, Height = (sceneItem.Size * height) / 100, Width = (sceneItem.Size*height)/100, CornerRadius = new CornerRadius((sceneItem.IsRound ? 90 : 0)), Background = new SolidColorBrush(Colors.Green), Opacity = .4, VerticalAlignment = VerticalAlignment.Top, Tag = Guid.NewGuid() }; border.MouseLeftButtonDown += border_MouseLeftButtonDown; System.Windows.Controls.ContextMenu menu = new System.Windows.Controls.ContextMenu(); MenuItem item1 = new MenuItem() { Header = "Change sound file", Tag = border }; item1.Click += ChangeSoundFile_Click; menu.Items.Add(item1); MenuItem item2 = new MenuItem() { Header = "Delete point", Tag = border }; item2.Click += DeleteDot_Click; menu.Items.Add(item2); MenuItem item3 = new MenuItem() { Header = "Play", Tag = border }; item3.Click += PlayAudio_Click; menu.Items.Add(item3); MenuItem item4 = new MenuItem() { Header = "Reset the order", Tag = border }; item4.Click += ResetTheDotNumber_Click; menu.Items.Add(item4); border.ContextMenu = menu; border.Margin = new Thickness((sceneItem.XPos * width / 100) - border.Width / 2, (sceneItem.YPos * height / 100) - border.Height / 2, 0, 0); border.Tag = sceneItem; //add it to grid grdPoints.Children.Add(border); //Heighlight the border SelectBorder(border); if(sceneItem.Phrase==null) { border.Background = new SolidColorBrush(Colors.Yellow); } }
/// <summary> /// 道具头顶文字 /// </summary> /// <param name="npc"></param> private static void CreateHeadTip(SceneItem item) { var headTip = (GameObject.Instantiate(Resources.Load("Prefabs/Gui/HeadTipItem")) as GameObject).GetComponent<UILabel>(); #if UNITY_EDITOR headTip.name = item.name; #endif headTip.text = item.TableInfo.name; headTip.hideIfOffScreen = true; headTip.SetAnchor(item.gameObject); headTip.bottomAnchor.absolute = 120; headTip.topAnchor.absolute = headTip.bottomAnchor.absolute + 30; var recycle = item.gameObject.AddComponent<OnDestroyAction>(); recycle.Action = () => { try { NGUITools.Destroy(headTip.gameObject); } catch { } }; }
/// <summary> /// SpacewarSceneItem handles all the gravity and wrapping calculations /// </summary> /// <param name="time"></param> /// <param name="elapsedTime"></param> public override void Update(TimeSpan time, TimeSpan elapsedTime, SceneItem writeTarget) { SpacewarSceneItem target = writeTarget as SpacewarSceneItem; if (!Paused) { //Add in gravity Vector3 forceDirection = Position - new Vector3(SpacewarGame.Settings.SunPosition, 0.0f); double distancePower = Math.Pow(forceDirection.Length(), SpacewarGame.Settings.GravityPower); double factor = Math.Min(SpacewarGame.Settings.GravityStrength / distancePower, 100.0); //stops insane accelerations at the sun since we have no collisions Vector3 gravityAcceleration = Vector3.Multiply(Vector3.Normalize(forceDirection), (float)factor); target.acceleration -= gravityAcceleration; } //Call the base to update velocity and position base.Update(time, elapsedTime, target); //Zero out acceleration - will be reset on next update target.acceleration = Vector3.Zero; //Wrap around the screen to the correct position. if (SpacewarGame.GameState == GameState.PlayEvolved) { if (position.X > 400) target.position.X = -400; else if (position.X < -400) target.position.X = 400; } else { if (position.X > 300) target.position.X = -300; else if (position.X < -300) target.position.X = 300; } if (position.Y > 250) target.position.Y = -250; else if (position.Y < -250) target.position.Y = 250; }
/// <summary> /// Adds particles to represent vapour trail /// </summary> /// <param name="world">Start position of the particle</param> /// <param name="direction">Direction the ship is heading. Particles will be lined up along this vec</param> public void AddShipTrail(Matrix world, Vector2 direction, SceneItem readSource) { //Move source point into screen space Vector4 source = Vector4.Transform(new Vector4(0, 0, 130000, 1), world * SpacewarGame.Camera.View * SpacewarGame.Camera.Projection); //and into pixels Vector2 source2D = new Vector2((int)((source.X / source.W + 1f) / 2f * 1280), (int)((-source.Y / source.W + 1f) / 2f * 720)); direction = Vector2.Normalize(direction); for (int i = 0; i < 70; i++) { float trailDistance = random.Next(50); float trailOffset = random.Next(21) - 10; Add(new Particle(this.GameInstance, new Vector2(source2D.X + trailDistance * direction.X + trailOffset * direction.Y, source2D.Y + trailDistance * direction.Y + trailOffset * direction.X), new Vector2(trailDistance * trailOffset * direction.Y / 5, trailDistance * trailOffset * direction.X / 5), new Vector4(1f, 1f, .5f, .5f), new Vector4(.2f, .2f, 0f, .2f), new TimeSpan(0, 0, 2))); } }
/// <summary> /// Creates a new SpacewarScreen /// </summary> public RetroScreen(Game game) : base(game) { //Retro backdrop = new SceneItem(game, new RetroStarfield(game)); scene.Add(backdrop); bullets = new RetroProjectiles(game); ship1 = new Ship(game, PlayerIndex.One, new Vector3(-250, 0, 0), bullets); ship1.Radius = 10f; scene.Add(ship1); ship2 = new Ship(game, PlayerIndex.Two, new Vector3(250, 0, 0), bullets); ship2.Radius = 10f; scene.Add(ship2); sun = new Sun(game, new RetroSun(game), new Vector3(SpacewarGame.Settings.SunPosition, 0.0f)); scene.Add(sun); scene.Add(bullets); paused = false; }
/// <summary> /// Update all this particle /// </summary> /// <param name="time">Current game time</param> /// <param name="elapsedTime">Elapsed time since last update</param> public override void Update(TimeSpan time, TimeSpan elapsedTime, SceneItem writeTarget) { Particle target = writeTarget as Particle; //Start the animation 1st time round if (endTime == TimeSpan.Zero) { target.endTime = time + lifetime; } //End the animation when its time is due as long as lifet if (time > endTime) { target.Delete = true; } //Fade between the colors float percentLife = (float)((endTime.TotalSeconds - time.TotalSeconds) / lifetime.TotalSeconds); target.color = Vector4.Lerp(endColor, startColor, percentLife); //Do any velocity moving base.Update(time, elapsedTime, target); }
internal void SetOwner(SceneItem owner) { _owner = owner; }
private void ReplaceScene(SceneItem sun, Ship one, Ship two, Asteroid[] astr, Particles part, Projectiles proj) { scene.Remove(this.sun); scene.Remove(ship1); scene.Remove(ship2); this.sun = sun; this.ship1 = one; this.ship2 = two; scene.Add(ship1); scene.Add(ship2); scene.Add(sun); for (int i = 0; i < astr.Length; i++) { asteroids[i] = astr[0].Copy(); if(!asteroids[i].Delete) scene.Add(asteroids[i]); } this.particles = part; scene.Add(particles); this.bullets = proj; scene.Add(bullets); }
public override void CopyValuesTo(SceneItem target) { base.CopyValuesTo(target); PostProcessAnimation ppAnim = target as PostProcessAnimation; #if !XNATOUCH ppAnim.IceEffect = this.IceEffect; #endif ppAnim.Life = this.Life; ppAnim.LoopMax = this.LoopMax; ppAnim.AutoPlay = this.AutoPlay; ppAnim.HideWhenStopped = this.HideWhenStopped; ppAnim.OwnLayerOnly = this.OwnLayerOnly; for (int i = 0; i < _linearProperties.Length; i++) { this.LinearProperties[i].CopyValuesTo(ppAnim.LinearProperties[i]); } }
public override void CopyValuesTo(SceneItem target) { base.CopyValuesTo(target); Sprite sprite = target as Sprite; sprite.Material = this.Material; sprite.BoundingRect = this.BoundingRect; sprite.BlendingType = this.BlendingType; sprite.SourceRectangle = this.SourceRectangle; sprite.MaterialArea = this.MaterialArea; sprite.Tint = this.Tint; sprite.UseTilingSafeBorders = this.UseTilingSafeBorders; }
public override void CopyValuesTo(SceneItem target) { base.CopyValuesTo(target); CompositeEntity compositeEntity = target as CompositeEntity; if (this.RootBone == null) { compositeEntity.RootBone = null; } else { this.RootBone.CopyValuesTo(compositeEntity.RootBone, null, compositeEntity); } // copy animations for (int i = 0; i < this._animations.Count; i++) { // if no animation is available if (compositeEntity.Animations.Count <= i) { compositeEntity.Animations.Add(new CompositeAnimation(compositeEntity)); } this.Animations[i].CopyValuesTo(compositeEntity.Animations[i], compositeEntity); compositeEntity.Animations[i].Parent = compositeEntity; } // Remove remaining animations (can cause garbage!) for (int i = compositeEntity.Animations.Count; i > this.Animations.Count; i--) { compositeEntity.Animations.RemoveAt(i-1); } // copy bank foreach (String key in this.SceneItemBank.Keys) { // if the entry is not available, create it if (compositeEntity.SceneItemBank.ContainsKey(key) == false || this.SceneItemBank[key].GetType() != compositeEntity.SceneItemBank[key].GetType()) { //Can't just create a blank sceneitem. it won't create a new instance of AnimatedSprite for instance SceneItem newItem = CreateNewInstaceCopyOf(this.SceneItemBank[key]); compositeEntity.SceneItemBank[key] = newItem; } this.SceneItemBank[key].CopyValuesTo(compositeEntity.SceneItemBank[key]); } // Remove remaining unused key (can cause garbage!) List<String> keysToRemove = new List<string>(); foreach (String key in compositeEntity.SceneItemBank.Keys) { if (this.SceneItemBank.ContainsKey(key) == false) { keysToRemove.Add(key); } } foreach (String key in keysToRemove) { compositeEntity.SceneItemBank.Remove(key); } }
private SceneItem CreateNewInstaceCopyOf(SceneItem item) { SceneItem copy = (SceneItem)item.GetType().Assembly.CreateInstance(item.GetType().FullName); item.CopyValuesTo(copy); return copy; }
//private static void UpdateNetworkToSend(float elapsed) //{ // NetworkSession session = SceneManager.networkSession; // if (SceneManager.IsNetworkOwner) // { // //foreach (var item in SceneManager.ActiveScene.SceneItems) // //{ // // packetWriter.Write((int)NetworkDataType.UpdateSceneItem); // // packetWriter.Write(item.Position); // //} // //LocalNetworkGamer server = (LocalNetworkGamer)session.Host; // //server.SendData(packetWriter, SendDataOptions.InOrder); // } // session.Update(); //} private static void UpdateItemsComponents(SceneItem item) { if (item.Components == null) { return; } for (int i = 0; i < item.Components.Count; i++) { IceComponent _component = item.Components[i]; if (_component.Enabled == true) { _component.Update(IceCream.Game.Instance.Elapsed); } } }
public override void CopyValuesTo(SceneItem target) { base.CopyValuesTo(target); TileGrid tileGrid = target as TileGrid; tileGrid.TileSize = this.TileSize; tileGrid.TileCols = this.TileCols; tileGrid.TileRows = this.TileRows; tileGrid.TileLayers = new List<TileLayer>(); for (int i = 0; i < this.TileLayers.Count; i++) { TileLayer newLayer = new TileLayer(this.TileCols, this.TileRows); newLayer.Parent = tileGrid; this.TileLayers[i].CopyValuesTo(newLayer); tileGrid.TileLayers.Add(newLayer); } tileGrid.TileSheet = this.TileSheet; }
public void EditSceneItem(SceneItem item) { if (item != null) { bool isSceneInstance = false; if (SceneManager.ActiveScene.SceneItems.Contains(item) || SceneManager.ActiveScene.TemplateItems.Contains(item)) { isSceneInstance = true; } if (OpenSceneItemInEditor(item, isSceneInstance) == true) { SceneWasModified = true; RefreshEditorStatus(); } } }
public CollisionEventArgs() { _collidedSceneItemA = null; _collidedSceneItemB = null; }
public bool OpenSceneItemInEditor(SceneItem item, bool isSceneInstance) { SceneItemType itemType = GetTypeOfSceneItem(item); SceneItemEditor editor = null; switch (itemType) { case SceneItemType.TileGrid: editor = new TileGridEditor(); break; case SceneItemType.ParticleEffect: editor = new ParticleEffectEditor(); break; case SceneItemType.AnimatedSprite: editor = new AnimatedSpriteEditor(); break; case SceneItemType.Sprite: editor = new SpriteEditor(); break; case SceneItemType.PostProcessingAnimation: editor = new PostProcessAnimationEditor(); break; case SceneItemType.CompositeEntity: editor = new CompositeEntityEditor(); break; default: editor = null; break; } if (editor != null) { editor.SceneItem = item; editor.ItemIsLocal = isSceneInstance; editor.StartPosition = FormStartPosition.CenterParent; if (editor.ShowDialog(this) == DialogResult.OK) { if (SceneManager.GlobalDataHolder.TemplateItems.Contains(item)) { this.SceneWasModified = true; } else { this.SceneWasModified = true; } } } return false; }
public override void CopyValuesTo(SceneItem target) { base.CopyValuesTo(target); TextItem text = target as TextItem; text.Font = this.Font; text.Text = this.Text; text.AutoCenterPivot = this.AutoCenterPivot; text.Shadow = this.Shadow; text.Tint = this.Tint; }
public override void CopyValuesTo(SceneItem target) { base.CopyValuesTo(target); ParticleEffect effect = target as ParticleEffect; effect.Life = this.Life; effect.LoopMax = this.LoopMax; effect.MaxLife = this.MaxLife; effect.AutoPlay = this.AutoPlay; effect.HideWhenStopped = this.HideWhenStopped; effect.EditorBackgroundColor = this.EditorBackgroundColor; this.Emitter.CopyValuesTo(effect.Emitter); }