예제 #1
0
        public BotAction GetNextAction()
        {
            BotAction        act            = CurrentAction;
            List <BotAction> KnownBotAcions = GetPossibleActions(MaxThinkAboutDistance, MaxSupportedZChange);

            lock (KnownBotAcions)
            {
                if (KnownBotAcions.Count > 0)
                {
                    act = KnownBotAcions[0];// (BotAction)FindBestUsage(KnownBotAcions);
                }
                if (act == null)
                {
                    SimRegion R = Actor.GetSimRegion();
                    if (R == null)
                    {
                        return(new CommandAction(Actor, "anim shrug"));
                    }
                    Vector3d v3d =
                        R.LocalToGlobal(new Vector3(MyRandom.Next(250) + 5, MyRandom.Next(250) + 5,
                                                    Actor.SimPosition.Z));
                    Actor.Debug("MoveToLocation: " + Actor.DistanceVectorString(v3d));
                    SimPosition WP = SimWaypointImpl.CreateGlobal(v3d);
                    act = new MoveToLocation(Actor, WP);
                }
                return(act);
            }
        }
예제 #2
0
    public override bool Activate()
    {
        blockOffset   = CombatExecutor.blockOffset;
        gridHeight    = CombatExecutor.gridHeight;
        characterGrid = CombatExecutor.characterGrid;
        source        = parent.GetComponent <FighterClass>();

        //source.RemoveObjectFromGrid();
        Vector3        currentPosition = GridManager.GridToPosition(source.pos, source.TileSize);
        MoveToLocation moveTo          = ScriptableObject.CreateInstance <MoveToLocation>();

        if (parent.GetComponent <SpriteFlipper>().targetLeft)
        {
            EndPos             = source.pos + new Vector2Int(-1, 0);
            moveTo.endPosition = currentPosition - new Vector3(GridManager.blockOffset.x / 2f, 0, 0);
        }
        else
        {
            EndPos             = source.pos + new Vector2Int(1, 0);
            moveTo.endPosition = currentPosition + new Vector3(GridManager.blockOffset.x / 2f, 0, 0);
        }
        moveTo.parent = parent;
        moveTo.speed  = source.WalkSpeed;
        cutscene      = moveTo;
        return(true);
    }
예제 #3
0
 public virtual void MoveCharacterExecute(Vector2Int EndPos, float walkSpeed, float jumpSpeed, GameObject[,] grid)
 {
     if (CombatExecutor.gridHeight[EndPos.x, EndPos.y] != CombatExecutor.gridHeight[pos.x, pos.y])
     {
         JumpToLocation JumpTo = ScriptableObject.CreateInstance <JumpToLocation>();
         JumpTo.endPosition = GridManager.GridToPosition(EndPos, TileSize);
         JumpTo.parent      = gameObject;
         JumpTo.heightOverHighestCharacter = 1;
         JumpTo.speed  = jumpSpeed;
         LastMoveSpeed = jumpSpeed;
         JumpTo.Activate();
         move = JumpTo;
     }
     else
     {
         MoveToLocation WalkTo = ScriptableObject.CreateInstance <MoveToLocation>();
         WalkTo.endPosition = GridManager.GridToPosition(EndPos, TileSize);
         WalkTo.parent      = gameObject;
         WalkTo.speed       = walkSpeed;
         LastMoveSpeed      = walkSpeed;
         WalkTo.Activate();
         move = WalkTo;
     }
     MoveObject(EndPos);
 }
예제 #4
0
    public void MoveToMessage(string locationId)
    {
        AssertSerializable <MoveToLocation>();

        var sut = new MoveToLocation(locationId);

        Assert.Equal(locationId, sut.LocationId);
    }
예제 #5
0
    /// <summary>
    /// Reached the endpoint of the travel path
    /// </summary>
    /// <param name="traveller">Script that called this method</param>
    public void ReachedEndpoint(RFPathTraveller traveller)
    {
        float speed = 7;

        moveToLocal = true;
        MoveToLocation mv = GetComponent <MoveToLocation>();

        mv.StartMove(transform.localPosition, startLocalPosition, true, speed);
    }
예제 #6
0
    void Start()
    {
        var entity = GetComponent <Entity>();

        actionQueue = new Queue <CharacterAction>();
        var goTo = new MoveToLocation();

        goTo.Setup(new PointContext(entity, waypoint0.position));
        actionQueue.Enqueue(goTo);

        var meleeRange = new MoveToMeleeRange();

        meleeRange.Setup(new SingleTargetContext(entity, meleeRangeTarget));
        actionQueue.Enqueue(meleeRange);
    }
