public EMMotionProperties(MotionType motionType)
    {
        transform       = new EMTransform();
        this.motionType = motionType;

        sound  = null;
        volume = 1;

        autoClose          = false;
        autoCloseDelayTime = 0;

        isMove        = false;
        moveDirection = MotionDirection.Top;
        moveEasing    = new EMEasingParameter();

        isRotate     = false;
        rotateEasing = new EMEasingParameter();

        isAlpha     = false;
        alphaEasing = new EMEasingParameter();

        isScale     = false;
        scaleEasing = new EMEasingParameter();

        if (motionType == MotionType.OneShot)
        {
            isInside = true;
        }
        else
        {
            isInside = false;
        }
    }
Пример #2
0
    private void ReadControlAxes()
    {
        if (ControlManager.NoControlsPressed)
        {
            Motion.HaltEntity();
            return;
        }

        float verticalDirection   = ControlManager.GetAxis(VerticalAxis);
        float horizontalDirection = ControlManager.GetAxis(HorizontalAxis);

        MotionDirection direction = MotionDirection.None;

        if (verticalDirection > 0.0f)
        {
            if (Mathf.Abs(horizontalDirection - 0.0f) < 0.001f)
            {
                direction = MotionDirection.North;
            }
            else if (horizontalDirection > 0.0f)
            {
                direction = MotionDirection.NorthEast;
            }
            else if (horizontalDirection < 0.0f)
            {
                direction = MotionDirection.NorthWest;
            }
        }
        else if (verticalDirection < 0.0f)
        {
            if (Mathf.Abs(horizontalDirection - 0.0f) < 0.001f)
            {
                direction = MotionDirection.South;
            }
            else if (horizontalDirection > 0.0f)
            {
                direction = MotionDirection.SouthEast;
            }
            else if (horizontalDirection < 0.0f)
            {
                direction = MotionDirection.SouthWest;
            }
        }
        else if (Mathf.Abs(verticalDirection - 0.0f) < 0.001f)
        {
            if (horizontalDirection > 0.0f)
            {
                direction = MotionDirection.East;
            }
            else if (horizontalDirection < 0.0f)
            {
                direction = MotionDirection.West;
            }
        }

        FormattedDebugMessage(LogLevel.Info, "Vertical: {0} Horizontal: {1} D-Value: {2}", verticalDirection, horizontalDirection, direction.ToString());

        Motion.RotateEntity(direction);
        Motion.MoveEntity();
    }
    private void MoveTowardsTarget(Vector3 targetPoint)
    {
        MotionDirection direction = GetDirectionToPoint(targetPoint);

        Motion.RotateEntity(direction);
        Motion.MoveEntity();
    }
Пример #4
0
        public void Move(MotionDirection motionType, float distance = 3.0f)
        {
            var     transform = GetComponent <Transform>();
            Vector3 movement  = new Vector3(0.0f, 0.0f, 0.0f);

            switch (motionType)
            {
            case MotionDirection.Right:
                movement = new Vector3(distance, 0.0f, 0.0f);
                break;

            case MotionDirection.Left:
                movement = new Vector3(-distance, 0.0f, 0.0f);
                break;

            case MotionDirection.Forward:
                movement = new Vector3(0.0f, 0.0f, distance);
                break;

            case MotionDirection.Backward:
                movement = new Vector3(0.0f, 0.0f, -distance);
                break;
            }
            transform.position += movement;
        }
    private MotionDirection InvertDirection(MotionDirection direction)
    {
        switch (direction)
        {
        case MotionDirection.None:
            return(MotionDirection.None);

        case MotionDirection.North:
            return(MotionDirection.South);

        case MotionDirection.South:
            return(MotionDirection.North);

        case MotionDirection.East:
            return(MotionDirection.West);

        case MotionDirection.West:
            return(MotionDirection.East);

        case MotionDirection.NorthEast:
            return(MotionDirection.SouthWest);

        case MotionDirection.NorthWest:
            return(MotionDirection.SouthEast);

        case MotionDirection.SouthEast:
            return(MotionDirection.NorthWest);

        case MotionDirection.SouthWest:
            return(MotionDirection.NorthEast);

        default:
            throw new ApplicationException("Unexpected direction " + direction);
        }
    }
