Esempio n. 1
0
    private MOVE_TYPE GetCurrentMoveType()
    {
        float moveAngle = Vector3.SignedAngle(tpc.transform.forward, move, Vector3.up); // Positive: moving right - Negative: moving left

        MOVE_TYPE result = MOVE_TYPE.NONE;

        if (move != Vector3.zero)
        {
            if (moveAngle > 30 && moveAngle < 150)
            {
                result = MOVE_TYPE.RIGHT;
            }
            else if (moveAngle < -30 && moveAngle > -150)
            {
                result = MOVE_TYPE.LEFT;
            }
            else if (Mathf.Abs(moveAngle) >= 150)
            {
                result = MOVE_TYPE.BACK;
            }
            else
            {
                result = MOVE_TYPE.FRONT;
            }
        }

        return(result);
    }
Esempio n. 2
0
        public void InvokeChangeMode()
        {
            switch (mode)
            {
            case MOVE_TYPE.UpdateType:
                mode = MOVE_TYPE.FixedType;
                break;

            case MOVE_TYPE.FixedType:
                mode = MOVE_TYPE.UpdateType;
                break;
            }
            modeLabel.text = mode.ToString();
        }
Esempio n. 3
0
    private void MovePlayer()
    {
        // Move the player (movement will be slightly different depending on the camera type)
        move            = GetPlayerMoveNormalized();
        currentMoveType = GetCurrentMoveType();
        float speed = GetCurrentSpeed();

        move *= speed;

        _cam.transform.position += move * Time.deltaTime;
        transform.position      += move * Time.deltaTime; // Move the actual player global gameobject

        SetPlayerMovementAnimation();
    }
Esempio n. 4
0
        public static MoveEvent Create(object origin, MOVE_TYPE moveType)
        {
            MoveEvent returningEvent = EventManager.Instance.GetEventFromType<MoveEvent>(EventType.MOVE_EVENT);
            if (returningEvent == null)
            {
                returningEvent = EventManager.Instance.AddEventToPool(new MoveEvent(origin, moveType));
            }
            else
            {
                returningEvent.moveType = moveType;
                returningEvent.origin = origin;
            }

            return returningEvent;
        }
Esempio n. 5
0
    public virtual void Start()
    {
        Health = HealthMax;
        //stateHandler = GetComponent<EnemyStateHandler>();

        //set appropriate move type
        if (Flying)
        {
            MoveType = MOVE_TYPE.FLYING;
        }
        else
        {
            MoveType = MOVE_TYPE.WALKING;
        }
    }
Esempio n. 6
0
    public void ResetState()
    {
        winState      = WIN_STATE.IN_PROGRESS;
        currentPlayer = PLAYER.PLAYER1;
        nextMove      = MOVE_TYPE.PLACE_MARBLE;

        for (int i = 0; i < winningLine.Length; i++)
        {
            winningLine[i] = 0;
        }

        for (int i = 0; i < spaces.Length; i++)
        {
            spaces[i] = SPACE_STATE.UNOCCUPIED;
        }
    }
Esempio n. 7
0
    public void MakeMove(MOVE_TYPE type)
    {
        makingMove = true;
        switch (type)
        {
        case MOVE_TYPE.BULLETHELL1:
            StartCoroutine(RiseAndShoot(0));
            break;

        case MOVE_TYPE.BULLETHELL2:
            StartCoroutine(RiseAndShoot(1));
            break;

        case MOVE_TYPE.BULLETHELL3:
            StartCoroutine(RiseAndShoot(2));
            break;

        case MOVE_TYPE.LASEREYE1:
            StartCoroutine(RiseAndLaser(0));
            break;

        case MOVE_TYPE.LASEREYE2:
            StartCoroutine(RiseAndLaser(1));
            break;

        case MOVE_TYPE.LASEREYE3:
            StartCoroutine(RiseAndLaser(2));
            break;

        case MOVE_TYPE.SKYROCKET1:
            StartCoroutine(RiseAndRocket(0));
            break;

        case MOVE_TYPE.SKYROCKET2:
            StartCoroutine(RiseAndRocket(1));
            break;

        case MOVE_TYPE.SKYROCKET3:
            StartCoroutine(RiseAndLastRocket());
            break;

        default:
            break;
        }
    }
