protected override void OnNewSubMove(Move m, SubMove sm)
        {
            if ((sm.agent is ConnectedBlock cBlock))
            {
                if (siblings.Contains(cBlock))                //we must move with this, because we are connected.
                {
                    if (CanMoveInDir(sm.dir))
                    {
                        m.AddAgentToMove(this, sm.dir, false, sm, null, 50);                        //should relies on be a submove?
                        return;
                    }
                    else
                    {
                        sm.Invalidate();
                        return;
                    }
                }
            }
            //If this is not a chain setup (which should exit the function before this code happens).

            if (sm.destinationNode == _node)
            {
                if (CanMoveInDir(sm.dir))
                {
                    m.AddAgentToMove(this, sm.dir, false, sm, sm, 60);
                }
                else
                {
                    sm.Invalidate();
                }
            }
        }
示例#2
0
        protected override void OnNewSubMove(Move m, SubMove sm)
        {
            //if we are not already involved. There is absolutely a way for this recursive move tree to get bungled up by the first thing saying "yes you can move" and a second one saying "no you cannot".
            // if (!m.IsInvolved(this))
            // {
            //we check pushing because a move should be invalid if we are being pushed.
            //below, the move should only be invalid if we are forcefully sticky. (todo: rename that lol).
            //This could be cleaned up with a check where we set the criticalToMove bool to 'destination == current || forcefullysticky'. But uh, thats conceptually harder, even if this is uglier. Whatever.
            if (sm.destinationNode == _node)
            {
                if ((sm.destinationNode.cellPos - _node.cellPos).magnitude != 1)
                {
                    // Debug.Log("edge case found?");
                }

                // bool critical = sm.agent is Player;
                //a tile agent is moving to here, we need to either invalidate the move or get pushed or move out of the way or whatever.
                if (CanMoveInDir(sm.dir))
                {
                    //critical to move should be true! but only if the move that was passed to us is critical. If we are being pushed by a stickyblock, then we aren't critical....
                    m.AddAgentToMove(this, sm.dir, false, sm, sm, 19);
                }
                else
                {
                    //we are being pushed, and we cannot move. so the submove trying to push us cannot move.
                    sm.Invalidate();
                }
            }
            else
            {
                if (onlyStickToPlayer)
                {
                    if (!(sm.agent is Player))
                    {
                        return;
                    }
                }

                //we arent being pushed. Time to behave like a sticky object, getting scraped off!
                //if we are adjacent to the moving object...
                if ((_node.cellPos - sm.startingNode.cellPos).magnitude == 1)
                {
                    if (CanMoveInDir(sm.dir))
                    {
                        //we follow along. If we don't get to move, thats fine! The thing pushing us isn't a big problem, ya know?
                        m.AddAgentToMove(this, sm.dir, false, null, sm, -5);
                    }
                    else
                    {
                        //uh oh, youre stuck to us now! sucks lol.
                        if (forcefulSticky)
                        {
                            sm.Invalidate();
                        }
                    }
                }
            }
        }
 public override void MoveToInstant(SubMove subMove, Move contextMove)
 {
     if (subMove.GetExtraData() != null)
     {
         SetFacingDir((Vector2Int)subMove.GetExtraData()); //the direction that the thing that moved is on, PROBABLY.
     }
     else
     {
         //SetFacingDir((Vector2Int) subMove.dir);
     }
     SnapTo(subMove.destinationNode);
 }
 public override void MoveTo(SubMove subMove, Move contextMove)
 {
     if (subMove.GetExtraData() != null)
     {
         SetFacingDir((Vector2Int)subMove.GetExtraData()); //the direction that the thing that moved is on, PROBABLY.
     }
     else
     {
         //SetFacingDir((Vector2Int) subMove.dir);
     }
     simpleLerpCoroutine = StartCoroutine(SimpleMoveLerp(subMove.destinationNode, 10, contextMove));
 }
        protected override void OnNewSubMove(Move m, SubMove sm)
        {
            if (!m.IsInvolved(this))
            {
                if (sm.destinationNode == _node)//if we are being pushed.
                {
                    //a tile agent is moving to here, we need to either invalidate the move or get pushed or move out of the way or whatever.
                    if (CanMoveInDir(sm.dir))
                    {
                        //critical to
                        m.AddAgentToMove(this, sm.dir, false, sm, sm, 20);
                    }
                    else
                    {
                        //we are being pushed, and we cannot move. So the submove tr
                        sm.Invalidate();
                    }
                }
                else
                {
                    Vector3Int dir = (Vector3Int)(sm.startingNode.cellPos - _node.cellPos);
                    if ((Vector3Int)FacingDir == dir && dir.magnitude == 1)//facingDir
                    {
                        //We need to check if another agent is moving into the spot of the player.

                        SubMove otherMove = m.GetSubMoveWithDestination(sm.startingNode);
                        if (otherMove != null)
                        {
                            if (otherMove.subMovePriority < 11)//ijjj
                            {
                                //that other thing is less important.
                                otherMove.Invalidate();
                            }
                            else
                            {
                                //we can't move, a more important thing is moving.
                                return;
                            }
                        }

                        if (CanMoveInDir(dir))
                        {
                            //critical to
                            SubMove newSM = m.AddAgentToMove(this, dir, false, null, sm, 11);
                            newSM.SetExtraData((Vector2Int)sm.dir);
                        }
                    }
                }
            }
        }