Пример #6
0
	public EMMotionProperties(MotionType motionType){

		transform = new EMTransform();
		this.motionType = motionType;

		sound = null;
		volume =1;

		autoClose = false;
		autoCloseDelayTime =0;

		isMove = false;
		moveDirection = MotionDirection.Top;
		moveEasing = new EMEasingParameter();

		isRotate = false;
		rotateEasing= new EMEasingParameter();

		isAlpha = false;
		alphaEasing = new EMEasingParameter();

		isScale = false;
		scaleEasing = new EMEasingParameter();

		if (motionType == MotionType.OneShot){
			isInside = true;
		}
		else{
			isInside = false;
		}
	}
Пример #7
0
    IEnumerator WheelEffect_Async(Vector2 startpos, MotionDirection motionDirection)
    {
        int boundCol = GameController.HEIGHT;
        int boundRow = GameController.WIDTH;

        List <Vector2> dirs = new List <Vector2>();

        switch (motionDirection)
        {
        case MotionDirection.RIGHT:
            for (int i = (int)startpos.x; i < boundRow; i++)
            {
                dirs.Add(new Vector2((float)i, startpos.y));
            }
            break;

        case MotionDirection.LEFT:
            for (int i = (int)startpos.x; i > -1; i--)
            {
                dirs.Add(new Vector2((float)i, startpos.y));
            }
            break;

        case MotionDirection.UP:
            for (int i = (int)startpos.y; i < boundCol; i++)
            {
                dirs.Add(new Vector2(startpos.x, (float)i));
            }
            break;

        case MotionDirection.DOWN:
            for (int i = (int)startpos.y; i > -1; i--)
            {
                dirs.Add(new Vector2(startpos.x, (float)i));
            }
            break;
        }

        for (int i = 1; i < dirs.Count; i++)
        {
            JewelObj tmp = JewelSpawner.spawn.JewelGribScript [(int)dirs[i].x, (int)dirs[i].y];
            if (tmp != null)
            {
                if (i < 4)
                {
                    int random = Random.Range(6, 8);
                    Supporter.sp.SpawnJewelPower(tmp.jewel.JewelType, random, tmp.jewel.JewelPosition, true);
                }
                else
                {
                    tmp.Destroy();
                }
            }
        }
        yield return(new WaitForSeconds(1f));

        GameController.action.dropjewel();
    }
    private void MoveAwayFromTarget(Vector3 targetPoint)
    {
        MotionDirection direction = GetDirectionToPoint(targetPoint);

        direction = InvertDirection(direction);

        Motion.RotateEntity(direction);
        Motion.MoveEntity();
    }
    public static Vector2 ToVector(MotionDirection motionDirection)
    {
        Vector2 direction;

        if (!DIRECTION_MAP.TryGetValue(motionDirection, out direction))
        {
            Debug.LogError("huh... couldnt find direction for " + motionDirection);
        }
        return(direction);
    }
    public void RotateEntity(MotionDirection direction)
    {
        if (!CanTurn)
        {
            return;
        }

        Vector3 rotation = GetDirectionByMotionDirection(direction);

        transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.Euler(rotation), 0.5f);
    }
    private static void GetCheckRay(MotionDirection side, CharacterMotorConfig config, Transform toMove, Vector3[] output, float index, float distance)
    {
        Vector3 sideDir   = MotionUtil.ToVector(side);
        Vector3 origin    = toMove.position;
        Vector3 direction = Vector3.zero;

        GetCheckValue(ref origin, ref direction, sideDir.x, config, index, Vector3.right, Vector3.up, distance);
        GetCheckValue(ref origin, ref direction, sideDir.y, config, index, Vector3.up, Vector3.right, distance);
        output[0] = origin;
        output[1] = origin + direction;
    }
