Inheritance: MonoBehaviour
コード例 #1
0
    public void Setup(CellProperties cp)
    {
        cellProperties = cp;

        ApplyCellProperties(cp);
        energy = GetComponent <Energy>();

        defaultPos = GameManager.Instance.GetRandomLocationInsideSpawn();

        InvokeRepeating("Sense", UnityEngine.Random.Range(0, cp.sensor.updateFrequency), cp.sensor.updateFrequency);
        InvokeRepeating("EnergyConsumptionByBody", UnityEngine.Random.Range(0, 1), 1);
        InvokeRepeating("Reproduction", UnityEngine.Random.Range(0, 5), 5);


        switch (cellProperties.digestiveSystem)
        {
        case DigestiveSystem.hervivouros:
            body.GetComponent <Renderer>().material.color = Color.green;
            break;

        case DigestiveSystem.carinvorous:
            body.GetComponent <Renderer>().material.color = Color.red;
            break;

        case DigestiveSystem.homnivorous:
            body.GetComponent <Renderer>().material.color = Color.yellow;
            break;
        }
    }
コード例 #2
0
ファイル: MyXlsTestFixture.cs プロジェクト: shi5588/shi5588
 public static string GetCellPropertyString(CellProperties property)
 {
     switch (property)
     {
         case CellProperties.Value:
         case CellProperties.Text:
         case CellProperties.Width:
             return property.ToString();
         case CellProperties.Rotation:
             return "Orientation";
         case CellProperties.Font_Bold:
             return "Font.Bold";
         case CellProperties.Font_Italic:
             return "Font.Italic";
         case CellProperties.Font_Underline:
             return "Font.Underline";
         case CellProperties.Font_Name:
             return "Font.Name";
         case CellProperties.MergeAreaCount:
             return "MergeArea.Count";
         case CellProperties.PatternColor:
             return "Interior.PatternColorIndex";
         case CellProperties.PatternBackgroundColor:
             return "Interior.ColorIndex";
         case CellProperties.Comment:
             return "Comment";
         default:
             throw new NotSupportedException(property.ToString());
     }
 }
コード例 #3
0
ファイル: GameManager.cs プロジェクト: passchnik/MazeRunner
    private void SpawnMaze(Cell[,] maze)
    {
        if (LevelNumber > 0)
        {
            GameObject[] gos = FindObjectsOfType <GameObject>();
            foreach (GameObject go in gos)
            {
                if (go.tag == "Cell" || go.tag == "Trigger")
                {
                    Destroy(go);
                }
            }
        }


        for (int i = 0; i < maze.GetLength(0); i++)
        {
            for (int j = 0; j < maze.GetLength(1); j++)
            {
                CellProperties cp = Instantiate(cellPrefab, new Vector2(i, j), Quaternion.identity).GetComponent <CellProperties>();

                cp.LeftWall.SetActive(maze[i, j].LeftWall);
                cp.RightWall.SetActive(maze[i, j].RightWall);
                cp.BottomWall.SetActive(maze[i, j].BottomWall);
                cp.TopWall.SetActive(maze[i, j].TopWall);

                if (maze[i, j].End == true)
                {
                    Instantiate(EndTrigger, new Vector2(i + 0.5f, j + 0.5f), Quaternion.identity).GetComponent <CellProperties>();
                }
            }
        }
    }
コード例 #4
0
ファイル: MapGenerator.cs プロジェクト: thebpfeif/crux
    private void generateCells()
    {
        Vector2 coordinates;

        for (int x = 0; x < MapWidth; x++)
        {
            for (int y = 0; y < MapHeight; y++)
            {
                coordinates = new Vector2(x, y);

                /* Create new cell object for the grid */
                GameObject newCell = (GameObject)Instantiate(CellGO);

                /* Set the cell coordinates in properties */
                CellProperties properties = newCell.GetComponent <CellProperties>();
                properties.CellCoordinates = coordinates;

                /* Give it a random asteroid density (for now) */
                properties.AsteroidDenstiy = Random.Range(0, 50);

                /* Set random large and medium asteroid ratios */
                properties.LargeAsteroidPercent = Random.Range(0, 100);

                properties.MedAsteroidPercent = Random.Range(0, 100 - (int)(properties.LargeAsteroidPercent * 100));

                /* Place the cell in the world space, save it to list */
                newCell.transform.position = new Vector2(x * cellLength, y * cellLength);
                newCell.transform.parent   = transform;
                cells.Add(newCell);
            }
        }
    }
コード例 #5
0
        static void OutputProperties(StreamWriter file, CellProperties cp)
        {
            file.WriteLine("     texture {");
            file.WriteLine("   pigment {");
            file.WriteLine("        agate");
            file.WriteLine("        turbulence 1");
            file.WriteLine("        lambda 1.5");
            file.WriteLine("        omega .8");
            file.WriteLine("        octaves 8");
            file.WriteLine("        color_map {");
            byte r, g, b, a;

            RasterLib.RasterApi.Ulong2Rgba(cp.Rgba, out r, out g, out b, out a);
            file.WriteLine("          [0.00 color rgb <{0}, {1}, {2}>]",
                           (float)r / (float)255,
                           (float)g / (float)255,
                           (float)b / (float)255,
                           (float)a / (float)255);
            file.WriteLine("        }");
            file.WriteLine("      }");

            file.WriteLine("	finish {");
            file.WriteLine("		phong 0.8");
            file.WriteLine("		reflection 0.25");
            file.WriteLine("	       }");
            file.WriteLine("   }");
            file.WriteLine("}");
        }
