Exemple #1
0
        /// <summary>
        /// Called if the User is using his Thumb for this feature. Check if the Position to use on the thumbstick are set correctly in the Inspector.
        /// </summary>
        /// <returns>true if everything is set correctly</returns>
        private bool CheckGivenThumbParameter()
        {
            if (ActionButton == EControllersInput.LEFT_THUMBSTICK)
            {
                if (LeftClickThumbPosition == EThumbPosition.NONE &&
                    LeftTouchThumbPosition == EThumbPosition.NONE)
                {
                    Debug.LogError("VRSF : You need to assign a Thumb Position for the Left Thumbstick in this script : " + this.name);
                    return(false);
                }

                _thumbPos = _inputContainer.LeftThumbPosition;
            }
            else if (ActionButton == EControllersInput.RIGHT_THUMBSTICK)
            {
                if (RightClickThumbPosition == EThumbPosition.NONE &&
                    RightTouchThumbPosition == EThumbPosition.NONE)
                {
                    Debug.LogError("VRSF : You need to assign a Thumb Position for the Right Thumbstick in this script : " + this.name);
                    return(false);
                }

                _thumbPos = _inputContainer.RightThumbPosition;
            }

            return(true);
        }
Exemple #2
0
        static GenericMenu GetCategoryMenu(Vector2Variable current, System.Action <Vector2Variable> callback)
        {
            var menu = new GenericMenu();

            menu.AddItem(
                new GUIContent(DEFAULT_NAME),
                current == null,
                () => callback(null));

            ParallaxSettings.Current.Vector2Variables.ForEach(c => {
                menu.AddItem(
                    new GUIContent(GetVariableName(c)),
                    current == c,
                    () => callback(c));
            });

            menu.AddSeparator("");

            menu.AddItem(
                new GUIContent("Create Vector2"),
                false,
                () => Selection.activeObject = ParallaxSettings.Current);

            return(menu);
        }
Exemple #3
0
    private void AddValueToList(FieldInfo f)
    {
        IBaseVariable variable = null;

        if (f.FieldType.ToString() == "System.String")
        {
            variable = new StringVariable();
        }
        else if (f.FieldType.ToString() == "System.Int32")
        {
            variable = new IntegerVariable();
        }
        else if (f.FieldType.ToString() == "System.Single")
        {
            variable = new FloatVariable();
        }
        else if (f.FieldType.ToString() == "System.Boolean")
        {
            variable = new BooleanVariable();
        }
        else if (f.FieldType.ToString() == "System.String[]")
        {
            variable = new StringVariableArray();
        }
        else if (f.FieldType.ToString() == "System.Int32[]")
        {
            variable = new IntegerVariableArray();
        }
        else if (f.FieldType.ToString() == "System.Single[]")
        {
            variable = new FloatVariableArray();
        }
        else if (f.FieldType.ToString() == "System.Boolean[]")
        {
            variable = new BooleanVariableArray();
        }
        else if (f.FieldType.ToString() == "UnityEngine.Vector2")
        {
            variable = new Vector2Variable();
        }
        else if (f.FieldType.ToString() == "UnityEngine.Vector3")
        {
            variable = new Vector3Variable();
        }
        else if (f.FieldType.ToString() == "UnityEngine.Vector2[]")
        {
            variable = new Vector2VariableArray();
        }
        else if (f.FieldType.ToString() == "UnityEngine.Vector3[]")
        {
            variable = new Vector3VariableArray();
        }
        if (variable != null)
        {
            variable.value = f.GetValue(this);
            ListValue.Add((string)f.Name, variable);
        }
    }
Exemple #4
0
        static string GetVariableName(Vector2Variable variable)
        {
            if (variable == null)
            {
                return(DEFAULT_NAME);
            }

            return(variable.DisplayName);
        }
    void Awake()
    {
        Damage    = ScriptableObject.Instantiate(Damage);
        Direction = ScriptableObject.Instantiate(Direction);
        Velocity  = ScriptableObject.Instantiate(Velocity);

        ProjectileMovement movement = GetComponent <ProjectileMovement>();

        movement.Direction.InstanceVariable = Direction;
        movement.Velocity.InstanceVariable  = Velocity;

        ProjectileDamage damage = GetComponent <ProjectileDamage>();

        damage.Damage.InstanceVariable = Damage;
    }