Пример #12
0
    private MotionDirection GetDirectionToPoint(Vector3 targetPoint)
    {
        MotionDirection direction = MotionDirection.None;

        bool targetToTheRight = targetPoint.x > transform.position.x;
        bool targetToTheLeft  = targetPoint.x < transform.position.x;

        bool targetVerticallyAligned = Mathf.Abs(transform.position.z - targetPoint.z) < 0.001f;
        bool targetAhead             = targetPoint.z > transform.position.z;
        bool targetBehind            = targetPoint.z < transform.position.z;

        if (targetAhead)
        {
            direction = MotionDirection.North;

            if (targetToTheLeft)
            {
                direction = MotionDirection.NorthWest;
            }
            else if (targetToTheRight)
            {
                direction = MotionDirection.NorthEast;
            }
        }
        else if (targetBehind)
        {
            direction = MotionDirection.South;

            if (targetToTheLeft)
            {
                direction = MotionDirection.SouthWest;
            }
            else if (targetToTheRight)
            {
                direction = MotionDirection.SouthEast;
            }
        }
        else if (targetVerticallyAligned)
        {
            if (targetToTheLeft)
            {
                direction = MotionDirection.West;
            }
            else if (targetToTheRight)
            {
                direction = MotionDirection.East;
            }
        }

        return(direction);
    }
        public void StartMotion(byte speed, MotionDirection direction)
        {
            var voltageToSet = minMotorVoltage + (maxMotorVoltage - minMotorVoltage) / 255.0 * speed;

            switch (direction)
            {
            case MotionDirection.cw:
                _boxController.AO_ChannelCollection.ApplyVoltageToChannel(_controlChannel, voltageToSet);
                break;

            case MotionDirection.ccw:
                _boxController.AO_ChannelCollection.ApplyVoltageToChannel(_controlChannel, -voltageToSet);
                break;
            }
        }
    private Vector3 GetDirectionByMotionDirection(MotionDirection direction)
    {
        Vector3 rotation = Vector3.zero;

        for (int i = 0; i < MovementDirections.Count; i++)
        {
            DirectionVectorPair current = MovementDirections[i];
            if (current.Direction != direction)
            {
                continue;
            }

            rotation = current.EulerAngles;
            break;
        }

        return(rotation);
    }
Пример #15
0
    Vector3 getDirectionVector(MotionDirection dir)
    {
        switch (dir)
        {
        case MotionDirection.Up: return(Vector3.up);

        case MotionDirection.Down: return(Vector3.down);

        case MotionDirection.Left: return(Vector3.left);

        case MotionDirection.Right: return(Vector3.right);

        case MotionDirection.Back: return(Vector3.back);

        case MotionDirection.Forward: return(Vector3.forward);
        }
        return(Vector3.zero);
    }
        public void SetDirection(MotionDirection motionDirection)
        {
            if (_CurrentDirection != motionDirection)
            {
                _CurrentDirection = motionDirection;
                ++_CurrentIteration;
            }

            switch (motionDirection)
            {
            case MotionDirection.Up:
            {
            } break;

            case MotionDirection.Down:
            {
            } break;

            default:
                break;
            }
        }
        public void SetDirection(MotionDirection motionDirection)
        {
            if (_CurrentDirection != motionDirection)
            {
                _CurrentDirection = motionDirection;
                ++_CurrentIteration;
            }

            switch (motionDirection)
            {
                case MotionDirection.Up:
                    {
                        SetValueToChannel(8.0, KEITHLEY_2601A_SourceMode.Voltage, KEITHLEY_2602A_Channels.ChannelA);
                    } break;
                case MotionDirection.Down:
                    {
                        SetValueToChannel(-8.0, KEITHLEY_2601A_SourceMode.Voltage, KEITHLEY_2602A_Channels.ChannelA);
                    } break;
                default:
                    break;
            }
        }
        public void SetDirection(MotionDirection motionDirection)
        {
            if (_CurrentDirection != motionDirection)
            {
                _CurrentDirection = motionDirection;
                ++_CurrentIteration;
            }

            switch (motionDirection)
            {
            case MotionDirection.Up:
            {
                SetValueToChannel(8.0, KEITHLEY_2601A_SourceMode.Voltage, KEITHLEY_2602A_Channels.ChannelA);
            } break;

            case MotionDirection.Down:
            {
                SetValueToChannel(-8.0, KEITHLEY_2601A_SourceMode.Voltage, KEITHLEY_2602A_Channels.ChannelA);
            } break;

            default:
                break;
            }
        }