コード例 #6
0
 private static void DrawSpecularArea(CellProperties properties, MaterialEditor materialEditor)
 {
     TextureColorProps(materialEditor, LabelText.SpecularMap, properties.SpecGlossTex, properties.SpecColor);
     EditorGUI.indentLevel++;
     DrawSmoothnessArea(properties);
     EditorGUI.indentLevel--;
 }
コード例 #7
0
ファイル: Program.cs プロジェクト: katascope/Glyphics2
        static void Main(string[] args)
        {
            //for (int i=0;i<zodiac.Length;i+=2)
            //s{
            //  Console.WriteLine("{0:X}, {1:X} ",(uint)zodiac[i], (uint)zodiac[i+1]);
            //}

            byte[] unicodeBytes = Encoding.Unicode.GetBytes(zodiac);

//♈️ ♉️ ♊️ ♋️ ♌️ ♍️ ♎️ ♏️ ♐️ ♑️ ♒️ ♓️

            int bands = zodiac.Length;

            for (int i = 0; i < bands; i++)
            {
                byte v = (byte)(i * (255 / bands));
                rgbV.Add(RasterLib.RasterApi.Rgba2Ulong(v, v, v, 255));
            }

            //  rgbV.Add(RasterLib.RasterApi.Rgba2Ulong(0, 0, 0, 0));
            //rgbV.Add(RasterLib.RasterApi.Rgba2Ulong(0, 0, 0, 0));
            //rgbV.Add(RasterLib.RasterApi.Rgba2Ulong(255,255,255,255));

            /*
             * for (int i = 0; i < 360; i += 30)
             * {
             *  ulong rgb = RasterLib.Utility.Converter.Hsl2Rgb(i, 100, 49);
             *  byte r, g, b, a;
             *  RasterLib.RasterApi.Ulong2Rgba(rgb, out r, out g, out b, out a);
             *  Console.WriteLine("hue "+i + " - rgb " + r + "," + g + "," + b + "," + a);
             *  rgbV.Add(rgb);
             * }*/

            Grid gridIn = GraphicsApi.PngToGrid("c:\\github\\logo.png");

            string str = "";

            using (var file = new System.IO.StreamWriter("testUnicode.txt", false, Encoding.Unicode))
            {
                for (int y = 0; y < gridIn.SizeY; y++)
                {
                    for (int x = 0; x < gridIn.SizeX; x++)
                    {
                        CellProperties cp = gridIn.GetProperty(x, y, 0);
                        byte           r, g, b, a;
                        RasterLib.RasterApi.Ulong2Rgba(cp.Rgba, out r, out g, out b, out a);

                        string character = Rgb2UnicodeChar(r, g, b);

                        file.Write(character);
                        Console.Write(character);
                        str += character;
                    }
                    file.WriteLine();
                    str += "\n";
                }
            }
            Clipboard.SetText(str);
        }
コード例 #8
0
        /// <summary>
        /// Creates the cell properties.
        /// </summary>
        /// <param name="style">The style.</param>
        /// <param name="propertyNode">The property node.</param>
        /// <returns></returns>
        private CellProperties CreateCellProperties(IStyle style, XmlNode propertyNode)
        {
            CellProperties cellProperties = new CellProperties(style as CellStyle);

            cellProperties.Node = propertyNode;

            return(cellProperties);
        }
コード例 #9
0
    public static void GiveBirth(Cell father)
    {
        GameObject     child        = Instantiate(GameManager.Instance.defaultCell, Instance.GetRandomLocationInsideSpawn(), Quaternion.identity);
        CellProperties newCp        = father.cellProperties.Clone();
        CellProperties newCpMutated = CellProperties.Mutate(newCp);

        child.GetComponent <Cell>().Setup(newCpMutated);
    }
コード例 #10
0
    public void ApplyCellProperties(CellProperties cp)
    {
        this.bodySize = cp.bodySize;

        movementController.Setup(GetComponent <Rigidbody2D>(), this);

        cp.sensor.setup(this);
    }
コード例 #11
0
        /// <summary>
        /// Creates the cell properties.
        /// </summary>
        /// <param name="style">The style.</param>
        /// <param name="propertyNode">The property node.</param>
        /// <returns></returns>
        private static CellProperties CreateCellProperties(IStyle style, XElement propertyNode)
        {
            CellProperties cellProperties = new CellProperties(style as CellStyle)
            {
                Node = propertyNode
            };

            return(cellProperties);
        }
