Esempio n. 1
0
 // Use this for initialization
 void Awake()
 {
     _ItselfSR          = GetComponent <SpriteRenderer>();
     _InteractionUIText = GameObject.Find("InteractionUIText").GetComponent <Text>();
     _Active            = null;
     _ControlMeta       = Camera.main.GetComponent <ControlMeta>();
 }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the class.
 /// </summary>
 public ControlModel(string code, string topic)
 {
     Code  = code ?? throw new ArgumentNullException(nameof(code));
     Topic = topic ?? throw new ArgumentNullException(nameof(topic));
     Meta  = new ControlMeta {
         Name = code
     };
 }
Esempio n. 3
0
        /// <summary>
        /// Builds the channels.
        /// </summary>
        private void BuildCnls(DeviceConfigEntry entry, ControlModel controlModel,
                               ChannelNumberingOptions options, int?objNum, int deviceNum, ref int cnlNum)
        {
            string      namePrefix  = options.PrependDeviceName ? entry.DeviceEntity.Name + " - " : "";
            ControlMeta controlMeta = controlModel.Meta;
            int?        formatID    = GetFormatID(controlMeta);
            int?        quantityID  = GetQuantityID(controlMeta);
            int?        unitID      = GetUnitID(controlMeta);

            // control value
            entry.Cnls.Add(new Cnl
            {
                CnlNum     = cnlNum++,
                Active     = true,
                Name       = namePrefix + controlMeta.Name + " Last",
                CnlTypeID  = CnlTypeID.Input,
                ObjNum     = objNum,
                DeviceNum  = deviceNum,
                TagCode    = controlModel.Code,
                FormatID   = formatID,
                QuantityID = quantityID,
                UnitID     = unitID
            });

            // control error
            entry.Cnls.Add(new Cnl
            {
                CnlNum    = cnlNum++,
                Active    = true,
                Name      = namePrefix + controlMeta.Name + " Error",
                CnlTypeID = CnlTypeID.Input,
                ObjNum    = objNum,
                DeviceNum = deviceNum,
                TagCode   = controlModel.Code + "_error"
            });

            // calculated channel
            entry.Cnls.Add(new Cnl
            {
                CnlNum         = cnlNum++,
                Active         = true,
                Name           = namePrefix + controlMeta.Name,
                CnlTypeID      = controlMeta.ReadOnly ? CnlTypeID.Calculated : CnlTypeID.CalculatedOutput,
                ObjNum         = objNum,
                DeviceNum      = deviceNum,
                TagCode        = controlModel.Code,
                FormulaEnabled = true,
                InFormula      = "WB_CalcControl()",
                FormatID       = formatID,
                QuantityID     = quantityID,
                UnitID         = unitID,
                EventMask      = ControlEventMask
            });
        }
Esempio n. 4
0
        /// <summary>
        /// Gets the control unit.
        /// </summary>
        private int?GetUnitID(ControlMeta controlMeta)
        {
            Unit unit = controlMeta.Type switch
            {
                "temperature" => project.ConfigDatabase.GetUnitByCode(UnitCode.Celsius),
                "voltage" => project.ConfigDatabase.GetUnitByCode(UnitCode.Volt),
                _ => null
            };

            return(unit?.UnitID);
        }
Esempio n. 5
0
        /// <summary>
        /// Gets the control quantity.
        /// </summary>
        private int?GetQuantityID(ControlMeta controlMeta)
        {
            Quantity quantity = controlMeta.Type switch
            {
                "temperature" => project.ConfigDatabase.GetQuantityByCode(QuantityCode.Temperature),
                "voltage" => project.ConfigDatabase.GetQuantityByCode(QuantityCode.Voltage),
                _ => null
            };

            return(quantity?.QuantityID);
        }
Esempio n. 6
0
        /// <summary>
        /// Gets the control format.
        /// </summary>
        private int?GetFormatID(ControlMeta controlMeta)
        {
            Format format = controlMeta.Type switch
            {
                "pushbutton" => project.ConfigDatabase.GetFormatByCode(FormatCode.Execute),
                "switch" => project.ConfigDatabase.GetFormatByCode(FormatCode.OffOn),
                _ => null
            };

            return(format?.FormatID);
        }
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    //override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
    //
    //}

    // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        // player = GameObject.Find(“Player”);
        ControlMeta _ControlMeta = GameObject.Find("CharacterPivot").GetComponent <ControlMeta>();
        float       horizontal   = _ControlMeta._KineticControl.animationDirection.x;
        float       vertical     = _ControlMeta._KineticControl.animationDirection.z;

        hrznt  = horizontal;
        vertic = vertical;
        Vector2 input = new Vector2(horizontal, vertical);

        animator.SetFloat(m_HashHorizontalPara, input.x, m_Damping, Time.deltaTime);
        animator.SetFloat(m_HashVerticalPara, input.y, m_Damping, Time.deltaTime);
    }
Esempio n. 8
0
 protected override void SetControl(ControlMeta meta)
 {
     base.SetControl(meta);
 }
Esempio n. 9
0
 /// <summary>
 /// Updates the control information.
 /// </summary>
 public void UpdateMeta(ControlMeta controlMeta)
 {
     Meta = controlMeta ?? throw new ArgumentNullException(nameof(controlMeta));
 }
Esempio n. 10
0
 protected virtual void SetControl(ControlMeta meta)
 {
     commander = meta;
     commander.AddControls(this);
     _player = commander.GetPlayer();
 }
Esempio n. 11
0
 void Awake()
 {
     gameObject.layer = LayerMask.NameToLayer("interactionUILayer");
     _ControlMeta     = Camera.main.GetComponent <ControlMeta>();
 }