Esempio n. 8
0
    // Update is called once per frame
    void Update()
    {
        // 針の上下の動き
        switch (type)
        {
        case MOVE_TYPE.MOVE_DOWN:
            this.transform.position = new Vector3(this.transform.position.x, this.transform.position.y - 0.01f, this.transform.position.z);
            break;

        case MOVE_TYPE.MOVE_UP:
            this.transform.position = new Vector3(this.transform.position.x, this.transform.position.y + 0.01f, this.transform.position.z);
            break;
        }

        // 針の上下の動き判断
        if (this.transform.position.y < under_limit)
        {
            type = MOVE_TYPE.MOVE_UP;
        }
        if (this.transform.position.y > upper_limit)
        {
            type = MOVE_TYPE.MOVE_DOWN;
        }
    }
Esempio n. 9
0
        // make sure only 1 thread at a time is executing this method
        public void MoveActor(MOVE_TYPE mType, Actor mActor, short[] pos, ushort dir, ushort speed)
        {
            try
            {
                // check wheter the destination is in range, if not kick the client
                if (!this.MoveStepIsInRange(mActor, pos))
                {
                    Logger.ShowError("MoveStep is not in range", null);
                    mActor.e.OnKick();
                    return;
                }

                //scroll through all actors that "could" see the mActor at "from"
                //or are going "to see" mActor, or are still seeing mActor
                for (short deltaY = -1; deltaY <= 1; deltaY++)
                {
                    for (short deltaX = -1; deltaX <= 1; deltaX++)
                    {
                        uint region = (uint)(mActor.region + (deltaX * 1000000) + deltaY);
                        if (!this.actorsByRegion.ContainsKey(region))
                        {
                            continue;
                        }

                        foreach (Actor actor in this.actorsByRegion[region])
                        {
                            if (actor.ActorID == mActor.ActorID)
                            {
                                continue;
                            }

                            // A) INFORM OTHER ACTORS

                            //actor "could" see mActor at its "from" position
                            if (this.ACanSeeB(actor, mActor))
                            {
                                //actor will still be able to see mActor
                                if (this.ACanSeeB(actor, mActor, pos[0], pos[1]))
                                {
                                    if (mType == MOVE_TYPE.START)
                                    {
                                        actor.e.OnActorStartsMoving(mActor, pos, dir, speed);
                                    }
                                    else
                                    {
                                        actor.e.OnActorStopsMoving(mActor, pos, dir, speed);
                                    }
                                }
                                //actor won't be able to see mActor anymore
                                else
                                {
                                    actor.e.OnActorDisappears(mActor);
                                }
                            }
                            //actor "could not" see mActor, but will be able to see him now
                            else if (this.ACanSeeB(actor, mActor, pos[0], pos[1]))
                            {
                                actor.e.OnActorAppears(mActor);

                                //send move / move stop
                                if (mType == MOVE_TYPE.START)
                                {
                                    actor.e.OnActorStartsMoving(mActor, pos, dir, speed);
                                }
                                else
                                {
                                    actor.e.OnActorStopsMoving(mActor, pos, dir, speed);
                                }
                            }

                            // B) INFORM mActor
                            //mActor "could" see actor on its "from" position
                            if (this.ACanSeeB(mActor, actor))
                            {
                                //mActor won't be able to see actor anymore
                                if (!this.ACanSeeB(mActor, pos[0], pos[1], actor))
                                {
                                    mActor.e.OnActorDisappears(actor);
                                }
                                //mAactor will still be able to see actor
                                else
                                {
                                }
                            }

                            else if (this.ACanSeeB(mActor, pos[0], pos[1], actor))
                            {
                                //mActor "could not" see actor, but will be able to see him now
                                //send pcinfo
                                mActor.e.OnActorAppears(actor);
                            }
                        }
                    }
                }

                //update x/y/z/yaw of the actor
                mActor.X   = pos[0];
                mActor.Y   = pos[1];
                mActor.Dir = dir;


                //update the region of the actor
                uint newRegion = this.GetRegion(pos[0], pos[1]);
                if (mActor.region != newRegion)
                {
                    this.actorsByRegion[mActor.region].Remove(mActor);
                    //turn off all the ai if the old region has no player on it
                    if (GetRegionPlayerCount(mActor.region) == 0 && mActor.type == ActorType.PC)
                    {
                        MobAIToggle(mActor.region, false);
                    }
                    mActor.region = newRegion;
                    if (GetRegionPlayerCount(mActor.region) == 0 && mActor.type == ActorType.PC)
                    {
                        MobAIToggle(mActor.region, true);
                    }

                    if (!this.actorsByRegion.ContainsKey(newRegion))
                    {
                        this.actorsByRegion.Add(newRegion, new List <Actor>());
                    }

                    this.actorsByRegion[newRegion].Add(mActor);
                }
            }
            catch (Exception)
            { }
        }
