コード例 #1
0
 private void GoHomeImmediate()
 {
     Action = LerpTravel;
     thisRigidbody.isKinematic = true;
     thisCollider.enabled = false;
     thisRigidbody.useGravity = false;
     thisCollider.isTrigger = true;
 }
コード例 #2
0
ファイル: Engine.cs プロジェクト: NikolaNikushev/TeamLutetium
        public void ReadAction()
        {
            communicator.RenderGameField(field);
            Command commandInput = Command.Invalid;

            this.currentAction = CurrentAction.IsRunning;
            string commandInputString = communicator.ProvidePlayerCommand();
            commandInput = parser.ParseCommand(commandInputString, field);
            HandleCommand(commandInput, commandInputString);
        }
コード例 #3
0
ファイル: GameState.cs プロジェクト: urgamedev/TurnBasedGame
 // Use this for initialization
 void Start()
 {
     currentAction = Grid.controller.currentAction;
     map = Grid.map;
     factions = new Faction[NUMFACTIONS];
     factions[0] = new PlayerFaction();
     factions[1] = new AIFaction();
     TurnManager manager = Grid.turnManager;
     manager.factions = factions;
     manager.active = factions[0];
 }
コード例 #4
0
        public override void Update(DwarfTime gameTime)
        {
            CompositeLibrary.Update();
            MainWindow.LocalBounds = new Rectangle(EdgePadding, EdgePadding, Game.GraphicsDevice.Viewport.Width - EdgePadding * 2, Game.GraphicsDevice.Viewport.Height - EdgePadding * 2);
            Input.Update();
            GUI.Update(gameTime);

            if (CurrentAction != null)
            {
                if (CurrentCoroutine == null)
                {
                    CurrentCoroutine  = CurrentAction.Action();
                    CurrentEnumerator = CurrentCoroutine.GetEnumerator();
                }

                if (CurrentCoroutine != null)
                {
                    SpeechNode node = CurrentEnumerator.Current;

                    if (node != null)
                    {
                        Transition(node);
                        CurrentCoroutine = null;
                        CurrentAction    = null;
                    }
                    else
                    {
                        if (!CurrentEnumerator.MoveNext())
                        {
                            CurrentCoroutine  = null;
                            CurrentAction     = null;
                            CurrentEnumerator = null;
                            Transition(DialougeTree);
                        }
                    }
                }
            }

            base.Update(gameTime);
        }
コード例 #5
0
ファイル: Toilet.cs プロジェクト: dhon2407/LSW-alpha
        public override void Use()
        {
            CurrentAction.ApplyStatsOnUse();

            if (breakFunctionality.isBroken)
            {
                SpriteControler.Instance.FaceDOWN();

                if (shouldCancel)
                {
                    ResetObjectState(true);
                    ProgressBar.HideUI(progressBarID);
                    PlayerAnimationHelper.ResetPlayer();
                }
                else if (breakFunctionality.AttemptFix())
                {
                    gameObject.GetComponent <Interactivity>().options = originalOptions;
                    breakFunctionality.isBroken = false;
                    PlayerAnimationHelper.ResetPlayer();
                    useState = ObjectUseState.Unused;
                    ResetObjectState(false);
                    ProgressBar.HideUI(progressBarID);
                }
            }
            else
            {
                SpriteControler.Instance.FaceLEFT();

                if (shouldCancel)
                {
                    FinishUsing(true);
                }
                else if (!CurrentAction.ValidateStats())
                {
                    useState = ObjectUseState.Preparation;
                    ExitAfterDelay(false);
                }
            }
        }
コード例 #6
0
        } // RecordAction

        #endregion

        #region Check Not Running Before Recording

        private static void CheckNotRunningBeforeRecording(IAction candidate)
        {
            if (CurrentAction != null)
            {
                string candidateActionName = candidate != null ? candidate.ToString() : "";
                throw new InvalidOperationException
                (
                    string.Format
                    (
                          "ActionManager.RecordActionDirectly: the ActionManager is currently running "
                        + "or undoing an action ({0}), and this action (while being executed) attempted "
                        + "to recursively record another action ({1}), which is not allowed. "
                        + "You can examine the stack trace of this exception to see what the "
                        + "executing action did wrong and change this action not to influence the "
                        + "Undo stack during its execution. Checking if ActionManager.ActionIsExecuting == true "
                        + "before launching another transaction might help to avoid the problem. Thanks and sorry for the inconvenience.",
                        CurrentAction.ToString(),
                        candidateActionName
                    )
                );
            }
        } // CheckNotRunningBeforeRecording
コード例 #7
0
        public void SwitchAction(string actionName)
        {
            //if (PendingAction != null)
            //{
            //    PendingAction.OnDeactivate();
            //    PendingAction.DisconnectInputs();
            //}
            if (CurrentAction != null)
            {
                CurrentAction.OnDeactivate();
                CurrentAction.DisconnectInputs();
            }

            CurrentAction = ModifierContainer.Get(actionName);
            CurrentAction.Setup();
            CurrentAction.OnActivate();

            if (OnSwitchAction != null)
            {
                OnSwitchAction();
            }
            if (actionName == ModifierNames.None && PendingAction != null && PendingAction.Name != ModifierNames.None)
            {
                if (CurrentAction != null)
                {
                    CurrentAction.OnDeactivate();
                    CurrentAction.DisconnectInputs();
                }
                PendingAction.Setup();
                PendingAction.OnActivate();

                if (OnSwitchAction != null)
                {
                    OnSwitchAction();
                }
                PendingAction = ModifierContainer.Get(ModifierNames.None);
                //return;
            }
        }
コード例 #8
0
        private void ReceivedAction()
        {
            var action = _actionRequest.Result;

            _actionRequest = null;
            // Actions with lower scores should be implicitly dumped by GetAction
            // If we're not allowed to replace the action with an action of the same type then dump.
            if (action == null || !action.CanOverride && CurrentAction?.GetType() == action.GetType())
            {
                return;
            }

            var currentOp = CurrentAction?.ActionOperators.Peek();

            if (currentOp != null && currentOp.HasStartup)
            {
                currentOp.Shutdown(Outcome.Failed);
            }

            CurrentAction = action;
            action.SetupOperators(_blackboard);
        }