コード例 #12
0
    //Returns a list containing all of a given cells neighbours
    public List <GameObject> GetNeighbours(GameObject TargetCell)
    {
        //Create a new list to store the target cells neighbours
        List <GameObject> Neighbours = new List <GameObject>();

        //Fetch the target cells grid coordinates from its properties component
        CellProperties TargetProperties = TargetCell.GetComponent <CellProperties>();
        int            CellRow          = TargetProperties.CellRow;
        int            CellColumn       = TargetProperties.CellColumn;

        //Compare the target cells grid coordinates to the current grid size so we know which sides it has neighbours on
        bool NorthNeighbours = CellRow < GridSize;
        bool EastNeighbours  = CellColumn < GridSize;
        bool SouthNeighbours = CellRow > 1;
        bool WestNeighbours  = CellColumn > 1;

        //Add all the neighbouring cells to the list, using these flags so we know which ones we can add
        int RowIndex    = CellRow - 1;
        int ColumnIndex = CellColumn - 1;

        if (NorthNeighbours)
        {
            Neighbours.Add(CellGrid[RowIndex + 1, ColumnIndex]);
        }
        if (NorthNeighbours && EastNeighbours)
        {
            Neighbours.Add(CellGrid[RowIndex + 1, ColumnIndex + 1]);
        }
        if (EastNeighbours)
        {
            Neighbours.Add(CellGrid[RowIndex, ColumnIndex + 1]);
        }
        if (SouthNeighbours && EastNeighbours)
        {
            Neighbours.Add(CellGrid[RowIndex - 1, ColumnIndex + 1]);
        }
        if (SouthNeighbours)
        {
            Neighbours.Add(CellGrid[RowIndex - 1, ColumnIndex]);
        }
        if (SouthNeighbours && WestNeighbours)
        {
            Neighbours.Add(CellGrid[RowIndex - 1, ColumnIndex - 1]);
        }
        if (WestNeighbours)
        {
            Neighbours.Add(CellGrid[RowIndex, ColumnIndex - 1]);
        }
        if (NorthNeighbours && WestNeighbours)
        {
            Neighbours.Add(CellGrid[RowIndex + 1, ColumnIndex - 1]);
        }

        //Return the final list containing all of the target cells neighbours
        return(Neighbours);
    }
コード例 #13
0
        /// <summary>
        /// Changes a single property of a cell
        /// </summary>
        /// <param name="cell">The cell to modify</param>
        /// <param name="propertyName">The property to change</param>
        /// <param name="newValue">The new value of the property</param>
        public void ChangeCellProperty(IHTMLTableCell cell, CellProperties propertyName, string newValue)
        {
            IHTMLElement cellElement = cell as IHTMLElement;;

            if (cellElement != null)
            {
                switch (propertyName)
                {
                case CellProperties.BackgroundColor:
                    cellElement.style.backgroundColor = newValue;
                    break;

                case CellProperties.BorderColor:
                    cellElement.style.borderColor = newValue;
                    break;

                case CellProperties.BorderSize:
                    if (newValue != null)
                    {
                        cellElement.style.borderWidth = newValue;
                    }
                    break;

                case CellProperties.Height:
                    if (newValue != null)
                    {
                        cellElement.style.height = newValue;
                    }
                    break;

                case CellProperties.Width:
                    if (newValue != null)
                    {
                        cellElement.style.width = newValue;
                    }
                    break;

                case CellProperties.Rowspan:
                    if (newValue != null)
                    {
                        cell.rowSpan = int.Parse(newValue);
                    }
                    break;

                case CellProperties.Colspan:
                    if (newValue != null)
                    {
                        cell.colSpan = int.Parse(newValue);
                    }
                    break;
                }
            }
        }
コード例 #14
0
        public static void GlycToPov(string glycFilename, string povFilename, string headerFilename)
        {
            string codeString = RasterLib.RasterApi.ReadGlyc(glycFilename).Replace(';', '\n');

            Code code = new Code(codeString);

            code = RasterLib.RasterApi.CodeToRescaledCode(code, 31, 32, 31);
            Grid     grid  = RasterLib.RasterApi.CodeToGrid(code);
            RectList rects = RasterLib.RasterApi.GridToRects(grid);

            using (var file = new System.IO.StreamWriter(povFilename))
            {
                InsertHeader(file, headerFilename);

                float scalex = 0.5f;
                float scaley = 0.5f;
                float scalez = 0.5f;
                float ox     = -32 * scalex;
                float oy     = 0;
                float oz     = 32 * scalex;

                foreach (Rect rect in rects)
                {
                    CellProperties cp = rect.Properties;

                    file.WriteLine("box {");
                    file.WriteLine("  <{0},{1},{2}> <{3}, {4}, {5}>",
                                   rect.Pt1[0] * scalex - ox, rect.Pt1[1] * scaley - oy, rect.Pt1[2] * scalez - oz,
                                   rect.Pt2[0] * scalex - ox, rect.Pt2[1] * scaley - oy, rect.Pt2[2] * scalez - oz);

                    OutputProperties(file, cp);
                }

                /*for (int z = 0; z < grid.SizeZ; z++)
                 * {
                 *  for (int y = 0; y < grid.SizeY; y++)
                 *  {
                 *      for (int x = 0; x < grid.SizeX; x++)
                 *      {
                 *          CellProperties cp = grid.GetProperty(x, y, z);
                 *
                 *          if (cp.Rgba > 0)
                 *          {
                 *              file.WriteLine("sphere {");
                 *              file.WriteLine("    <{0},{1},{2}>,{3}", x - 32, y, z - 32, scalex * 1.5);
                 *              OutputProperties(file, cp);
                 *          }
                 *      }
                 *  }
                 * }*/
            }
        }
コード例 #15
0
    private int xMax;                      // The variable to hold the maximum size of the base along the x axis
    #endregion

    #endregion

    #region Unity Events

    // Use this for initialization
    void Start()
    {
        // Add listener to the Player Walking Event
        PlayerEventsAndDelegates.Instance.PlayerWalking += OnPlayerWalking;

        // Get the instance of Cell Properties
        cellProperties = gameObject.GetComponent <CellProperties>();

        // Grab base size from base manager
        zTop    = BaseManager.Instance.ZTop;
        zBottom = BaseManager.Instance.ZBottom;
        xMax    = BaseManager.Instance.XMax;
    }