Exemple #6
0
        /// <summary>
        /// Set an Vector2Variable with the given tag.
        /// </summary>
        /// <param name="tag"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public void SetVector2(string tag, Vector2 value)
        {
            foreach (var variable in Vector2Variables)
            {
                if (variable.Tag == tag)
                {
                    variable.Value = value;
                    return;
                }
            }
            //Not found
            var newVariable = new Vector2Variable();

            newVariable.Tag   = tag;
            newVariable.Value = value;
            Vector2Variables.Add(newVariable);
        }
Exemple #7
0
 		public void EditorSetVariableData(Vector2Variable global, Vector2VariableInstanced instanced, Vector2 constant,
 			AssignmentType type, IDTokenHolder tokenHolder)
 		{
 			_assignmentType = type;
 			EditorSetTokenHolder(tokenHolder);
 			
 			switch (type)
 			{
 				case AssignmentType.Constant:
 					_constantValue = constant;
 					break;
 				case AssignmentType.GlobalVariable:
 					_globalVariable = global;
 					break;
 				case AssignmentType.PersonalVariable:
 					_instancedVariable = instanced;
 					break;
 			}
 		}
    void Awake()
    {
        Direction         = ScriptableObject.Instantiate(Direction);
        Velocity          = ScriptableObject.Instantiate(Velocity);
        DesirableVelocity = ScriptableObject.Instantiate(DesirableVelocity);
        UnableToMove      = ScriptableObject.Instantiate(UnableToMove);

        Health     = ScriptableObject.Instantiate(Health);
        Resistence = ScriptableObject.Instantiate(Resistence);

        AttackDelay = ScriptableObject.Instantiate(AttackDelay);
        Target      = ScriptableObject.Instantiate(Target);

        EnemyMovement movement = GetComponent <EnemyMovement>();

        movement.Direction.InstanceVariable         = Direction;
        movement.Velocity.InstanceVariable          = Velocity;
        movement.DesirableVelocity.InstanceVariable = DesirableVelocity;
        movement.UnableToMove.InstanceVariable      = UnableToMove;
        movement.Target.InstanceVariable            = Target;

        EnemyHealth health = GetComponent <EnemyHealth>();

        health.Health.InstanceVariable      = Health;
        health.Resistence.InstanceVariable  = Resistence;
        health.Velocity.InstanceVariable    = Velocity;
        health.Target.InstanceVariable      = Target;
        health.AttackDelay.InstanceVariable = AttackDelay;

        EnemyAttack attack = GetComponent <EnemyAttack>();

        attack.Target.InstanceVariable      = Target;
        attack.AttackDelay.InstanceVariable = AttackDelay;

        EnemyTargetDetector target = GetComponentInChildren <EnemyTargetDetector>();

        target.Target.InstanceVariable = Target;
    }
