Ejemplo n.º 1
0
    public static void Play(this GameObject go, BaseAction action, Action callback = null, bool isSelfDestroy = true)
    {
        // Add action script
        ActionScript actionScript = go.AddComponent<ActionScript>();

        // Play action
        actionScript.Play(action, callback, isSelfDestroy);
    }
Ejemplo n.º 2
0
    public ParallelAction(BaseAction[] actions, bool isAll)
    {
        // Set actions
        _actions = actions;

        // Set one or all
        _isAll = isAll;
    }
Ejemplo n.º 3
0
    public SequenceAction(BaseAction[] actions)
    {
        // Set actions
        _actions = actions;

        // Set length
        _length = _actions.Length;
    }
Ejemplo n.º 4
0
 public SSTUActionData(ConfigNode node, PartModule module)
     : base(node, module)
 {
     act = module.Actions[fieldName];
     if (act == null)
     {
         throw new NullReferenceException("ERROR: Could not locate action for name: " + fieldName + " in module: " + module + " in part: " + module.part);
     }
 }
Ejemplo n.º 5
0
    public RepeatAction(BaseAction action, int count)
    {
        Debug.Assert(count != 0, "E123456789: Count must be not zero!");

        // Set action
        _action = action;

        // Set repeat count
        _repeatCount = count;
    }
Ejemplo n.º 6
0
 public void Remove(BaseAction bA)
 {
     if (!internalHighlight.Any(
         (e) =>
         {
             return e == bA.listParent.part;
         }))
     {
         Remove(bA.listParent.part);
     }
 }
        public static IEnumerable<KSPActionGroup> GetActionGroupList(BaseAction bA)
        {
            List<KSPActionGroup> ret = new List<KSPActionGroup>();

            foreach (KSPActionGroup ag in Enum.GetValues(typeof(KSPActionGroup)) as KSPActionGroup[])
            {
                if (ag == KSPActionGroup.None)
                    continue;

                if (bA.IsInActionGroup(ag))
                    ret.Add(ag);
            }
            return ret;
        }
Ejemplo n.º 8
0
    // Play the specified action
    public void Play(BaseAction action, Action callback = null, bool isSelfDestroy = true)
    {
        bool isFinished = _action.IsFinished();

        // Set current action
        _action = action;

        // Set callback
        _callback = callback;

        // Set self-destroy
        _isSelfDestroy = isSelfDestroy;

        // Play action
        _action.Play(gameObject);

        // Check if action finished
        if (_action.IsFinished())
        {
            if (isSelfDestroy)
            {
                if (_callback != null)
                {
                    _callback();
                }

                Destroy(this);
            }
            else
            {
                if (!isFinished)
                {
                    StopCoroutine("UpdateAction");
                }

                if (_callback != null)
                {
                    _callback();
                }
            }
        }
        else
        {
            if (isFinished)
            {
                StartCoroutine("UpdateAction");
            }
        }
    }
		public void Process(BaseAction action)
		{
			var size = _queue.Count;

			if (size > MaxQueueSize)
			{
				Logger.Warn("Dropped message because queue is too full.", new Dict
				{
					{ "message id", action.MessageId },
					{ "queue size", _queue.Count },
					{ "max queue size", MaxQueueSize }
				});
			}
			else
			{
				_queue.Enqueue(action);
			}
		}
Ejemplo n.º 10
0
 private void EndAction(BaseAction action)
 {
     var modeAction = action as ModeAction;
     if (modeAction != null && modeAction.IsActivate)
         DeactivateMode(modeAction.ModeName);
     else
         action.End();
 }