コード例 #9
0
ファイル: Returnable.cs プロジェクト: FreeLoop1994/AdamUnity
    private void LerpTravel()
    {
        float returnSpeed = (1 / (thisTransform.position - origin).sqrMagnitude < .5f) ? .5f : 1 / (thisTransform.position - origin).magnitude;

        thisTransform.position = Vector3.Lerp(thisTransform.position, origin, Time.fixedDeltaTime * returnSpeed * 10);
        thisTransform.rotation = Quaternion.Lerp(thisTransform.rotation, rot, Time.fixedDeltaTime * returnSpeed * 10);

        //if object is close enough to origin, stop travelling
        if ((thisTransform.position - origin).sqrMagnitude < .001f)
        {
            thisTransform.position = origin;
            thisTransform.rotation = rot;

            thisRigidbody.isKinematic     = false;
            thisCollider.enabled          = true;
            thisRigidbody.velocity        = Vector3.zero;
            thisRigidbody.angularVelocity = Vector3.zero;
            thisCollider.isTrigger        = false;

            //rigidbody actions and collider actions go here
            Action = DoNothing;
        }
    }
コード例 #10
0
 // If newCurrentAction is different to the currentAction, change the action and cursor.
 private void SetAction(CurrentAction newCurrentAction)
 {
     if (currentAction != newCurrentAction)
     {
         if (newCurrentAction == CurrentAction.idle)
         {
             Cursor.SetCursor(idle, new Vector2(4, 132), CursorMode.Auto);
         }
         else if (newCurrentAction == CurrentAction.selecting)
         {
             Cursor.SetCursor(selecting, new Vector2(16, 140), CursorMode.Auto);
         }
         else if (newCurrentAction == CurrentAction.moving)
         {
             Cursor.SetCursor(moving, new Vector2(125, 125), CursorMode.Auto);
         }
         else if (newCurrentAction == CurrentAction.attacking)
         {
             Cursor.SetCursor(attacking, new Vector2(125, 125), CursorMode.Auto);
         }
         currentAction = newCurrentAction;
     }
 }
コード例 #11
0
ファイル: Player.cs プロジェクト: biru100/TeamIdentity
    protected override void Update()
    {
        Status.PrepareState();
        for (int i = 0; i < StateStack.Count; ++i)
        {
            StateStack[i].UpdateState();
        }

        foreach (var deletedState in DeleteStateList)
        {
            StateStack.Remove(deletedState);
        }

        if (UseCardStack.Count != 0 && !(CurrentAction is PlayerCardAction))
        {
            EntityUtil.ChangeCardAction(this, UseCardStack[0].card.CardActionName, UseCardStack[0].card.Data, UseCardStack[0].target);
            UseCardStack.RemoveAt(0);
        }
        else
        {
            CurrentAction?.UpdateAction();
        }
    }
コード例 #12
0
    /// <summary>
    /// Returns URL for the inner IFrame.
    /// </summary>
    private string GetFrameUrl(object nodeIds, object parentAlias, object targetId, object ext, object aliasPath, object multiple, object action, object parameters)
    {
        string frameUrl = ResolveUrl("~/CMSModules/Content/Controls/Dialogs/Properties/DocCopyMoveProperites.aspx");

        Hashtable properties = new Hashtable();

        // Fill properties table
        properties.Add("sourcenodeids", nodeIds);
        properties.Add("parentalias", parentAlias);
        properties.Add("targetid", targetId);
        properties.Add("ext", ext);
        properties.Add("aliaspath", aliasPath);
        properties.Add("multiple", multiple);
        properties.Add("parameters", parameters);
        properties.Add("output", CurrentAction.ToString());

        Hashtable param = WindowHelper.GetItem(parameters as string) as Hashtable;

        if (param != null)
        {
            // Transfer parameters to new hashtable for iframe
            foreach (string key in param.Keys)
            {
                properties[key] = param[key];
            }
        }

        if ((action != null) && (ValidationHelper.GetInteger(targetId, 0) > 0))
        {
            properties.Add("action", action);
        }
        WindowHelper.Add(Identifier, properties);

        frameUrl = URLHelper.AddParameterToUrl(frameUrl, "params", Identifier);
        frameUrl = URLHelper.AddParameterToUrl(frameUrl, "hash", QueryHelper.GetHash(frameUrl));
        return(frameUrl);
    }
コード例 #13
0
    /// <summary>
    /// Ends work of InfiniteDash.
    /// </summary>
    public void EndInfiniteDash(ScreenAndCamera cam)
    {
        Action = CurrentAction.Nothing;

        //cam.gameObject.GetComponent<Rigidbody2D>().velocity = new Vector2(0, cam.gameObject.GetComponent<Rigidbody2D>().velocity.y - this.Velocity);
        cam.ChangeSpeed(-this.Velocity);

        halo.enabled = false;

        BoxCollider2D[] col = this.Blocks[0].GetComponents <BoxCollider2D>();
        for (int i = 0; i < col.Length; i++)
        {
            if (col[i].isTrigger)
            {
                col[i].size = new Vector2(2.07f, col[i].size.y);
                continue;
            }
            else
            {
                col[i].enabled = true;
            }
        }
        col = this.Blocks[1].GetComponents <BoxCollider2D>();
        for (int i = 0; i < col.Length; i++)
        {
            if (col[i].isTrigger)
            {
                col[i].size = new Vector2(2.07f, col[i].size.y);
                continue;
            }
            else
            {
                col[i].enabled = true;
            }
        }
    }
