Esempio n. 1
0
        protected void Interact(GameObject collisionOb)
        {
            if (cancelInteractions)
            {
                KickStarter.playerInteraction.StopMovingToHotspot();
            }

            if (actionListType == ActionListType.PauseGameplay)
            {
                KickStarter.playerInteraction.DeselectHotspot(false);
            }

            KickStarter.eventManager.Call_OnRunTrigger(this, collisionOb);

            // Set correct parameter
            if (collisionOb != null)
            {
                if (source == ActionListSource.InScene)
                {
                    if (useParameters && parameters != null && parameters.Count >= 1)
                    {
                        if (parameters[0].parameterType == ParameterType.GameObject)
                        {
                            parameters[0].gameObject = collisionOb;
                        }
                        else
                        {
                            ACDebug.Log("Cannot set the value of parameter 0 ('" + parameters[0].label + "') as it is not of the type 'Game Object'.", this);
                        }
                    }
                }
                else if (source == ActionListSource.AssetFile &&
                         assetFile != null &&
                         assetFile.NumParameters > 0 &&
                         gameObjectParameterID >= 0)
                {
                    ActionParameter param = null;
                    if (syncParamValues)
                    {
                        param = assetFile.GetParameter(gameObjectParameterID);
                    }
                    else
                    {
                        param = GetParameter(gameObjectParameterID);
                    }

                    if (param != null)
                    {
                        param.SetValue(collisionOb);
                    }
                }
            }

            base.Interact();
        }
Esempio n. 2
0
        public void SetParameter(ActionListSource source, GameObject gameObject)
        {
            if (source == ActionListSource.InScene && cutscene != null)
            {
                if (cutscene.useParameters && parameterID >= 0 && cutscene.parameters.Count > parameterID)
                {
                    ActionParameter parameter = cutscene.GetParameter(parameterID);
                    if (parameter != null)
                    {
                        parameter.SetValue(gameObject);
                    }
                }

                if (!pausesCharacter)
                {
                    cutscene.Interact();
                }
            }
            else if (source == ActionListSource.AssetFile && actionListAsset != null)
            {
                if (actionListAsset.useParameters && parameterID >= 0 && actionListAsset.parameters.Count > parameterID)
                {
                    int idToSend = 0;
                    if (gameObject.GetComponent <ConstantID>())
                    {
                        idToSend = gameObject.GetComponent <ConstantID>().constantID;
                    }
                    else
                    {
                        ACDebug.LogWarning(gameObject.name + " requires a ConstantID script component!", gameObject);
                    }

                    ActionParameter parameter = actionListAsset.GetParameter(parameterID);
                    if (parameter != null)
                    {
                        parameter.SetValue(idToSend);
                    }
                }

                if (!pausesCharacter)
                {
                    actionListAsset.Interact();
                }
            }
        }
