Exemplo n.º 1
0
    private void SetNextWayPoint(RunDirection direction)
    {
        try
        {
            //Find the next tile
            Vector3 currentTilePos = _currentTile.gameObject.transform.position;

            switch (direction)
            {
            case RunDirection.North:
                _nextTile = LevelModel.Instance.Tiles[(int)currentTilePos.z + 1][(int)currentTilePos.x];
                break;

            case RunDirection.South:
                _nextTile = LevelModel.Instance.Tiles[(int)currentTilePos.z - 1][(int)currentTilePos.x];
                break;

            case RunDirection.East:
                _nextTile = LevelModel.Instance.Tiles[(int)currentTilePos.z][(int)currentTilePos.x + 1];
                break;

            case RunDirection.West:
                _nextTile = LevelModel.Instance.Tiles[(int)currentTilePos.z][(int)currentTilePos.x - 1];
                break;
            }
        }
        catch
        {
            LevelManager.Points++;
            Destroy(this.gameObject);
        }
    }
Exemplo n.º 2
0
    private void FindNextWaypoint(bool ignoreLast = false)
    {
        if (!ignoreLast)
        {
            if (Random.value < 0.33f)
            {
                ignoreLast = true;
            }
        }

        if (CanRunTo(_lastRunDirection) && !ignoreLast)
        {
            SetNextWayPoint(_lastRunDirection);
        }
        else
        {
            RunDirection[] possibleDirection = (RunDirection[])Enum.GetValues(typeof(RunDirection));
            RunDirection   nextDirection;

            do
            {
                int next;
                do
                {
                    next = UnityEngine.Random.Range((int)possibleDirection[0], (int)possibleDirection[possibleDirection.Length - 1] + 3);
                } while (next > (int)possibleDirection[possibleDirection.Length - 1]);
                nextDirection = (RunDirection)next;
            }while (!CanRunTo(nextDirection));

            SetNextWayPoint(nextDirection);
            _lastRunDirection = nextDirection;
        }

        _state = LemmingState.RunningToWaypoint;
    }
Exemplo n.º 3
0
    public static float ToRotation(RunDirection direction)
    {
        float rotation;

        _directionMapping.TryGetByFirst(direction, out rotation);
        return(rotation);
    }
Exemplo n.º 4
0
        public void JudgeBallSacleFbxVector(Vector3 ballVec, RunDirection direction)
        {
            Vector3 offset = Vector3.right;

            switch (direction)
            {
            case RunDirection.Up:
                offset = Vector3.forward;
                break;

            case RunDirection.Down:
                offset = Vector3.forward * (-1);
                break;

            case RunDirection.Left:
                offset = Vector3.right * (-1);
                break;

            case RunDirection.Right:
                offset = Vector3.right;
                break;

            case RunDirection.LeftUp:
                offset = new Vector3(-1, 0, 1);
                break;

            case RunDirection.LeftDown:
                offset = new Vector3(-1, 0, -1);
                break;

            case RunDirection.RightUp:
                offset = new Vector3(1, 0, 1);
                break;

            case RunDirection.RightDown:
                offset = new Vector3(1, 0, -1);
                break;
            }

            float   baseY      = 0f; // 3f
            Vector3 ballIntVec = new Vector3(Mathf.Round(ballVec.x), baseY + 0f, Mathf.Round(ballVec.z));
            Vector3 pos        = ballIntVec;

            while (mapVecDic.ContainsKey(pos))
            {
                ballFbxPos = pos;
                pos       += offset;
            }

            if (ballFbxPos == ballIntVec)
            {
                ballFbxPos = outBorderVec;
            }
            else
            {
                isPlayScaleFbx = true;
                //Debug.Log("####### " + ballFbxPos);
            }
        }
Exemplo n.º 5
0
 private bool CanRunTo(RunDirection direction)
 {
     if (_currentTile == null)
     {
         return(false);
     }
     return(_currentTile.QueryDirections()[direction]);
 }
Exemplo n.º 6
0
 private static string UniJIS_UCS2(RunDirection dir, bool halfWidth)
 {
     if (halfWidth)
     {
         return(dir == RunDirection.Vertical ? "UniJIS-UCS2-HW-V" : "UniJIS-UCS2-HW-H");
     }
     else
     {
         return(dir == RunDirection.Vertical ? "UniJIS-UCS2-V" : "UniJIS-UCS2-H");
     }
 }