コード例 #14
0
    private void UnitActionSelected(CurrentAction action)
    {
        this.currentAction = action;
        GetNode <Control>("UnitActions").Visible = false;

        var maze        = GetNode <Maze>("Maze");
        var units       = this.GetTree().GetNodesInGroup(Groups.MyUnits).Cast <Unit>().ToList();
        var currentUnit = units.FirstOrDefault(a => a.IsSelected);

        switch (this.currentAction)
        {
        case CurrentAction.Move:
        {
            maze.HighliteAvailableMoves(maze.WorldToMap(currentUnit.Position), currentUnit.ClientUnit.MoveDistance);
            break;
        }

        case CurrentAction.Attack:
        {
            maze.HighliteAvailableAttacks(currentUnit.NewTarget == Vector2.Zero ? maze.WorldToMap(currentUnit.Position) : currentUnit.NewTarget, currentUnit.ClientUnit.AttackDistance, currentUnit.ClientUnit.AttackRadius);
            break;
        }
        }
    }
コード例 #15
0
 //method for returning objects via their rigidbody/physics
 //the difference between lerp and physics movement is mostly aesthetic
 private void RigidBodyTravel()
 {
     thisRigidbody.AddForce((origin - thisTransform.position).normalized, ForceMode.Impulse);
     //if object is close enough to origin, switch to LerpTravel() to ensure arrival at destination
     if(Vector3.Distance(thisTransform.position, origin) < physicsToLerpThresh)
     {
         thisRigidbody.isKinematic = true;
         thisCollider.enabled = false;
         Action = LerpTravel;
     }
 }
コード例 #16
0
ファイル: Sandbox.cs プロジェクト: polytronicgr/Rant
        public IEnumerable <RantOutput> RunSerial(double timeout, RantProgram pattern = null)
        {
            Stack <IEnumerator <RST> > callStack;
            IEnumerator <RST>          action;

            LastTimeout = timeout;
            long timeoutMS = (long)(timeout * 1000);
            bool timed     = timeoutMS > 0;
            bool stopwatchAlreadyRunning = _stopwatch.IsRunning;

            lock (PatternArgs ?? fallbackArgsLockObj)
            {
#if !DEBUG
                try
                {
#endif
                if (pattern == null)
                {
                    pattern = Pattern;
                }

                if (!_stopwatch.IsRunning)
                {
                    _stopwatch.Reset();
                    _stopwatch.Start();
                }

                callStack = new Stack <IEnumerator <RST> >();


                // Push the AST root
                CurrentAction = pattern.SyntaxTree;
                callStack.Push(pattern.SyntaxTree.Run(this));
#if !DEBUG
            }
            catch (RantRuntimeException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new RantInternalException(ex);
            }
#endif
top:
                while (callStack.Any())
                {
#if !DEBUG
                    try
                    {
#endif
                    // Get the topmost call stack item
                    action = callStack.Peek();

                    // Execute the node until it runs out of children
                    while (action.MoveNext())
                    {
                        if (timed && _stopwatch.ElapsedMilliseconds >= timeoutMS)
                        {
                            throw new RantRuntimeException(this, action.Current.Location,
                                                           GetString("err-pattern-timeout", timeout));
                        }

                        if (callStack.Count >= RantEngine.MaxStackSize)
                        {
                            throw new RantRuntimeException(this, action.Current.Location,
                                                           GetString("err-stack-overflow", RantEngine.MaxStackSize));
                        }

                        if (action.Current == null)
                        {
                            break;
                        }

                        // Push child node onto stack and start over
                        CurrentAction = action.Current;
                        callStack.Push(CurrentAction.Run(this));
                        goto top;
                    }

#if !DEBUG
                }
                catch (RantRuntimeException)
                {
                    throw;
                }
                catch (Exception ex)
                {
                    throw new RantInternalException(ex);
                }
#endif

                    if (shouldYield)
                    {
                        shouldYield = false;
                        yield return(Return());

                        AddOutputWriter();
                    }

#if !DEBUG
                    try
                    {
#endif
                    // Remove node once finished
                    callStack.Pop();
#if !DEBUG
                }
                catch (RantRuntimeException)
                {
                    throw;
                }
                catch (Exception ex)
                {
                    throw new RantInternalException(ex);
                }
#endif
                }

                if (!stopwatchAlreadyRunning)
                {
                    _stopwatch.Stop();
                }
            }
        }
コード例 #17
0
ファイル: Engine.cs プロジェクト: NikolaNikushev/TeamLutetium
 public virtual void RunGame()
 {
     this.currentAction = CurrentAction.IsRunning;
 }