Ejemplo n.º 11
0
        protected bool isInstrumentOk()
        {
            //MerillData.log("SCIENCE! isInstrumentOk isInactive="+isInactive+" for part "+part.name);
            if (isInactive)
            {
                return(false);
            }

            float chance = 15 + 40f / ((((float)MerillData.instance.partNameTested.Count) / 8f) + 1);

            // luck?
            int peudoAleat = MerillData.instance.get0to99FromNotAleatTable("science_" + part.name + "_vessel_" + part.vessel.id.ToString());

            print("[MERILL][Mun Rush] experiment " + part.name + " self-testing : " + peudoAleat + " ?> " + chance);

            isInactive = peudoAleat < chance;

            //Here, can send event to btsmExperiemnt, like "set inactive" "set dead"
            if (isInactive)
            {
                //TODO: use a field to get displaymessage (and rand to get one)
                //set the display to "dead"
                stateDisplay = "Dead";
                if (scienceExperiment != null)
                {
                    //MerillData.log("sciecnefail set to inoperable");
                    scienceExperiment.SetInoperable();
                }

                MerillData.instance.nbPartDestroy++;
                if (!MerillData.instance.partNameCrashed.Contains(part.name + "_Break"))
                {
                    MerillData.instance.partNameCrashed.Add(part.name + "_Break");
                }

                if (!MerillData.instance.partNameTested.Contains(part.name + "_Break"))
                {
                    MerillData.instance.partNameTested.Add(part.name + "_Break");
                    MerillData.instance.nbPartTested++;
                }
                //emit message
                //ScreenMessages.PostScreenMessage("Experiment " + part.partInfo.title.ToString()
                //	+ " is not working anymore, something britlle or delicate has fail."
                //	, 10f, ScreenMessageStyle.UPPER_LEFT);
                ScreenMessages.PostScreenMessage(string.Format(MerillData.str_science_fail, part.partInfo.title.ToString())
                                                 , 10f, ScreenMessageStyle.UPPER_LEFT);
                //maj gui
                BaseEvent merillScienceEvent = Events["MERILLScienceEventDeployOrTest"];
                if (merillScienceEvent != null)
                {
                    merillScienceEvent.guiActive = false;
                }
                BaseAction merillScienceAction = Actions["MERILLScienceActionDeployOrTest"];
                if (merillScienceAction != null)
                {
                    merillScienceAction.active = false;
                }
            }

            //fail
            return(!isInactive);
        }
Ejemplo n.º 12
0
 /// <summary>
 /// 等一帧
 /// </summary>
 /// <param name="onComplete"></param>
 public void Yield(BaseAction onComplete)
 {
     StartCoroutine(YieldCoroutine(onComplete));
 }
Ejemplo n.º 13
0
 public static ParallelAction Create(BaseAction[] actions, bool isAll)
 {
     return new ParallelAction(actions, isAll);
 }