コード例 #16
0
    //Performs a single update to all the cells in the grid
    public void UpdateCells()
    {
        //Fetch the total list of Cell objects
        List <GameObject> Cells = CellArray.Instance.GetCells();

        //Loop through and find out what the new value will be for all cells
        foreach (GameObject Cell in Cells)
        {
            //Fetch the properties component of the Cell we are about to update
            CellProperties Properties = Cell.GetComponent <CellProperties>();

            //Fetching all of this cells neighbours
            List <GameObject> Neighbours = CellArray.Instance.GetNeighbours(Cell);

            //Check how many of the cells neighbours are alive
            int LivingNeighbours = CellArray.Instance.LivingCount(Neighbours);

            //Apply Rule 1 (any living cell with <2 living neighbours is killed, as if by underpopulation)
            if (Properties.IsAlive && LivingNeighbours < 2)
            {
                Properties.SetNewState(false);
            }
            //Apply Rule 2 (any living cell with two or three living neighbours remains alive)
            else if (Properties.IsAlive && LivingNeighbours == 2 || LivingNeighbours == 3)
            {
                Properties.SetNewState(true);
            }
            //Apply Rule 3 (any living cell with >3 living neighbours is killed, as if by overpopulation)
            else if (Properties.IsAlive && LivingNeighbours > 3)
            {
                Properties.SetNewState(false);
            }
            //Apply Rule 4 (any dead cell with exactly 3 living neighbours is brought to life, as if by reproduction)
            else if (!Properties.IsAlive && LivingNeighbours == 3)
            {
                Properties.SetNewState(true);
            }
            //Otherwise we just tell the cell to remain in whatever state its currently in
            else
            {
                Properties.SetNewState(Properties.IsAlive);
            }
        }

        //Now each Cell knows what its new state needs to be, tell them all to change to that state
        foreach (GameObject Cell in Cells)
        {
            //Call the UpdateState function on all the Cells properties components
            Cell.GetComponent <CellProperties>().UpdateState();
        }
    }
コード例 #17
0
        public void ShapeToColor(GridContext bgc, int span1, int span2, int span3, int span4, int span5, int span6, int span7, int span8)
        {
            if (bgc == null)
            {
                return;
            }
            Grid grid = bgc.Grid;

            grid.InhibitCodeTracking();
            int[] spans = new int[8];
            spans[0] = span1;
            spans[1] = span2;
            spans[2] = span3;
            spans[3] = span4;
            spans[4] = span5;
            spans[5] = span6;
            spans[6] = span7;
            spans[7] = span8;

            for (int z = 0; z < grid.SizeZ; z++)
            {
                for (int y = 0; y < grid.SizeY; y++)
                {
                    for (int x = 0; x < grid.SizeX; x++)
                    {
                        ulong          u  = grid.GetRgba(x, y, z);
                        CellProperties cp = grid.GetProperty(x, y, z);

                        if (cp.ShapeId == 0)
                        {
                        }
                        else if (cp.ShapeId > 0 && cp.ShapeId <= spans[0])
                        {
                            u = Converter.Rgba2Ulong(0, 255, 0, 255);
                        }
                        else if (cp.ShapeId > spans[0] && cp.ShapeId <= spans[1])
                        {
                            u = Converter.Rgba2Ulong(255, 0, 0, 255);
                        }
                        else
                        {
                            u = Converter.Rgba2Ulong(255, 0, 255, 255);
                        }

                        grid.Plot(x, y, z, u);
                    }
                }
            }
            grid.AllowCodeTracking();
        }
コード例 #18
0
        public CellPropertiesForm(CellProperties cellProperties)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            this.buttonOK.Text              = Res.Get(StringId.OKButtonText);
            this.buttonCancel.Text          = Res.Get(StringId.CancelButton);
            this.cellPropertiesControl.Text = Res.Get(StringId.Cells);
            this.Text = Res.Get(StringId.CellPropertiesTitle);

            cellPropertiesControl.CellProperties = cellProperties;
        }
コード例 #19
0
        private static void DrawSmoothnessArea(CellProperties properties)
        {
            EditorGUI.indentLevel++;

            EditorGUI.BeginChangeCheck();

            EditorGUI.showMixedValue = properties.Smoothness.hasMixedValue;
            var smoothness = EditorGUILayout.Slider(LabelText.Smoothness, properties.Smoothness.floatValue, 0f, 1f);

            if (EditorGUI.EndChangeCheck())
            {
                properties.Smoothness.floatValue = smoothness;
            }
            EditorGUI.showMixedValue = false;

            EditorGUI.indentLevel--;
        }