コード例 #18
0
    void Update()
    {
        timer += Time.deltaTime;

        if (LoadInfo.Instance.pause == false)
        {
            hit = Physics2D.Linecast(transform.position, target.transform.position, opaqueLayers);

            if (hit.collider.gameObject.tag == "WorldPlayer" && activeAction != ActiveAction.Ignore)
            {
                currentAction = CurrentAction.Aggro;
            }
            else if (currentAction == CurrentAction.Aggro && activeAction != ActiveAction.Ignore)
            {
                currentAction = CurrentAction.LoseSight;
            }

            switch (currentAction)
            {
            case CurrentAction.Passive:

                switch (passiveAction)
                {
                case PassiveAction.Patroll:         // To do: double check to see if there's any bugs
                    if ((Vector3.Distance(transform.position, patrollPoints[currentPatrollPoint]) < 0.25f ||
                         Vector3.Distance(currentPath.Last().position, patrollPoints[currentPatrollPoint]) > 0.25f) && timer > waitTime && !lookingForPath)
                    {
                        timer = 0;
                        currentPatrollPoint += 1;
                        if (currentPatrollPoint >= patrollPoints.Count)
                        {
                            currentPatrollPoint = 0;
                        }
                        StartCoroutine(GetPath(patrollPoints[currentPatrollPoint]));
                        //currentPath = GetPath(patrollPoints[currentPatrollPoint]);
                    }

                    GoTowardsNode();
                    break;

                case PassiveAction.Wander:

                    if ((Vector3.Distance(transform.position, goalPosition) < 0.1 || currentPath.Count == 0) && timer > waitTime && !lookingForPath)
                    {
                        patrollPoints.Clear();
                        foreach (PathFindingGrid.Node node in PathFindingGrid.graph)
                        {
                            if (Vector3.Distance(transform.position, node.position) <= 3 && node.walkable)         //&& Random.Range(0, 100) < 10 )
                            {
                                patrollPoints.Add(node.position);
                            }
                        }
                        //Debug.Log("PatrollPoints: " + patrollPoints.Count);
                        goalPosition = patrollPoints[Random.Range(0, patrollPoints.Count - 1)];
                        StartCoroutine(GetPath(goalPosition));
                        //currentPath = GetPath(goalPosition);
                    }
                    else
                    {
                        GoTowardsNode();
                    }
                    break;

                case PassiveAction.Stay:
                    rigidBody.velocity = new Vector3(0, 0);
                    break;
                }

                break;

            case CurrentAction.Aggro:

                switch (activeAction)
                {
                case ActiveAction.Forget:
                case ActiveAction.Search:

                    if ((currentPath.Count == 0 || Vector3.Distance(currentPath.Last().position, target.transform.position) > 1))
                    {
                        if (!lookingForPath)
                        {
                            goalPosition = hit.point;
                            StartCoroutine(GetPath(target.transform.position));
                        }
                        else if (Vector3.Distance(goalPosition, target.transform.position) > 1)
                        {
                            StopAllCoroutines();
                            lookingForPath = false;

                            goalPosition = hit.point;
                            StartCoroutine(GetPath(target.transform.position));
                        }
                    }

                    GoTowardsNode();
                    break;

                case ActiveAction.Ignore:


                    break;
                }

                break;

            case CurrentAction.LoseSight:

                switch (activeAction)
                {
                case ActiveAction.Forget:

                    rigidBody.velocity = new Vector3(0, 0);
                    currentAction      = CurrentAction.Passive;
                    break;

                case ActiveAction.Search:
                    if (Vector3.Distance(transform.position, goalPosition) <= 0.1 || currentPath.Count == 0)
                    {
                        rigidBody.velocity = new Vector3(0, 0);
                        currentAction      = CurrentAction.Passive;
                    }
                    else
                    {
                        GoTowardsNode();
                    }
                    break;

                case ActiveAction.Ignore:

                    // Look really angry
                    break;
                }

                break;
            }
        }
        else
        {
            rigidBody.velocity = new Vector3(0, 0);
        }
    }
コード例 #19
0
 private void CommitDying()
 {
     _action = CurrentAction.Dying;
     anim.SetBool("isDying", true);
     gameObject.GetComponent <CapsuleCollider2D>().enabled = false;
 }
コード例 #20
0
        public IEnumerable <RantOutput> RunSerial(double timeout, RantPattern pattern = null)
        {
            lock (_patternArgs ?? fallbackArgsLockObj)
            {
                if (pattern == null)
                {
                    pattern = _pattern;
                }
                LastTimeout = timeout;
                long timeoutMS = (long)(timeout * 1000);
                bool timed     = timeoutMS > 0;
                bool stopwatchAlreadyRunning = _stopwatch.IsRunning;
                if (!_stopwatch.IsRunning)
                {
                    _stopwatch.Reset();
                    _stopwatch.Start();
                }

                _scriptObjectStack.Clear();
                var callStack   = new Stack <IEnumerator <RantAction> >();
                var actionStack = new Stack <RantAction>();
                IEnumerator <RantAction> action;

                // Push the AST root
                CurrentAction = pattern.Action;
                actionStack.Push(CurrentAction);
                callStack.Push(pattern.Action.Run(this));

top:
                while (callStack.Any())
                {
                    // Get the topmost call stack item
                    action = callStack.Peek();

                    // Execute the node until it runs out of children
                    while (action.MoveNext())
                    {
                        if (timed && _stopwatch.ElapsedMilliseconds >= timeoutMS)
                        {
                            throw new RantRuntimeException(pattern, action.Current.Range,
                                                           $"The pattern has timed out ({timeout}s).");
                        }

                        if (callStack.Count >= RantEngine.MaxStackSize)
                        {
                            throw new RantRuntimeException(pattern, action.Current.Range,
                                                           $"Exceeded the maximum stack size ({RantEngine.MaxStackSize}).");
                        }

                        if (action.Current == null)
                        {
                            break;
                        }

                        if (HandleRichardBreak(callStack, actionStack, action))
                        {
                            goto top;
                        }

                        // Push child node onto stack and start over
                        CurrentAction = action.Current;
                        actionStack.Push(CurrentAction);
                        callStack.Push(CurrentAction.Run(this));
                        goto top;
                    }

                    if (shouldYield)
                    {
                        shouldYield = false;
                        yield return(Return());

                        AddOutputWriter();
                    }

                    if (HandleRichardReturn(callStack, actionStack))
                    {
                        continue;
                    }

                    // Remove node once finished
                    callStack.Pop();
                    actionStack.Pop();
                }

                if (!stopwatchAlreadyRunning)
                {
                    _stopwatch.Stop();
                }
            }
        }
コード例 #21
0
ファイル: Engine.cs プロジェクト: NikolaNikushev/TeamLutetium
        private void HandleCommand(Command commandInput, string commandInputString)
        {
            switch (commandInput)
            {
                case Command.Restart:
                    this.currentAction = CurrentAction.Restarting;
                    field = new PlayField(5, 10);
                    player = new Player();
                    communicator.RenderGameField(field);
                    break;

                case Command.Top:
                    this.currentAction = CurrentAction.PrintingTopBoard;
                    communicator.RenderWinnerBoard(scoreBoard);
                    break;

                case Command.Exit:
                    this.currentAction = CurrentAction.IsNotRunning;
                    communicator.PrintUserMessage("Good Bye! ");
                    System.Threading.Thread.Sleep(500);
                    break;

                case Command.CoordinateForParsing:
                    this.currentAction = CurrentAction.CheckingCoordinates;
                    int userInputRow = parser.ParseCommandToRow(commandInputString);
                    int userInputColumn = parser.ParseCommandToCol(commandInputString);

                    field.MakeChangesToField(userInputRow, userInputColumn);
                    player.UpdateMovesAmmount();
                    if (field.ClearedLevel()) //if field is empty
                    {
                        FinalizeGame();
                        this.currentAction = CurrentAction.FinishedGame;
                    }
                    communicator.RenderGameField(field);
                    break;

                case Command.Invalid:
                    this.currentAction = CurrentAction.IsWaitingForValidInput;
                    if (parser.CheckIfCommandIsCoordinate(commandInputString, field) && !parser.CheckPoppableBalloon(commandInputString, field))
                    {
                        communicator.PrintUserMessage("Illegal move: cannot pop missing ballon!\n");
                    }
                    else
                    {
                        communicator.PrintUserMessage("Wrong input ! Try Again !\n");
                    }
                    break;
            }
        }
