Esempio n. 1
0
    private void Awake()
    {
        this.clickable            = GetComponent <Clickable>();
        this.clickable.Click     += Clickable_Click;
        this.clickable.MouseOver += Clickable_MouseOver;
        this.clickable.MouseOut  += Clickable_MouseOut;

        SetHighlighted(false);

        this.SlotState = SlotStates.EMPTY;
    }
Esempio n. 2
0
        /// <summary>
        /// Create a new slot
        /// </summary>
        /// <param name="gc">Owning graph controller</param>
        /// <param name="type">Input/Output slot</param>
        /// <param name="firstOwner">Node where there slot resides</param>
        internal Slot(IGraphController gc, SlotType type, IVisualNode firstOwner)
        {
            if (gc == null || firstOwner == null)
                throw new ArgumentNullException();

            this.graphController = gc as GraphController;
            Validity.Assert(this.graphController != null);
            IdGenerator idGenerator = this.graphController.GetIdGenerator();

            this.slotType = type;
            this.version = Slot.Version.Current;
            this.slotId = idGenerator.GetNextId(ComponentType.Slot);
            this.slotState = SlotStates.Visible;
            this.owners.Add(firstOwner.NodeId);
        }
Esempio n. 3
0
        /// <summary>
        /// Create a new slot
        /// </summary>
        /// <param name="gc">Owning graph controller</param>
        /// <param name="type">Input/Output slot</param>
        /// <param name="firstOwner">Node where there slot resides</param>
        internal Slot(IGraphController gc, SlotType type, IVisualNode firstOwner)
        {
            if (gc == null || firstOwner == null)
            {
                throw new ArgumentNullException();
            }

            this.graphController = gc as GraphController;
            Validity.Assert(this.graphController != null);
            IdGenerator idGenerator = this.graphController.GetIdGenerator();

            this.slotType  = type;
            this.version   = Slot.Version.Current;
            this.slotId    = idGenerator.GetNextId(ComponentType.Slot);
            this.slotState = SlotStates.Visible;
            this.owners.Add(firstOwner.NodeId);
        }
Esempio n. 4
0
        public bool Deserialize(IStorage storage)
        {
            if (storage == null)
            {
                throw new ArgumentNullException("storage");
            }

            if (storage.ReadUnsignedInteger(FieldCode.SlotSignature) != Configurations.SlotSignature)
            {
                throw new InvalidOperationException("Invalid input data {9D939DA2}");
            }

            try
            {
                this.slotType  = (SlotType)storage.ReadInteger(FieldCode.SlotType);
                this.version   = (Slot.Version)storage.ReadInteger(FieldCode.SlotVersion);
                this.slotId    = storage.ReadUnsignedInteger(FieldCode.SlotId);
                this.slotState = (SlotStates)storage.ReadInteger(FieldCode.SlotState);

                int ownersCount = storage.ReadInteger(FieldCode.OwnersCount);
                this.owners.Clear();
                for (int i = 0; i < ownersCount; i++)
                {
                    owners.Add(storage.ReadUnsignedInteger(FieldCode.Owners));
                }

                int connectingSlotsCount = storage.ReadInteger(FieldCode.ConnectingSlotsCount);
                this.connectingSlots.Clear();
                for (int i = 0; i < connectingSlotsCount; i++)
                {
                    connectingSlots.Add(storage.ReadUnsignedInteger(FieldCode.ConnectingSlots));
                }

                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message + "\n Slot deserialization failed.");
                return(false);
            }
        }
Esempio n. 5
0
        public bool Deserialize(IStorage storage)
        {
            if (storage == null)
                throw new ArgumentNullException("storage");

            if (storage.ReadUnsignedInteger(FieldCode.SlotSignature) != Configurations.SlotSignature)
                throw new InvalidOperationException("Invalid input data {9D939DA2}");

            try
            {
                this.slotType = (SlotType)storage.ReadInteger(FieldCode.SlotType);
                this.version = (Slot.Version)storage.ReadInteger(FieldCode.SlotVersion);
                this.slotId = storage.ReadUnsignedInteger(FieldCode.SlotId);
                this.slotState = (SlotStates)storage.ReadInteger(FieldCode.SlotState);

                int ownersCount = storage.ReadInteger(FieldCode.OwnersCount);
                this.owners.Clear();
                for (int i = 0; i < ownersCount; i++)
                    owners.Add(storage.ReadUnsignedInteger(FieldCode.Owners));

                int connectingSlotsCount = storage.ReadInteger(FieldCode.ConnectingSlotsCount);
                this.connectingSlots.Clear();
                for (int i = 0; i < connectingSlotsCount; i++)
                    connectingSlots.Add(storage.ReadUnsignedInteger(FieldCode.ConnectingSlots));

                return true;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message + "\n Slot deserialization failed.");
                return false;
            }
        }
Esempio n. 6
0
 public void AssignContent(GameObject buildable)
 {
     this.SlotState        = SlotStates.OCCUPIED;
     this.currentBuildable = buildable;
 }
Esempio n. 7
0
        void Update()
        {
            if (slotState == SlotStates.hover)
            {
                if (GameManager.Instance.gamestate != GameStates.play)
                {
                    slotState = SlotStates.idle;
                    return;
                }

                if (glowLerpFactor > 1f)
                {
                    glowLerpFactor = 0f;
                    float tempGlow = minGlow;
                    minGlow = maxGlow;
                    maxGlow = tempGlow;

                    float tempTexGlow = minTexGlow;
                    minTexGlow = maxTexGlow;
                    maxTexGlow = minTexGlow;
                }

                glowLerpFactor += Time.deltaTime * glowLerpSpeed;
                curGlow         = Mathf.Lerp(minGlow, maxGlow, glowLerpFactor);
                curTexGlow      = Mathf.Lerp(curTexGlow, minTexGlow, glowLerpFactor);

                if (isCombinedSlot)
                {
                    for (int i = 0; i < rends.Length; i++)
                    {
                        rends[i].material.SetFloat("_MKGlowPower", curGlow);
                        rends[i].material.SetFloat("_MKGlowTexStrength", curTexGlow);
                    }
                }
                else
                {
                    rend.material.SetFloat("_MKGlowPower", curGlow);
                    rend.material.SetFloat("_MKGlowTexStrength", curTexGlow);
                }
            }
            else    // idle
            {
                if (isCombinedSlot)
                {
                    for (int i = 0; i < rends.Length; i++)
                    {
                        if (rends[i].material.GetFloat("_MKGlowPower") != 0f)
                        {
                            rends[i].material.SetFloat("_MKGlowPower", 0f);
                        }

                        if (rends[i].material.GetFloat("_MKGlowTexStrength") != 0f)
                        {
                            rends[i].material.SetFloat("_MKGlowTexStrength", 0f);
                        }
                    }
                }
                else
                {
                    if (rend.material.GetFloat("_MKGlowPower") != 0f)
                    {
                        rend.material.SetFloat("_MKGlowPower", 0f);
                    }

                    if (rend.material.GetFloat("_MKGlowTexStrength") != 0f)
                    {
                        rend.material.SetFloat("_MKGlowTexStrength", 0f);
                    }
                }
            }
        }