コード例 #20
0
        //Blit one grid's rectangle portion into another
        public void RectBlit(GridContext bgc, Grid pal, int x1, int y1, int z1, int x2, int y2, int z2, byte groupId)
        {
            if (bgc == null || pal == null)
            {
                return;
            }

            MinMax(ref x1, ref x2);
            MinMax(ref y1, ref y2);
            MinMax(ref z1, ref z2);
            if (x2 - x1 == 0)
            {
                x2++;
            }
            if (y2 - y1 == 0)
            {
                y2++;
            }
            if (z2 - z1 == 0)
            {
                z2++;
            }
            double scaleX = (double)pal.SizeX / (x2 - x1);
            double scaleY = (double)pal.SizeY / (y2 - y1);
            double scaleZ = (double)pal.SizeZ / (z2 - z1);

            for (int z = z1; z < z2; z++)
            {
                for (int y = y1; y < y2; y++)
                {
                    for (int x = x1; x < x2; x++)
                    {
                        double scaledx = (x - x1) * scaleX;
                        double scaledy = (y - y1) * scaleY;
                        double scaledz = (z - z1) * scaleZ;
                        ulong  b       = pal.GetRgba((int)scaledx, (int)scaledy, (int)scaledz);
                        if (b != 0)
                        {
                            CellProperties cp = pal.GetProperty((int)scaledx, (int)scaledy, (int)scaledz);
                            bgc.Grid.Plot(x, y, z, cp);
                        }
                    }
                }
            }
        }
コード例 #21
0
        public override Object getCellPrefabFor(GameObject cell)
        {
            PrefabType type = PrefabUtility.GetPrefabType(cell);

            if (type == PrefabType.PrefabInstance)
            {
                return(PrefabUtility.GetPrefabObject(cell));
            }

            Cell c = cell.GetComponent <Cell>();

            string path = "Assets/CellPrefabs/" + Mathf.CeilToInt(c.Properties.height) + "/";

            Object prefab = null;

            if (AssetDatabase.IsValidFolder(path))
            {
                string[] prefabs = AssetDatabase.FindAssets(c.Properties.ToString(), new string[] { path });
                if (prefabs != null && prefabs.Length > 0)
                {
                    prefab = AssetDatabase.LoadAssetAtPath(prefabs[0], typeof(Object));
                }
            }
            else
            {
                AssetDatabase.CreateFolder("Assets/CellPrefabs", Mathf.CeilToInt(c.Properties.height) + "");
            }

            if (prefab == null)
            {
                prefab = PrefabUtility.CreateEmptyPrefab(path);

                CellProperties properties = c.Properties;

                /*Material myMat = new Material(Shader.Find("Transparent/Cutout/Diffuse"));
                 * texture.filterMode = FilterMode.Point;
                 * myMat.SetTexture("_MainTex", texture);
                 * this.GetComponent<Renderer>().sharedMaterial = myMat;*/
            }


            return(prefab);
        }
コード例 #22
0
ファイル: GameManager.cs プロジェクト: TheDiG3/GameOfLife
    /**
     * <summary> Builds the grid based on the rows and columns specified inside the class. </summary>
     */
    private void buildGrid()
    {
        int local_grid_rows    = int.Parse(grid_rows_);
        int local_grid_columns = int.Parse(grid_columns_);

        // This is actually only needed for the first time the buildGrid method is called
        // and to make sure that the game objects grid contains any object to destroy.
        if (game_objects_grid_ != null)
        {
            // I need to destroy the previous cells to avoid conflicts with the new ones.
            foreach (GameObject temp_previous_cell in game_objects_grid_)
            {
                Destroy(temp_previous_cell);
            }
        }

        // Creates a new empty grid.
        game_grid_         = new GameSimulator.ECellState[local_grid_rows, local_grid_columns];
        game_objects_grid_ = new GameObject[local_grid_rows, local_grid_columns];

        // Temporary game object used to store the reference for the newly created cell so that I can parent it in the scene hierarchy.
        GameObject temp_cell_reference;

        // Temporary reference to the GRID in the hierarchy used for easier organization of the objects and parenting.
        GameObject temp_hierarchy_reference = GameObject.Find("GRID");

        for (int cycle_row_index = 0; cycle_row_index < local_grid_rows; cycle_row_index++)
        {
            for (int cycle_column_index = 0; cycle_column_index < local_grid_columns; cycle_column_index++)
            {
                temp_cell_reference = (GameObject)Instantiate(cell_prefab_,
                                                              new Vector2(cycle_column_index - local_grid_columns / 2, -cycle_row_index + local_grid_rows / 2),
                                                              Quaternion.identity);
                temp_cell_reference.transform.parent = temp_hierarchy_reference.transform;
                CellProperties temp_cell_properties = temp_cell_reference.GetComponent <CellProperties>();
                temp_cell_properties.cell_column_ = cycle_column_index;
                temp_cell_properties.cell_row_    = cycle_row_index;
                temp_cell_properties.cell_state_  = GameSimulator.ECellState.DEAD;
                game_grid_[cycle_row_index, cycle_column_index]         = GameSimulator.ECellState.DEAD;
                game_objects_grid_[cycle_row_index, cycle_column_index] = temp_cell_reference;
            }
        }
    }