コード例 #22
0
    /// <summary>
    /// Ends work of Double Coiner.
    /// </summary>
    public void EndDoubleCoiner()
    {
        Action = CurrentAction.Nothing;

        Player.MultipleCoinAmount = 1;
    }
コード例 #23
0
 private void MainCanvas_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     mCurrentAction = CurrentAction.None;
 }
コード例 #24
0
 public NewActionEvent(CurrentAction action)
 {
     eventType   = "newAction";
     this.action = action;
 }
コード例 #25
0
    private void getDealerCode(CurrentAction act)
    {
        if (!(ddlDealerCode.Items.Count > 0))
        {
            if (UserHelper.IsSysAdmin || (!VDMSSetting.CurrentSetting.CheckWarrantyInfoDatabase))
            {
                ddlDealerCode.DataSource = Dealer.GetListDealerALL();
            }
            else if (UserHelper.IsVMEPService && (act == CurrentAction.AddNew) && (VDMSSetting.CurrentSetting.AllowServiceAddNewWarrantyInfoForAllRegion))
            {
                ddlDealerCode.DataSource = Dealer.GetListDealerALL();
            }
            else
            {
                ddlDealerCode.DataSource = Dealer.GetListDealerByDatabase(UserHelper.DatabaseCode);
            }

            ddlDealerCode.DataTextField = "BranchName";
            ddlDealerCode.DataValueField = "BranchCode";
            ddlDealerCode.DataBind();

            // fix sell dealer as keyin dealer
            if (UserHelper.IsDealer) ddlDealerCode.SelectedValue = UserHelper.DealerCode;
        }
    }
コード例 #26
0
        public override uint KeyDown(KeyEventArgs e, GL_ControlBase control, bool isRepeat)
        {
            TransformChangeInfos transformChangeInfos = new TransformChangeInfos(new List <TransformChangeInfo>());
            uint var = 0;

            bool selectionHasChanged = false;

            if (!isRepeat)
            {
                if ((SelectionTransformAction != NoAction || CurrentAction != null))
                {
                    SelectionTransformAction.KeyDown(e);
                    CurrentAction?.KeyDown(e);
                    var = NO_CAMERA_ACTION | REDRAW;
                }
                else
                {
                    if (e.KeyData == KS_Focus)
                    {
                        BoundingBox box = BoundingBox.Default;

                        foreach (IEditableObject obj in GetObjects())
                        {
                            obj.GetSelectionBox(ref box);
                        }

                        if (box != BoundingBox.Default)
                        {
                            control.CameraTarget = box.GetCenter();
                        }

                        var = REDRAW_PICKING;
                    }
                    else if (e.KeyData == KS_Undo)
                    {
                        Undo();

                        var = REDRAW_PICKING;
                    }
                    else if (e.KeyData == KS_Redo)
                    {
                        Redo();

                        var = REDRAW_PICKING;
                    }
                    else if (e.KeyData == KS_Hide)
                    {
                        foreach (IEditableObject obj in GetObjects())
                        {
                            if (obj.IsSelected())
                            {
                                obj.Visible = false;
                            }
                        }
                        var = REDRAW_PICKING;
                    }
                    else if (e.KeyData == KS_UnHide)
                    {
                        foreach (IEditableObject obj in GetObjects())
                        {
                            if (obj.IsSelected())
                            {
                                obj.Visible = true;
                            }
                        }
                        var = REDRAW_PICKING;
                    }
                    else if (e.KeyData == KS_SnapSelected)
                    {
                        SnapAction action = new SnapAction();
                        foreach (IEditableObject obj in GetObjects())
                        {
                            obj.ApplyTransformActionToSelection(action, ref transformChangeInfos);
                        }
                        var = REDRAW_PICKING;
                    }
                    else if (e.KeyData == KS_ResetRotation)
                    {
                        ResetRot action = new ResetRot();
                        foreach (IEditableObject obj in GetObjects())
                        {
                            obj.ApplyTransformActionToSelection(action, ref transformChangeInfos);
                        }
                        var = REDRAW_PICKING;
                    }
                    else if (e.KeyData == KS_ResetScale)
                    {
                        ResetScale action = new ResetScale();
                        foreach (IEditableObject obj in GetObjects())
                        {
                            obj.ApplyTransformActionToSelection(action, ref transformChangeInfos);
                        }
                        var = REDRAW_PICKING;
                    }
                    else if (e.KeyData == KS_DeSelectAll)
                    {
                        foreach (IEditableObject obj in GetObjects())
                        {
                            obj.DeselectAll(control);
                        }
                        selectionHasChanged = true;
                        var = REDRAW;
                    }
                    else if (e.KeyData == KS_SelectAll)
                    {
                        if (multiSelect)
                        {
                            foreach (IEditableObject obj in GetObjects())
                            {
                                obj.SelectAll(control);
                            }
                            selectionHasChanged = true;
                        }
                        var = REDRAW;
                    }
                }
            }
            foreach (IEditableObject obj in GetObjects())
            {
                var |= obj.KeyDown(e, control, isRepeat);
            }
            foreach (AbstractGlDrawable obj in StaticObjects)
            {
                var |= obj.KeyDown(e, control, isRepeat);
            }
            if (selectionHasChanged)
            {
                UpdateSelection(var);
            }

            AddTransformToUndo(transformChangeInfos);

            return(var);
        }