Exemplo n.º 7
0
 public override int GetHashCode()
 {
     unchecked
     {
         int result = EndPoint.GetHashCode();
         result = (result * 397) ^ StartPoint.GetHashCode();
         result = (result * 397) ^ RunDirection.GetHashCode();
         result = (result * 397) ^ IsUnknown.GetHashCode();
         return(result);
     }
 }
Exemplo n.º 8
0
        void Update()
        {
            if (GameMgr.instance.isOpenTouchCtrl && isPointerDown)
            {
                Vector3 offsetVec = Input.mousePosition - lastMousePos;
                float   distance  = Vector3.Distance(Input.mousePosition, lastMousePos);
                if (distance < limitDistance)
                {
                    return;
                }

                float   angle  = Vector3.Angle(Vector3.up, offsetVec); //求出两向量之间的夹角
                Vector3 normal = Vector3.Cross(Vector3.up, offsetVec); //叉乘求出法线向量
                angle *= Mathf.Sign(Vector3.Dot(normal, Vector3.up));  //求法线向量与物体上方向向量点乘,结果为1或-1,修正旋转方向

                RunDirection runDirection = GetRunDirectionByAngle(offsetVec, angle);
                //lastDirection = runDirection;
                ChangeGroundRotate(runDirection);

                lastMousePos = Input.mousePosition;

                if (ballTrm != null)
                {
                    JudgeBallSacleFbxVector(ballTrm.localPosition, runDirection);
                    //JudgeBallSacleFbx();
                }
            }
            else
            {
                JudgeBallSacleFbx();
            }

            //Debug.Log("@@@@@@@ 速率:" + ballRigidbody.velocity.magnitude);
            //if (ballRigidbody.velocity.magnitude < 1)
            //{
            //    lastDirection = RunDirection.None;
            //    BallMoveFbx(ballRigidbody.velocity.magnitude, RunDirection.None);
            //}
            //else
            //{
            //    BallMoveFbx(ballRigidbody.velocity.magnitude, lastDirection);
            //}
        }
 public GeneralSBJControllerSettings (double bias, bool acBias, double range, bool isAutoRangeOn,double biasError, string gain, double triggerVoltage,
                              double triggerConductance, int sampleRate,
                              int totalSamples, int pretriggerSamples,
                              int stepperWaitTime1, int stepperWaitTime2, bool isFileSavingRequired, 
                              bool useKeithley, bool changeGain, string path, int currentFileNumber, int totalNUmberOfCycles,
                              double shourtCircuitVoltage, double openCircuitVoltage, bool useDefaultGain, 
                              bool useShortCircuitDelayTime, int shortCircuitDelayTime,
                              RunDirection runDirection, Sample bottom, Sample top)
 {
     Bias = bias;
     ACBias = acBias;
     Range = range;
     AutoRange = isAutoRangeOn;
     BiasError = biasError;
     Gain = gain;
     TriggerConductance = triggerConductance;
     TriggerVoltage = triggerVoltage;
     SampleRate = sampleRate;
     TotalSamples = totalSamples;
     PretriggerSamples = pretriggerSamples;
     StepperWaitTime1 = stepperWaitTime1;
     StepperWaitTime2 = stepperWaitTime2;
     IsFileSavingRequired = isFileSavingRequired;
     UseKeithley = useKeithley;
     ChangeGain = changeGain;
     UseShortCircuitDelayTime = useShortCircuitDelayTime;
     ShortCircuitDelayTime = shortCircuitDelayTime;
     Path = path;
     CurrentFileNumber = currentFileNumber;
     TotalNumberOfCycles = totalNUmberOfCycles;
     ShortCircuitVoltage = shourtCircuitVoltage;
     OpenCircuitVoltage = openCircuitVoltage;
     UseDefaultGain = useDefaultGain;
     RunDirection = runDirection;
     Bottom = bottom;
     Top = top;
 }
Exemplo n.º 10
0
 private static string Identity(RunDirection dir, bool halfWidth)
 {
     return(dir == RunDirection.Vertical ? BaseFont.IDENTITY_V : BaseFont.IDENTITY_H);
 }
 private void _Run(RunDirection direction)
 {
     if(_isOnGround) {
         _isRunning = true;
         _currRunDirection = direction;
     }
 }