Ejemplo n.º 14
0
        public override void OnUpdate()
        {
            base.OnUpdate();
            if (slotResearched)
            {
                return;
            }

            // FindObjectOfType the BTSM science module
            //MerillData.log("MerillScienceSlotModule start, search in module " + part.Modules.Count + " , (" + state+")"
            //	+ (state.Equals(StartState.PreLaunch)) + " ; " + (state.CompareTo(StartState.PreLaunch)) + " ; " + (state & StartState.PreLaunch));
            //MerillData.log("MerillScienceSlotModule update " + HighLogic.LoadedSceneIsFlight + ", '" + part.vessel.situation+"'");
            if ((part.vessel.situation) == Vessel.Situations.FLYING)
            {
                foreach (PartModule pm in part.Modules)
                {
                    //search what is the most upper sciecne module to consider (hiding /disabling if no science slot)
                    //MerillData.log("MerillScienceSlotModule start, find module " + pm.moduleName);
                    if (pm.moduleName.Equals("ModuleScienceExperiment"))
                    {
                        BaseEvent  scienceEvent  = pm.Events["DeployExperiment"];
                        BaseAction scienceAction = pm.Actions["DeployExperimentAction"];
                        if (scienceEvent != null)
                        {
                            if (levelOfEvent == 0)
                            {
                                eventToEnable      = scienceEvent;
                                actionToEnable     = scienceAction;
                                partModuleToEnable = pm;
                            }
                            scienceEvent.guiActive       = false;
                            scienceEvent.guiActiveEditor = false;
                            if (scienceAction != null)
                            {
                                scienceAction.active = false;
                            }
                            MerillData.log("MerillScienceSlotModule : disable scienceEvent '" + eventToEnable + "', '" + actionToEnable + "'");
                        }
                    }

                    if (pm.moduleName.Equals("BTSMModuleScienceExperiment"))
                    {
                        BaseEvent  btsmScienceEvent  = pm.Events["BTSMDeployExperiment"];
                        BaseAction btsmScienceAction = pm.Actions["BTSMDeployExperimentAction"];
                        if (btsmScienceEvent != null && btsmScienceAction != null)
                        {
                            if (levelOfEvent < 1)
                            {
                                levelOfEvent       = 1;
                                eventToEnable      = btsmScienceEvent;
                                actionToEnable     = btsmScienceAction;
                                partModuleToEnable = pm;
                            }
                            eventToEnable.guiActive       = false;
                            eventToEnable.guiActiveEditor = false;
                            actionToEnable.active         = false;
                            MerillData.log("MerillScienceSlotModule : disable btsmScienceEvent '" + eventToEnable + "', '" + actionToEnable + "'");
                        }
                    }

                    if (pm is MerillModuleScienceFail)
                    {
                        BaseEvent  merillScienceEvent  = pm.Events["MERILLScienceEventDeployOrTest"];
                        BaseAction merillScienceAction = pm.Actions["MERILLScienceActionDeployOrTest"];
                        if (merillScienceEvent != null && merillScienceAction != null)
                        {
                            if (levelOfEvent < 2)
                            {
                                levelOfEvent       = 2;
                                eventToEnable      = merillScienceEvent;
                                actionToEnable     = merillScienceAction;
                                partModuleToEnable = pm;
                            }
                            ((MerillModuleScienceFail)pm).isInactive = true;
                            BaseField merillShowState = pm.Fields["stateDisplay"];
                            merillShowState.SetValue("Dead", merillShowState.host);
                            eventToEnable.guiActive       = false;
                            eventToEnable.guiActiveEditor = false;
                            actionToEnable.active         = false;
                            MerillData.log("MerillScienceSlotModule : disable merillScienceEvent '" + eventToEnable + "', '" + actionToEnable + "'");
                        }
                    }
                }

                checkSlot();
            }
        }
Ejemplo n.º 15
0
 public void ClearNextAction()
 {
     nextAction = null;
 }
Ejemplo n.º 16
0
        private bool PreviousIndex(BaseAction ba, MenuAction ma)
        {
            //case that we don't want to roll around but instead perform ba()
            if (m_selectedIndex - 1 == -1 && (ma != null || m_selectedIndex == -1))
                return ba();

            setIndexReverse();

            return false;
        }
Ejemplo n.º 17
0
 /// <summary>
 /// Executes the LDAP logic
 /// </summary>
 /// <param name="parentAction">Inherit parent properties = null</param>
 /// <param name="CurrentTime">Locked program timestamp value</param>
 /// <param name="logger">The logger.</param>
 public override void Run(BaseAction parentAction, DateTime CurrentTime, LogHelper logger)
 {
     ExtractLDAPResults(logger, CurrentTime);
     logger.LogVerbose(string.Format("Successfully extracted {0} user objects from {1} with {2} failures", _TotalUsers, this.ServerName, _TotalFailures ));
 }
Ejemplo n.º 18
0
    private void QueueAction(BaseAction action)
    {
        if (action == null)
            return;

        if (currentAction == null && action.CooldownReady() && !action.IsDisabled())
        {
            currentAction = action;
            nextAction = null;
            currentAction.Execute();
        }
        else if (action.IsQueueable())
        {
            if (currentAction == action && currentAction.IsMultiStep())
            {
                currentAction.QueueNextStep();
                nextAction = null;
            }
            else
            {
                nextAction = action;

                if (currentAction != null && currentAction.IsMultiStep())
                {
                    currentAction.CancelNextStep();
                }
            }
        }
    }
Ejemplo n.º 19
0
 public static RepeatAction Create(BaseAction action, int count)
 {
     return new RepeatAction(action, count);
 }