コード例 #27
0
        public override uint MouseDown(MouseEventArgs e, GL_ControlBase control)
        {
            bool TryGetActionType(out DragActionType dragActionType)
            {
                if (e.Button == MouseButtons.Left)
                {
                    dragActionType = DragActionType.TRANSLATE;
                    return(true);
                }
                else if (e.Button == MouseButtons.Right)
                {
                    dragActionType = DragActionType.ROTATE;
                    return(true);
                }
                else if (e.Button == MouseButtons.Middle)
                {
                    bool ctrl = WinInput.Keyboard.IsKeyDown(WinInput.Key.LeftCtrl);

                    dragActionType = ctrl ? DragActionType.SCALE_INDIVIDUAL : DragActionType.SCALE;
                    return(true);
                }
                dragActionType = DragActionType.NONE;
                return(false);
            }

            uint var = 0;

            {
                var buttons = OpenTK.Input.Mouse.GetCursorState();

                if (SelectionTransformAction == NoAction && CurrentAction == null && Hovered != null && TryGetActionType(out DragActionType dragActionType))
                {
                    if (!WinInput.Keyboard.IsKeyDown(WinInput.Key.LeftAlt))
                    {
                        Hovered.StartDragging(dragActionType, HoveredPart, this);
                    }
                }
                else if (buttons.RightButton == OpenTK.Input.ButtonState.Pressed ||                           //the right mouse button is pressed or
                         (int)buttons.LeftButton + (int)buttons.RightButton + (int)buttons.MiddleButton >= 2) //atleast 2 buttons are pressed at once
                {
                    var |= REDRAW_PICKING;
                    var |= FORCE_REENTER;

                    if (SelectionTransformAction != NoAction)
                    {
                        EndUndoCollection();
                    }

                    if (SelectionTransformAction != NoAction || CurrentAction != null)
                    {
                        control.CameraTarget = actionStartCamTarget;
                    }

                    SelectionTransformAction = NoAction; //abort current action
                    CurrentAction?.Cancel();
                    CurrentAction = null;
                }
            }

            foreach (AbstractGlDrawable obj in StaticObjects)
            {
                var |= obj.MouseDown(e, control);
            }

            foreach (IEditableObject obj in GetObjects())
            {
                var |= obj.MouseDown(e, control);
            }

            return(var);
        }
コード例 #28
0
 void Start()
 {
     Action = DoNothing;
 }
コード例 #29
0
 public void Reset()
 {
     Action = RigidBodyTravel;
     Invoke("GoHome", .2f);
 }
コード例 #30
0
    protected override void Update()
    {
        base.Update();

        //m_NavMeshAgent.destination = m_Player.transform.position;

        if (m_KingBoss.m_ShieldUp == true)
        {
            //  m_Shield.SetActive(true);
        }
        if (m_KingBoss.m_ShieldUp == false)
        {
            // m_Shield.SetActive(false);
        }

        ShowDebugStuff();

        // Enable the AI if the plater gets close
        if (GetDistanceToPlayer() < 50.0f && m_AiActive == false)
        {
            Services.GameManager.KingTriggered = true;
            m_AiActive = true;
            SetBehaviour((int)AIKingController.Behaviour.Offensive);
            SetAction((int)AIKingController.Action.None);
            m_MakeDecision = true;
        }

        // Enable the AI with button press
        if (Input.GetKeyDown("n"))
        {
            m_AiActive = true;
            SetBehaviour((int)AIKingController.Behaviour.Passive);
            SetAction((int)AIKingController.Action.Dodge);
            //SetNextAction((int)AIKingController.Action.DuelMove);
            // m_MakeDecision = true;
            //m_Animator.SetTrigger("t_Vertical_Swing");
        }

        // If the AI is active
        if (m_AiActive == true)
        {
            // If the player enters the pillars and the current beahviour isint pillar
            //if (m_LeftPillars.m_IsPlayerinside == true || m_RightPillars.m_IsPlayerinside == true && !IsCurrentAction((int)AIKingController.Behaviour.Pillar))
            //{
            //      // Change the behaviour to pillar
            //      SetBehaviour((int)AIKingController.Behaviour.Pillar);
            //}

            // If the Duel Behaviour is true and the behaviour isin't dueling
            if (m_IsDueling == true && !IsCurrentBehaviour((int)Behaviour.Dueling))
            {
                // Set Dueling to false and restart the Fire Circle cooldown
                m_IsDueling = false;
                FireCirlceCooldownTimer.Restart();
            }

            if (IsCurrentBehaviour((int)AIKingController.Behaviour.Offensive))
            {
                // If the king is walking
                if (IsCurrentAction((int)AIKingController.Action.Walk))
                {
                    // If the boss reaches melee range
                    if (GetDistanceToPlayer() < Constants.MeleeRange)
                    {
                        // Reset the walk and finish the action so the behaviour will choose the melee attack or continue walking
                        CurrentAction.Start();
                        CurrentBehaviour.OnActionFinished();
                    }
                }
            }

            // If the player and the king are in the center of the room
            if (m_RoomCenter.m_IsKingInside == true && m_RoomCenter.m_IsPlayerinside == true && m_IsDueling == false && FireCirlceCooldownTimer.IsFinished() && IsCurrentAction((int)AIKingController.Action.Walk))
            {
                // If the player is within range to start the duel
                if (GetDistanceToPlayer() < 15.0f && GetDistanceToPlayer() > 8.0f)
                {
                    // Set the action to summon fire circle and switch behaviour to dueling
                    SetBehaviour((int)AIKingController.Behaviour.Dueling);
                    SetAction((int)AIKingController.Action.FireCircle);
                    m_IsDueling = true;
                    FireCircleLengthTimer.Restart();
                }
            }
        }

        //// If the boss hit the player
        //if (m_HitPlayer == true)
        //{
        //    // Set hit to false so it only will be true for one frame
        //    m_HitPlayer = false;
        //}
    }