Esempio n. 10
0
        // make sure only 1 thread at a time is executing this method
        public void MoveActor(MOVE_TYPE mType, Actor mActor, short[] pos, ushort dir, ushort speed)
        {
            try
            {
                // check wheter the destination is in range, if not kick the client
                if (!this.MoveStepIsInRange(mActor, pos))
                {
                    Logger.ShowError("MoveStep is not in range", null);
                    mActor.e.OnKick();
                    return;
                }

                //scroll through all actors that "could" see the mActor at "from"
                //or are going "to see" mActor, or are still seeing mActor
                for (short deltaY = -1; deltaY <= 1; deltaY++)
                {
                    for (short deltaX = -1; deltaX <= 1; deltaX++)
                    {
                        uint region = (uint)(mActor.region + (deltaX * 1000000) + deltaY);
                        if (!this.actorsByRegion.ContainsKey(region)) continue;

                        foreach (Actor actor in this.actorsByRegion[region])
                        {
                            if (actor.ActorID == mActor.ActorID) continue;

                            // A) INFORM OTHER ACTORS

                            //actor "could" see mActor at its "from" position
                            if (this.ACanSeeB(actor, mActor))
                            {
                                //actor will still be able to see mActor
                                if (this.ACanSeeB(actor, mActor, pos[0], pos[1]))
                                {
                                    if (mType == MOVE_TYPE.START)
                                        actor.e.OnActorStartsMoving(mActor, pos, dir, speed);
                                    else
                                        actor.e.OnActorStopsMoving(mActor, pos, dir, speed);
                                }
                                //actor won't be able to see mActor anymore
                                else actor.e.OnActorDisappears(mActor);
                            }
                            //actor "could not" see mActor, but will be able to see him now
                            else if (this.ACanSeeB(actor, mActor, pos[0], pos[1]))
                            {
                                actor.e.OnActorAppears(mActor);

                                //send move / move stop
                                if (mType == MOVE_TYPE.START)
                                    actor.e.OnActorStartsMoving(mActor, pos, dir, speed);
                                else
                                    actor.e.OnActorStopsMoving(mActor, pos, dir, speed);
                            }

                            // B) INFORM mActor
                            //mActor "could" see actor on its "from" position
                            if (this.ACanSeeB(mActor, actor))
                            {
                                //mActor won't be able to see actor anymore
                                if (!this.ACanSeeB(mActor, pos[0], pos[1], actor))
                                    mActor.e.OnActorDisappears(actor);
                                //mAactor will still be able to see actor
                                else { }
                            }

                            else if (this.ACanSeeB(mActor, pos[0], pos[1], actor))
                            {
                                //mActor "could not" see actor, but will be able to see him now
                                //send pcinfo
                                mActor.e.OnActorAppears(actor);
                            }
                        }
                    }
                }

                //update x/y/z/yaw of the actor
                mActor.X = pos[0];
                mActor.Y = pos[1];
                mActor.Dir = dir;

                //update the region of the actor
                uint newRegion = this.GetRegion(pos[0], pos[1]);
                if (mActor.region != newRegion)
                {
                    this.actorsByRegion[mActor.region].Remove(mActor);
                    //turn off all the ai if the old region has no player on it
                    if (GetRegionPlayerCount(mActor.region) == 0 && mActor.type == ActorType.PC)
                    {
                        MobAIToggle(mActor.region, false);
                    }
                    mActor.region = newRegion;
                    if (GetRegionPlayerCount(mActor.region) == 0 && mActor.type == ActorType.PC)
                    {
                        MobAIToggle(mActor.region, true);
                    }

                    if (!this.actorsByRegion.ContainsKey(newRegion))
                        this.actorsByRegion.Add(newRegion, new List<Actor>());

                    this.actorsByRegion[newRegion].Add(mActor);
                }
            }
            catch(Exception)
            { }
        }
 private bool TypeIsOn(MOVE_TYPE type)
 {
     return((moveType & type) == type);
 }
 private void TypeOff(MOVE_TYPE type)
 {
     moveType &= ~type;
 }
 private void TypeOn(MOVE_TYPE type)
 {
     moveType |= type;
 }