コード例 #23
0
ファイル: Cell.cs プロジェクト: gitter-badger/IsoUnity
    // Deserialization moment
    void Awake()
    {
#if UNITY_EDITOR
        if (Application.isEditor && !Application.isPlaying)
        {
            // Code to prevent losing information from old versions
            if (faces != null && faces.Length != 0)
            { // The first time i have to initialize those
                FaceNoSC[] nfaces = new FaceNoSC[faces.Length];
                for (int i = 0; i < faces.Length; i++)
                {
                    if (faces[i] == null)
                    {
                        // Debug.Log("Null face detected at " + this + " at map " + Map);
                        break;
                    }

                    nfaces[i]                = new FaceNoSC();
                    nfaces[i].Texture        = faces[i].Texture;
                    nfaces[i].TextureMapping = faces[i].TextureMapping;
                }


                this.properties = new CellProperties(height, topType, cellTopRotation, 1, faces != null ? nfaces : new FaceNoSC[0]);
                Debug.Log("No era null");
                faces = null;
            }
        }
#endif

        // This will prevent older versions to lose face information about textures.

        /*if (this.faces == null) {
         *      faces = new Face[faceTextures.Length];
         *      for (int i = 0; i< faces.Length; i++) {
         *              faces[i].Texture = faceTextures[i];
         *              faces[i].TextureMapping = faceMappings[i];
         *      }
         *      faceTextures = null;
         *      faceMappings = null;
         * }		*/
    }
コード例 #24
0
        private void SetTableCells()
        {
            System.Console.WriteLine(@"Enter cell values");
            for (var rowIndex = 0; rowIndex < RowCount; rowIndex++)
            {
                var values = GetValueFromConsoleByTab();
                ThrowIfIncorrectInputSize(values, ColumnCount);

                for (var columnIndex = 0; columnIndex < values.Length; columnIndex++)
                {
                    ICellProperties cellProperties = new CellProperties(values[columnIndex]);
                    cellProperties.SetupProperties();

                    ICell cell = new Cell(columnIndex, rowIndex, cellProperties);
                    cell.SetupProperties();

                    Cells.Add(cell);
                }
            }
        }
コード例 #25
0
    public CellProperties GetValue(int column, int row)
    {
        bool invalidColumn = (column < 0) || (column >= Width);
        bool invalidRow    = (row < 0) || (row >= Height);

        int index = GetCellIndex(column, row);

        if (invalidColumn || invalidRow || index >= m_CellsProperties.Length)
        {
            CellProperties emptyCell = new CellProperties
            {
                m_Type = CellType.Type.None,
            };

            return(emptyCell);
        }

        // In case previously save map is
        return(m_CellsProperties[index]);
    }
コード例 #26
0
        public static string GetCellPropertyString(CellProperties property)
        {
            switch (property)
            {
            case CellProperties.Value:
            case CellProperties.Text:
            case CellProperties.Width:
                return(property.ToString());

            case CellProperties.Rotation:
                return("Orientation");

            case CellProperties.Font_Bold:
                return("Font.Bold");

            case CellProperties.Font_Italic:
                return("Font.Italic");

            case CellProperties.Font_Underline:
                return("Font.Underline");

            case CellProperties.Font_Name:
                return("Font.Name");

            case CellProperties.MergeAreaCount:
                return("MergeArea.Count");

            case CellProperties.PatternColor:
                return("Interior.PatternColorIndex");

            case CellProperties.PatternBackgroundColor:
                return("Interior.ColorIndex");

            case CellProperties.Comment:
                return("Comment");

            default:
                throw new NotSupportedException(property.ToString());
            }
        }
コード例 #27
0
ファイル: Cell.cs プロジェクト: gitter-badger/IsoUnity
    private static void extractFacesFromMesh(Mesh mesh, CellProperties properties)
    {
        int numLateralFaces = Mathf.CeilToInt(properties.height) * 4;

        //Numero de vertices de la ultima capa
        int[] topFacesNumVertex = (properties.top == CellTopType.flat) ? new int[1] {
            4
        } : new int[4] {
            3, 4, 3, 4
        };

        int verticesForThisFace;
        int totalVertices = 0;

        for (int i = 0; i < numLateralFaces + topFacesNumVertex.Length; i++)
        {
            // Calculamos cuantos vertices tendra la cara. Si es lateral 4 y sino, los que esten preestablecidos.
            verticesForThisFace = (i < numLateralFaces)?4:topFacesNumVertex[i - numLateralFaces];
            FaceNoSC.extractFaceInfoFromMesh(mesh, verticesForThisFace, totalVertices, properties.faces[i]);
            totalVertices += verticesForThisFace;
        }
    }
コード例 #28
0
ファイル: MizJam1Game.cs プロジェクト: BasicLich/MizJam1-5
        private void drawLeftWindow()
        {
            screenSpriteBatch.Draw(whitePixel, new Rectangle(0, 0, 420, 1080), Global.Colors.Background2);
            screenSpriteBatch.Draw(windowBorder, new Rectangle(0, 0, 420, 1080), Global.Colors.Main1);

            Cell cell;

            if ((cell = currentLevel.MouseOverCell).ID != 0)
            {
                string infoTitles  = "SOLID: \nDIFF: ";
                string information = "\n{0}\n{1}";

                CellProperties props = cell.Properties;

                information = string.Format(information,
                                            props.IsSolid ? "YES" : "NO",
                                            props.Difficulty);
                int width = (int)Math.Ceiling(mizjamSmallFont.MeasureString(infoTitles).X);
                screenSpriteBatch.DrawString(mizjamSmallFont, "CURRENT TILE\n" + infoTitles, new Vector2(48), Global.Colors.Main1);
                screenSpriteBatch.DrawString(mizjamSmallFont, information, new Vector2(48 + width, 48), Global.Colors.Main1);
            }
        }