Exemplo n.º 12
0
 ///<summary>
 ///ISO-8859-3(Latin 3)エスペラントのサーカムフレックスつき g に必要。
 /// </summary>
 private static string Latin3(RunDirection dir, bool halfWidth)
 {
     return("ISO-8859-3");
 }
Exemplo n.º 13
0
 private static string Identity(RunDirection dir, bool halfWidth)
 {
     return dir == RunDirection.Vertical ? BaseFont.IDENTITY_V : BaseFont.IDENTITY_H;
 }
Exemplo n.º 14
0
 public BaseFont CreateBaseFont(RunDirection dir, bool halfWidth)
 {
     return BaseFont.CreateFont(Name, Encoding(dir, halfWidth), Embedded);
 }
Exemplo n.º 15
0
 private static string UniJIS_UCS2(RunDirection dir, bool halfWidth)
 {
     if (halfWidth)
         return dir == RunDirection.Vertical ? "UniJIS-UCS2-HW-V" : "UniJIS-UCS2-HW-H";
     else
         return dir == RunDirection.Vertical ? "UniJIS-UCS2-V" : "UniJIS-UCS2-H";
 }
Exemplo n.º 16
0
        /// <summary>
        /// Get the task for the data aquisition
        /// </summary>
        /// <param name="settings"></param>
        /// <param name="worker"></param>
        /// <param name="e"></param>
        /// <returns></returns>
        private Task GetMultipleChannelsTriggeredTask(SBJControllerSettings settings, string taskName, RunDirection runDirection, AnalogEdgeReferenceTriggerSlope triggerSlope, double triggerVoltage, BackgroundWorker worker, DoWorkEventArgs e)
        {
            AnalogEdgeReferenceTriggerSlope localTriggerSlope;
            double localTriggerVoltage;

            //
            // Determine the trigger slope direction and voltage according to sign of the measured signal.
            //
            if (triggerSlope > 0) 
            {
                localTriggerSlope = triggerSlope;
                localTriggerVoltage = triggerVoltage;
            }
            else
            {
                //
                // Reach to contact in order to retrieve the signal.
                // 
                if (settings.ElectromagnetSettings.IsEMEnable)
                {
                    EMTryObtainShortCircuit(settings.ElectromagnetSettings.EMShortCircuitDelayTime, settings.GeneralSettings.ShortCircuitVoltage, worker, e);
                }
                else
                {
                    TryObtainShortCircuit(settings.GeneralSettings.ShortCircuitVoltage, settings.GeneralSettings.UseShortCircuitDelayTime, settings.GeneralSettings.ShortCircuitDelayTime, worker, e);
                }

                //
                // Determines the direction of the current - 
                // Either positive (then voltage is negative) or negative (then voltage is positive number)
                //
                bool isPositiveVoltage = AnalogIn(0) > 0;

                //
                // Trigger's slope depends both on voltage sign and also on the direction of measurement - break or make junction.
                //
                if (isPositiveVoltage)
                {
                    localTriggerSlope = (runDirection == RunDirection.Break) ? AnalogEdgeReferenceTriggerSlope.Falling : AnalogEdgeReferenceTriggerSlope.Rising;
                }
                else
                {
                    localTriggerSlope = (runDirection == RunDirection.Break) ? AnalogEdgeReferenceTriggerSlope.Rising : AnalogEdgeReferenceTriggerSlope.Falling;
                }

                localTriggerVoltage = isPositiveVoltage ? settings.GeneralSettings.TriggerVoltage * (-1) : settings.GeneralSettings.TriggerVoltage;

                //
                // Before re-openning the junction set auto range off
                // so we can stay at high range suitable to E5 gain.
                //
                if (settings.GeneralSettings.UseKeithley)
                {
                    m_sourceMeter.SetAutoRange(false);
                }

                //
                // Open the junction once again as if we didn't do anything.
                //
                if (settings.ElectromagnetSettings.IsEMEnable)
                {
                    EMTryObtainOpenCircuit(settings.ElectromagnetSettings.EMShortCircuitDelayTime, settings.GeneralSettings.OpenCircuitVoltage, worker, e);
                }
                else
                {
                    TryObtainOpenCircuit(settings.GeneralSettings.OpenCircuitVoltage, worker, e);
                }
            }            

            //
            // Create the task with its propertites
            //
            TriggeredTaskProperties taskProperties = new TriggeredTaskProperties(taskName,
                                                                                 settings.ChannelsSettings.ActiveChannels,                                                                                 
                                                                                 settings.GeneralSettings.SampleRate,
                                                                                 settings.GeneralSettings.TotalSamples,
                                                                                 localTriggerVoltage,
                                                                                 settings.GeneralSettings.PretriggerSamples,
                                                                                 localTriggerSlope);


            return m_daqController.CreateMultipleChannelsTriggeredTask(taskProperties);
        }