Esempio n. 14
0
        public Move(string name)
        {
            this.name = name;

            if (name.Equals("Dick Slam"))
            {
                this.pp         = 40;
                this.damage     = 77;
                this.acc        = 100;
                this.type       = TYPECHART.Robotic;
                this.asset_name = "shock";

                this.move_type    = MOVE_TYPE.Damage;
                this.moveDelegate = MoveDelegateBank.Shock;
            }

            if (name.Equals("Shock"))
            {
                this.pp         = 40;
                this.damage     = 10;
                this.acc        = 75;
                this.type       = TYPECHART.Robotic;
                this.asset_name = "shock";

                this.move_type    = MOVE_TYPE.Damage;
                this.moveDelegate = MoveDelegateBank.Shock;
            }
            else if (name.Equals("Discharge"))
            {
                this.pp         = 30;
                this.damage     = 20;
                this.acc        = 100;
                this.type       = TYPECHART.Robotic;
                this.asset_name = "discharge";

                this.move_type    = MOVE_TYPE.Damage;
                this.moveDelegate = MoveDelegateBank.Shock;
            }
            else if (name.Equals("Thunder"))
            {
                this.pp         = 20;
                this.damage     = 25;
                this.acc        = 95;
                this.type       = TYPECHART.Robotic;
                this.asset_name = "thunder";

                this.move_type    = MOVE_TYPE.Damage;
                this.moveDelegate = MoveDelegateBank.Shock;
            }
            else if (name.Equals("Lightning Bolt"))
            {
                this.pp         = 15;
                this.damage     = 30;
                this.acc        = 90;
                this.type       = TYPECHART.Robotic;
                this.asset_name = "lightning_bolt";

                this.move_type    = MOVE_TYPE.Damage;
                this.moveDelegate = MoveDelegateBank.Shock;
            }
            else if (name.Equals("Lightning"))
            {
                this.pp         = 10;
                this.damage     = 60;
                this.acc        = 50;
                this.type       = TYPECHART.Robotic;
                this.asset_name = "lightning";

                this.move_type    = MOVE_TYPE.Damage;
                this.moveDelegate = MoveDelegateBank.Shock;
            }
        }
Esempio n. 15
0
 private MoveEvent(object origin, MOVE_TYPE moveType)
     : base(origin, EventType.MOVE_EVENT)
 {
     this.moveType = moveType;
 }
Esempio n. 16
0
    //呼び出されたあと、移動先を計算
    public int Move_Calculation(int move_Num, int unit_Num)
    {
        switch (move_Num)
        {
        //前進
        case 0:
            ans_Num = unit_Num + MOVE_FRONT;
            break;

        //後退
        case 1:
            move_num = MOVE_TYPE.Back;
            ans_Num  = unit_Num + BACK_FRONT;
            move_num = MOVE_TYPE.Front;
            break;

        //左
        case 2:
            move_num = MOVE_TYPE.Left;
            ans_Num  = unit_Num + MOVE_LEFT;
            move_num = MOVE_TYPE.Front;
            break;

        //右
        case 3:
            move_num = MOVE_TYPE.Rigth;
            ans_Num  = unit_Num + MOVE_RIGTH;
            move_num = MOVE_TYPE.Front;
            break;

        //左後ろ
        case 4:
            move_num = MOVE_TYPE.Back_Left;
            ans_Num  = unit_Num + BACK_LEFT;
            move_num = MOVE_TYPE.Front;
            break;

        //右後ろ
        case 5:
            move_num = MOVE_TYPE.Back_Rigth;
            ans_Num  = unit_Num + BACK_RIGTH;
            move_num = MOVE_TYPE.Front;
            break;

        //右前
        case 6:
            move_num = MOVE_TYPE.Front_Rigth;
            ans_Num  = unit_Num + FRONT_RIGTH;
            move_num = MOVE_TYPE.Front;
            break;

        //左前
        case 7:
            move_num = MOVE_TYPE.Front_Left;
            ans_Num  = unit_Num + FRONT_LEFT;
            move_num = MOVE_TYPE.Front;
            break;

        default:
            break;
        }
        return(ans_Num);
    }