コード例 #29
0
    //Used to spawn in a new grid of cells when the game is being started
    public void SetupGrid(int GridSize)
    {
        //Store the size of the grid that we are creating
        this.GridSize = GridSize;

        //Start by initializing our 2D array where reference to each cell will be stored
        CellGrid = new GameObject[GridSize, GridSize];

        //Create a new Vector3 structure which will be passed into each Instantiate call when placing the grid cells
        Vector3 CellPosition = new Vector3(0, 0, 0);

        //Loop along the X axis to create each row of cells
        for (int x = 0; x < GridSize; x++)
        {
            //For each row, loop along and place each cell for the matching columns
            for (int z = 0; z < GridSize; z++)
            {
                //Spawn a new CellPrefab at the next CellPosition
                GameObject NewCell = GameObject.Instantiate(CellPrefab, CellPosition, Quaternion.identity);

                //Store the new cells grid coordinates inside the cells properties component
                CellProperties NewCellProperties = NewCell.GetComponent <CellProperties>();
                NewCellProperties.CellRow    = x + 1;
                NewCellProperties.CellColumn = z + 1;

                //Store the new cell in our 2D array
                CellGrid[x, z] = NewCell;

                //Increment the CellPosition X position value for spawning in the next cell
                CellPosition.x += 1.1f;
            }

            //After each row is complete, reset the X value and increment the ZPos value for spawning in the next row of cells
            CellPosition.x  = 0;
            CellPosition.z += 1.1f;
        }
    }
コード例 #30
0
ファイル: Program.cs プロジェクト: katascope/Glyphics2
        static void BirdsEye(Grid grid, Grid targetGrid, int ox, int oy)
        {
            for (int y = 0; y < grid.SizeY; y++)
            {
                for (int z = 0; z < grid.SizeZ; z++)
                {
                    for (int x = 0; x < grid.SizeX; x++)
                    {
                        CellProperties cp = grid.GetProperty(x, y, z);
                        byte           r, g, b, a;
                        RasterLib.RasterApi.Ulong2Rgba(cp.Rgba, out r, out g, out b, out a);
                        if (r + g + b > 10)
                        {
                            //targetGrid.Plot(x + ox, y + oy, 0, cp);
                            grid.Plot(x, z, 0, cp);
                        }
                    }
                }
            }

            for (int y = 0; y < grid.SizeY / 2; y++)
            {
                for (int x = 0; x < grid.SizeX / 2; x++)
                {
                    CellProperties cp1 = grid.GetProperty(x * 2, y * 2, 0);
                    CellProperties cp2 = grid.GetProperty(x * 2 + 1, y * 2, 0);
                    if (cp1.Rgba > 0)
                    {
                        targetGrid.Plot(x + ox, y + oy, 0, cp1);
                    }
                    if (cp2.Rgba > 0)
                    {
                        targetGrid.Plot(x + ox, y + oy, 0, cp2);
                    }
                }
            }
        }
コード例 #31
0
        private static void Extrusion(Grid grid, Grid gridImage, int div)
        {
            for (int y = 0; y < gridImage.SizeY; y++)
            {
                for (int x = 0; x < gridImage.SizeX; x++)
                {
                    CellProperties cp = gridImage.GetProperty(x, y, 0);

                    byte r, g, b, a;
                    RasterLib.RasterApi.Ulong2Rgba(cp.Rgba, out r, out g, out b, out a);

                    int lum    = (r + g + b) / 3;
                    int height = (lum) / div;

                    if (height > 0)
                    {
                        for (int barY = 0; barY <= height; barY++)
                        {
                            grid.Plot(x, barY, y, cp);
                        }
                    }
                }
            }
        }
コード例 #32
0
ファイル: MeshFactory.cs プロジェクト: nvidiosin/isoAbbeyTFG
 public override void Generate(CellProperties properties)
 {
     faces = regenerateFaces(properties.faces, properties.height, properties.top, properties.width, properties.orientation);
     texture = getTextureAndGenerateUVs(faces);
     mesh =  generateMeshFromFaces(faces);
 }
コード例 #33
0
ファイル: MeshFactory.cs プロジェクト: nvidiosin/isoAbbeyTFG
 public abstract void Generate(CellProperties properties);
コード例 #34
0
        /// <summary>
        /// Changes a single property of a cell
        /// </summary>
        /// <param name="cell">The cell to modify</param>
        /// <param name="propertyName">The property to change</param>
        /// <param name="newValue">The new value of the property</param>
        public void ChangeCellProperty(IHTMLTableCell cell, CellProperties propertyName, string newValue)
        {
            IHTMLElement cellElement = cell as IHTMLElement; ;
            if (cellElement != null)
            {
                switch (propertyName)
                {
                    case CellProperties.BackgroundColor:
                        cellElement.style.backgroundColor = newValue;
                        break;

                    case CellProperties.BorderColor:
                        cellElement.style.borderColor = newValue;
                        break;

                    case CellProperties.BorderSize:
                        if (newValue != null)
                        {
                            cellElement.style.borderWidth = newValue;
                        }
                        break;

                    case CellProperties.Height:
                        if (newValue != null)
                        {
                            cellElement.style.height = newValue;
                        }
                        break;

                    case CellProperties.Width:
                        if (newValue != null)
                        {
                            cellElement.style.width = newValue;
                        }
                        break;

                    case CellProperties.Rowspan:
                        if(newValue != null)
                        {
                            cell.rowSpan = int.Parse(newValue);
                        }
                        break;

                    case CellProperties.Colspan:
                        if (newValue != null)
                        {
                            cell.colSpan = int.Parse(newValue);
                        }
                        break;
                }
            }
        }