Exemplo n.º 17
0
 ///<summary>
 ///ISO-8859-3(Latin 3)エスペラントのサーカムフレックスつき g に必要。
 /// </summary>
 private static string Latin3(RunDirection dir, bool halfWidth)
 {
     return "ISO-8859-3";
 }
Exemplo n.º 18
0
    // Start is called before the first frame update
    public void Start()
    {
        body.gravityScale = 3.5f;
        body.constraints  = RigidbodyConstraints2D.FreezeRotation;


        // BoxCollider2D
        //col.size = new Vector2(1, 1.5f);
        //col.offset = new Vector2(0, -0.25f);

        col = GetComponent <BoxCollider2D>();
        //col.size = new Vector2(1, 2.5f);
        body = GetComponent <Rigidbody2D>();

        runninCompass = new RunDirection("CheckDirection");
        runninLegs    = new RunToward();     //Doesn't have just one string that it responds to.
        eyes          = new Look4Player("lookAround");
        brain         = new Brain();
        chkr          = new checkCollision("checkCollisions");
        chase         = new Chase();
        patrol        = new Patrol();
        walkHelp      = new walk("walkToFarthestEdge");
        runninEyes    = new Check4Edge();
        transition    = new SwitchState();

        brain.setState(patrol);
        brain.setState(chase);

        patrol.setJob("walkToFarthestEdge");     //this should probably be separate from runToPlayer, and slower than that. Should walk to edge of plat.
        patrol.setJob("checkCollisions");        //checks if current velocity is 0
        patrol.setJob("lookAround");
        chase.setJob("CheckDirection");
        chase.setJob("checkCollisions");
        transition.addTrigger("edge");
        transition.addTrigger("turn");        //if checkCollision tells us that we've hit a wall (which usually means turn around) we switch states.
        transition.addResponse("statePatrol");

        brain.setComrade(walkHelp);
        brain.setComrade(eyes);
        brain.setComrade(chkr);
        chkr.setComrade(runninCompass);
        chkr.setComrade(runninLegs);
        runninCompass.setComrade(runninEyes);
        runninCompass.setComrade(transition);

        walkHelp.setLeader(brain);
        eyes.setLeader(brain);
        chkr.setLeader(brain);
        runninCompass.setLeader(runninLegs);
        runninLegs.setLeader(runninEyes);
        runninEyes.setLeader(brain);
        transition.setLeader(brain);

        chkr.setBod(body);
        walkHelp.setBody(body);
        eyes.setBody(body);
        runninLegs.setBody(body);
        runninCompass.setBody(body);
        runninEyes.setBody(body);

        runninLegs.setSpeed(sprint);
        walkHelp.setSpeed(speed);
        eyes.setFollowDist(followDist);
        walkHelp.set_raycast_length(raycast_length);
        runninEyes.set_raycast_length(raycast_length);
    }