Esempio n. 17
0
    private void MovePlayer()
    {
        Vector3 vect = Vector3.zero;

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Application.Quit();
        }

        if (Input.GetAxis("Vertical") > 0.0f)
        {
            vect.y += 1.0f;
        }

        float check = Input.GetAxis("Horizontal");

        if (Input.GetAxis("Horizontal") > 0.0f)
        {
            vect.x += 1.0f;
        }

        if (Input.GetAxis("Vertical") < 0.0f)
        {
            vect.y -= 1.0f;
        }

        if (Input.GetAxis("Horizontal") < 0.0f)
        {
            vect.x -= 1.0f;
        }

        vect.Normalize();

        if (Input.GetAxis("Slowdown") == 0.0f)
        {
            move.SetMoveRun();
            //move.SetMoveJog();
        }
        else
        {
            move.SetMoveJog();
        }

        if (vect != Vector3.zero)
        {
            move_type = MOVE_TYPE.DIRECTIONAL;
        }
        else
        {
            move_type = MOVE_TYPE.WAYPOINT;
        }

        switch (move_type)
        {
        case MOVE_TYPE.DIRECTIONAL:
        {
            if (A_Star.GetWaypointCount() > 0)
            {
                A_Star.ClearWaypoints();
            }

            move.SetDirection(vect);
        }
        break;

        case MOVE_TYPE.WAYPOINT:
        {
            if (A_Star.GetWaypointCount() > 0)
            {
                // new Dir is (target pos - curr pos), then normalize
                Vector3 targetPos = A_Star.GetWaypointFirstValue();
                Vector3 currPos   = gameObject.transform.position;

                vect = targetPos - currPos;

                if (vect != Vector3.zero)
                {
                    vect.Normalize();
                    move.SetDirection(vect);
                }

                // if player is near target pos, then take node off of waypoint
                if (move.GetPosDist(targetPos, currPos) < move.RelativeSpeed())
                {
                    gameObject.transform.position = targetPos;
                    //move.SetMoveIdle();
                    A_Star.RemoveFirstWaypoint();
                }
            }
            else
            {
                move.SetMoveIdle();
            }
        }
        break;

        default:
            break;
        }
    }
Esempio n. 18
0
 public void SetDirection(Vector2 direction)
 {
     m_move_direction = direction;
     m_move_type      = MOVE_TYPE.DIRECTION;
 }