Ejemplo n.º 20
0
        /// <summary>
        /// 打开ui窗口
        /// </summary>
        /// <param name="uiFormID">UI的对应id</param>
        /// <param name="userData">要传的数据</param>
        /// <param name="onOpen">回调</param>
        internal void OpenUIForm(int uiFormID, object userData = null, BaseAction <UIFormBase> onOpen = null)
        {
            if (IsExists(uiFormID))
            {
                return;
            }
            //1.读表
            Sys_UIFormEntity entity = GameEntry.DataTable.DataTableManager.Sys_UIFormDBModel.Get(uiFormID);

            if (entity == null)
            {
                Debug.Log(uiFormID + "对应的UI窗体不存在");
                return;
            }

            UIFormBase formBase = GameEntry.UI.Dequeue(uiFormID);

            if (formBase == null)
            {
                //TODO:异步加载ui需要时间 此处需要处理过滤加载中的ui

                string assetPath = null;
                switch (GameEntry.Localization.CurrLanguage)
                {
                case TQLanguage.Chinese:
                    assetPath = entity.AssetPath_Chinese;
                    break;

                case TQLanguage.English:
                    assetPath = entity.AssetPath_English;
                    break;
                }
                LoadUIAsset(assetPath, (ResourceEntity resourceEntity) =>
                {
                    GameObject uiObj = UnityEngine.Object.Instantiate((UnityEngine.Object)resourceEntity.Target) as GameObject;
                    //把克隆出来的资源 加入实例资源池
                    GameEntry.Pool.RegisterInstanceResource(uiObj.GetInstanceID(), resourceEntity);
                    uiObj.transform.SetParent(GameEntry.UI.GetGroup(entity.UIGroupId).Group);
                    uiObj.transform.localPosition = Vector3.zero;
                    uiObj.transform.localScale    = Vector3.one;

                    RectTransform rect = uiObj.GetComponent <RectTransform>();
                    rect.offsetMax     = new Vector2(0, 0);
                    rect.offsetMin     = new Vector2(0, 0);
                    formBase           = uiObj.GetComponent <UIFormBase>();

                    formBase.Init(uiFormID, entity.UIGroupId, entity.DisableUILayer == 1, entity.IsLock == 1, userData);

                    m_OpenUIFormList.AddLast(formBase);
                    if (onOpen != null)
                    {
                        onOpen(formBase);
                    }
                });
            }
            else
            {
                formBase.gameObject.SetActive(true);
                formBase.Open(userData);
                m_OpenUIFormList.AddLast(formBase);
                if (onOpen != null)
                {
                    onOpen(formBase);
                }
            }
        }
Ejemplo n.º 21
0
 internal void RaiseFailure(BaseAction action, System.Exception e)
 {
     if (Failed != null)
         Failed(action, e);
 }
Ejemplo n.º 22
0
 internal void RaiseSuccess(BaseAction action)
 {
     if (Succeeded != null)
         Succeeded(action);
 }
Ejemplo n.º 23
0
 void Client_Failed(BaseAction action, System.Exception e)
 {
     Debug.WriteLine(String.Format("Action [{0}] {1} failed : {2}",
                                   action.MessageId, action.Type, e.Message));
 }
Ejemplo n.º 24
0
 public static RepeatAction RepeatForever(BaseAction action)
 {
     return Create(action, -1);
 }
Ejemplo n.º 25
0
 private void BeginAction(BaseAction action)
 {
     var modeAction = action as ModeAction;
     if (modeAction != null)
     {
         if (modeAction.IsActivate)
             ActivateMode(modeAction.ModeName);
         else
             DeactivateMode(modeAction.ModeName);
     }
     else
         action.Begin();
 }
Ejemplo n.º 26
0
    private void HandleCurrentAction()
    {
        if (currentAction == null && nextAction == null)
            return;

        if (currentAction != null && currentAction.IsActive())
        {
            currentAction.ActiveUpdate();
        }
        else if(currentAction == null || !currentAction.IsActive())
        {
            currentAction = null;

            if (nextAction != null && nextAction.CooldownReady())
            {
                if (!nextAction.IsDisabled())
                {
                    currentAction = nextAction;
                    currentAction.Execute();
                }

                nextAction = null;
            }
        }
    }