Exemplo n.º 19
0
        public EGameState Update(Microsoft.Xna.Framework.GameTime gameTime,Input.Inputhandler inputhandler,Options options)
        {
            List<Star.Game.CollisionType> collission = new List<Star.Game.CollisionType>();
            List<EventAction> actions;
            Inputhandler input;
            actions = gamelogic.Update(gameTime, player.BoundingBox,level.GetQuadtree,enemyManager.Enemies,this);
            if (!actions.Contains(EventAction.Exit))
            {
                 if (actions.Contains(EventAction.BlockInput))
                {
                    input = new Inputhandler(player.Pos,options);
                }
                else
                {
                    input = inputhandler;
                }
                if (!actions.Contains(EventAction.BlockUpdate) || firstFrame)
                {
                    firstFrame = false;
                    enemyManager.Update(gameTime, level.GetQuadtree, player.Pos, player.BoundingBox, level.Tiles, camera.getMatrix);

                    collission = player.Update(gameTime, input.Pos, level.GetQuadtree, input.GetInputKeys, input.GetOldInputkeys, input.RunDirection, input.RunFactor, iObjectManager.GetPlayerInfluences());
                    camera.update(gameTime, player.getDifference, player.Pos, false);

                    debugscreen.update(start, player.Pos, player.speed, player.Gravity, player.Jump, input.Pos, collission, input.RunFactor, input.GetInputKeys);
                }
                iObjectManager.Update(gameTime, this);
                input.UpdateRunFactor(gameTime, collission);
                Vector2 relativePosition = new Vector2(-camera.Position.X / (level.Tiles.GetLength(1) * Tile.TILE_SIZE), -camera.Position.Y / ((level.Tiles.GetLength(0) * Tile.TILE_SIZE) - options.ScreenHeight / 2));
                relativePosition.Y = MathHelper.Clamp(relativePosition.Y, 0, 1);
                cloudlayer.Update(gameTime, camera.CamDifference, options,relativePosition);
                frontparallaxLayer.Update(gameTime, camera.CamDifference, options,relativePosition);
                rearparallaxLayer.Update(gameTime, camera.CamDifference, options,relativePosition);
                frontDecoLayer.Update(gameTime, camera.CamDifference, options,relativePosition);
                rearDecoLayer.Update(gameTime, camera.CamDifference, options,relativePosition);
                if (collission.Contains(Star.Game.CollisionType.WalksAgainstIt))
                {
                    input.Pos = player.Pos;
                }

                if (inputhandler.GetMenuKeys.Contains(MenuKeys.Back))
                {
                    return EGameState.Menu;
                }
                rundirection = input.RunDirection;
                while (!enemyManager.IsFinished())
                {
                    Thread.Sleep(0);
                }
            }
            else
            {
                return EGameState.Menu;
            }
            return EGameState.Game;
        }
Exemplo n.º 20
0
 public static bool ToDirection(float rotation, out RunDirection direction)
 {
     return(_directionMapping.TryGetBySecond((int)rotation, out direction));
 }
Exemplo n.º 21
0
        /// <summary>
        /// 根据方向修改地面角度
        /// </summary>
        /// <param name="direction"></param>
        public void ChangeGroundRotate(RunDirection direction)
        {
            float   time           = 0.3f;
            Vector3 dirGround      = Vector3.zero;
            Vector3 dirForce       = Vector3.zero;
            Vector3 dirForceOffset = new Vector3(0f, -1f, 0f);

            switch (direction)
            {
            case RunDirection.Up:
                dirGround = Vector3.right;
                dirForce  = Vector3.forward;
                break;

            case RunDirection.Down:
                dirGround = Vector3.left;
                dirForce  = Vector3.back;
                break;

            case RunDirection.Left:
                dirGround = Vector3.forward;
                dirForce  = Vector3.left;
                break;

            case RunDirection.Right:
                dirGround = Vector3.back;
                dirForce  = Vector3.right;
                break;

            case RunDirection.LeftUp:
                dirGround = new Vector3(1f, 0f, 1f);
                dirForce  = new Vector3(-1f, 0f, 1f);
                break;

            case RunDirection.LeftDown:
                dirGround = new Vector3((-1f), 0f, 1f);
                dirForce  = new Vector3(-1f, 0f, -1f);
                break;

            case RunDirection.RightUp:
                dirGround = new Vector3(1f, 0f, -1f);
                dirForce  = new Vector3(1f, 0f, 1f);
                break;

            case RunDirection.RightDown:
                dirGround = new Vector3(-1f, 0f, -1f);
                dirForce  = new Vector3(1f, 0f, -1f);
                break;

            case RunDirection.None:
                return;
            }

            dirForce += dirForceOffset;
            if (groundTrm != null)
            {
                groundTrm.DOLocalRotate(dirGround * rotationCtrlParam, time);
            }
            //ballRigidbody.velocity = dirForce * velocityParam;


            //GameObject[] objects = GameObject.FindGameObjectsWithTag("Player");
            //for (int i = 0; i < objects.Length; i++)
            //{
            //    Rigidbody rigidbody = objects[i].GetComponent<Rigidbody>();
            //    rigidbody.velocity = dirForce * velocityParam;
            //}
        }