示例#6
0
 protected override void OnNewSubMove(Move m, SubMove sm)
 {
     if (sm.destinationNode == _node)
     {
         //this is almost identical to the default tileAgent except for this "sm.agent is player" check. Only can be pushed by the playER
         if (CanMoveInDir(sm.dir) && sm.agent is Player)
         {
             m.AddAgentToMove(this, sm.dir, false, sm);
         }
         else
         {
             sm.Invalidate();
         }
     }
 }
示例#7
0
 protected virtual void OnNewSubMove(Move m, SubMove sm)
 {
     //if we are not already involved with the move.
     if (!m.IsInvolved(this))
     {
         if (sm.destinationNode == _node)                //if we are being pushed.
         {
             //a tile agent is moving to here, we need to either invalidate the move or get pushed or move out of the way or whatever.
             if (CanMoveInDir(sm.dir))
             {
                 //critical to
                 m.AddAgentToMove(this, sm.dir, false, sm, sm, 20);
             }
             else
             {
                 //we are being pushed, and we cannot move. So the submove tryu
                 sm.Invalidate();
             }
         }
     }
 }
示例#8
0
文件: Move.cs 项目: heugel/m0nst3rz
 public SubMove(SubMove copy)
 {
     Name         = copy.Name;
     type         = copy.type;
     basedam      = copy.basedam;
     hurtselfdam  = copy.hurtselfdam;
     healself     = copy.healself;
     hurtself     = copy.hurtself;
     dodamage     = copy.dodamage;
     multihit     = copy.multihit;
     maxhits      = copy.maxhits;
     MHP          = copy.MHP;
     PP           = copy.PP;
     curPP        = copy.PP;
     critp        = copy.critp;
     hitp         = copy.hitp;
     mt           = copy.mt;
     status       = copy.status;
     statoverride = copy.statoverride;
     statlen      = copy.statlen;
     self         = copy.self;
     descr        = copy.descr;
 }
示例#9
0
 ///Movement calling these Actions
 //Passing along by Move Events.
 public void CallNewSubMove(Move move, SubMove subMove)
 {
     newSubMove?.Invoke(move, subMove);
 }
示例#10
0
 public override void MoveToInstant(SubMove subMove, Move contextMove)
 {
     SetFacingDir((Vector2Int)subMove.dir);
     SnapTo(subMove.destinationNode);
 }
示例#11
0
 public override void MoveTo(SubMove subMove, Move contextMove)
 {
     SetFacingDir((Vector2Int)subMove.dir);
     simpleLerpCoroutine = StartCoroutine(SimpleMoveLerp(subMove.destinationNode, 10, contextMove));
 }
示例#12
0
        protected override void OnNewSubMove(Move m, SubMove sm)
        {
            //distance between us and the cell we would move to (the thing we are following's starting cell).
            Vector3Int dir = sm.startingNode.cellPos - _node.cellPos;

            if (dir.magnitude == 1 && dir != -sm.dir)    //we are one block away, and not being pushed.
            {
                bool agentIsPlayer = (sm.agent is Player);
                if (!(sm.agent is FollowerAgent) && !agentIsPlayer)
                {
                    return;
                }
                SubMove otherMove = m.GetSubMoveWithDestination(sm.startingNode);
                if (otherMove != null)
                {
                    if (otherMove.subMovePriority < 10)    //ijjj
                    {
                        //that other thing is less important.
                        otherMove.Invalidate();
                    }
                    else
                    {
                        //we can't move, a more important thing is moving.
                        return;
                    }
                }
                int bonus = agentIsPlayer ? 2 : 0;       //prioritize first leader in a chain
                bonus += (dir == sm.dir ? 1 : 0);        //prioritize following straight over following curved
                m.AddAgentToMove(this, dir, false, null, sm, movePriority + bonus);
            }
            else
            {
                //If we are being pushed and are one block away.
                if (sm.destinationNode == _node && dir.magnitude == 1 && dir == -sm.dir)
                {
                    //a tile agent is moving to here, we need to either invalidate the move or get pushed or move out of the way or whatever.
                    if (CanMoveInDir(sm.dir))
                    {
                        if (m.GetValidSubMove(this, out SubMove sm2))
                        {
                            sm.SetReliesOn(sm2);
                        }
                        //critical to move should be true! but only if the move that was passed to us is critical. If we are being pushed by a stickyblock, then we aren't critical....
                        //If we ARE being pushed, criticalFor should NOT be null, or the player could end up landing on the current fella in odd edge cases.
                        m.AddAgentToMove(this, sm.dir, false, sm, sm, 12);       //this needs to be lower than the follower ones, or a follower 'further back' on a chain will push those ahead of it instead of them moving to the side.
                    }
                    else
                    {
                        //If we are moving already, then lets just move on out of the way!
                        if (m.GetValidSubMove(this, out SubMove sm2))
                        {
                            sm.SetReliesOn(sm2);
                        }
                        else
                        {
                            // sm.Invalidate();//cant move in dir that sm moves in...
                            //we need to tell the system that sm MIGHT be valid if we move out of the way... but we don't yet know if that will happen.
                            sm.ReliesOnAgentMoving(this);
                        }
                    }
                }
            }
        }
示例#13
0
 /// <summary>
 /// Used when Redo is triggered.
 /// </summary>
 public virtual void MoveToInstant(SubMove subMove, Move contextMove)
 {
     SnapTo(subMove.destinationNode);
 }
示例#14
0
        //override this and implement animation logic.

        //I use DOTween, but this starts a simple coroutine.

        public virtual void MoveTo(SubMove subMove, Move contextMove)
        {
            Assert.IsTrue(canMove);
            simpleLerpCoroutine = StartCoroutine(SimpleMoveLerp(subMove.destinationNode, 10, contextMove));
            OnMoveTo?.Invoke(subMove);
        }