Пример #19
0
    void PowerTypeProcess(GameObject obj1, GameObject obj2)
    {
        int powerType = obj2.GetComponent <JewelObj> ().jewel.JewelPower;

        switch (powerType)
        {
        case (int)GameController.Power.MAGIC:
            obj1.GetComponent <JewelObj>().Destroy();
            PDestroyType(obj1.GetComponent <JewelObj>().jewel.JewelType, obj1.transform.position);
            obj2.GetComponent <JewelObj>().Destroy();
            break;

        case (int)GameController.Power.WHEEL:
            //obj1.GetComponent<JewelObj>().Destroy();
            MotionDirection motionDir = Supporter.sp.GetMotionDirection(obj1.transform.localPosition, obj2.transform.localPosition);
            EffectSpawner.effect.WheelEffect(obj1.transform.localPosition, motionDir);
            obj2.GetComponent <JewelObj>().Destroy();
            break;

        case (int)GameController.Power.LUCKY:
            GameController.action._guestManager.GiveItemToFirstFoundGuest();
            break;
        }
    }
Пример #20
0
	public void WheelEffect(Vector2 startpos,MotionDirection motionDirection)
	{
		StartCoroutine ( WheelEffect_Async(startpos,motionDirection) );
	}
Пример #21
0
        public void Move(MotionDirection motion, float distance)
        {
            var message = new MotionNetworkMessage(motion, distance);

            ConnectionManager.Instanse.Send(message.Serialize());
        }
Пример #22
0
 public void WheelEffect(Vector2 startpos, MotionDirection motionDirection)
 {
     StartCoroutine(WheelEffect_Async(startpos, motionDirection));
 }
Пример #23
0
 //***************************************************************************
 // Class Constructors
 //
 public MotionPoint(Rectangle drawBounds, MotionDirection direction, MotionSpeed speed, Color color, MotionPointCollection owner)
     : this(new RectangleF((float)drawBounds.Left, (float)drawBounds.Top, (float)drawBounds.Width, (float)drawBounds.Height), direction, speed, color, owner)
 {
 }
 public MotionNetworkMessage(MotionDirection motionType, float distance)
 {
     MotionType = motionType;
     Distance   = distance;
 }
