Ejemplo n.º 1
0
    public void toggleElement(ElementIdentity element)
    {
        CardFilterObject filter = cardsView.filter;

        // no list exists
        if (filter.elements == null)
        {
            List <ElementIdentity> elements = new List <ElementIdentity>();
            elements.Add(element);
            filter.elements = elements;
        }
        else if (!filter.elements.Contains(element))
        {
            Debug.Log("Adding element");
            filter.elements.Add(element);
        }
        else
        {
            Debug.Log("Removing element");
            filter.elements.Remove(element);
        }
        foreach (ElementIdentity id in filter.elements)
        {
            Debug.Log(id);
        }
    }
Ejemplo n.º 2
0
    protected override void OnValueUpdated(object value)
    {
        //Debug.Log("EID Change");
        ElementIdentity eId        = (ElementIdentity)value;
        string          spriteName = null;

        switch (eId)
        {
        case ElementIdentity.Fire:
            spriteName = "fire background";
            break;

        case ElementIdentity.Water:
            spriteName = "water background";
            break;

        case ElementIdentity.Wind:
            spriteName = "wind background";
            break;

        case ElementIdentity.Earth:
            spriteName = "earth background";
            break;

        case ElementIdentity.Nuetral:
            spriteName = "nuetral background";
            break;
        }
        image.sprite = Resources.Load <Sprite>(spriteName);
    }
Ejemplo n.º 3
0
        /// <summary>
        /// Returns a List with all available Vertices
        /// </summary>
        /// <returns></returns>
        public SimPe.Geometry.Vectors4f GetVectors(ElementIdentity id)
        {
            SimPe.Geometry.Vectors4f ret = new SimPe.Geometry.Vectors4f();
            if (this.Link != null)
            {
                GmdcElement e = this.Link.FindElementType(id);
                if (e != null)
                {
                    int nr = this.Link.GetElementNr(e);

                    for (int i = 0; i < Link.ReferencedSize; i++)
                    {
                        GmdcElementValueBase    vb = Link.GetValue(nr, i);
                        SimPe.Geometry.Vector4f v;
                        if (vb is GmdcElementValueOneInt)
                        {
                            GmdcElementValueOneInt oi = (GmdcElementValueOneInt)vb;
                            byte[] data = oi.Bytes;
                            if (data.Length == 4)
                            {
                                v = new SimPe.Geometry.Vector4f(data[0], data[1], data[2], data[3]);
                            }
                            else if (data.Length == 3)
                            {
                                v = new SimPe.Geometry.Vector4f(data[0], data[1], data[2]);
                            }
                            else if (data.Length == 2)
                            {
                                v = new SimPe.Geometry.Vector4f(data[0], data[1], 0);
                            }
                            else
                            {
                                v = new SimPe.Geometry.Vector4f(data[0], 0, 0);
                            }
                        }
                        else if (vb.Data.Length == 3)
                        {
                            v = new SimPe.Geometry.Vector4f(vb.Data[0], vb.Data[1], vb.Data[2]);
                        }
                        else if (vb.Data.Length == 2)
                        {
                            v = new SimPe.Geometry.Vector4f(vb.Data[0], vb.Data[1], 0);
                        }
                        else
                        {
                            v = new SimPe.Geometry.Vector4f(vb.Data[0], 0, 0);
                        }

                        ret.Add(v);
                    }
                }
            }

            return(ret);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Returns the first Element Referenced from this Link that implements
        /// the passed <see cref="ElementIdentity"/>.
        /// </summary>
        /// <param name="id">Identity you are looking for</param>
        /// <returns>null or the First mathcing Element</returns>
        public GmdcElement FindElementType(ElementIdentity id)
        {
            foreach (int i in this.ReferencedElement)
            {
                if (parent.Elements[i].Identity == id)
                {
                    return(parent.Elements[i]);
                }
            }

            return(null);
        }
Ejemplo n.º 5
0
    private Sprite elementIdToSprite(ElementIdentity eId)
    {
        switch (eId)
        {
        case ElementIdentity.Fire:
            return(fireBackground);

        case ElementIdentity.Water:
            return(waterBackground);

        case ElementIdentity.Wind:
            return(windBackground);

        case ElementIdentity.Earth:
            return(earthBackground);

        case ElementIdentity.Nuetral:
            return(nuetralBackground);

        default:
            return(earthBackground);
        }
    }
Ejemplo n.º 6
0
    private string elementIdToString(ElementIdentity eId)
    {
        switch (eId)
        {
        case ElementIdentity.Fire:
            return("fire background");

        case ElementIdentity.Water:
            return("earth background");

        case ElementIdentity.Wind:
            return("wind background");

        case ElementIdentity.Earth:
            return("water background");

        case ElementIdentity.Nuetral:
            return("earth background");

        default:
            return("earth background");
        }
    }
Ejemplo n.º 7
0
        /// <summary>
        /// Unserializes a BinaryStream into the Attributes of this Instance
        /// </summary>
        /// <param name="reader">The Stream that contains the FileData</param>
        public void Unserialize(System.IO.BinaryReader reader)
        {
            number = reader.ReadInt32();
            uint id = reader.ReadUInt32();

            identity    = (ElementIdentity)id;
            repeat      = reader.ReadInt32();
            blockformat = (SimPe.Plugin.Gmdc.BlockFormat)reader.ReadInt32();
            setformat   = (SimPe.Plugin.Gmdc.SetFormat)reader.ReadInt32();

            GmdcElementValueBase dummy = GetValueInstance();
            int len = reader.ReadInt32() / (4 * dummy.Size);

            data.Clear();
            for (int i = 0; i < len; i++)
            {
                dummy = GetValueInstance();
                dummy.Unserialize(reader);
                data.Add(dummy);
            }

            this.ReadBlock(reader, items);
        }
Ejemplo n.º 8
0
 public void setElementIdentity(ElementIdentity newId)
 {
     background.sprite = elementIdToSprite(newId);
 }