Esempio n. 19
0
    public static bool PathSearch(CoordDef start, CoordDef goal, ref Stack <CoordDef> will_move, TileWrraper[,] map, int columns, int rows, MOVE_TYPE type)
    {
        if (column != columns || row != rows)
        {
            column     = columns;
            row        = rows;
            astar_node = new Searchnode[columns, rows];
            for (int x = 0; x < columns; x++)
            {
                for (int y = 0; y < rows; y++)
                {
                    astar_node[x, y] = new Searchnode();
                }
            }
        }



        will_move = new Stack <CoordDef>();
        CoordDef ano_goal = start;
        bool     is_move  = !map[goal.X, goal.Y].HasFlag(TILE_FLAG.NONE_MOVE);

        if (!is_move)
        {
            return(false);
        }

        int heuristic          = 5;
        List <Searchnode> open = new List <Searchnode>();

        for (int x = 0; x < columns; x++)
        {
            for (int y = 0; y < rows; y++)
            {
                astar_node[x, y].pos    = new CoordDef(0, 0);
                astar_node[x, y].cfs    = 0;
                astar_node[x, y].ctg    = 0;
                astar_node[x, y].tc     = 0;
                astar_node[x, y].opcl   = 0;
                astar_node[x, y].parent = null;
            }
        }
        astar_node.Initialize();

        priqueusPush(open, astar_node[start.X, start.Y].Set(start, 0, pathCost(start, goal), null));

        while (open.Count > 0)
        {
            Searchnode node = open[0];
            open.RemoveAt(0);
            node.opcl &= ~1;
            node.opcl |= 2;
            if (node.pos == goal)
            {
                Searchnode path = node;
                int        i    = 30;
                DebugLogger.Log("start position [{0},{1}]", start.X, start.Y);
                while (path != null && path.pos != start)
                {
                    if (path.parent != null)
                    {
                        DebugLogger.Log("test willmove [{0},{1}] parent[{2},{3}]", path.pos.X, path.pos.Y, path.parent.pos.X, path.parent.pos.Y);
                    }
                    else
                    {
                        DebugLogger.Log("test willmove [{0},{1}] ", path.pos.X, path.pos.Y);
                    }
                    will_move.Push(path.pos);
                    path = path.parent;
                    i--;
                    if (i <= 0)
                    {
                        break;
                    }
                }
                DebugLogger.Log("goal position [{0},{1}]", goal.X, goal.Y);
                return(true);
            }
            else
            {
                //rect_iterator로 수정하기

                for (int x_ = -1; x_ <= 1; x_++)
                {
                    for (int y_ = -1; y_ <= 1; y_++)
                    {
                        if (x_ == 0 && y_ == 0)
                        {
                            continue;
                        }
                        CoordDef   it           = new CoordDef(node.pos.X + x_, node.pos.Y + y_);
                        Searchnode newnode      = astar_node[it.X, it.Y];
                        int        newcost      = node.cfs + 1;
                        bool       is_open      = (newnode.opcl & 1) != 0;
                        bool       is_close     = (newnode.opcl & 2) != 0;
                        bool       is_move_node = !map[it.X, it.Y].HasFlag(TILE_FLAG.NONE_MOVE);
                        DebugLogger.Log("newnode.cfs{0}, newcost{1}", newnode.cfs, newcost);
                        if (!is_move_node)
                        {
                            continue;
                        }
                        else if ((is_open || is_close) && (newnode.cfs <= newcost))
                        {
                            continue;
                        }

                        DebugLogger.Log("set [{0},{1}] cost[{2}] parent[{3},{4}]", it.X, it.Y, newcost, node.pos.X, node.pos.Y);
                        newnode.Set(new CoordDef(it.X, it.Y), newcost, heuristic * pathCost(it, goal), node);
                        priqueusPush(open, newnode);
                    }
                }
            }
        }
        return(false);
    }
Esempio n. 20
0
 public void MoveMove(MOVE_TYPE _mode, float _speed)
 {
     mode  = _mode;
     speed = _speed;
 }