Ejemplo n.º 27
0
        public override void OnStart(StartState state)
        {
            // Start up the base PartModule, just in case.
            base.OnStart(state);

            // Fetch all of the ModuleJettisons from the part, filling a list of modules and a dict of transforms
            PartModule module;
            for (int mIdx = 0; mIdx < base.part.Modules.Count; mIdx++)
            {
                module = base.part.Modules[mIdx];
                if (module is ModuleJettison)
                {
                    ModuleJettison jettisonModule = module as ModuleJettison;

                    if (jettisonModule == null || jettisonModule.jettisonName == string.Empty)
                    {
                        Debug.Log("Skipping problematic jettisonModule");
                        continue;
                    }

                    if (this.bottomNode == null)
                    {
                        this.bottomNode = this.part.findAttachNode(jettisonModule.bottomNodeName);
                    }

                    this.jettisonModules.Add(jettisonModule);

                    this.jettisonTransforms[jettisonModule.jettisonName] = jettisonModule.jettisonTransform;

                    // Seed the hasJettisoned table with the module's state at start up to avoid loading up a shroud
                    // when we shouldn't have one.
                    this.hasJettisonedTable[jettisonModule.jettisonName] = jettisonModule.isJettisoned;

                    BaseEvent moduleJettisonEvent = new BaseEvent(
                        this.Events,
                        string.Format("{0}{1}", jettisonModule.jettisonName, "jettisonEvent"),
                        (BaseEventDelegate)delegate
                        {
                            this.JettisonEvent(jettisonModule, actionParam);
                        }
                    );

                    moduleJettisonEvent.active = true;
                    moduleJettisonEvent.guiActive = jettisonModule.isJettisoned && !this.disableFairing;
                    moduleJettisonEvent.guiActiveEditor = false;
                    moduleJettisonEvent.guiName = "Jettison";

                    this.Events.Add(moduleJettisonEvent);

                    Debug.Log("Added new Jettison event wrapper " + moduleJettisonEvent);

                    jettisonModule.Events["Jettison"].active = false;
                    jettisonModule.Events["Jettison"].guiActive = false;
                    jettisonModule.Events["Jettison"].guiActiveEditor = false;
                    jettisonModule.Events["Jettison"].guiName += "(DEPRECATED)";

                    BaseAction moduleJettisonAction = new BaseAction(
                        this.Actions,
                        string.Format("{0}{1}", jettisonModule.jettisonName, "jettisonAction"),
                        (BaseActionDelegate)delegate(KSPActionParam param)
                        {
                            this.JettisonEvent(jettisonModule, param);
                        },
                        new KSPAction("Jettison")
                    );

                    this.Actions.Add(moduleJettisonAction);

                    Debug.Log("Added new JettisonAction action wrapper " + moduleJettisonAction);

                    jettisonModule.Actions["JettisonAction"].active = false;
                    jettisonModule.Actions["JettisonAction"].guiName += "(DEPRECRATED)";
                }
            }

            Debug.Log("Found "+ jettisonModules.Count + " ModuleJettisons.");

            // Seed the disableState for first-run behavior.
            if (this.disableFairing || true)
            {
                this.disableState = !this.disableFairing;
            }
        }
Ejemplo n.º 28
0
    void Start()
    {
        Time.timeScale = timescale;
        controller = gameObject.GetComponent<BaseController>();
        animator = GetComponentInChildren<Animator>();

        comboAction = GetComponent<Combo>();
        dashAction = GetComponent<Dash>();
        blockAction = GetComponent<Block>();
        airFloatAction = GetComponent<AirFloat>();
        slamAction = GetComponent<Slam>();
        tornadoAction = GetComponent<Tornado>();

        if (GetComponent<AirAttack>() != null)
        {
            airSpecialAction = GetComponent<AirAttack>();
        }
        else if (GetComponent<AirSpecial>())
        {
            airSpecialAction = GetComponent<AirSpecial>();
        }

        controller.OnLand += HandleLanding;

        PlayerInput.SwipeLeft += SwipeLeft;
        PlayerInput.SwipeRight += SwipeRight;
    }
		public void Process(BaseAction action)
		{
			var batch = _batchFactory.Create(new List<BaseAction>() { action });
			_requestHandler.MakeRequest(batch);
		}