Esempio n. 3
0
        public override float Run()
        {
            if (_gameObject == null)
            {
                return(0f);
            }

            switch (invAction)
            {
            case InvAction.Add:
            {
                GameObject oldOb = AssignFile(constantID, _gameObject);
                if (_gameObject.activeInHierarchy || (oldOb != null && oldOb.activeInHierarchy))
                {
                    RememberTransform rememberTransform = oldOb.GetComponent <RememberTransform> ();

                    if (rememberTransform != null && rememberTransform.saveScenePresence && rememberTransform.linkedPrefabID != 0)
                    {
                        // Bypass this check
                    }
                    else
                    {
                        LogWarning(_gameObject.name + " won't be instantiated, as it is already present in the scene.", _gameObject);
                        return(0f);
                    }
                }

                Vector3    position = _gameObject.transform.position;
                Quaternion rotation = _gameObject.transform.rotation;

                if (positionRelativeTo != PositionRelativeTo.Nothing)
                {
                    float forward = _gameObject.transform.position.z;
                    float right   = _gameObject.transform.position.x;
                    float up      = _gameObject.transform.position.y;

                    if (positionRelativeTo == PositionRelativeTo.RelativeToActiveCamera)
                    {
                        Transform mainCam = KickStarter.mainCamera.transform;
                        position              = mainCam.position + (mainCam.forward * forward) + (mainCam.right * right) + (mainCam.up * up);
                        rotation.eulerAngles += mainCam.transform.rotation.eulerAngles;
                    }
                    else if (positionRelativeTo == PositionRelativeTo.RelativeToPlayer)
                    {
                        if (KickStarter.player)
                        {
                            Transform playerTranform = KickStarter.player.transform;
                            position              = playerTranform.position + (playerTranform.forward * forward) + (playerTranform.right * right) + (playerTranform.up * up);
                            rotation.eulerAngles += playerTranform.rotation.eulerAngles;
                        }
                    }
                    else if (positionRelativeTo == PositionRelativeTo.RelativeToGameObject)
                    {
                        if (relativeGameObject != null)
                        {
                            Transform relativeTransform = relativeGameObject.transform;
                            position              = relativeTransform.position + (relativeTransform.forward * forward) + (relativeTransform.right * right) + (relativeTransform.up * up);
                            rotation.eulerAngles += relativeTransform.rotation.eulerAngles;
                        }
                    }
                    else if (positionRelativeTo == PositionRelativeTo.EnteredValue)
                    {
                        position += relativeVector;
                    }
                    else if (positionRelativeTo == PositionRelativeTo.VectorVariable)
                    {
                        if (runtimeVariable != null)
                        {
                            position += runtimeVariable.Vector3Value;
                        }
                    }
                }

                GameObject newObject = Instantiate(_gameObject, position, rotation);
                newObject.name = _gameObject.name;

                if (newObject.GetComponent <RememberTransform> ())
                {
                    newObject.GetComponent <RememberTransform> ().OnSpawn();
                }

                KickStarter.stateHandler.IgnoreNavMeshCollisions();

                if (runtimeSpawnedObjectParameter != null)
                {
                    runtimeSpawnedObjectParameter.SetValue(newObject);
                }
            }
            break;

            case InvAction.Remove:
                KickStarter.sceneChanger.ScheduleForDeletion(_gameObject);
                break;

            case InvAction.Replace:
            {
                if (replaceGameObject == null)
                {
                    LogWarning("Cannot perform swap because the object to remove was not found in the scene.");
                    return(0f);
                }

                Vector3    position = replaceGameObject.transform.position;
                Quaternion rotation = replaceGameObject.transform.rotation;

                GameObject oldOb = AssignFile(constantID, _gameObject);
                if (gameObject.activeInHierarchy || (oldOb != null && oldOb.activeInHierarchy))
                {
                    Log(_gameObject.name + " won't be instantiated, as it is already present in the scene.", _gameObject);
                    return(0f);
                }

                KickStarter.sceneChanger.ScheduleForDeletion(replaceGameObject);

                GameObject newObject = (GameObject)Instantiate(_gameObject, position, rotation);
                newObject.name = _gameObject.name;
                KickStarter.stateHandler.IgnoreNavMeshCollisions();
            }
            break;

            default:
                break;
            }

            return(0f);
        }
        override public float Run()
        {
            if (_parameter == null)
            {
                ACDebug.LogWarning("Cannot set parameter value since it cannot be found!");
                return(0f);
            }

            if (setParamMethod == SetParamMethod.CopiedFromGlobalVariable)
            {
                GVar gVar = GlobalVariables.GetVariable(globalVariableID);
                if (gVar != null)
                {
                    if (_parameter.parameterType == ParameterType.Boolean ||
                        _parameter.parameterType == ParameterType.Integer)
                    {
                        _parameter.intValue = gVar.val;
                    }
                    else if (_parameter.parameterType == ParameterType.Float)
                    {
                        _parameter.floatValue = gVar.floatVal;
                    }
                    else if (_parameter.parameterType == ParameterType.Vector3)
                    {
                        _parameter.vector3Value = gVar.vector3Val;
                    }
                    else if (_parameter.parameterType == ParameterType.String)
                    {
                        _parameter.stringValue = GlobalVariables.GetStringValue(globalVariableID, true, Options.GetLanguage());
                    }
                }
            }
            else if (setParamMethod == SetParamMethod.EnteredHere)
            {
                if (_parameter.parameterType == ParameterType.Boolean ||
                    _parameter.parameterType == ParameterType.Integer ||
                    _parameter.parameterType == ParameterType.GlobalVariable ||
                    _parameter.parameterType == ParameterType.LocalVariable ||
                    _parameter.parameterType == ParameterType.InventoryItem ||
                    _parameter.parameterType == ParameterType.Document)
                {
                    _parameter.intValue = intValue;
                }
                else if (_parameter.parameterType == ParameterType.Float)
                {
                    _parameter.floatValue = floatValue;
                }
                else if (_parameter.parameterType == ParameterType.String)
                {
                    _parameter.stringValue = stringValue;
                }
                else if (_parameter.parameterType == ParameterType.GameObject)
                {
                    _parameter.gameObject = runtimeGameobjectValue;
                    _parameter.intValue   = gameObjectConstantID;
                }
                else if (_parameter.parameterType == ParameterType.UnityObject)
                {
                    _parameter.objectValue = unityObjectValue;
                }
                else if (_parameter.parameterType == ParameterType.Vector3)
                {
                    _parameter.vector3Value = vector3Value;
                }
                else if (_parameter.parameterType == ParameterType.ComponentVariable)
                {
                    _parameter.SetValue(runtimeVariables, intValue);
                }
            }
            else if (setParamMethod == SetParamMethod.Random)
            {
                if (_parameter.parameterType == ParameterType.Boolean)
                {
                    _parameter.intValue = Random.Range(0, 2);
                }
                else if (_parameter.parameterType == ParameterType.Integer)
                {
                    _parameter.intValue = Random.Range(intValue, intValueMax + 1);
                }
                else if (_parameter.parameterType == ParameterType.Float)
                {
                    _parameter.floatValue = Random.Range(floatValue, floatValueMax);
                }
                else
                {
                    ACDebug.LogWarning("Parameters of type '" + _parameter.parameterType + "' cannot be set randomly.");
                }
            }
            else if (setParamMethod == SetParamMethod.CopiedFromParameter)
            {
                if (_parameterToCopy == null)
                {
                    ACDebug.LogWarning("Cannot copy parameter value since it cannot be found!");
                    return(0f);
                }

                _parameter.CopyValues(_parameterToCopy);
            }

            return(0f);
        }