Пример #1
0
    public virtual void TemporaryMoveToPathNode(PathNode pn, MoveExecutor.MoveFinished callback = null)
    {
        currentTarget.Path(pn);
        MoveExecutor me = Executor;

        me.TemporaryMoveTo(pn, delegate(Vector3 src, PathNode endNode, bool finishedNicely) {
            scheduler.CharacterMovedTemporary(
                character,
                map.InverseTransformPointWorld(src),
                map.InverseTransformPointWorld(endNode.pos),
                pn
                );
            if (callback != null)
            {
                callback(src, endNode, finishedNicely);
            }
        }, 10.0f, false, remainMounted);
    }
Пример #2
0
    public virtual void IncrementalMoveToPathNode(PathNode pn, MoveExecutor.MoveFinished callback = null)
    {
        currentTarget.Path(pn);
        MoveExecutor me = Executor;

        me.IncrementalMoveTo(pn, delegate(Vector3 src, PathNode endNode, bool finishedNicely) {
/*			Debug.Log("moved from "+src);*/
            scheduler.CharacterMovedIncremental(
                character,
                src,
                endNode.pos,
                pn
                );
            if (callback != null)
            {
                callback(src, endNode, finishedNicely);
            }
        }, 10.0f, false, remainMounted);
    }
Пример #3
0
    public virtual void PerformMoveToPathNode(PathNode pn, MoveExecutor.MoveFinished callback = null)
    {
        currentTarget.Path(pn);
        // Debug.Log("perform move to "+currentTarget);
        MoveExecutor me = Executor;

        // if(!(currentSettings.targetingMode == TargetingMode.Path && currentSettings.immediatelyExecuteDrawnPath)) {
        //  Debug.Log("first, pop back to "+initialTarget.Position);
        //  me.ImmediatelyMoveTo(new PathNode(initialTarget.Position, null, 0));
        // }
        //FIXME: really? what about chained moves?
        if (character.IsMounting && !remainMounted)
        {
            character.Dismount();
        }
        me.MoveTo(pn, delegate(Vector3 src, PathNode endNode, bool finishedNicely) {
            Character c = map.OtherCharacterAt(character, endNode.pos);
            if (c != null &&
                !character.IsMounting && !character.IsMounted &&
                !c.IsMounted && !c.IsMounting)
            {
                if (character.CanMount(c) && c.IsMountableBy(character))
                {
                    character.Mount(c);
                }
                else
                {
                    Debug.LogError("Can't mount character we're standing on!");
                }
            }
            scheduler.CharacterMoved(
                character,
                map.InverseTransformPointWorld(src),
                map.InverseTransformPointWorld(endNode.pos),
                pn
                );
            if (callback != null)
            {
                callback(src, endNode, finishedNicely);
            }
        }, 10.0f, false, remainMounted);
    }
Пример #4
0
    public void SpecialMove(
        Vector3 start,
        bool animateMoveToStart,
        string moveType,
        Region lineMove,
        float specialMoveSpeedXY,
        float specialMoveSpeedZ,
        SkillDef cause
        )
    {
        specialMoveType                = moveType;
        specialMoveExecutor.XYSpeed    = specialMoveSpeedXY;
        specialMoveExecutor.ZSpeedDown = specialMoveSpeedZ;
        List <Character> collidedCharacters = new List <Character>();
        float            direction = -1, amount = -1, remaining = -1, dropDistance = -1;
        PathNode         movePath = lineMove.GetLineMove(
            out direction,
            out amount,
            out remaining,
            out dropDistance,
            collidedCharacters,
            this,
            start
            );

        //move executor special move (path)
        specialMoveExecutor.Activate();
        CharacterSpecialMoveReport rep = new CharacterSpecialMoveReport(
            this,
            moveType,
            lineMove,
            cause,
            start,
            movePath,
            direction,
            amount,
            remaining,
            dropDistance,
            collidedCharacters
            );

        map.BroadcastMessage(
            "WillSpecialMoveCharacter",
            rep,
            SendMessageOptions.DontRequireReceiver
            );
        MoveExecutor.MoveFinished movedToStart =
            (srcStart, srcEndNode, srcFinishedNicely) => {
            Debug.Log("src finished nicely? " + srcFinishedNicely);
            specialMoveExecutor.SpecialMoveTo(
                movePath,
                (src, endNode, finishedNicely) => {
                Debug.Log(
                    "specially moved character " + this.name +
                    " by " + moveType +
                    " from " + start +
                    " in dir " + direction +
                    " node " + movePath +
                    " into " + (
                        collidedCharacters.Count == 0 ?
                        "nobody":
                        "" + collidedCharacters.Count + " folks"
                        ) +
                    " left over " + remaining +
                    " dropped " + dropDistance
                    );
                map.BroadcastMessage(
                    "DidSpecialMoveCharacter",
                    rep,
                    SendMessageOptions.DontRequireReceiver
                    );
                specialMoveExecutor.Deactivate();
                var allChars      = map.CharactersAt(endNode.pos);
                var otherChars    = allChars.Where(c => c != this && c != mountedCharacter).ToArray();
                Character[] chars = null;
                if (otherChars.Length > 0)
                {
                    //try to fix myself
                    chars = new Character[] { IsMounting?mountedCharacter: this };
                }
                if (chars != null && chars.Length > 0)
                {
                    //if any collisions left over between me and somebody else...
                    Debug.Log("fix collisions");
                    bool success = false;
                    if (!success)
                    {
                        Debug.Log("try straight");
                        success = TrySpecialMoveResponse(direction, endNode, chars, lineMove, cause);
                    }
                    if (!success)
                    {
                        Debug.Log("try left");
                        success = TrySpecialMoveResponse(SRPGUtil.WrapAngle(direction + 90), endNode, chars, lineMove, cause);
                    }
                    if (!success)
                    {
                        Debug.Log("try right");
                        success = TrySpecialMoveResponse(SRPGUtil.WrapAngle(direction - 90), endNode, chars, lineMove, cause);
                    }
                    if (!success)
                    {
                        Debug.Log("try back");
                        success = TrySpecialMoveResponse(SRPGUtil.WrapAngle(direction + 180), endNode, chars, lineMove, cause);
                    }
                    if (!success)
                    {
                        Debug.LogError("Can't shove " + chars.Length + " chars out of the way!");
                    }
                }
            }
                );
        };

        if (start != TilePosition)
        {
            if (animateMoveToStart)
            {
                specialMoveExecutor.SpecialMoveTo(
                    new PathNode(start, null, 0),
                    movedToStart,
                    3.0f
                    );
            }
            else
            {
                specialMoveExecutor.ImmediatelyMoveTo(
                    new PathNode(start, null, 0),
                    movedToStart,
                    3.0f
                    );
            }
        }
        else
        {
            movedToStart(start, new PathNode(start, null, 0), true);
        }
    }