예제 #7
0
파일: Actor.cs 프로젝트: dbmccoy/network
    void TurnManager_instance_step()
    {
        //routine placeholders

        if (taskList.GetListLength(taskList.moveQueue) == 0)
        {
            MoveToLocation NextLocation = new MoveToLocation(_self, taskList.NextLocation());
            NextLocation.Do();
        }

        // add intel test code

        /*if(taskList.GetListLength()==0 && location.actors.Count > 1){
         *      var t_actor = from a in location.actors where a != _self select a;
         *      taskList.AddTask(new TransferIntelLocal(_self,t_actor.FirstOrDefault(),intelligence.inv[0],location));
         *      taskList.ExecuteTask();
         * }*/
    }
예제 #8
0
    // Update is called once per frame
    void Update()
    {
        if (mv == null)
        {
            mv = AppController.instance.mtl;
        }

        if (v3origin != null)
        {
            if (mv.bouncingBack)
            {
                mv.getAgent().transform.Translate(Vector3.back * _f);
                if (Vector3.Distance(mv.getAgent().transform.position, mv.bounceBackPosition) < _f)
                {
                    mv.bouncingBack = false;
                }
            }
        }
    }
예제 #9
0
    public static void handle(ReceivablePacket packet)
    {
        switch (packet.ReadShort())
        {
        case 1:
            AccountAuthenticationResult.notify(packet);
            break;

        case 2:
            CharacterSelectionInfoResult.notify(packet);
            break;

        case 3:
            CharacterCreationResult.notify(packet);
            break;

        case 4:
            CharacterDeletionResult.notify(packet);
            break;

        case 5:
            EnterWorldInformation.notify(packet);
            break;

        case 6:
            PlayerInformation.notify(packet);
            break;

        case 7:
            DeleteObject.notify(packet);
            break;

        case 8:
            Logout.notify(packet);
            break;

        case 9:
            MoveToLocation.notify(packet);
            break;
        }
    }
예제 #10
0
 //Collision col;
 // Use this for initialization
 void Start()
 {
     v3origin = transform.position;
     mv       = AppController.instance.mtl;
 }
예제 #11
0
        protected override Composite CreateBehavior()
        {
            return(_root ?? (_root =
                                 new PrioritySelector(

                                     new Decorator(ret => Counter > NumOfTimes && QuestId == 0,
                                                   new Action(ret => _isBehaviorDone = true)),

                                     new Decorator(
                                         ret => UseType == QBType.Current,
                                         new PrioritySelector(
                                             new Decorator(
                                                 new Sequence(
                                                     new Action(ret => TreeRoot.StatusText = "Using Pet Ability:" + " " + Counter + " Out of " + NumOfTimes + " Times"),
                                                     new Action(ret => Navigator.PlayerMover.MoveStop()),
                                                     new Action(ret => StyxWoW.SleepForLagDuration()),
                                                     new Action(ret => Lua.DoString("CastPetAction({0})", AttackButton)),
                                                     new Action(ret => StyxWoW.SleepForLagDuration()),
                                                     new Action(ret => Counter++),
                                                     new Action(ret => Thread.Sleep(WaitTime)))
                                                 ))),

                                     new Decorator(
                                         ret => UseType == QBType.Location,
                                         new PrioritySelector(
                                             new Decorator(
                                                 ret => Me.Location.Distance(MoveToLocation) > 3,
                                                 new Sequence(
                                                     new Action(ret => TreeRoot.StatusText = "Moving To Use Ability at Location, Distance: " + MoveToLocation.Distance(Me.Location)),
                                                     new Action(ret => Navigator.MoveTo(MoveToLocation)))),
                                             new Sequence(
                                                 new Action(ret => TreeRoot.StatusText = "Using Pet Ability At Location:" + " " + Counter + " Out of " + NumOfTimes + " Times"),
                                                 new Action(ret => Navigator.PlayerMover.MoveStop()),
                                                 new Action(ret => StyxWoW.SleepForLagDuration()),
                                                 new Action(ret => Lua.DoString("CastPetAction({0})", AttackButton)),
                                                 new Action(ret => StyxWoW.SleepForLagDuration()),
                                                 new Action(ret => Counter++),
                                                 new Action(ret => Thread.Sleep(WaitTime)))
                                             )),

                                     new Decorator(
                                         ret => UseType == QBType.ToObject,
                                         new PrioritySelector(
                                             new Decorator(
                                                 ret => UseObject == null && Me.Location.DistanceSqr(MoveToLocation) >= 2 * 2,
                                                 new Sequence(
                                                     new Action(ret => TreeRoot.StatusText = "Moving To Use Ability around Location. Distance: " + MoveToLocation.Distance(Me.Location)),
                                                     new Action(ret => Navigator.MoveTo(MoveToLocation)))),
                                             new Decorator(
                                                 ret => UseObject != null,
                                                 new PrioritySelector(
                                                     new Decorator(
                                                         ret => UseObject.DistanceSqr >= Range * Range,
                                                         new Sequence(
                                                             new Action(ret => TreeRoot.StatusText = "Moving closer to the Target, Distance: " + MoveToLocation.Distance(Me.Location)),
                                                             new Action(ret => Navigator.MoveTo(UseObject.Location)))),
                                                     new Decorator(
                                                         ret => UseObject.DistanceSqr < MinRange * MinRange,
                                                         new Sequence(
                                                             new Action(ret => TreeRoot.StatusText = "Too Close, Backing Up"),
                                                             new Action(ret => Navigator.MoveTo(WoWMathHelper.CalculatePointFrom(Me.Location, UseObject.Location, (float)MinRange + 2f)))
                                                             )),
                                                     new Sequence(
                                                         new Action(ret => TreeRoot.StatusText = "Using Pet Ability On Target : " + UseObject.Name + " " + Counter + " Out of " + NumOfTimes + " Times"),
                                                         new Action(ret => UseObject.Target()),
                                                         new Action(ret => Navigator.PlayerMover.MoveStop()),
                                                         new Action(ret => UseObject.Face()),
                                                         new Action(ret => StyxWoW.SleepForLagDuration()),
                                                         new Action(ret => Lua.DoString("CastPetAction({0})", AttackButton)),
                                                         new Action(ret => Counter++),
                                                         new Action(ret => StyxWoW.SleepForLagDuration()),
                                                         new Action(ret => _npcBlacklist.Add(UseObject.Guid)),
                                                         new Action(ret => Thread.Sleep(WaitTime))))),
                                             new Action(ret => TreeRoot.StatusText = "No objects around. Waiting")
                                             ))
                                     )));
        }