Пример #25
0
        public MotionPoint(RectangleF originBounds, MotionDirection direction, MotionSpeed speed, Color color, MotionPointCollection owner)
        {
            this._owner     = owner;
            this._orgBounds = originBounds;
            this._mDir      = direction;
            this._mSpd      = speed;
            this._clr       = color;
            this._bubble    = false;
            this._life      = 0;
            this._aFade     = AlphaFade.None;
            this._drwBounds = originBounds;
            this._xCen      = originBounds.Width / 2;
            this._yCen      = originBounds.Height / 2;

            if (owner != null)
            {
                rnd = this._owner.rnd;
            }
            else
            {
                rnd = new Random(Convert.ToInt32((DateTime.Now.Ticks / 20) + (DateTime.Now.Millisecond * (DateTime.Now.TimeOfDay.Ticks / 10))));
            }

            if (direction > MotionDirection.FromLeft)
            {
                // Calculate for Left/Right/Top/Bottom movement types.

                if (direction > MotionDirection.FromTop)
                {
                    // Top/Bottom
                    _xPos = rnd.Next((int)originBounds.Left, (int)originBounds.Right);
                    if (direction == MotionDirection.FromTop)
                    {
                        _yPos = originBounds.Top;
                    }
                    else
                    {
                        _yPos = originBounds.Bottom;
                    }
                }
                else
                {
                    // Left/Right
                    if (direction == MotionDirection.FromLeft)
                    {
                        _xPos = originBounds.Left;
                    }
                    else
                    {
                        _xPos = originBounds.Right;
                    }
                    _yPos = rnd.Next((int)originBounds.Top, (int)originBounds.Bottom);
                }
                _xSpd = rnd.Next(1, 10);
                _ySpd = rnd.Next(1, 10);
            }
            else
            {
                // For free-random origin types

                _xPos = rnd.Next((int)originBounds.Left, (int)originBounds.Right);
                _yPos = rnd.Next((int)originBounds.Top, (int)originBounds.Bottom);

                if (direction == MotionDirection.Zoom)
                {
                    _xSpd = (_xPos - _xCen) / 2;
                    _ySpd = (_yPos - _yCen) / 2;
                }
                else if (direction == MotionDirection.Bounce)
                {
                    _xSpd = rnd.Next(10) - 5;
                    if (_xSpd == 0)
                    {
                        _xSpd = 1 * System.Math.Sign((originBounds.Width / 2) - _xPos);
                    }

                    _ySpd = rnd.Next(10) - 5;
                    if (_ySpd == 0)
                    {
                        _ySpd = 1 * System.Math.Sign((originBounds.Height / 2) - _yPos);
                    }
                }
                else if (direction == MotionDirection.Snow)
                {
                    _xSpd = rnd.Next(1, 5);
                    _ySpd = rnd.Next(1, 5);
                }
                else if (direction == MotionDirection.Rotate)
                {
                    this.RotationPrecesion = 2;
                    _rad    = rnd.Next(2, (int)(originBounds.Width / 2));
                    _offset = rnd.Next(_rotPrec * 2);
                }
            }
        }
        public void SetDirection(MotionDirection motionDirection)
        {
            if (_CurrentDirection != motionDirection)
            {
                _CurrentDirection = motionDirection;
                ++_CurrentIteration;
            }

            switch (motionDirection)
            {
                case MotionDirection.Up:
                    {
                    } break;
                case MotionDirection.Down:
                    {
                    } break;
                default:
                    break;
            }
        }
Пример #27
0
 public MotionCard()
 {
     this.currentDirection = MotionDirection.Initial;
 }
Пример #28
0
	IEnumerator WheelEffect_Async(Vector2 startpos,MotionDirection motionDirection)
	{
		int boundCol = GameController.HEIGHT;
		int boundRow = GameController.WIDTH;
		
		List<Vector2> dirs = new List<Vector2>();
		switch (motionDirection) {
			
		case MotionDirection.RIGHT:
			for(int i = (int)startpos.x ; i < boundRow; i ++)
			{
				dirs.Add( new Vector2( (float)i,startpos.y) );
			}
			break;
			
		case MotionDirection.LEFT:
			for(int i = (int)startpos.x ; i > -1 ; i --)
			{
				dirs.Add( new Vector2( (float)i,startpos.y) );
			}
			break;
			
		case MotionDirection.UP:
			for(int i = (int)startpos.y ; i < boundCol ; i ++)
			{
				dirs.Add( new Vector2( startpos.x,(float)i) );
			}
			break;
			
		case MotionDirection.DOWN:
			for(int i = (int)startpos.y ; i > -1 ; i --)
			{
				dirs.Add( new Vector2( startpos.x,(float)i) );
			}
			break;
		}
		
		for(int i = 1 ; i < dirs.Count ; i++)
		{
			JewelObj tmp = JewelSpawner.spawn.JewelGribScript [(int)dirs[i].x, (int)dirs[i].y];
			if (tmp != null)
			{
				if( i < 4 )
				{
					int random = Random.Range( 6,8 );
					Supporter.sp.SpawnJewelPower( tmp.jewel.JewelType, random, tmp.jewel.JewelPosition,true );
				}
				else
				{
					tmp.Destroy();
				}
			}
		}
		yield return new WaitForSeconds(1f);
		GameController.action.dropjewel ();
	}