Exemple #9
0
        //EMPTY
        #region PUBLIC_METHODS
        #endregion PUBLIC_METHODS


        #region PRIVATE_METHODS
        /// <summary>
        /// Handle the Left Controller input and put them in the Events
        /// </summary>
        public void CheckControllerInput(VRInputsEvents clickEvents, VRInputsEvents touchEvents, VRInputsBoolean clickBools, VRInputsBoolean touchBools, SteamVR_Controller.Device controller, Vector2Variable thumbOrientation)
        {
            BoolVariable tempClick;
            BoolVariable tempTouch;

            #region TRIGGER
            tempClick = clickBools.Get("TriggerIsDown");
            tempTouch = touchBools.Get("TriggerIsTouching");

            // Check Click Events
            if (!tempClick.Value && controller.GetHairTriggerDown())
            {
                tempClick.SetValue(true);
                tempTouch.SetValue(false);
                _tempEvent = (GameEvent)clickEvents.Get("TriggerDown");
                _tempEvent.Raise();
            }
            else if (tempClick.Value && controller.GetHairTriggerUp())
            {
                tempClick.SetValue(false);
                _tempEvent = (GameEvent)clickEvents.Get("TriggerUp");
                _tempEvent.Raise();
            }
            // Check Touch Events if user is not clicking
            else if (!tempClick.Value && !tempTouch.Value && controller.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger))
            {
                tempTouch.SetValue(true);
                _tempEvent = (GameEvent)touchEvents.Get("TriggerStartTouching");
                _tempEvent.Raise();
            }
            else if (tempTouch.Value && controller.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
            {
                tempTouch.SetValue(false);
                _tempEvent = (GameEvent)touchEvents.Get("TriggerStopTouching");
                _tempEvent.Raise();
            }
            #endregion TRIGGER

            #region TOUCHPAD
            thumbOrientation.SetValue(controller.GetAxis());

            tempClick = clickBools.Get("ThumbIsDown");
            tempTouch = touchBools.Get("ThumbIsTouching");

            // Check Click Events
            if (!tempClick.Value && controller.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad))
            {
                tempClick.SetValue(true);
                tempTouch.SetValue(false);
                _tempEvent = (GameEvent)clickEvents.Get("ThumbDown");
                _tempEvent.Raise();
            }
            else if (tempClick.Value && controller.GetPressUp(SteamVR_Controller.ButtonMask.Touchpad))
            {
                tempClick.SetValue(false);
                _tempEvent = (GameEvent)clickEvents.Get("ThumbUp");
                _tempEvent.Raise();
            }
            // Check Touch Events if user is not clicking
            else if (!tempClick.Value && !tempTouch.Value && controller.GetTouchDown(SteamVR_Controller.ButtonMask.Touchpad))
            {
                tempTouch.SetValue(true);
                _tempEvent = (GameEvent)touchEvents.Get("ThumbStartTouching");
                _tempEvent.Raise();
            }
            else if (tempTouch.Value && controller.GetTouchUp(SteamVR_Controller.ButtonMask.Touchpad))
            {
                tempTouch.SetValue(false);
                _tempEvent = (GameEvent)touchEvents.Get("ThumbStopTouching");
                _tempEvent.Raise();
            }
            #endregion TOUCHPAD

            #region GRIP
            tempClick = clickBools.Get("GripIsDown");

            // Check Click Events
            if (!tempClick.Value && controller.GetPressDown(SteamVR_Controller.ButtonMask.Grip))
            {
                tempClick.SetValue(true);
                _tempEvent = (GameEvent)clickEvents.Get("GripDown");
                _tempEvent.Raise();
            }
            else if (tempClick.Value && controller.GetPressUp(SteamVR_Controller.ButtonMask.Grip))
            {
                tempClick.SetValue(false);
                _tempEvent = (GameEvent)clickEvents.Get("GripUp");
                _tempEvent.Raise();
            }
            #endregion GRIP

            #region MENU
            tempClick = clickBools.Get("MenuIsDown");

            // Check Click Events
            if (!tempClick.Value && controller.GetPressDown(SteamVR_Controller.ButtonMask.ApplicationMenu))
            {
                tempClick.SetValue(true);
                _tempEvent = (GameEvent)clickEvents.Get("MenuDown");
                _tempEvent.Raise();
            }
            else if (tempClick.Value && controller.GetPressUp(SteamVR_Controller.ButtonMask.ApplicationMenu))
            {
                tempClick.SetValue(false);
                _tempEvent = (GameEvent)clickEvents.Get("MenuUp");
                _tempEvent.Raise();
            }
            #endregion MENU
        }
Exemple #10
0
 public Vector2Data(Vector2 v)
 {
     vector2Val = v;
     vector2Ref = null;
 }
Exemple #11
0
 public void SetValue(Vector2Variable value)
 {
     currentValue = value.currentValue;
 }
