Exemplo n.º 1
0
        public override void update(float elapsed_tm)
        {
            if (Done)
            {
                return;
            }

            base.update(elapsed_tm);

            //线型点出鱼代码
            if (getGeneratorData().mStartTime < getPassedTime())
            {
                if (getGeneratorData().mAmount == 0)
                {
                    return;
                }

                EbVector3 start_point  = new EbVector3(getGeneratorData().mStartPointX, getGeneratorData().mStartPointY, 0);
                EbVector3 end_to_start = (new EbVector3(getGeneratorData().mEndPointX, getGeneratorData().mEndPointY, 0) - start_point);

                float     angle          = CLogicUtility.getRightAngle(CLogicUtility.getAngle(-end_to_start));
                EbVector3 delta_position = end_to_start / getGeneratorData().mAmount;
                for (int i = getGeneratorData().mAmount; i > 0; i--)
                {
                    BaseEntity entity = buildEntity(getGeneratorData().mFishVibID);
                    entity.setPosition(start_point + delta_position * i);
                    entity.setDirection(angle);
                }

                setDone();
            }
        }
Exemplo n.º 2
0
        //---------------------------------------------------------------------
        public static float angle(CDirection left_direction, CDirection right_direction)
        {
            float left  = CLogicUtility.getAngle(left_direction.mDirection);
            float right = CLogicUtility.getAngle(right_direction.mDirection);

            return(_abs(left - right));
        }
Exemplo n.º 3
0
        //-------------------------------------------------------------------------
        public void update(float elapsed_tm)
        {
            if (mIsSignDestroy)
            {
                return;
            }

            CRenderFish fish = getLockFish();

            if (fish == null || fish.IsDie)
            {
                EbVector3 cur_pos = CLogicUtility.getCurrentPos(mPos, mfAngle, mfBulletSpeed, elapsed_tm);
                mPos = cur_pos;
                mSpriteBullet.setPosition(mPos);

                mSpriteBullet.setDirection(mfAngle);
            }
            else
            {
                float angle = CLogicUtility.getAngle(fish.Position - mPos);
                mPos = CLogicUtility.getCurrentPos(mPos, angle, mfBulletSpeed, elapsed_tm);

                mSpriteBullet.setPosition(mPos);
                mSpriteBullet.setDirection(angle);
            }

            if (mScene.getSceneBox().check(ref mPos, ref mfAngle))
            {
                mLockedFishObjid = -1;
                mSpriteBullet.setPosition(mPos);
                mSpriteBullet.setDirection(mfAngle);
            }
        }
Exemplo n.º 4
0
        //-----------------------------------------------------------------------------
        void _initTurning()
        {
            mIsTurning       = true;
            mTargetDirection = (mPoints[mAtWhichPoint + 1] - mPoints[mAtWhichPoint]).normalized;
            float included_angle = _abs(CLogicUtility.getAngle(mTargetDirection - mDirection));

            mAngleTurning = included_angle / mTurningMaxTime;
        }
Exemplo n.º 5
0
        //-------------------------------------------------------------------------
        public void updateTurretAngle(EbVector3 target_position)
        {
            EbVector3 bullet_direction = target_position - mTurretPos;

            mTurretAngle   = CLogicUtility.getAngle(bullet_direction);
            mBulletFirePos = mTurretPos + bullet_direction.normalized * mBarrelOffset;
            mCSpriteTurretShow.aimAt(mTurretAngle);
        }
Exemplo n.º 6
0
        void updateView(CRenderFish fish)
        {
            EbVector3 turret_position = mCRenderTurret.getTurretPos();
            EbVector3 fish_position   = fish.Position;

            float turret_fish_distance = turret_position.getDistance(fish_position);

            int rectangle_count = (int)(turret_fish_distance / mRectangleGap);

            if (rectangle_count < 0)
            {
                rectangle_count = 0;
            }
            if (mRectangle.Count > rectangle_count)
            {
                int remove_count = mRectangle.Count - rectangle_count;

                do
                {
                    mScene.getRenderObjectPool().freeStillSprite(mRectangle[0]);
                    mRectangle.RemoveAt(0);
                    --remove_count;
                } while (remove_count > 0);
            }
            else if (mRectangle.Count < rectangle_count)
            {
                int add_count = rectangle_count - mRectangle.Count;
                do
                {
                    newRectangleSprite();
                    --add_count;
                } while (add_count > 0);
            }


            float angle = CLogicUtility.getAngle(fish_position - turret_position);

            float node_count = mRectangle.Count + 2;

            for (int i = 0; i < mRectangle.Count; i++)
            {
                mRectangle[i].setPosition(EbVector3.lerp(turret_position, fish_position, ((float)i + 1) / node_count));
                mRectangle[i].setDirection(angle);
            }

            mArrow.setPosition(EbVector3.lerp(turret_position, fish_position, (node_count - 1) / node_count));
            mArrow.setDirection(angle);

            mNumber.setPosition(fish_position);
        }