Ejemplo n.º 30
0
        private bool IncrementIndex(BaseAction ba, MenuAction ma)
        {
            //case that we don't want to roll around but instead perform ba()
            if (m_selectedIndex + 1 == m_items.Count && (ma != null || m_selectedIndex == -1))
                return ba();

            setIndexForward();

            return false;
        }
Ejemplo n.º 31
0
 public void ClearFrameInfo()
 {
     selectedTile = null;
     targetTile = null;
     selectedAgent = null;
     selectedAction = null;
 }
Ejemplo n.º 32
0
 //转换状态
 public virtual void SwitchAction(BaseAction action)
 {
     m_ActionCtrler.SwitchAction(action);
 }
Ejemplo n.º 33
0
 /// <summary>
 /// 取得当前的Action
 /// </summary>
 /// <typeparam name="T">Action类型</typeparam>
 /// <returns>Action对象</returns>
 public T GetAction <T>()
 {
     return(BaseAction.GetAction <T>(ActionID));
 }
Ejemplo n.º 34
0
    /// <summary>
    /// Sets the triggers context menu.
    /// </summary>
    /// <param name='contextRect'>
    /// Context active rectangle for mouse click
    /// </param>
    /// <param name='action'>
    /// Action that the trigger is linked to
    /// </param>
    /// <param name='trigger'>
    /// the Trigger in question
    /// </param>
    private void SetTriggersContextMenu(Rect contextRect, BaseAction action, Trigger trigger)
    {
        var evt = Event.current;

        if (evt.type == EventType.ContextClick)
        {
            var mousePos = evt.mousePosition;
            if (contextRect.Contains (mousePos))
            {
                // Now create the menu, add items and show it
                var menu  = new GenericMenu ();

                menu.AddItem (new GUIContent ("Reset"), false, ResetTrigger, trigger);

                if( action.IsSupportCustomTriggers() )
                {
                    menu.AddItem (new GUIContent ("Remove"), false, RemoveTrigger, trigger);
                }

                menu.ShowAsContext ();
                evt.Use();
            }
        }
    }
Ejemplo n.º 35
0
 public void EnqueueAction(BaseAction action)
 {
     _actions.Enqueue(action);
 }
Ejemplo n.º 36
0
 public void ClearSelectedAction()
 {
     selectedAction = null;
 }
Ejemplo n.º 37
0
 public void Add(BaseAction bA)
 {
     Add(bA.listParent.part);
 }
Ejemplo n.º 38
0
        public void SetDefaultAction(BaseAction ba, int group)
        {
            Dictionary<int, KSPActionGroup> KSPActs = new Dictionary<int, KSPActionGroup>();
            KSPActs[1] = KSPActionGroup.Custom01; //setup list to delete action from 
            KSPActs[2] = KSPActionGroup.Custom02;
            KSPActs[3] = KSPActionGroup.Custom03;
            KSPActs[4] = KSPActionGroup.Custom04;
            KSPActs[5] = KSPActionGroup.Custom05;
            KSPActs[6] = KSPActionGroup.Custom06;
            KSPActs[7] = KSPActionGroup.Custom07;
            KSPActs[8] = KSPActionGroup.Custom08;
            KSPActs[9] = KSPActionGroup.Custom09;
            KSPActs[10] = KSPActionGroup.Custom10;

            ba.actionGroup = ba.actionGroup | KSPActs[group];
        }
Ejemplo n.º 39
0
 /// <summary>
 /// 取得Action传回来的值
 /// </summary>
 /// <param name="key">关键字</param>
 /// <returns>字段的数据值</returns>
 public object Get(string key)
 {
     return(BaseAction.Get(key, ActionID));
 }