Esempio n. 21
0
        // make sure only 1 thread at a time is executing this method
        public void MoveActor(MOVE_TYPE mType, Actor mActor, float[] pos, int yaw, float[] accel, uint delayTime, ushort speed)
        {
            try
            {
                // check wheter the destination is in range, if not kick the client
                if (!this.MoveStepIsInRange(mActor, pos))
                {
                    Logger.ShowError("MoveStep is not in range", null);
                    mActor.e.OnKick();
                    return;
                }

                if (mActor.type == ActorType.NPC)
                {
                    ActorNPC npc = (ActorNPC)mActor;
                    if (npc.npcType >= 50000)
                    {
                        foreach (Actor actor in this.actorsByID.Values)
                        {
                            if (actor.type != ActorType.PC) continue;
                            actor.e.OnActorStartsMoving((ActorNPC)mActor, 0, null, speed);
                        }
                        return;
                    }
                }

                //scroll through all actors that "could" see the mActor at "from"
                //or are going "to see" mActor, or are still seeing mActor
                for (short deltaY = -1; deltaY <= 1; deltaY++)
                {
                    for (short deltaX = -1; deltaX <= 1; deltaX++)
                    {
                        uint region = (uint)(mActor.region + (deltaX * 1000000) + deltaY);
                        if (!this.actorsByRegion.ContainsKey(region)) continue;

                        foreach (Actor actor in this.actorsByRegion[region])
                        {
                            //if (actor.id == mActor.id) continue;

                            // A) INFORM OTHER ACTORS

                            //actor "could" see mActor at its "from" position
                            if (this.ACanSeeB(actor, mActor))
                            {
                                //actor will still be able to see mActor
                                if (this.ACanSeeB(actor, mActor, pos[0], pos[1]))
                                {
                                    if (mType == MOVE_TYPE.START)
                                        if (mActor.type == ActorType.PC)
                                        {
                                            actor.e.OnActorStartsMoving(mActor, pos, accel, yaw, speed, delayTime);
                                        }
                                        else
                                        {
                                            mActor.yaw = yaw;
                                            actor.e.OnActorStartsMoving((ActorNPC)mActor, (byte)(accel.Length / 3), accel, speed);
                                        }
                                    else
                                        actor.e.OnActorStopsMoving(mActor, pos, yaw, speed, delayTime);
                                }
                                //actor won't be able to see mActor anymore
                                else actor.e.OnActorDisappears(mActor);
                            }
                            //actor "could not" see mActor, but will be able to see him now
                            else if (this.ACanSeeB(actor, mActor, pos[0], pos[1]))
                            {
                                actor.e.OnActorAppears(mActor);
                                actor.e.OnActorChangesState(mActor, null);

                                //send move / move stop
                                if (mType == MOVE_TYPE.START)
                                    actor.e.OnActorStartsMoving(mActor, pos, accel, yaw, speed, delayTime);
                                else
                                    actor.e.OnActorStopsMoving(mActor, pos, yaw, speed, delayTime);
                            }

                            // B) INFORM mActor
                            //mActor "could" see actor on its "from" position
                            if (this.ACanSeeB(mActor, actor))
                            {
                                //mActor won't be able to see actor anymore
                                if (!this.ACanSeeB(mActor, pos[0], pos[1], actor))
                                    mActor.e.OnActorDisappears(actor);
                                //mAactor will still be able to see actor
                                else { }
                            }

                            else if (this.ACanSeeB(mActor, pos[0], pos[1], actor))
                            {
                                //mActor "could not" see actor, but will be able to see him now
                                //send pcinfo
                                mActor.e.OnActorAppears(actor);
                                //send state
                                mActor.e.OnActorChangesState(actor, null);
                            }
                        }
                    }
                }

                //update x/y/z/yaw of the actor
                mActor.x = pos[0];
                mActor.y = pos[1];
                if (mActor.type == ActorType.NPC) mActor.z = this.GetHeight(pos[0], pos[1]);
                else mActor.z = pos[2];
                mActor.yaw = yaw;

                //update the region of the actor
                uint newRegion = this.GetRegion(pos[0], pos[1], pos[2]);
                if (mActor.region != newRegion)
                {
                    this.actorsByRegion[mActor.region].Remove(mActor);
                    //turn off all the ai if the old region has no player on it
                    if (GetRegionPlayerCount(mActor.region) == 0 && mActor.type == ActorType.PC)
                    {
                        MobAIToggle(mActor.region, false);
                    }
                    mActor.region = newRegion;
                    if (GetRegionPlayerCount(mActor.region) == 0 && mActor.type == ActorType.PC)
                    {
                        MobAIToggle(mActor.region, true);
                    }

                    if (!this.actorsByRegion.ContainsKey(newRegion))
                        this.actorsByRegion.Add(newRegion, new List<Actor>());

                    this.actorsByRegion[newRegion].Add(mActor);
                }
            }
            catch(Exception)
            { }
        }
