コード例 #1
0
        public bool ManualPushBack(LogicVector2 position, int speed, int time, int id)
        {
            if (speed > 0)
            {
                if (this.m_parent != null && this.m_parent.GetJump() <= 0)
                {
                    if (id != 0)
                    {
                        int idx = -1;

                        for (int k = 0; k < 3; k++)
                        {
                            if (this.m_preventsPushId[k] == id)
                            {
                                return(false);
                            }

                            if (this.m_preventsPushTime[k] == 0)
                            {
                                idx = k;
                            }
                        }

                        if (idx == -1)
                        {
                            return(false);
                        }

                        this.m_preventsPushId[idx]   = id;
                        this.m_preventsPushTime[idx] = 1500;
                    }

                    LogicGameObject parent = this.m_parent.GetParent();

                    int rndX = parent.Rand(100) & 0x7F;
                    int rndY = parent.Rand(200) & 0x7F;

                    int pushBackX = rndX + position.m_x - 0x3F;
                    int pushBackY = rndY + position.m_y - 0x3F;

                    LogicVector2 pushForce = new LogicVector2((2 * speed * pushBackX) >> 8, (2 * speed * pushBackY) >> 8);

                    int prevPushBackTime = this.m_pushTime;

                    if (prevPushBackTime <= 0)
                    {
                        this.m_pushTime     = time - 16;
                        this.m_pushInitTime = time;

                        this.m_ignorePush = false;

                        this.m_pushBackStartPosition.m_x = this.m_position.m_x;
                        this.m_pushBackStartPosition.m_y = this.m_position.m_y;

                        this.m_pushBackEndPosition.m_x = this.m_position.m_x + pushForce.m_x;
                        this.m_pushBackEndPosition.m_y = this.m_position.m_y + pushForce.m_y;
                    }
                    else
                    {
                        LogicVector2 prevPushForce = new LogicVector2(this.m_pushBackEndPosition.m_x - this.m_position.m_x, this.m_pushBackEndPosition.m_y - this.m_position.m_y);

                        this.m_pushTime     = prevPushBackTime + time - 16;
                        this.m_pushInitTime = prevPushBackTime + time;

                        this.m_ignorePush = false;

                        pushForce.Add(prevPushForce);

                        this.m_pushBackStartPosition.m_x = this.m_position.m_x;
                        this.m_pushBackStartPosition.m_y = this.m_position.m_y;
                        this.m_pushBackEndPosition.m_x   = this.m_position.m_x + pushForce.m_x;
                        this.m_pushBackEndPosition.m_y   = this.m_position.m_y + pushForce.m_y;

                        prevPushForce.Destruct();
                    }

                    return(true);
                }
            }

            return(false);
        }
コード例 #2
0
        public void PushBack(LogicVector2 position, int speed, int unk1, int id, bool ignoreWeight, bool gravity)
        {
            if (speed > 0 && this.m_pushTime <= 0)
            {
                if (this.m_parent != null && this.m_parent.GetJump() <= 0 && !this.m_parent.GetParent().IsHero())
                {
                    if (id != 0)
                    {
                        int idx = -1;

                        for (int k = 0; k < 3; k++)
                        {
                            if (this.m_preventsPushId[k] == id)
                            {
                                return;
                            }

                            if (this.m_preventsPushTime[k] == 0)
                            {
                                idx = k;
                            }
                        }

                        if (idx == -1)
                        {
                            return;
                        }

                        this.m_preventsPushId[idx]   = id;
                        this.m_preventsPushTime[idx] = 1500;
                    }

                    LogicGameObject     parent = this.m_parent.GetParent();
                    LogicGameObjectData data   = parent.GetData();

                    int housingSpace = 1;

                    if (data.GetDataType() == LogicDataType.CHARACTER)
                    {
                        housingSpace = ((LogicCombatItemData)data).GetHousingSpace();

                        if (housingSpace >= 4 && !ignoreWeight)
                        {
                            return;
                        }
                    }

                    int pushForce = 256;

                    if (100 / unk1 != 0)
                    {
                        pushForce = 256 / (100 / unk1);
                    }

                    if (gravity)
                    {
                        pushForce = (LogicMath.Min(speed, 5000) << 8) / 5000 / housingSpace;
                    }

                    int rndX         = parent.Rand(100) & 0x7F;
                    int rndY         = parent.Rand(200) & 0x7F;
                    int pushBackX    = rndX + position.m_x - 0x3F;
                    int pushBackY    = rndY + position.m_y - 0x3F;
                    int pushBackTime = (1000 * pushForce) >> 8;

                    this.m_pushTime     = pushBackTime;
                    this.m_pushInitTime = pushBackTime;
                    this.m_ignorePush   = false;
                    this.m_pushBackStartPosition.m_x = this.m_position.m_x;
                    this.m_pushBackStartPosition.m_y = this.m_position.m_y;

                    pushForce *= 2;

                    this.m_pushBackEndPosition.m_x = this.m_position.m_x + ((pushForce * pushBackX) >> 8);
                    this.m_pushBackEndPosition.m_y = this.m_position.m_y + ((pushForce * pushBackY) >> 8);

                    int angle     = position.GetAngle();
                    int direction = angle <= 180 ? 180 : -180;

                    this.m_direction = direction + angle;
                }
            }
        }