예제 #12
0
    public override bool Update()
    {
        if (cutscenePhase == 0)
        {
            cutscene.Activate();
            cutscenePhase++;
        }
        if (cutscenePhase == 1)
        {
            bool done = cutscene.Update();
            if (done)
            {
                cutscene = null;
                cutscenePhase++;
            }
        }
        if (cutscenePhase == 2)
        {
            bool rollAllowed = false;
            if (BattleMapProcesses.isThisOnTheGrid(EndPos))
            {
                List <Vector2Int> potentialGridOccupations = source.PotentialGridOccupation(EndPos);
                bool landingEmpty = BattleMapProcesses.isTileEmpty(potentialGridOccupations, source.gameObject);
                if (landingEmpty && BattleMapProcesses.CanIMoveToTile(EndPos, source))
                {
                    rollAllowed = true;
                }
            }
            if (rollAllowed)
            {
                MoveToLocation moveTo = ScriptableObject.CreateInstance <MoveToLocation>();
                moveTo.endPosition = GridManager.GridToPosition(EndPos, source.TileSize);
                moveTo.parent      = parent;
                moveTo.speed       = source.WalkSpeed;
                cutscene           = moveTo;

                source.RemoveObjectFromGrid();
                source.AddObjectToGrid(EndPos);
            }
            else
            {
                parent.GetComponent <SpriteFlipper>().flip();
                JumpToLocation jumpTo = ScriptableObject.CreateInstance <JumpToLocation>();
                jumpTo.endPosition = GridManager.GridToPosition(source.pos, source.TileSize);
                jumpTo.parent      = parent;
                jumpTo.heightOverHighestCharacter = 0.5f;
                jumpTo.speed = source.JumpSpeed;
                cutscene     = jumpTo;

                if (BattleMapProcesses.isThisOnTheGrid(EndPos))
                {
                    if (characterGrid[EndPos.x, EndPos.y] != null)
                    {
                        target = characterGrid[EndPos.x, EndPos.y].GetComponent <FighterClass>();
                        if (target.objectID <= 10)
                        {
                            target.postBufferAttackEffect(source.Power, FighterClass.attackType.Normal, FighterClass.statusEffects.None, FighterClass.attackLocation.Ground, parent);
                        }
                    }
                }
            }
            cutscene.Activate();
            cutscenePhase++;
        }
        if (cutscenePhase == 3)
        {
            if (cutscene.Update())
            {
                cutscene = null;
                cutscenePhase++;
                return(true);
            }
        }

        //jumpToTwo.endPosition = new Vector3(EndPos.y * blockOffset.x, gridHeight[(int)EndPos.x, (int)EndPos.y] * blockOffset.z + 0, EndPos.x * blockOffset.y);
        return(false);
    }