Esempio n. 22
0
        // make sure only 1 thread at a time is executing this method
        public void MoveActor(MOVE_TYPE mType, Actor mActor, float[] pos, int yaw, float[] accel, uint delayTime, ushort speed)
        {
            try
            {
                // check wheter the destination is in range, if not kick the client
                if (!this.MoveStepIsInRange(mActor, pos))
                {
                    Logger.ShowError("MoveStep is not in range", null);
                    mActor.e.OnKick();
                    return;
                }

                if (mActor.type == ActorType.NPC)
                {
                    ActorNPC npc = (ActorNPC)mActor;
                    if (npc.npcType >= 50000)
                    {
                        foreach (Actor actor in this.actorsByID.Values)
                        {
                            if (actor.type != ActorType.PC)
                            {
                                continue;
                            }
                            actor.e.OnActorStartsMoving((ActorNPC)mActor, 0, null, speed);
                        }
                        return;
                    }
                }

                //scroll through all actors that "could" see the mActor at "from"
                //or are going "to see" mActor, or are still seeing mActor
                for (short deltaY = -1; deltaY <= 1; deltaY++)
                {
                    for (short deltaX = -1; deltaX <= 1; deltaX++)
                    {
                        uint region = (uint)(mActor.region + (deltaX * 1000000) + deltaY);
                        if (!this.actorsByRegion.ContainsKey(region))
                        {
                            continue;
                        }

                        foreach (Actor actor in this.actorsByRegion[region])
                        {
                            //if (actor.id == mActor.id) continue;

                            // A) INFORM OTHER ACTORS

                            //actor "could" see mActor at its "from" position
                            if (this.ACanSeeB(actor, mActor))
                            {
                                //actor will still be able to see mActor
                                if (this.ACanSeeB(actor, mActor, pos[0], pos[1]))
                                {
                                    if (mType == MOVE_TYPE.START)
                                    {
                                        if (mActor.type == ActorType.PC)
                                        {
                                            actor.e.OnActorStartsMoving(mActor, pos, accel, yaw, speed, delayTime);
                                        }
                                        else
                                        {
                                            mActor.yaw = yaw;
                                            actor.e.OnActorStartsMoving((ActorNPC)mActor, (byte)(accel.Length / 3), accel, speed);
                                        }
                                    }
                                    else
                                    {
                                        actor.e.OnActorStopsMoving(mActor, pos, yaw, speed, delayTime);
                                    }
                                }
                                //actor won't be able to see mActor anymore
                                else
                                {
                                    actor.e.OnActorDisappears(mActor);
                                }
                            }
                            //actor "could not" see mActor, but will be able to see him now
                            else if (this.ACanSeeB(actor, mActor, pos[0], pos[1]))
                            {
                                actor.e.OnActorAppears(mActor);
                                actor.e.OnActorChangesState(mActor, null);

                                //send move / move stop
                                if (mType == MOVE_TYPE.START)
                                {
                                    actor.e.OnActorStartsMoving(mActor, pos, accel, yaw, speed, delayTime);
                                }
                                else
                                {
                                    actor.e.OnActorStopsMoving(mActor, pos, yaw, speed, delayTime);
                                }
                            }

                            // B) INFORM mActor
                            //mActor "could" see actor on its "from" position
                            if (this.ACanSeeB(mActor, actor))
                            {
                                //mActor won't be able to see actor anymore
                                if (!this.ACanSeeB(mActor, pos[0], pos[1], actor))
                                {
                                    mActor.e.OnActorDisappears(actor);
                                }
                                //mAactor will still be able to see actor
                                else
                                {
                                }
                            }

                            else if (this.ACanSeeB(mActor, pos[0], pos[1], actor))
                            {
                                //mActor "could not" see actor, but will be able to see him now
                                //send pcinfo
                                mActor.e.OnActorAppears(actor);
                                //send state
                                mActor.e.OnActorChangesState(actor, null);
                            }
                        }
                    }
                }

                //update x/y/z/yaw of the actor
                mActor.x = pos[0];
                mActor.y = pos[1];
                if (mActor.type == ActorType.NPC)
                {
                    mActor.z = this.GetHeight(pos[0], pos[1]);
                }
                else
                {
                    mActor.z = pos[2];
                }
                mActor.yaw = yaw;


                //update the region of the actor
                uint newRegion = this.GetRegion(pos[0], pos[1], pos[2]);
                if (mActor.region != newRegion)
                {
                    this.actorsByRegion[mActor.region].Remove(mActor);
                    //turn off all the ai if the old region has no player on it
                    if (GetRegionPlayerCount(mActor.region) == 0 && mActor.type == ActorType.PC)
                    {
                        MobAIToggle(mActor.region, false);
                    }
                    mActor.region = newRegion;
                    if (GetRegionPlayerCount(mActor.region) == 0 && mActor.type == ActorType.PC)
                    {
                        MobAIToggle(mActor.region, true);
                    }

                    if (!this.actorsByRegion.ContainsKey(newRegion))
                    {
                        this.actorsByRegion.Add(newRegion, new List <Actor>());
                    }

                    this.actorsByRegion[newRegion].Add(mActor);
                }
            }
            catch (Exception)
            { }
        }
Esempio n. 23
0
 public void SetTargetPoint(Vector2 point)
 {
     m_target_point = point;
     m_move_type    = MOVE_TYPE.TARGET_POINT;
 }