Exemple #12
0
    public void PopulateContainer()
    {
        TriggerVariables.Clear();
        BoolVariables.Clear();
        IntVariables.Clear();
        FloatVariables.Clear();
        Vector2Variables.Clear();
        Vector3Variables.Clear();
        QuaternionVariables.Clear();
        TimerVariables.Clear();

        foreach (var propertyPath in AssetDatabaseUtils.GetAssetRelativePaths(FolderPath, IncludeSubdirectories))
        {
            TriggerVariable assetAsTrigger =
                AssetDatabase.LoadAssetAtPath(propertyPath, typeof(TriggerVariable)) as TriggerVariable;
            if (assetAsTrigger != null)
            {
                TriggerVariables.Add(assetAsTrigger);
                continue;
            }

            BoolVariable assetAsBool =
                AssetDatabase.LoadAssetAtPath(propertyPath, typeof(BoolVariable)) as BoolVariable;
            if (assetAsBool != null)
            {
                BoolVariables.Add(assetAsBool);
                continue;
            }

            IntVariable assetAsInt =
                AssetDatabase.LoadAssetAtPath(propertyPath, typeof(IntVariable)) as IntVariable;
            if (assetAsInt != null)
            {
                IntVariables.Add(assetAsInt);
                continue;
            }

            FloatVariable assetAsFloat =
                AssetDatabase.LoadAssetAtPath(propertyPath, typeof(FloatVariable)) as FloatVariable;
            if (assetAsFloat != null)
            {
                FloatVariables.Add(assetAsFloat);
                continue;
            }

            Vector2Variable assetAsVector2 =
                AssetDatabase.LoadAssetAtPath(propertyPath, typeof(Vector2Variable)) as Vector2Variable;
            if (assetAsVector2 != null)
            {
                Vector2Variables.Add(assetAsVector2);
                continue;
            }

            Vector3Variable assetAsVector3 =
                AssetDatabase.LoadAssetAtPath(propertyPath, typeof(Vector3Variable)) as Vector3Variable;
            if (assetAsVector3 != null)
            {
                Vector3Variables.Add(assetAsVector3);
                continue;
            }

            QuaternionVariable assetAsQuaternion =
                AssetDatabase.LoadAssetAtPath(propertyPath, typeof(QuaternionVariable)) as QuaternionVariable;
            if (assetAsQuaternion != null)
            {
                QuaternionVariables.Add(assetAsQuaternion);
                continue;
            }

            TimerVariable assetAsTimer =
                AssetDatabase.LoadAssetAtPath(propertyPath, typeof(TimerVariable)) as TimerVariable;
            if (assetAsTimer != null)
            {
                TimerVariables.Add(assetAsTimer);
                continue;
            }

            FunctionVariable assetAsFunction =
                AssetDatabase.LoadAssetAtPath(propertyPath, typeof(TimerVariable)) as FunctionVariable;
            if (assetAsFunction != null)
            {
                FunctionVariables.Add(assetAsFunction);
                continue;
            }
        }
        Debug.Log($"{TriggerVariables.Count} Triggers" +
                  $" | {BoolVariables.Count} Bools" +
                  $" | {IntVariables.Count} Ints" +
                  $" | {FloatVariables.Count} Floats" +
                  $" | {Vector2Variables.Count} Vector2s" +
                  $" | {Vector3Variables.Count} Vector3s" +
                  $" | {QuaternionVariables.Count} Quaternions" +
                  $" | {TimerVariables.Count} Timers" +
                  $" | {FunctionVariables.Count} Functions");
    }
 public void ModValue(Vector2Variable amount)
 {
     value += amount.value;
 }
 //Setter which takes V2V
 public void SetValue(Vector2Variable v)
 {
     value = v.value;
 }
 public void ApplyChange(Vector2Variable amount)
 {
     Value += amount.Value;
 }
Exemple #16
0
 public void SetDefaultValue(Vector2Variable value)
 {
     defaultValue = value.currentValue;
 }
Exemple #17
0
 public void SetValue(Vector2Variable value)
 {
     Value = value.Value;
 }
Exemple #18
0
 public bool SetVector2Reference(BlackboardTargetParameter target, ref Vector2Variable var)
 {
     return(SetReference <Vector2, Vector2Variable>(target, ref var));
 }