Exemplo n.º 22
0
    private void HandleExitSign(bool left)
    {
        _placeableUseTimer -= Time.deltaTime;
        if (_placeableUseTimer > 0)
        {
            return;
        }

        Transform    placeable = _currentTile.Placeable.transform.GetChild(0);
        RunDirection direction;

        RunDirectionHelper.ToDirection(placeable.transform.localEulerAngles.y, out direction);
        if (left)
        {
            switch (direction)
            {
            case RunDirection.North:
                direction = RunDirection.West;
                break;

            case RunDirection.West:
                direction = RunDirection.South;
                break;

            case RunDirection.South:
                direction = RunDirection.East;
                break;

            case RunDirection.East:
                direction = RunDirection.North;
                break;
            }
        }
        else
        {
            switch (direction)
            {
            case RunDirection.North:
                direction = RunDirection.East;
                break;

            case RunDirection.West:
                direction = RunDirection.North;
                break;

            case RunDirection.South:
                direction = RunDirection.West;
                break;

            case RunDirection.East:
                direction = RunDirection.South;
                break;
            }
        }

        if (CanRunTo(direction))
        {
            _lastRunDirection = direction;
            SetNextWayPoint(direction);
        }
        _state = LemmingState.RunningToWaypoint;
    }
Exemplo n.º 23
0
 public BaseFont CreateBaseFont(RunDirection dir, bool halfWidth)
 {
     return(BaseFont.CreateFont(Name, Encoding(dir, halfWidth), Embedded));
 }
Exemplo n.º 24
0
 /// <summary>
 /// ラテン文字基本
 /// </summary>
 private static string LatinBasic(RunDirection dir)
 {
     return BaseFont.CP1252;
 }
Exemplo n.º 25
0
 /// <summary>
 /// ラテン文字基本
 /// </summary>
 private static string LatinBasic(RunDirection dir)
 {
     return(BaseFont.CP1252);
 }
Exemplo n.º 26
0
 public void UpdateRunFactor(GameTime gametime,List<CollisionType> collision)
 {
     if (collision.Contains(CollisionType.WalksAgainstIt) || collision.Contains(CollisionType.JumpsAgainstIt))
     {
         //run_factor = GameParameters.minRunFactor;
     }
     else
     {
         if (inputkeys.Contains(InputKeys.Run))
         {
             max_run_factor = 2.25f;
         }
         else
         {
             max_run_factor = 1.5f;
         }
         if (rundirection == RunDirection.Right &&
             inputkeys.Contains(InputKeys.Right))
         {
             run_factor += ((float)gametime.ElapsedGameTime.TotalSeconds / GameParameters.RunFactorCoefficient) * (max_run_factor / 1.5f);
             run_factor = MathHelper.Clamp(run_factor, GameParameters.minRunFactor, max_run_factor);
         }
         else if (rundirection == RunDirection.Left &&
             inputkeys.Contains(InputKeys.Right))
         {
             run_factor = GameParameters.minRunFactor;
             rundirection = RunDirection.Right;
         }
         else if (rundirection == RunDirection.Right &&
             inputkeys.Contains(InputKeys.Left))
         {
             run_factor = GameParameters.minRunFactor;
             rundirection = RunDirection.Left;
         }
         else if (rundirection == RunDirection.Left &&
             inputkeys.Contains(InputKeys.Left))
         {
             run_factor += ((float)gametime.ElapsedGameTime.TotalSeconds / GameParameters.RunFactorCoefficient) * (max_run_factor / 1.5f);
             run_factor = MathHelper.Clamp(run_factor, GameParameters.minRunFactor, max_run_factor);
         }
         else if (!inputkeys.Contains(InputKeys.Left) && !inputkeys.Contains(InputKeys.Right))
         {
             run_factor -= ((float)gametime.ElapsedGameTime.TotalSeconds / GameParameters.RunFactorCoefficient);
             run_factor = MathHelper.Clamp(run_factor, GameParameters.minRunFactor, max_run_factor);
         }
         else
         {
             //run_factor = GameParameters.minRunFactor;
         }
     }
 }