コード例 #31
0
    private void LerpTravel()
    {
        float returnSpeed = (1/(thisTransform.position - origin).sqrMagnitude < .5f ) ? .5f : 1/(thisTransform.position - origin).magnitude;

        thisTransform.position = Vector3.Lerp(thisTransform.position, origin, Time.fixedDeltaTime * returnSpeed * 10);
        thisTransform.rotation = Quaternion.Lerp(thisTransform.rotation, rot, Time.fixedDeltaTime * returnSpeed * 10);

        //if object is close enough to origin, stop travelling
        if((thisTransform.position - origin).sqrMagnitude < .001f)
        {
            thisTransform.position = origin;
            thisTransform.rotation = rot;

            thisRigidbody.isKinematic = false;
            thisCollider.enabled = true;
            thisRigidbody.velocity = Vector3.zero;
            thisRigidbody.angularVelocity = Vector3.zero;
            thisCollider.isTrigger = false;

            //rigidbody actions and collider actions go here
            Action = DoNothing;
        }
    }
コード例 #32
0
        private void UpdateControlsOnActionStart(CurrentAction action)
        {
            btnView.Enabled = false;
            btnValidate.Enabled = false;

            lblConvert.Enabled = false;
            lstConvert.Enabled = false;
            btnConvert.Enabled = false;
            chkSelectDeselectAll.Enabled = false;

            btnCancel.Visible = true;

            lstResults.Items.Clear();

            actionProgress.Value = 0;
            actionProgress.Visible = true;
            actionStatus.Text = string.Empty;
        }
コード例 #33
0
        public override uint KeyDown(KeyEventArgs e, GL_ControlBase control)
        {
            TransformChangeInfos transformChangeInfos = new TransformChangeInfos(new List <TransformChangeInfo>());
            uint var = 0;

            bool selectionHasChanged = false;

            if ((CurrentAction != NoAction || ExclusiveAction != NoAction) && e.KeyCode != Keys.V)
            {
                CurrentAction.KeyDown(e);
                ExclusiveAction.KeyDown(e);
                var = NO_CAMERA_ACTION | REDRAW;
            }
            else if (e.KeyCode == Keys.Z) //focus camera on the selection
            {
                if (e.Control)
                {
                    Undo();
                }
                else
                {
                    BoundingBox box = BoundingBox.Default;

                    foreach (IEditableObject obj in GetObjects())
                    {
                        obj.GetSelectionBox(ref box);
                    }

                    if (box != BoundingBox.Default)
                    {
                        control.CameraTarget = box.GetCenter();
                    }
                }

                var = REDRAW_PICKING;
            }
            else if (e.KeyCode == Keys.Y && e.Control)
            {
                Redo();

                var = REDRAW_PICKING;
            }
            else if (e.KeyCode == Keys.H) //hide/show selected objects
            {
                foreach (IEditableObject obj in GetObjects())
                {
                    if (obj.IsSelected())
                    {
                        obj.Visible = e.Shift;
                    }
                }
                var = REDRAW_PICKING;
            }
            else if (e.KeyCode == Keys.S && e.Shift) //auto snap selected objects
            {
                SnapAction action = new SnapAction();
                foreach (IEditableObject obj in GetObjects())
                {
                    obj.ApplyTransformActionToSelection(action, ref transformChangeInfos);
                }
                var = REDRAW_PICKING;
            }
            else if (e.KeyCode == Keys.R && e.Shift && e.Control) //reset scale for selected objects
            {
                ResetScale action = new ResetScale();
                foreach (IEditableObject obj in GetObjects())
                {
                    obj.ApplyTransformActionToSelection(action, ref transformChangeInfos);
                }
                var = REDRAW_PICKING;
            }
            else if (e.KeyCode == Keys.R && e.Shift) //reset rotation for selected objects
            {
                ResetRot action = new ResetRot();
                foreach (IEditableObject obj in GetObjects())
                {
                    obj.ApplyTransformActionToSelection(action, ref transformChangeInfos);
                }
                var = REDRAW_PICKING;
            }
            else if (e.Control && e.KeyCode == Keys.A) //select/deselect all objects
            {
                if (e.Shift)
                {
                    foreach (IEditableObject obj in GetObjects())
                    {
                        obj.DeselectAll(control);
                    }
                    selectionHasChanged = true;
                }

                if (!e.Shift && multiSelect)
                {
                    foreach (IEditableObject obj in GetObjects())
                    {
                        obj.SelectAll(control);
                    }
                    selectionHasChanged = true;
                }
                var = REDRAW;
            }

            foreach (IEditableObject obj in GetObjects())
            {
                var |= obj.KeyDown(e, control);
            }
            foreach (AbstractGlDrawable obj in StaticObjects)
            {
                var |= obj.KeyDown(e, control);
            }
            if (selectionHasChanged)
            {
                UpdateSelection(var);
            }

            AddTransformToUndo(transformChangeInfos);

            return(var);
        }
コード例 #34
0
ファイル: Controller.cs プロジェクト: urgamedev/TurnBasedGame
 /*********************************
  * Possible Actions:
  * 	neutral : nothing of note is happening, the default.
  *	selectedUnit : A unit is selected, but nothing has happened yet.
  *	movedUnit	: A unit has moved and is selecting the options.
  *	looking     : A unit has selected attack and is looking for opponents.
  */
 // Use this for initialization
 void Start()
 {
     currentAction = GetComponent<CurrentAction>();
     gameState = Grid.gameState;
     map = Grid.map;
 }
コード例 #35
0
 private void AddAction(int chunkIndex, Entity entity, DynamicBuffer <Action> actions, int posToAdd, CurrentAction current, Action toAdd)
 {
     if (posToAdd == 0) // if the action was added at the start of the buffer
     //Debug.Log("Added to start!");
     {
         if (current.type == ActionType.No_Action)
         {
             entityCommandBuffer.AddComponent <ChangeAction>(chunkIndex, entity, new ChangeAction {
             });                                                                                    // tell the system that the current action should be changed
         }
     }
     else  //
           //Debug.Log("Added after start");
     {
     }
     // Add the action at the correct position
     actions.Insert(posToAdd, toAdd);
 }
コード例 #36
0
ファイル: Engine.cs プロジェクト: NikolaNikushev/TeamLutetium
 /// <summary>
 /// Runs the game. Prints the field and instructions 
 /// and sets the current action of the engine to running
 /// </summary>
 public virtual void RunGame()
 {
     communicator.RenderGameField(field);
     this.currentAction = CurrentAction.IsRunning;
 }
