Esempio n. 1
0
            /// <summary>
            /// Call from the function which is the value of OnEnd.
            /// </summary>
            public void EndAnimationEffect()
            {
                OCCharacterMotor motor = _Target.GetComponent <OCCharacterMotor>();

                motor.enabled = true;

                if (_State.wrapMode != WrapMode.Loop)
                {
                    _Target.animation.Stop();
                }
            }
            private ActionStatus StartAction()
            {
                //OCLogger.Debugging("Starting the " + FullName + " Action.");
                if (_blockOnFail && _blockOnRunning)
                {
                    _ActionController.RunningActions.Add(FullName);
                }

                // Start animation effects
                if (_blockOnRunning || !_Source.animation.isPlaying)
                {
                    foreach (OCAnimationEffect afx in _AnimationEffects)
                    {
                        afx.Play();
                    }
                }

                foreach (OCCreateBlockEffect cbfx in _CreateBlockEffects)
                {
                    cbfx.CreateBlock(VectorUtil.Vector3ToVector3i(_Source.transform.position + _Source.transform.forward));
                }

                //@TODO: Fix this hack...
                if (Descriptors.Contains("Jump") || Descriptors.Contains("Climb"))
                {
                    OCCharacterMotor motor = _Source.GetComponent <OCCharacterMotor>();
                    motor.enabled = false;
                }

                if (!Descriptors.Contains("Idle"))
                {
                    Debug.LogWarning("Starting Action: " + FullName);
                }

                return(ActionStatus.RUNNING);
            }
            private ActionStatus EndAction()
            {
                //OCLogger.Debugging("Ending the " + FullName + " Action.");

                OCActionArgs args = null;

                if (_ActionController.Step != null)
                {
                    args = _ActionController.Step.Arguments;
                }

                if (_blockOnFail && _blockOnRunning)
                {
                    _ActionController.RunningActions.Remove(FullName);
                }

                // End animation effects
//		foreach(OCAnimationEffect afx in _AnimationEffects)
//		{
//			afx.Stop();
//		}

                foreach (OCDestroyBlockEffect dbfx in _DestroyBlockEffects)
                {
                    Vector3i forward     = VectorUtil.Vector3ToVector3i(_Source.transform.position + _Source.transform.forward);
                    Vector3i forwardUp   = VectorUtil.Vector3ToVector3i(_Source.transform.position + _Source.transform.forward + _Source.transform.up);
                    Vector3i forwardUp2x = VectorUtil.Vector3ToVector3i(_Source.transform.position + _Source.transform.forward + 2 * _Source.transform.up);

                    OCBlockData forwardBlock     = _Map.GetBlock(forward);
                    OCBlockData forwardUpBlock   = _Map.GetBlock(forwardUp);
                    OCBlockData forwardUp2xBlock = _Map.GetBlock(forwardUp2x);

                    dbfx.DestroyBlock(forward);
                    dbfx.DestroyBlock(forwardUp);
                    dbfx.DestroyBlock(forwardUp2x);

                    args.EndTarget.transform.position   = Vector3.zero;
                    args.StartTarget.transform.position = Vector3.zero;

                    // This is just some example code for you Lake, that you can use to give energy to the robot after consuming a battery.
                    if ((forwardBlock.block != null && forwardBlock.block.GetName() == "Battery") || (forwardUpBlock.block != null && forwardUpBlock.block.GetName() == "Battery") || (forwardUp2xBlock.block != null && forwardUp2xBlock.block.GetName() == "Battery"))
                    {
                        UnityEngine.GameObject[] agiArray = UnityEngine.GameObject.FindGameObjectsWithTag("OCAGI");

                        for (int iAGI = 0; iAGI < agiArray.Length; iAGI++)
                        {
                            UnityEngine.GameObject agiObject = agiArray[iAGI];

                            //args.EndTarget = agiObject;

                            OCPhysiologicalModel agiPhysModel = agiObject.GetComponent <OCPhysiologicalModel>();

                            OCPhysiologicalEffect batteryEatEffect = new OCPhysiologicalEffect(OCPhysiologicalEffect.CostLevel.NONE);

                            batteryEatEffect.EnergyIncrease = 0.2f;

                            agiPhysModel.ProcessPhysiologicalEffect(batteryEatEffect);

                            break;
                        }
                    }
                }

                //@TODO: Fix this hack...
                if (Descriptors.Contains("Jump") || Descriptors.Contains("Climb") || Descriptors.Contains("Fall"))
                {
                    OCCharacterMotor motor = _Source.GetComponent <OCCharacterMotor>();
                    motor.enabled = true;
                }

                if (!Descriptors.Contains("Idle"))
                {
                    Debug.LogWarning("Ending Action: " + FullName);
                }

//		if(args.ActionPlanID != null)
//			OCConnectorSingleton.Instance.SendActionStatus(args.ActionPlanID, args.SequenceID, args.ActionName, true);

                return(ActionStatus.SUCCESS);
            }
	//---------------------------------------------------------------------------

	#endregion

	//---------------------------------------------------------------------------

	#region Accessors and Mutators

	//---------------------------------------------------------------------------
		
	
			
	//---------------------------------------------------------------------------

	#endregion

	//---------------------------------------------------------------------------

	#region Public Member Functions

	//---------------------------------------------------------------------------

	// Use this for initialization
	public void Awake() 
	{
		_motor = gameObject.GetComponent<OCCharacterMotor>();
	}
Esempio n. 5
0
        //---------------------------------------------------------------------------

        #endregion

        //---------------------------------------------------------------------------

        #region Accessors and Mutators

        //---------------------------------------------------------------------------



        //---------------------------------------------------------------------------

        #endregion

        //---------------------------------------------------------------------------

        #region Public Member Functions

        //---------------------------------------------------------------------------

        // Use this for initialization
        public void Awake()
        {
            _motor = gameObject.GetComponent <OCCharacterMotor>();
        }