public void Spawn(Node camera, string Name) { PackedScene PackedScene = (PackedScene)ResourceLoader.Load(_weaponResource); _weaponMesh = (MeshInstance)PackedScene.Instance(); camera.AddChild(_weaponMesh); _weaponMesh.Translation = this.SpawnTranslation; _weaponMesh.SetName(Name); _weaponMesh.SetVisible(false); shootSound = (AudioStreamPlayer3D)_weaponMesh.GetNode("ShootSound"); if (_weaponMesh.HasNode("MuzzleFlash")) { muzzleFlash = (Sprite3D)_weaponMesh.GetNode("MuzzleFlash"); } if (_weaponMesh.HasNode("ReloadSound")) { reloadSound = (AudioStreamPlayer3D)_weaponMesh.GetNode("ReloadSound"); } // projectile mesh if (_weaponType == WeaponType.Projectile || _weaponType == WeaponType.Grenade) { _projectileScene = (PackedScene)ResourceLoader.Load(_projectileResource); } GD.Print("Loaded " + Name); }
public void registerAutoAtlas(Sprite3D sprite) { if (sprite.texture == null) { return; } if (string.IsNullOrEmpty(sprite.autoAtlasTag)) { sprite.SetUV(new AtlasInfo.UVDetail { uvBL = new Vector2(0f, 0f), uvTL = new Vector2(0f, 1f), uvBR = new Vector2(1f, 0f), uvTR = new Vector2(1f, 1f), width = sprite.texture.width, height = sprite.texture.height }); return; } Canvas3DImpl.AutoAtlasInfo autoAtlasInfo = null; if (!this.m_atlas.TryGetValue(sprite.autoAtlasTag, out autoAtlasInfo)) { autoAtlasInfo = new Canvas3DImpl.AutoAtlasInfo(); this.m_atlas.Add(sprite.autoAtlasTag, autoAtlasInfo); } autoAtlasInfo.Register(sprite); this.m_needRebuildAtlas = true; }
public void Register(Sprite3D sprite) { if (null == sprite || null == sprite.texture) { return; } int nativeTextureID = sprite.texture.GetNativeTextureID(); sprite.m_textureGUID = nativeTextureID; AtlasInfo.UVDetail uVDetail = null; this.padding = Mathf.Max(this.padding, sprite.padding); this.needCompress |= sprite.compress; if (this.textures.TryGetValue(nativeTextureID, out uVDetail)) { this.sprites.Add(sprite); if (null != this.mat) { sprite.SetMaterial(this.mat); } sprite.SetAutoAtlas(this.atlas, uVDetail); return; } uVDetail = new AtlasInfo.UVDetail(); uVDetail.width = 0; uVDetail.height = 0; uVDetail.width = sprite.texture.width; uVDetail.height = sprite.texture.height; uVDetail.rotate = false; this.textures.Add(nativeTextureID, uVDetail); this.waitForCombineTextures.Add(nativeTextureID, sprite.texture); this.needRebuildAtlas = true; this.sprites.Add(sprite); }
private void RefreshHierachy(Transform root) { if (root.gameObject.activeSelf) { for (int i = root.childCount - 1; i >= 0; i--) { this.RefreshHierachy(root.GetChild(i)); } Sprite3D component = null; if (this.m_childSprites.TryGetValue(root.GetInstanceID(), out component)) { if (null != component) { this.m_depth++; component.depth = this.m_depth; } } else { component = root.GetComponent <Sprite3D>(); this.m_childSprites.Add(root.GetInstanceID(), component); if (null != component) { this.m_depth++; component.depth = this.m_depth; } } } }
public void registerSprite3D(Sprite3D sprite) { if (!this.m_childSprites.ContainsKey(sprite.transform.GetInstanceID())) { this.m_childSprites.Add(sprite.transform.GetInstanceID(), sprite); } }
virtual public void Spawn(Player p, string nodeName) { PackedScene PackedScene = (PackedScene)ResourceLoader.Load(_weaponResource); _weaponMesh = (MeshInstance)PackedScene.Instance(); p.Head.AddChild(_weaponMesh); _playerOwner = p; _weaponMesh.Translation = _weaponPosition; _weaponMesh.Name = nodeName; _weaponMesh.Visible = false; _shootSound = (AudioStreamPlayer3D)_weaponMesh.GetNode("ShootSound"); if (_weaponMesh.HasNode("MuzzleFlash")) { _muzzleFlash = (Sprite3D)_weaponMesh.GetNode("MuzzleFlash"); } if (_weaponMesh.HasNode("ReloadSound")) { _reloadSound = (AudioStreamPlayer3D)_weaponMesh.GetNode("ReloadSound"); } // projectile mesh if (_weaponShotType == WEAPONSHOTTYPE.PROJECTILE || _weaponShotType == WEAPONSHOTTYPE.GRENADE) { _projectileScene = (PackedScene)ResourceLoader.Load(_projectileResource); } }
public static Vector3 Set3DUIWorldPos_ByScreenPoint(ref Vector3 worldPos, bool bMiniMap, out float finalScreenX, out float finalScreenY) { finalScreenX = (finalScreenY = 0f); MinimapSys theMinimapSys = Singleton <CBattleSystem> .GetInstance().TheMinimapSys; if (theMinimapSys == null) { return(Vector3.zero); } Vector2 vector = (!bMiniMap) ? Singleton <CBattleSystem> .get_instance().world_UI_Factor_Big : Singleton <CBattleSystem> .get_instance().world_UI_Factor_Small; Vector2 vector2 = new Vector2(worldPos.x * vector.x, worldPos.z * vector.y); vector2.x *= Sprite3D.Ratio(); vector2.y *= Sprite3D.Ratio(); Vector2 vector3 = (!bMiniMap) ? theMinimapSys.GetBMFianlScreenPos() : theMinimapSys.GetMMFianlScreenPos(); vector2.x += vector3.x; vector2.y += vector3.y; Vector3 position = new Vector3(vector2.x, vector2.y, (float)MiniMapSysUT.UI3D_Depth); Camera currentCamera = Singleton <Camera_UI3D> .GetInstance().GetCurrentCamera(); if (currentCamera == null) { return(Vector3.zero); } finalScreenX = position.x; finalScreenY = position.y; return(currentCamera.ScreenToWorldPoint(position)); }
public override void _Ready() { sprite = GetNode <Sprite3D>("Sprite"); movementArea = GetNode <Spatial>("MovementArea"); spaceState = GetWorld().DirectSpaceState; AddToGroup("Units"); }
// Called when the node enters the scene tree for the first time. public override void _Ready() { SeeableArea = (Area)GetNode("LineOfSight"); firingTimer = (Timer)GetNode("FiringTimer"); bulletContainer = GetNode("Bullet Container"); bullet = ResourceLoader.Load <PackedScene>("res://Scenes/Bullet.tscn"); rayCast = (RayCast)GetNode("RayCast"); muzzleFlashLight = GetNode("Firing light"); // Check if enemies are human IsHuman = ((Global)GetNode("/root/Global")).HumanEnemies; // Load accordingly if (IsHuman) { ((Spatial)GetNode("Human Nodes")).Visible = true; ((Spatial)GetNode("Wasp Nodes")).Visible = false; deathAudio = (AudioStreamPlayer3D)GetNode("Human Nodes/Death audio"); firingAudio = (AudioStreamPlayer3D)GetNode("Human Nodes/Firing audio"); hitAudio = (AudioStreamPlayer3D)GetNode("Human Nodes/Hit audio"); sprite = (Sprite3D)GetNode("Human Nodes/Sprite3D"); animationPlayer = (AnimationPlayer)GetNode("Human Nodes/Sprite3D/AnimationPlayer"); } else { ((Spatial)GetNode("Wasp Nodes")).Visible = true; ((Spatial)GetNode("Human Nodes")).Visible = false; deathAudio = (AudioStreamPlayer3D)GetNode("Wasp Nodes/Death audio"); firingAudio = (AudioStreamPlayer3D)GetNode("Wasp Nodes/Firing audio"); hitAudio = (AudioStreamPlayer3D)GetNode("Wasp Nodes/Hit audio"); sprite = (Sprite3D)GetNode("Wasp Nodes/Sprite3D"); animationPlayer = (AnimationPlayer)GetNode("Wasp Nodes/Sprite3D/AnimationPlayer"); } }
private void SetBtnHpFillAmount(int iBtnIndex) { if (iBtnIndex >= 0 && iBtnIndex < this.m_iCurEnemyPlayerCount && this.m_arrBtnInfo[iBtnIndex].btnTransform != null && this.m_arrBtnInfo[iBtnIndex].actorPtr) { float num = (float)this.m_arrBtnInfo[iBtnIndex].actorPtr.handle.ValueComponent.actorHp / (float)this.m_arrBtnInfo[iBtnIndex].actorPtr.handle.ValueComponent.actorHpTotal; Transform btnTransform = this.m_arrBtnInfo[iBtnIndex].btnTransform; if (btnTransform) { Sprite3D objHp = this.m_arrBtnInfo[iBtnIndex].objHp; Image component = btnTransform.GetComponent <Image>(); if (objHp && component) { if ((double)num < 0.3 && this.m_arrBtnInfo[iBtnIndex].bIsUseBlueHpImage) { objHp.spriteName = "Battle_HP_Red_Ring"; component.set_color(CUIUtility.s_Color_EnemyHero_Button_PINK); this.m_arrBtnInfo[iBtnIndex].bIsUseBlueHpImage = false; } else if ((double)num >= 0.3 && !this.m_arrBtnInfo[iBtnIndex].bIsUseBlueHpImage) { objHp.spriteName = "Battle_HP_Blue_Ring"; component.set_color(CUIUtility.s_Color_White); this.m_arrBtnInfo[iBtnIndex].bIsUseBlueHpImage = true; } objHp.fillAmount = num; } } } }
private void InitSprites() { _background = new Sprite3D { Texture = TextureManager.Textures("AllBackground"), Size = Core.Metrics["ScreenBackground.Size", 0], Position = Core.Metrics["ScreenBackground", 0], }; _header = new Sprite3D { Texture = TextureManager.Textures("CreditsHeader"), Position = Core.Metrics["ScreenHeader", 0], Size = Core.Metrics["ScreenHeader.Size", 0] }; for (int x = 0; x < TOTAL_PAGES; x++) { _creditsPages[x] = new Sprite3D { Texture = TextureManager.Textures("CreditsPage" + (x + 1)), Size = new Vector2(GameCore.INTERNAL_WIDTH, GameCore.INTERNAL_HEIGHT) }; } _baseSprite = new Sprite3D { Texture = TextureManager.Textures("LoadingMessageBase"), Position = (Core.Metrics["LoadMessageBase", 0]), Size = (Core.Metrics["LoadMessageBase.Size", 0]) }; _field = new SineSwayParticleField(); }
public void SetNativeSize(Camera camera, float depth) { float num = Sprite3D.Ratio(); this.RefreshUVDetail(); if (camera != null) { Vector3 vector = camera.transform.TransformPoint(0f, 0f, depth); Vector3 vector2 = camera.WorldToScreenPoint(vector); Vector3 position = new Vector3(vector2.x + (float)this.textureWidth * num, vector2.y, vector2.z); Vector3 position2 = new Vector3(vector2.x, vector2.y + (float)this.textureHeight * num, vector2.z); Vector3 b = camera.ScreenToWorldPoint(position); Vector3 b2 = camera.ScreenToWorldPoint(position2); if (this.fillType == Sprite3D.EnumFillType.RepeatHoriontal) { this.repeatUnitWidth = Vector3.Distance(vector, b); this.repeatUnitHeight = Vector3.Distance(vector, b2); } else { this.width = Vector3.Distance(vector, b); this.height = Vector3.Distance(vector, b2); } } }
private void InitSprites() { _background = new MovingBackground { Direction = Math.PI / 4, Speed = 30, Texture = TextureManager.Textures("MovingBackground1"), Size = Core.Metrics["ScreenBackground.Size", 0], Position = Core.Metrics["ScreenBackground", 0], }; _instructionPages = new Sprite3D[TOTAL_PAGES]; for (int x = 0; x < TOTAL_PAGES; x++) { _instructionPages[x] = new Sprite3D { Texture = TextureManager.Textures("InstructionPage" + (x + 1)), Size = new Vector2(GameCore.INTERNAL_WIDTH, GameCore.INTERNAL_HEIGHT) }; } _baseSprite = new Sprite3D { Texture = TextureManager.Textures("LoadingMessageBase"), Position = (Core.Metrics["LoadMessageBase", 0]), Size = Core.Metrics["LoadMessageBase.Size", 0] }; _beatline = new Beatline { Bpm = BEATLINE_BPM, Id = 0, Position = Core.Metrics["InstructionBeatline", 0], Size = Core.Metrics["InstructionBeatline.Size", 0], Speed = 1.0, }; }
public DosScreen() { AddChild(Viewport = new Viewport() { Size = new Vector2(720, 400), Disable3d = true, RenderTargetClearMode = Viewport.ClearMode.OnlyNextFrame, RenderTargetVFlip = true, }); Viewport.AddChild(new ColorRect() { Color = Color.Color8(0, 0, 0, 255), RectSize = Viewport.Size, }); AddChild(Sprite3D = new Sprite3D() { Texture = Viewport.GetTexture(), PixelSize = 0.00338666666f, Scale = new Vector3(1f, 1.35f, 1f), MaterialOverride = new SpatialMaterial() { FlagsUnshaded = true, FlagsDoNotReceiveShadows = true, FlagsDisableAmbientLight = true, ParamsSpecularMode = SpatialMaterial.SpecularMode.Disabled, ParamsCullMode = SpatialMaterial.CullMode.Back, FlagsTransparent = false, }, //GlobalTransform = new Transform(Basis.Identity, new Vector3(2.4384f / -2f, 0f, 0f)), }); BitmapFont font = new BitmapFont(); font.CreateFromFnt("res://Bm437_IBM_VGA9.fnt"); Label label = new Label() { Theme = new Theme() { DefaultFont = font, }, RectPosition = new Vector2(0, 0), }; label.Set("custom_constants/line_spacing", 0); label.Set("custom_colors/font_color", Color.Color8(170, 170, 170, 255)); Viewport.AddChild(label); Screen.Label = label; ColorRect cursor = new ColorRect { Color = Color.Color8(170, 170, 170, 255), RectSize = new Vector2(9, 2), }; Viewport.AddChild(cursor); Screen.Cursor = cursor; }
public void SetMaterial(Material material) { this.material = material; Sprite3D sprite3D = this.GetComponentInChildren <Sprite3D>(); sprite3D.SetMaterial(this.material); }
private static void SetEventComScreenSize(UI3DEventCom evtCom, float width, float height, float scale = 1f) { if (evtCom != null) { evtCom.m_screenSize.width = width * scale * Sprite3D.Ratio(); evtCom.m_screenSize.height = height * scale * Sprite3D.Ratio(); } }
public override void Initialize() { _songSortDisplay = new SongSortDisplay { Position = Core.Metrics["SongSortDisplay", 0], Size = Core.Metrics["SongSortDisplay.Size", 0] }; _songSortDisplay.InitSprites(); _songListDrawOpacity = 255; Crossfader = Core.Crossfader; _preloadState = PreloadState.NOT_LOADING; _previewStarted = false; _highScoreFrame = new HighScoreFrame { EnableFadeout = false, Position = (Core.Metrics["SongHighScoreFrame", 0]) }; _highScoreFrame.InitSprites(); _bpmMeter = new BpmMeter { Position = (Core.Metrics["BPMMeter", 0]) }; _playerOptionsSet = new PlayerOptionsSet { Players = Core.Players, Positions = Core.Metrics["PlayerOptionsFrame"], CurrentGameType = (GameType)Core.Cookies["CurrentGameType"], DrawAttract = true, StackableFrames = true, Size = Core.Metrics["PlayerOptionsFrame.Size", 0] }; _playerOptionsSet.GameTypeInvalidated += delegate { Core.ScreenTransition("MainMenu"); }; _playerOptionsSet.CreatePlayerOptionsFrames(); CreateSongList(); var lastSongHash = Core.Settings.Get <int>("LastSongPlayed"); var lastSong = (from e in _songList where e.Song.GetHashCode() == lastSongHash select e).FirstOrDefault(); if (lastSong != null) { _selectedIndex = _songList.IndexOf(lastSong); _songSortDisplay.SelectedSongIndex = _selectedIndex; } _songTypeDisplay = new SongTypeDisplay { Position = Core.Metrics["SongTypeDisplay", 0], Size = Core.Metrics["SongTypeDisplay.Size", 0] }; InitSprites(); _spectrumDrawer = new SpectrumDrawer { LevelsCount = SPECTRUM_POINTS / SPECTRUM_CLUSTER_SIZE, Size = Core.Metrics["SelectedSongSpectrum.Size", 0], Position = Core.Metrics["SelectedSongSpectrum", 0], ColorShading = Color.White }; _songLockedSprite = new Sprite3D { Position = Core.Metrics["BPMMeter", 0], Texture = TextureManager.Textures("SongLocked") }; base.Initialize(); }
private void InitSprites() { _optionsFrameAttract = new Sprite3D { Texture = TextureManager.Textures("PlayerOptionsFrameAttract"), ColorShading = new Color(255, 255, 255, 128), Size = Size }; }
private static void SetEventComScreenSize(UI3DEventCom evtCom, Sprite3D sptCom, float scale = 1f) { if (evtCom == null) { return; } evtCom.m_screenSize.width = (float)sptCom.textureWidth * scale * Sprite3D.Ratio(); evtCom.m_screenSize.height = (float)sptCom.textureHeight * scale * Sprite3D.Ratio(); }
protected void RegisterSignals() { foreach (var area in GetChildren().Select(o => o as Area).Where(a => a != null)) { area.Connect("body_entered", this, nameof(OnBodyEntered)); area.Connect("body_exited", this, nameof(OnBodyExited)); } billboard = GetNode("billboard") as Sprite3D; billboard.Visible = false; }
private void MoveToYPlane() { // TODO: Doesn't make any sense why divide by ten Sprite3D sprite3D = this.GetComponentInChildren <Sprite3D>(); float yPosition = this.yPlane + sprite3D.GetBounds().extents.z / 10.0f; Vector3 currentPosition = this.transform.position; this.transform.position = new Vector3(currentPosition.x, yPosition, currentPosition.z); }
public override void _Ready() { animation = ((AnimationPlayer)GetNode("AnimationPlayer")); audio = ((AudioStreamPlayer3D)GetNode("AudioStreamPlayer3D")); sprite = (Sprite3D)GetNode("Barrel"); timer = (Timer)GetNode("Timer"); area = (Area)GetNode("Explosion Area"); collisionShape = (CollisionShape)GetNode("CollisionShape"); explosionMesh = (MeshInstance)GetNode("Explosion mesh"); }
private void RefreshHierachy(Transform root) { if (!root.gameObject.activeSelf) { return; } for (int i = root.childCount - 1; i >= 0; i--) { this.RefreshHierachy(root.GetChild(i)); } Sprite3D sprite3D = null; if (this.m_childSprites.TryGetValue(root.GetInstanceID(), ref sprite3D)) { if (null != sprite3D) { this.m_depth++; sprite3D.depth = (float)this.m_depth; } } else { sprite3D = root.GetComponent <Sprite3D>(); this.m_childSprites.Add(root.GetInstanceID(), sprite3D); if (null != sprite3D) { this.m_depth++; sprite3D.depth = (float)this.m_depth; } } TextMesh textMesh = null; if (sprite3D == null) { if (this.m_childText.TryGetValue(root.GetInstanceID(), ref textMesh)) { if (null != textMesh) { this.m_depth++; textMesh.offsetZ = (float)this.m_depth / 10f; } } else { textMesh = root.GetComponent <TextMesh>(); this.m_childText.Add(root.GetInstanceID(), textMesh); if (null != textMesh) { this.m_depth++; textMesh.offsetZ = (float)this.m_depth / 10f; } } } }
public BTN_INFO(Transform _btnTransform, PoolObjHandle <ActorRoot> _actorPtr, CEnemyHeroAtkBtn.ENM_ENEMY_HERO_STATE _heroState, bool _bIsUseBlueHpImage, GameObject _objUI3DHp, Sprite3D _objHp) { this.btnTransform = _btnTransform; this.actorPtr = _actorPtr; this.heroState = 1 << (int)_heroState; this.bIsUseBlueHpImage = _bIsUseBlueHpImage; this.btnScreenPos = CUIUtility.WorldToScreenPoint(Singleton <CUIManager> .instance.FormCamera, _btnTransform.position); this.btnScreenPos.z = (float)MiniMapSysUT.UI3D_Depth; this.btnUI3DWorldPos = CEnemyHeroAtkBtn.m_UI3DCamera.ScreenToWorldPoint(this.btnScreenPos); this.objUI3DHp = _objUI3DHp; this.objUI3DHp.transform.position = this.btnUI3DWorldPos; this.objHp = _objHp; }
public void unregisterAutoAtlas(Sprite3D sprite) { if (sprite.texture == null || string.IsNullOrEmpty(sprite.autoAtlasTag)) { return; } Canvas3DImpl.AutoAtlasInfo autoAtlasInfo = null; if (!this.m_atlas.TryGetValue(sprite.autoAtlasTag, out autoAtlasInfo)) { return; } autoAtlasInfo.Unregister(sprite); }
private void InitSprites() { _background = new Sprite3D { Size = Core.Metrics["ScreenBackground.Size", 0], Position = Core.Metrics["ScreenBackground", 0], Texture = TextureManager.Textures("AllBackground"), }; _messageBackground = new Sprite3D { Texture = TextureManager.Textures("NewGameMessageBorder"), Size = Core.Metrics["NewGameMessageBorder.Size", 0] }; }
public override void _Ready() { TargetReticule = GetNode <Sprite3D>("Target"); Area = GetNode <Area>("Area"); Area.Connect("mouse_entered", this, nameof(OnMouseEntered)); Area.Connect("mouse_exited", this, nameof(OnMouseExit)); AttackIcon = GetNode <Sprite3D>("Attacking"); DefenseIcon = GetNode <Sprite3D>("Defending"); AnimationPlayer = GetNode <AnimationPlayer>("AnimationPlayer"); if (CardType == CardType.Unit) { ChangeAttack(); } }
private void SetupSprites() { _baseSprite = new Sprite3D(); _baseOvermaskSprite = new Sprite3D(); _streakBaseSprite = new Sprite3D(); _streakOvermaskSprite = new Sprite3D(); _baseSprite = _metrics.SetupFromMetrics(DeterminePrefix() + "HitsBar", 0); _streakBaseSprite = _metrics.SetupFromMetrics("StreakBar", 0); _baseOvermaskSprite = new Sprite3D(); _baseOvermaskSprite = _metrics.SetupFromMetrics(DeterminePrefix() + "HitsBar", 0); _streakOvermaskSprite = _metrics.SetupFromMetrics("StreakBar", 0); _baseOvermaskSprite.Texture = TextureManager.CreateWhiteMask(DeterminePrefix() + "HitsBar"); _streakOvermaskSprite.Texture = TextureManager.CreateWhiteMask("StreakBar"); }
public Sprite3D SetupFromMetrics(string metricsKey, int id) { var result = new Sprite3D(); if (_metrics.ContainsKey(metricsKey)) { result.Position = this[metricsKey, id]; } if (_metrics.ContainsKey(metricsKey + ".Size")) { //Handle both a single size definition and multiple (one per ID). result.Size = _metrics[metricsKey + ".Size"].Count() > id ? this[metricsKey + ".Size", id] : this[metricsKey + ".Size", 0]; } result.Texture = TextureManager.Textures(metricsKey); return(result); }
public override void Initialize() { _songFolderPath = "" + Core.Settings["SongFolder"]; _textPosition = Core.Metrics["SongLoadLog", 0].Clone(); _baseSprite = new Sprite3D { Texture = TextureManager.Textures("LoadingMessageBase"), Position = (Core.Metrics["LoadMessageBase", 0]), Size = Core.Metrics["LoadMessageBase.Size", 0] }; var thread = new Thread(LoadSongs); thread.Start(); base.Initialize(); }