コード例 #37
0
 private void ShowDebugStuff()
 {
     m_BossActionText.text = CurrentAction.ToString();
     //m_BossDecidedActionText.text = DecidedAction.ToString();
     //m_PlayerDistanceText.text = GetDistanceToPlayer().ToString();
 }
コード例 #38
0
        private void StartAction(CurrentAction action)
        {
            string directory = lstBaseDirectory.Text;
            if (string.IsNullOrEmpty(directory))
            {
                ShowWarning("Please specify a directory to check");
                return;
            }
            if (!Directory.Exists(directory))
            {
                ShowWarning("The directory you specified '{0}' does not exist", directory);
                return;
            }
            if (action == CurrentAction.Validate && lstValidCharsets.CheckedItems.Count == 0)
            {
                ShowWarning("Select one or more valid character sets to proceed with validation");
                return;
            }

            _currentAction = action;

            _settings.RecentDirectories.Add(directory);

            UpdateControlsOnActionStart(action);

            List<string> validCharsets = new List<string>(lstValidCharsets.CheckedItems.Count);
            foreach (string validCharset in lstValidCharsets.CheckedItems)
                validCharsets.Add(validCharset);

            WorkerArgs args = new WorkerArgs();
            args.Action = action;
            args.BaseDirectory = directory;
            args.IncludeSubdirectories = chkIncludeSubdirectories.Checked;
            args.FileMasks = txtFileMasks.Text;
            args.ValidCharsets = validCharsets;
            _actionWorker.RunWorkerAsync(args);
        }
コード例 #39
0
 private void MainCanvas_MouseLeave(object sender, MouseEventArgs e)
 {
     mCurrentAction = CurrentAction.None;
 }
コード例 #40
0
ファイル: MainForm.cs プロジェクト: rusand/EncodingChecker
        private void OnAction(object sender, EventArgs e)
        {
            CurrentAction action = (CurrentAction)((Button)sender).Tag;

            StartAction(action);
        }
コード例 #41
0
    public void CellSelected(Vector2 cell, Vector2 cellPosition, bool moveAvailable)
    {
        var maze  = GetNode <Maze>("Maze");
        var units = this.GetTree().GetNodesInGroup(Groups.MyUnits).Cast <Unit>().ToList();

        var currentUnit = units.FirstOrDefault(a => a.IsSelected);
        var unitActions = GetNode <Control>("UnitActions");

        switch (this.currentAction)
        {
        case CurrentAction.None:
        {
            var clickOnUnit = units.FirstOrDefault(a => maze.WorldToMap(a.Position) == cell || a.NewTarget == cell);
            if (currentUnit != null)
            {
                currentUnit.IsSelected = false;
            }

            GetNode <UnitDetails>("CanvasLayer/UnitDetails").SelectUnit(clickOnUnit?.ClientUnit);
            unitActions.Visible = clickOnUnit != null;

            if (clickOnUnit != null)
            {
                clickOnUnit.IsSelected = true;
                if (clickOnUnit.NewTarget == cell)
                {
                    unitActions.RectPosition = cellPosition;
                }
                else
                {
                    unitActions.RectPosition = clickOnUnit.Position;
                }
            }
            break;
        }

        case CurrentAction.Move:
        {
            if (moveAvailable)
            {
                this.currentAction = CurrentAction.None;
                currentUnit.MoveShadowTo(cell);
                unitActions.RectPosition = cellPosition;
                unitActions.Visible      = true;
                maze.RemoveHighliting();
            }
            break;
        }

        case CurrentAction.Attack:
        {
            if (moveAvailable)
            {
                this.currentAction = CurrentAction.None;
                currentUnit.AttackShadowTo(cell);
                unitActions.Visible = true;
                maze.RemoveHighliting();
            }
            break;
        }
        }
    }
コード例 #42
0
 public static void OnNewAction(CurrentAction action)
 {
     NewAction?.Invoke(BroadcastHubController.Instance, action);
 }
コード例 #43
0
        public override void Update(float frameTime)
        {
            // If we can't do anything then there's no point thinking
            if (_isDead || BehaviorSets.Count == 0)
            {
                _actionCancellation?.Cancel();
                _blackboard.GetState <LastUtilityScoreState>().SetValue(0.0f);
                CurrentAction?.Shutdown();
                CurrentAction = null;
                return;
            }

            // If we asked for a new action we don't want to dump the existing one.
            if (_actionRequest != null)
            {
                if (_actionRequest.Status != JobStatus.Finished)
                {
                    return;
                }

                ReceivedAction();
                // Do something next tick
                return;
            }

            _planCooldownRemaining -= frameTime;

            // Might find a better action while we're doing one already
            if (_planCooldownRemaining <= 0.0f)
            {
                _planCooldownRemaining = PlanCooldown;
                _actionCancellation    = new CancellationTokenSource();
                _actionRequest         = _planner.RequestAction(new AiActionRequest(SelfEntity.Uid, _blackboard, _availableActions), _actionCancellation);

                return;
            }

            // When we spawn in we won't get an action for a bit
            if (CurrentAction == null)
            {
                return;
            }

            var outcome = CurrentAction.Execute(frameTime);

            switch (outcome)
            {
            case Outcome.Success:
                if (CurrentAction.ActionOperators.Count == 0)
                {
                    CurrentAction.Shutdown();
                    CurrentAction = null;
                    // Nothing to compare new action to
                    _blackboard.GetState <LastUtilityScoreState>().SetValue(0.0f);
                }
                break;

            case Outcome.Continuing:
                break;

            case Outcome.Failed:
                CurrentAction.Shutdown();
                CurrentAction = null;
                _blackboard.GetState <LastUtilityScoreState>().SetValue(0.0f);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
コード例 #44
0
 public bool CurrentActionFinshed()
 {
     return(HasAction() == false || CurrentAction.HasFinshed() && CurrentAction.HasStarted);
 }