Exemplo n.º 7
0
        public override void update(float elapsed_tm)
        {
            if (Done)
            {
                return;
            }

            base.update(elapsed_tm);

            //线型点出鱼代码
            if (getGeneratorData().mStartTime < getPassedTime())
            {
                if (getGeneratorData().mAmount == 0)
                {
                    return;
                }

                EbVector3 centre_position = new EbVector3(getGeneratorData().mStartPointX, getGeneratorData().mStartPointY, 0);
                float     delta_angle     = 360f / getGeneratorData().mAmount;
                int       fish_vib_id     = -1;

                for (int i = getGeneratorData().mAmount; i > 0; i--)
                {
                    if (getGeneratorData().mRedFishIndex == i - 1)
                    {
                        fish_vib_id = getGeneratorData().mRedFishVibId;
                        if (fish_vib_id <= 0)
                        {
                            fish_vib_id = getGeneratorData().mFishVibID;
                        }
                    }
                    else
                    {
                        fish_vib_id = getGeneratorData().mFishVibID;
                    }

                    EbVector3 point_position = centre_position + CLogicUtility.getDirection(90 + delta_angle * i) * getGeneratorData().mRadius;

                    BaseEntity entity = buildEntity(
                        fish_vib_id);
                    entity.setPosition(point_position);
                    entity.setDirection(CLogicUtility.getRightAngle(CLogicUtility.getAngle(point_position - centre_position)));

                    entity.setSpeed(getGeneratorData().mAngleSpeed * 2f * (float)Math.PI * getGeneratorData().mRadius / 360f);
                    entity.setAngleSpeed(getGeneratorData().mAngleSpeed);
                }

                setDone();
            }
        }
Exemplo n.º 8
0
        //-----------------------------------------------------------------------------
        void _calculateDirection(float elapsed_tm)
        {
            if (mIsTurning)
            {
                float included_angle = _abs(CLogicUtility.getAngle(mTargetDirection - mDirection));
                float t = mAngleTurning * elapsed_tm / included_angle;

                mDirection = EbVector3.lerp(mDirection, mTargetDirection, t);

                if (t >= 1)
                {
                    mIsTurning = false;
                }
            }
        }
Exemplo n.º 9
0
        //-------------------------------------------------------------------------
        void create(EbVector3 cur_pos)
        {
            string animation_name = "";

            float scale_x = 1f;
            float scale_y = 1f;
            float width_x = 10f;
            float width_y = 60f;

            if (mScene.getLevel().getRandoNumber(0, 100) < 50)
            {
                animation_name = "lightening-yellow";
                scale_y        = width_y / 132f;
                width_x        = 360f;
            }
            else
            {
                animation_name = "lightning-green";
                scale_y        = width_y / 85f;
                width_x        = 420f;
            }
            foreach (var n in fish_list)
            {
                float distance = n.Position.getDistance(cur_pos);
                if (distance > 1100)
                {
                    continue;
                }
                EbVector3   middle_pos   = EbVector3.lerp(n.Position, cur_pos, 0.5f);
                StillSprite still_sprite = mScene.getRenderObjectPool().newStillSprite();
                still_sprite.setPosition(middle_pos);
                still_sprite.setLayer(mScene.getLayerAlloter().getLayer(_eLevelLayer.FishSwim));

                still_sprite.setDirection(CLogicUtility.getAngle(CLogicUtility.getVector2ByRotateAngle(cur_pos - n.Position, 90)));
                still_sprite.setScale(n.Position.getDistance(cur_pos) / width_x, scale_y);

                still_sprite.playAnimation(animation_name);

                mListLight.Add(still_sprite);

#if UNITY_EDITOR
                still_sprite.gameObject.name = "TkSpriteEffectLighting_" + animation_name;
#endif
            }
        }
Exemplo n.º 10
0
        //---------------------------------------------------------------------
        public void update(float elapsed_tm)
        {
            mLifeCounter -= elapsed_tm;
            if (mLifeCounter < 0)
            {
                CLogicTurret turret = mScene.getTurret(mPlayerId);
                if (turret != null)
                {
                    turret.removeBullet(mBulletObjId);
                }
                return;
            }

            // 不是机器人则直接返回
            if (mBulletCollider == null)
            {
                return;
            }

            CLogicFish fish = getLockFish();

            if (fish == null || fish.IsDie)
            {
                EbVector3 cur_pos = CLogicUtility.getCurrentPos(mPos, mfAngle, mfBulletSpeed, elapsed_tm);
                mPos = cur_pos;
                mBulletCollider.setPosition(mPos);
            }
            else
            {
                mfAngle = CLogicUtility.getAngle(fish.Position - mPos);
                mPos    = CLogicUtility.getCurrentPos(mPos, mfAngle, mfBulletSpeed, elapsed_tm);
                mBulletCollider.setPosition(mPos);
                mBulletCollider.setDirection(mfAngle);
            }

            if (mScene.getSceneBox().check(ref mPos, ref mfAngle))
            {
                mLockedFishObjid = -1;
                mBulletCollider.setPosition(mPos);
                mBulletCollider.setDirection(mfAngle);
            }
        }