コード例 #35
0
ファイル: Cell.cs プロジェクト: nvidiosin/isoAbbeyTFG
    private static void extractFacesFromMesh(Mesh mesh, CellProperties properties)
    {
        int numLateralFaces = Mathf.CeilToInt(properties.height) * 4;
        //Numero de vertices de la ultima capa
        int[] topFacesNumVertex = (properties.top == CellTopType.flat) ? new int[1] { 4 } : new int[4] { 3, 4, 3, 4 };

        int verticesForThisFace;
        int totalVertices = 0;
        for (int i = 0; i < numLateralFaces + topFacesNumVertex.Length; i++) {
            // Calculamos cuantos vertices tendra la cara. Si es lateral 4 y sino, los que esten preestablecidos.
            verticesForThisFace = (i < numLateralFaces)?4:topFacesNumVertex[i - numLateralFaces];
            FaceNoSC.extractFaceInfoFromMesh(mesh, verticesForThisFace, totalVertices, properties.faces[i]);
            totalVertices += verticesForThisFace;
        }
    }
コード例 #36
0
ファイル: Cell.cs プロジェクト: nvidiosin/isoAbbeyTFG
    // Deserialization moment
    void Awake()
    {
        #if UNITY_EDITOR

        if (Application.isEditor && !Application.isPlaying)
        {

            // Code to prevent losing information from old versions
            if (faces != null && faces.Length != 0)
            { // The first time i have to initialize those

                FaceNoSC[] nfaces = new FaceNoSC[faces.Length];
                for (int i = 0; i < faces.Length; i++)
                {
                    if (faces[i] == null)
                    {
                        // Debug.Log("Null face detected at " + this + " at map " + Map);
                        break;
                    }

                    nfaces[i] = new FaceNoSC();
                    nfaces[i].Texture = faces[i].Texture;
                    nfaces[i].TextureMapping = faces[i].TextureMapping;
                }

                this.properties = new CellProperties(height, topType, cellTopRotation, 1, faces != null ? nfaces : new FaceNoSC[0]);
                Debug.Log("No era null");
                faces = null;
            }

        }
        #endif

        // This will prevent older versions to lose face information about textures.
        /*if (this.faces == null) {
            faces = new Face[faceTextures.Length];
            for (int i = 0; i< faces.Length; i++) {
                faces[i].Texture = faceTextures[i];
                faces[i].TextureMapping = faceMappings[i];
            }
            faceTextures = null;
            faceMappings = null;
        }		*/
    }
コード例 #37
0
ファイル: MyXlsTestFixture.cs プロジェクト: shi5588/shi5588
 public static void AssertPropertyViaExcelOle(string fileName, CellProperties property, string expected, string message)
 {
     AssertPropertyViaExcelOle(1, 1, 1, fileName, property, expected, message);
 }
コード例 #38
0
ファイル: MyXlsTestFixture.cs プロジェクト: shi5588/shi5588
 public static void AssertPropertyViaExcelOle(int sheetIndex, int rowIndex, int columnIndex, string fileName, CellProperties property, string expected, string message)
 {
     string actual = GetCellPropertyViaExcelOle(sheetIndex, rowIndex, columnIndex, fileName, property);
     Assert.AreEqual(expected, actual, message);
 }
コード例 #39
0
ファイル: MyXlsTestFixture.cs プロジェクト: shi5588/shi5588
 public static string GetCellPropertyViaExcelOle(int sheetIndex, int rowIndex, int columnIndex, string fileName, CellProperties property)
 {
     Process proc = new Process();
     ProcessStartInfo startInfo = new ProcessStartInfo();
     startInfo.FileName = "cscript.exe";
     string sourceScript = Path.Combine(TestsConfig.ScriptsFolder, "ReadXlsCellProperty.vbs");
     string propertyScript = string.Format("ReadXlsCell{0}.vbs", property);
     if (File.Exists(propertyScript))
         File.Delete(propertyScript);
     string script = File.ReadAllText(sourceScript);
     script = script.Replace(">>SheetIndex<<", sheetIndex.ToString());
     script = script.Replace(">>RowIndex<<", rowIndex.ToString());
     script = script.Replace(">>ColumnIndex<<", columnIndex.ToString());
     script = script.Replace(">>CellProperty<<", GetCellPropertyString(property));
     File.WriteAllText(propertyScript, script);
     startInfo.Arguments = string.Format("{0} //B //NoLogo \"{1}\"", propertyScript, fileName);
     startInfo.CreateNoWindow = true;
     startInfo.RedirectStandardOutput = true;
     startInfo.RedirectStandardError = true;
     startInfo.UseShellExecute = false;
     proc.StartInfo = startInfo;
     proc.Start();
     proc.WaitForExit();
     string output = proc.StandardOutput.ReadToEnd();
     if (string.IsNullOrEmpty(output))
         output = proc.StandardError.ReadToEnd();
     File.Delete(propertyScript);
     return output;
 }
コード例 #40
0
ファイル: MyXlsTestFixture.cs プロジェクト: shi5588/shi5588
 public static string GetCellPropertyViaExcelOle(string fileName, CellProperties property)
 {
     return GetCellPropertyViaExcelOle(1, 1, 1, fileName, property);
 }