virtual public void UpdateAllianceColor() { switch (Alliance) { case Alliance.Blue: color = Constants.BlueAllianceColor; break; case Alliance.Red: color = Constants.RedAllianceColor; break; } }
private SpatialMaterial CreateMaterial(Link.Visual.Material baseMat) { if (baseMat == null) { return(null); } SpatialMaterial temp = new SpatialMaterial(); var matColor = new Godot.Color(); matColor.r = (float)baseMat.color.rgba[0]; matColor.g = (float)baseMat.color.rgba[1]; matColor.b = (float)baseMat.color.rgba[2]; matColor.a = (float)baseMat.color.rgba[3]; temp.AlbedoColor = matColor; return(temp); }
public override void _Ready() { String dirpath = System.Environment.GetEnvironmentVariable("LOCALAPPDATA") + @"\12P1DFPS\level.bmp"; Bitmap image = new Bitmap(dirpath); WorldX = image.Width; WorldY = image.Height; map = new Lib.obj[WorldX, WorldY]; for (int i = 0; i < WorldX; i++) { for (int ii = 0; ii < WorldY; ii++) { System.Drawing.Color t = image.GetPixel(i, ii); Godot.Color tc = Godot.Color.Color8(t.R, t.G, t.B, 0); if (Lib.c2obj.ContainsKey(tc)) { Lib.obj temp; Lib.c2obj.TryGetValue(tc, out temp); if ((byte)temp < 5) { addObj(temp, i, ii); } else if (temp == Lib.obj.spawn) { Pos = new Vector2(i, ii); } else if ((byte)temp > 5) { map[i, ii] = temp; } } else { map[i, ii] = Lib.obj.empty; } } } Graphics.reload(); }
// Called when the node enters the scene tree for the first time. public override void _Ready() { // globale = (Global)GetNode("/root/Global"); // timer = (Timer)GetNode("Timer"); // animationPlayer = (AnimationPlayer)GetNode("L_click/AnimationPlayer"); animationPlayer.CurrentAnimation = "clignotement"; // if ((bool)globale.quick_saved_game["saved"] == true && globale.quick_saved_game.Keys.Contains("tipe") && globale.quick_saved_game.Keys.Contains("level") && globale.quick_saved_game.Keys.Contains("difficulty")) { globale.tipe = Convert.ToString(globale.quick_saved_game["tipe"]); globale.level = Convert.ToInt32(globale.quick_saved_game["level"]); globale.difficulty = Convert.ToInt32(globale.quick_saved_game["difficulty"]); //on supprime la sauvegarde globale.quick_saved_game["saved"] = false; } else { string[] tps = { "platforms" }; Random rand = new Random(); globale.tipe = tps[rand.Next(0, tps.Length)]; } if (globale.tipe == "platforms") { prepare_platform(); } if (globale.tipe == "maze") { prepare_maze(); } // Label l_dif = (Label)GetNode("L_difficulty"); Label l_time = (Label)GetNode("L_time"); Label l_titre = (Label)GetNode("Titre"); Label l_click = (Label)GetNode("L_click"); // l_dif.Text = "Difficulty : " + globale.difs[globale.difficulty]; l_titre.Text = "level " + globale.level + " : " + globale.tipe; l_time.Text = "time maximum : " + globale.timemax + " sec"; // l_click.Text = "click or press " + ((InputEvent)InputMap.GetActionList("jump")[0]).AsText() + " to play ..."; // bool gagne_skin = false; int rar = 0; for (int w = 0; w < globale.max_skin; w++) { if (globale.skins_recup[w] == "arcade" || globale.skins_recup[w] == "arcade-" + globale.difs[globale.difficulty]) { if (!globale.skins_unlocked[w] && globale.level >= globale.rar_deb_skin[globale.skins_rarity[w]]) { gagne_skin = true; if (globale.skins_rarity[w] > rar) { rar = globale.skins_rarity[w]; } } } } if (gagne_skin) { Panel ifd = (Panel)GetNode("Info_die"); Label lifd = (Label)GetNode("Info_die/L_srar"); Godot.Color cl = new Godot.Color(globale.cl_rars[rar]); //; lifd.Text = globale.rarities[rar]; lifd.AddColorOverride("font_color", cl); ifd.Visible = true; } }
private static void RenderDrawData(ImDrawDataPtr drawData, RID parent) { // allocate and clear out our CanvasItem pool as needed int neededNodes = 0; for (int i = 0; i < drawData.CmdListsCount; i++) { neededNodes += drawData.CmdListsRange[i].CmdBuffer.Size; } while (_children.Count < neededNodes) { RID newChild = VisualServer.CanvasItemCreate(); VisualServer.CanvasItemSetParent(newChild, parent); VisualServer.CanvasItemSetDrawIndex(newChild, _children.Count); _children.Add(newChild); _meshes.Add(new ArrayMesh()); } // trim unused nodes to reduce draw calls while (_children.Count > neededNodes) { int idx = _children.Count - 1; VisualServer.FreeRid(_children[idx]); _children.RemoveAt(idx); _meshes.RemoveAt(idx); } // render drawData.ScaleClipRects(ImGui.GetIO().DisplayFramebufferScale); int nodeN = 0; for (int n = 0; n < drawData.CmdListsCount; n++) { ImDrawListPtr cmdList = drawData.CmdListsRange[n]; int idxOffset = 0; int nVert = cmdList.VtxBuffer.Size; Godot.Vector2[] vertices = new Godot.Vector2[nVert]; Godot.Color[] colors = new Godot.Color[nVert]; Godot.Vector2[] uvs = new Godot.Vector2[nVert]; for (int i = 0; i < cmdList.VtxBuffer.Size; i++) { var v = cmdList.VtxBuffer[i]; vertices[i] = new Godot.Vector2(v.pos.X, v.pos.Y); // need to reverse the color bytes byte[] col = BitConverter.GetBytes(v.col); colors[i] = Godot.Color.Color8(col[0], col[1], col[2], col[3]); uvs[i] = new Godot.Vector2(v.uv.X, v.uv.Y); } for (int cmdi = 0; cmdi < cmdList.CmdBuffer.Size; cmdi++, nodeN++) { ImDrawCmdPtr drawCmd = cmdList.CmdBuffer[cmdi]; int[] indices = new int[drawCmd.ElemCount]; for (int i = idxOffset, j = 0; i < idxOffset + drawCmd.ElemCount; i++, j++) { indices[j] = cmdList.IdxBuffer[i]; } var arrays = new Godot.Collections.Array(); arrays.Resize((int)ArrayMesh.ArrayType.Max); arrays[(int)ArrayMesh.ArrayType.Vertex] = vertices; arrays[(int)ArrayMesh.ArrayType.Color] = colors; arrays[(int)ArrayMesh.ArrayType.TexUv] = uvs; arrays[(int)ArrayMesh.ArrayType.Index] = indices; var mesh = _meshes[nodeN]; while (mesh.GetSurfaceCount() > 0) { mesh.SurfaceRemove(0); } mesh.AddSurfaceFromArrays(Mesh.PrimitiveType.Triangles, arrays); RID child = _children[nodeN]; Texture tex = GetTexture(drawCmd.TextureId); VisualServer.CanvasItemClear(child); VisualServer.CanvasItemSetClip(child, true); VisualServer.CanvasItemSetCustomRect(child, true, new Godot.Rect2( drawCmd.ClipRect.X, drawCmd.ClipRect.Y, drawCmd.ClipRect.Z - drawCmd.ClipRect.X, drawCmd.ClipRect.W - drawCmd.ClipRect.Y) ); VisualServer.CanvasItemAddMesh(child, mesh.GetRid(), null, null, tex.GetRid(), new RID(null)); // why doesn't this quite work? // VisualServer.CanvasItemAddTriangleArray(child, indices, vertices, colors, uvs, null, null, tex.GetRid(), -1, new RID(null)); idxOffset += (int)drawCmd.ElemCount; } } }