Exemplo n.º 11
0
        //-------------------------------------------------------------------------
        public void update(float elapsed_tm)
        {
            if (mDynamicSystem != null)
            {
                mTotalElapsedTime += elapsed_tm;
                EbVector3 acc = mDynamicSystem.getAcce(mTotalElapsedTime, mViSpeed);
                if (mDynamicSystem.IsDelay)
                {
                }
                else
                {
                    mViSpeed  = mViSpeed + acc * elapsed_tm;
                    mPosition = mPosition + mViSpeed * elapsed_tm;
                    mAngle    = CLogicUtility.getAngle(mViSpeed);

                    if (mDynamicSystem.IsEnd)
                    {
                        mIsEndRoute = true;
                    }
                }
            }
            else
            if (mIRoute != null)
            {
                mIRoute.next(elapsed_tm, mSpeed);
                mPosition = mIRoute.Position;
                mAngle    = CLogicUtility.getAngle(mIRoute.Direction);

                if (mIRoute.IsEndRoute)
                {
                    mIsEndRoute = true;
                }
            }
            else
            {
                //mAngle += mAngleSpeed * elapsed_tm;

                float newAngle = mAngle + mAngleSpeed * elapsed_tm;

                if (mAngleSpeed > 0)
                {
                    if (mAngle <= 180 && newAngle > 180)
                    {
                        mAngle = newAngle - 360;
                    }
                    else
                    {
                        mAngle = newAngle;
                    }
                }
                else
                {
                    //if (mAngle <= -180) mAngle = mAngle - 180;
                    if (mAngle > -180 && newAngle <= 180)
                    {
                        mAngle = newAngle + 360;
                    }
                    else
                    {
                        mAngle = newAngle;
                    }
                }

                //mAngle = regularAngle(mAngle);

                mPosition += CLogicUtility.getDirection(mAngle) * mSpeed * elapsed_tm;
            }

            _updateState();
        }
Exemplo n.º 12
0
 //---------------------------------------------------------------------
 public CAngle toAngle()
 {
     return(new CAngle(CLogicUtility.getAngle(mDirection)));
 }
Exemplo n.º 13
0
        //---------------------------------------------------------------------
        float randomTurretAngle()
        {
            EbVector3 bullet_direction = randomTarget() - mTurret.getTurretPos();

            return(CLogicUtility.getAngle(bullet_direction));
        }
Exemplo n.º 14
0
        //---------------------------------------------------------------------
        float getTurretAngle(EbVector3 target_position)
        {
            EbVector3 bullet_direction = target_position - mTurret.getTurretPos();

            return(CLogicUtility.getAngle(bullet_direction));
        }
Exemplo n.º 15
0
 //-------------------------------------------------------------------------
 float getHitAngle(EbVector3 fish_pos, EbVector3 bullet_pos)
 {
     return(CLogicUtility.getAngle(fish_pos - bullet_pos));
 }
Exemplo n.º 16
0
        //---------------------------------------------------------------------
        public bool check(ref EbVector3 position, ref float direction)
        {
            EbVector3 dir_vector = CLogicUtility.getDirection(direction);

            if (position.x < -CCoordinate.LogicSceneLength / 2)
            {
                if (dir_vector.x == 0)
                {
                    return(false);
                }
                EbVector3 return_postion = new EbVector3();
                return_postion.x = -CCoordinate.LogicSceneLength / 2;
                return_postion.y = straightLineEquationByX(position, dir_vector, return_postion.x);
                return_postion.z = position.z;
                position         = return_postion;
                dir_vector.x     = -dir_vector.x;
                direction        = CLogicUtility.getAngle(dir_vector);
                return(true);
            }

            if (position.x > CCoordinate.LogicSceneLength / 2)
            {
                if (dir_vector.x == 0)
                {
                    return(false);
                }
                EbVector3 return_postion = new EbVector3();
                return_postion.x = CCoordinate.LogicSceneLength / 2;
                return_postion.y = straightLineEquationByX(position, dir_vector, return_postion.x);
                return_postion.z = position.z;
                position         = return_postion;
                dir_vector.x     = -dir_vector.x;
                direction        = CLogicUtility.getAngle(dir_vector);
                return(true);
            }

            if (position.y < -CCoordinate.LogicSceneWidth / 2)
            {
                if (dir_vector.y == 0)
                {
                    return(false);
                }
                EbVector3 return_postion = new EbVector3();
                return_postion.y = -CCoordinate.LogicSceneWidth / 2;
                return_postion.x = straightLineEquationByY(position, dir_vector, return_postion.y);
                return_postion.z = position.z;
                position         = return_postion;
                dir_vector.y     = -dir_vector.y;
                direction        = CLogicUtility.getAngle(dir_vector);
                return(true);
            }

            if (position.y > CCoordinate.LogicSceneWidth / 2)
            {
                if (dir_vector.y == 0)
                {
                    return(false);
                }
                EbVector3 return_postion = new EbVector3();
                return_postion.y = CCoordinate.LogicSceneWidth / 2;
                return_postion.x = straightLineEquationByY(position, dir_vector, return_postion.y);
                return_postion.z = position.z;
                position         = return_postion;
                dir_vector.y     = -dir_vector.y;
                direction        = CLogicUtility.getAngle(dir_vector);
                return(true);
            }

            return(false);
        }