Inheritance: MonoBehaviour
Ejemplo n.º 1
0
 public void Awake()
 {
     _jump_input_interpreter = new JumpInputInterpreter();
     _jump_impulse_movement = new Movement (jump_impulse_movement_curve, false);
     _jump_impulse_movement.Pause();
     _jump_held_movement = new Movement (jump_held_movement_curve, false);
 }
    // Update is called once per frame
    void Update()
    {
        if(isMine)
        {
            // get movement direction
            float mX = Input.GetAxis("Horizontal") * moveSpeed;
            float mY = Input.GetAxis("Vertical") * moveSpeed;

            this.transform.position += (new Vector3(mX, 0f, mY))*Time.deltaTime;

            if (Time.time >= timeOfLastMoveCmd + 0.1f && lastReceivedMove != this.transform.position)
            {
                lastReceivedMove = this.transform.position;
                timeOfLastMoveCmd = Time.time;

                // send move command to server every 0.1 seconds
                Dictionary<byte, object> requestDict = new Dictionary<byte, object>();

                Movement moveMent = new Movement();
                moveMent.actorID = actorInfo.actor.actorID;
                moveMent.posX = this.transform.position.x;
                moveMent.posY = this.transform.position.z;

                requestDict.Add((byte)Parameter.Data,LMLiblary.General.GeneralFunc.Serialize(moveMent));

                StarCollectorClient.connection.OpCustom((byte)AckRequestType.MoveCommand, requestDict, false);
                this.GetComponent<CheckRegion>().Load();
            }

            //transform.position = Vector3.Lerp(transform.position,lastReceivedMove, Time.deltaTime * 20f);
        }
    }
Ejemplo n.º 3
0
    public bool checkPush(Direction direction, int force)
    {
        GameObject next = faces[(int)direction];
        if (next != null)
        {
            force--;
            if(next.tag == "pushable" && force >= 0)
            {
                attached = next.GetComponent<Movement>();
                if (attached.checkPush(direction, force))
                {
                    moving = direction;
                    return true;
                }else
                {
                    attached = null;
                    return false;
                }

            }
            else
            {
                return false;
            }
        } else
        {
            return true;
        }
    }
Ejemplo n.º 4
0
        public static bool IsArcValid (Movement from, Analyzer.Node.Movement to) {
            if (from == Movement.Unknown) {
                return
                    to == Analyzer.Node.Movement.JustDown ||
                    to == Analyzer.Node.Movement.JustDownOrStayDown;
            } else if (from == Movement.Tap) {
                return
                    to == Analyzer.Node.Movement.JustDown ||

                    to == Analyzer.Node.Movement.JustDownOrStayDown;
            } else if (from == Movement.ForceDownStart) {
                return
                    to == Analyzer.Node.Movement.StayDown ||
                    to == Analyzer.Node.Movement.Relax;
            } else if (from == Movement.ForceDown) {
                return
                    to == Analyzer.Node.Movement.StayDown ||

                    to == Analyzer.Node.Movement.Relax;
            } else if (from == Movement.PassiveDown) {
                return
                    to == Analyzer.Node.Movement.JustDown ||
                    to == Analyzer.Node.Movement.JustDownOrStayDown;
            } else {
                throw new ArgumentException();
            }
        }
Ejemplo n.º 5
0
	// Use this for initialization
	void Start () {
		currentHealth = topHealth;
		Player = FindObjectOfType<Movement> ();
		//InvokeRepeating ("decreaseHealth", 1f,1f);
		die = FindObjectOfType<Die> ();
		decreaseHealth();
	}
Ejemplo n.º 6
0
 /// <summary>
 /// Check if the next move is possible
 /// </summary>
 /// <param name="position">Current position</param>
 /// <param name="movement">Next movement</param>
 /// <param name="newPosition">If the movement is valid this out parametr holds new location</param>
 /// <returns>Possibility of movement</returns>
 private bool Check(Point position, Movement movement, out Point newPosition)
 {
     Point oldPosition = position;
     switch (movement)
     {
         case Movement.Up:
             position.X--;
             break;
         case Movement.Left:
             position.Y--;
             break;
         case Movement.Down:
             position.X++;
             break;
         case Movement.Right:
             position.Y++;
             break;
         default:
             newPosition = position;
             return false;
     }
     newPosition = position;
     if (position.X <= 0 || position.X >= Playground.playgroundSize - 1 || position.Y <= 0 || position.Y >= Playground.playgroundSize - 1) return false;
     Square square = Program.playground.board[position.X][position.Y];
     if (square == Square.Empty || square == Square.Fire || square == character) return true;
     else return false;
 }
Ejemplo n.º 7
0
 void Awake()
 {
     var gd = GameObject.Find("/GameDirector");
     gameDirector = gd.GetComponent<GameDirector>();
     id = GetComponent<Id>();
     movement = GetComponent<Movement>();
 }
Ejemplo n.º 8
0
 // Use this for initialization
 void Start()
 {
     guiText = gameObject.GetComponent<GUIText>();
     textBackground = GameObject.Find("ScoreBackground").GetComponent<GUITexture>();
     mic = GameObject.Find ("Beat Detector").GetComponent<MicrophoneInput>();
     player = GameObject.Find ("Player").GetComponent<Movement>();
 }
 private void Awake()
 {
     this.mTrans = base.transform;
     this.mPanel = base.GetComponent<UIPanel>();
     if (this.mPanel.clipping == UIDrawCall.Clipping.None)
     {
         this.mPanel.clipping = UIDrawCall.Clipping.Invisible;
     }
     if ((this.movement != Movement.Custom) && (this.scale.sqrMagnitude > 0.001f))
     {
         if ((this.scale.x == 1f) && (this.scale.y == 0f))
         {
             this.movement = Movement.Horizontal;
         }
         else if ((this.scale.x == 0f) && (this.scale.y == 1f))
         {
             this.movement = Movement.Vertical;
         }
         else if ((this.scale.x == 1f) && (this.scale.y == 1f))
         {
             this.movement = Movement.Unrestricted;
         }
         else
         {
             this.movement = Movement.Custom;
             this.customMovement.x = this.scale.x;
             this.customMovement.y = this.scale.y;
         }
         this.scale = Vector3.zero;
     }
     if (Application.isPlaying)
     {
         this.mPanel.onChange = (UIPanel.OnChangeDelegate) Delegate.Combine(this.mPanel.onChange, new UIPanel.OnChangeDelegate(this.OnPanelChange));
     }
 }
 void Awake()
 {
     characterSwapScript = GetComponent<CharacterSwap>();
     movementScript = GetComponent<Movement>();
     attack = GetComponentsInChildren<IAttack>();
     special = GetComponentsInChildren<ISpecial>();
 }
Ejemplo n.º 11
0
 void Awake()
 {
     m_movement = Avatar.GetComponent<Movement>();
     m_light_attack = Avatar.GetComponent<LightAttack>();
     m_lock_on = Avatar.GetComponent<LockOn>();
     m_dodge = Avatar.GetComponent<Dodge>();
 }
Ejemplo n.º 12
0
        public void Game_AddMove_RaisesIsWonEventWhenAddingWinningMoveOnMainDiagonal()
        {
            //Arrange
            NotificationEventArgs<Game> argsWhenGameIsWon = null;
            _game.WonGame += new EventHandler<NotificationEventArgs<Game>>((o, e) => { argsWhenGameIsWon = e; });

            Movement m1 = new Movement(0, 0, 'x', _p1, true);
            Movement m2 = new Movement(1, 1, 'x', _p1, true);
            Movement m3 = new Movement(2, 2, 'x', _p1, true);

            Movement m4 = new Movement(0, 1, 'o', _p2, false);
            Movement m5 = new Movement(0, 2, 'o', _p2, false);

            //Act
            bool moveAdded = _game.AddMove(m1, _p1.Id);

            moveAdded = _game.AddMove(m4, _p2.Id);
            moveAdded = _game.AddMove(m5, _p2.Id);

            moveAdded = _game.AddMove(m2, _p1.Id);
            moveAdded = _game.AddMove(m3, _p1.Id);

            //Assert
            Assert.AreEqual<Game>(argsWhenGameIsWon.Value, _game);
            Assert.IsNotNull(_game.Winner);
        }
Ejemplo n.º 13
0
 public void Cleanup()
 {
     _p1 = null;
     _p2 = null;
     _game = null;
     _move = null;
 }
Ejemplo n.º 14
0
 void OnEnable()
 {
     // get relevant components
     playerRigidbody = GameObject.FindWithTag ("Player").GetComponent<Rigidbody> ();
     playerMovement = GameObject.FindWithTag ("Player").GetComponent<Movement> ();
     playerPMat = (PhysicMaterial) Resources.Load ("PhysicMaterials/Ball");
 }
 public Entity ReplaceMoveInput(Movement newMovement)
 {
     var component = CreateComponent<MoveInputComponent>(ComponentIds.MoveInput);
     component.movement = newMovement;
     ReplaceComponent(ComponentIds.MoveInput, component);
     return this;
 }
Ejemplo n.º 16
0
    /* This method extracts the data from the temporary XML object and places it
     * in runtime movement object that will be processed on the spot.
    */
    IEnumerator ExtractMovement(XmlDocument xml)
    {
        Movement movement;

        //Set the name of the test being run in the global variable
        gs.setTestName(xml.SelectSingleNode("Test/Name").InnerText);

        //Move through each tagged item within the xml document
        foreach (XmlNode node in xml.SelectNodes("Test/Movement")){
            movement = new Movement();

            //Extract and assign tagged items within the xmlDoc to object variables within Movement class
            movement.MovementID = node.SelectSingleNode("MovementId").InnerText;
            movement.MovementDesc = node.SelectSingleNode("MovementDesc").InnerText;

            //Assign MovementDetails to Movement Class variables
            foreach (XmlNode detail in node.SelectNodes("MovementDetail")){
                movement.Sequence = detail.SelectSingleNode("SequenceId").InnerText;
                movement.Path = detail.SelectSingleNode("Path").InnerText;
                movement.PathDesc = detail.SelectSingleNode("PathDesc").InnerText;
                movement.Gait = detail.SelectSingleNode("Gait").InnerText;

                //Call LoadMovement Coroutine method and pass movement object
                //and wait for the finish of Coroutine to process further information.
                yield return StartCoroutine(ProcessMovement(movement));
            }
        }
    }
Ejemplo n.º 17
0
 public void setAnimation(Movement.PlayerState newState, float animationSpeed)
 {
     m_actualState = newState;
     m_step = 0;
     m_stepStatus = 0;
     m_animationSpeed = animationSpeed;
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Load the components required for this script.
 /// </summary>
 protected void Awake()
 {
     animator     = GetComponent<Animator>();
     audioSource  = GetComponent<AudioSource>();
     shipMovement = GetComponent<Movement>();
     shipShooter  = GetComponent<Shooter>();
 }
Ejemplo n.º 19
0
 void Start()
 {
     float h = Screen.height / 4;
     rect = new Rect (Screen.width/2-h, Screen.height/2-h, h*2, h*2);
     movement = GetComponent<Movement>();
     highscores = GetComponent<Highscores>();
 }
Ejemplo n.º 20
0
 public Alma(int x, int y, Tile.ID type)
     : base(x, y, type)
 {
     AlmaMove = new Movement(Properties.Resources.alma_movement,150);
     dir = Hero.Direction.Down;
     loadRoll();
 }
Ejemplo n.º 21
0
 public new void Awake()
 {
     base.Awake();
     myCamera = GameObject.FindGameObjectWithTag("Player1Camera");
     movement = GetComponent<Movement>();
     shipName = name;
 }
Ejemplo n.º 22
0
 public void Move(Movement movement)
 {
     switch (movement)
     {
         case Movement.L:
             torso.ApplyForce(new Vector2(-speed, 0), torso.Position);
             break;
     
         case Movement.R:
             torso.ApplyForce(new Vector2(speed, 0), torso.Position);
             break;
     
         case Movement.U:
             torso.ApplyForce(new Vector2(0, -speed), torso.Position);
             break;
     
         case Movement.D:
             torso.ApplyForce(new Vector2(0, speed), torso.Position);
             break;
     }
     if (canJump)
         if (movement == Movement.J)
         {
             torso.ApplyForce(new Vector2( -m_gravRef.m_downDirection.X, -m_gravRef.m_downDirection.Y) * 35, torso.Position);
             canJump = false;
         }
 }
Ejemplo n.º 23
0
 void Start()
 {
     move = (Movement)GetComponent(typeof(Movement));
     rend = (Renderer)GetComponent(typeof(Renderer));
     warming = false;
     oldQuote = 0;
 }
Ejemplo n.º 24
0
 /// <summary>
 /// 	Get the basics components the player need
 /// </summary>
 void Awake()
 {
     moveEnnemy = GetComponent<Movement>();
     jumpEnnemy = GetComponent<Jump>();
     toHunt = Player.GetComponent<Rigidbody2D> ();
     myself = GetComponent<Rigidbody2D> ();
 }
Ejemplo n.º 25
0
 void Awake()
 {
     if (instance == null)
         instance = this;
     else if (instance != null)
         Destroy (gameObject);
 }
Ejemplo n.º 26
0
 /// <summary>
 /// Process key press coresponding to movement
 /// </summary>
 /// <param name="movement">Movement to precess</param>
 internal void ProcessMovement(Movement movement)
 {
     switch (movement)
     {
         case Movement.Up:
         case Movement.Left:
         case Movement.Down:
         case Movement.Right:
         case Movement.Plant_bomb:
             if (indexFutureMoves < futureMoves.Length)
             {
                 futureMoves[indexFutureMoves] = movement;
                 indexFutureMoves++;
                 UpdatePosition(movement);
             }
             break;
         case Movement.Backspace:
             if (indexFutureMoves == 0) break;
             indexFutureMoves--;
             futureMoves[indexFutureMoves] = Movement.Nothing;
             break;
         case Movement.Enter:
             SendMoves();
             break;
         default:
             break;
     }
 }
Ejemplo n.º 27
0
 public void cancelBackToMenu()
 {
     esctomenu = false;
     esctomenupanel.SetActive(false);
     currentselectedbutton = null;
     movement = FindObjectOfType<Movement>().GetComponent<Movement>();
     movement.onMenuEnd();
 }
Ejemplo n.º 28
0
 private static bool CanMove(int r, int c, Movement m, bool[,] blocks)
 {
     int nr = m == Movement.DOWN ? r + 1 : r;
     int nc = m == Movement.RIGHT ? c + 1 : c;
     return (nr >= 0 && nr < blocks.GetLength(0) &&
         nc >= 0 && nc < blocks.GetLength(1) &&
         !blocks[nr, nc]);
 }
Ejemplo n.º 29
0
 public void backToMenu()
 {
     movement = FindObjectOfType<Movement>().GetComponent<Movement>();
     movement.onMenuStart();
     esctomenupanel.SetActive(true);
     esctomenu = true;
     changeState(1, true);
 }
Ejemplo n.º 30
0
 void Start()
 {
     rigidBody = GetComponent<Rigidbody2D>();
     animator = GetComponent<Animator>();
     movement = GetComponent<Movement>();
     timeLastFired = -firingIntervalInSeconds;
     statsUI = GetComponent<PlayerStatsUI>();
 }
Ejemplo n.º 31
0
 public void modifyPosition(Movement movement)
 {
     position += (int)movement;
 }
Ejemplo n.º 32
0
 void Start()
 {
     movement = GetComponent <Movement>();
 }
Ejemplo n.º 33
0
        public static async Task <bool> Execute()
        {
            if (BotManager.Current.IsAutonomous)
            {
                if (Core.Me.HasTarget)
                {
                    Movement.NavigateToUnitLos(Core.Me.CurrentTarget, 23);
                }
            }

            if (!Core.Me.HasTarget || !Core.Me.CurrentTarget.ThoroughCanAttack())
            {
                return(false);
            }

            if (await CustomOpenerLogic.Opener())
            {
                return(true);
            }

            if (MachinistSettings.Instance.UseFlameThrower && Core.Me.HasAura(Auras.Flamethrower))
            {
                // Did someone use this manually? Make sure we don't cancel it...
                if (!MachinistSettings.Instance.UseFlameThrower)
                {
                    return(true);
                }

                if (MovementManager.IsMoving)
                {
                    return(false);
                }

                // Keep using it for the AOE benefit if we need to
                if (Core.Me.EnemiesInCone(8) >= MachinistSettings.Instance.FlamethrowerEnemies)
                {
                    return(true);
                }
            }

            if (await PhysicalDps.SecondWind(MachinistSettings.Instance))
            {
                return(true);
            }
            if (await PhysicalDps.Interrupt(MachinistSettings.Instance))
            {
                return(true);
            }

            if (Utilities.Routines.Machinist.OnGcd)
            {
                if (await Buff.BarrelStabilizer())
                {
                    return(true);
                }
                if (await Buff.Wildfire())
                {
                    return(true);
                }
                if (await Buff.Hypercharge())
                {
                    return(true);
                }
                if (await Turret.AutomationQueen())
                {
                    return(true);
                }
                if (await Turret.Rook())
                {
                    return(true);
                }
                if (await Aoe.Flamethrower())
                {
                    return(true);
                }

                if (Core.Me.ClassLevel < Spells.Drill.LevelAcquired)
                {
                    if (await Buff.Reassemble())
                    {
                        return(true);
                    }
                }

                if (await SingleTarget.GaussRound())
                {
                    return(true);
                }

                if (MachinistSettings.Instance.UseAoe)
                {
                    return(await Aoe.Ricochet());
                }

                return(await Buff.Tactician());
            }

            if (MachinistSettings.Instance.UseAoe)
            {
                if (await Aoe.Bioblaster())
                {
                    return(true);
                }
            }

            if (await SingleTarget.Drill())
            {
                return(true);
            }
            if (await SingleTarget.AirAnchor())
            {
                return(true);
            }

            if (MachinistSettings.Instance.UseAoe)
            {
                if (await Aoe.AutoCrossbow())
                {
                    return(true);
                }
                if (await Aoe.SpreadShot())
                {
                    return(true);
                }
            }

            if (await SingleTarget.HeatBlast())
            {
                return(true);
            }
            if (await SingleTarget.HotShot())
            {
                return(true);
            }
            if (await SingleTarget.CleanShot())
            {
                return(true);
            }
            if (await SingleTarget.SlugShot())
            {
                return(true);
            }
            return(await SingleTarget.SplitShot());
        }
Ejemplo n.º 34
0
 // Use this for initialization
 void Start()
 {
     movement = gameObject.GetComponent <Movement> ();
     velocity = new Vector2();
 }
Ejemplo n.º 35
0
 // Use this for initialization
 void Start()
 {
     mvm      = GetComponent <Movement> ();
     player   = GameObject.FindGameObjectWithTag("Player1");
     obstacle = GameObject.FindGameObjectWithTag("horizontal border");
 }
Ejemplo n.º 36
0
 void ClearObject()
 {
     currentObject = null;
     movement      = null;
     isTouch       = false;
 }
Ejemplo n.º 37
0
        public void MoveZSprintingTest()
        {
            Movement m = new Movement(1, 0, 0, 2, 1, 2, 2);

            Assert.AreEqual(2, m.Calculate(0, 1, false, true, true, 1).z);
        }
Ejemplo n.º 38
0
        public void MoveXSprintingNoStaminaTest()
        {
            Movement m = new Movement(1, 0, 0, 2, 0, 2, 2);

            Assert.AreEqual(1, m.Calculate(1, 0, false, true, true, 1).x);
        }
Ejemplo n.º 39
0
 /// <summary>
 /// make sure the player's grid position is the same as this buttons grid position
 /// </summary>
 /// <param name="playerPiecePos"></param>
 /// <returns></returns>
 bool SameRoundedPosition(Vector3 playerPiecePos)
 {
     return(Movement.RoundVectorToPoint5s(transform.position) == Movement.RoundVectorToPoint5s(playerPiecePos));
 }
 void startChasing(Transform target)
 {
     currentWaypoint = target;
     movementType    = Movement.Chasing;
     speed           = speedWhileChasing;
 }
 void Awake()
 {
     dist_to_end = 0.1f;
     movement    = GetComponent <Movement>();
 }
Ejemplo n.º 42
0
 public override void CollisionResponse(Movement movement)
 {
 }   // end of CursorChassis CollisionResponse()
Ejemplo n.º 43
0
 public ActionResult Create(Movement movement) //checked
 {
     _db.Movements.Add(movement);
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Ejemplo n.º 44
0
 public override Movement ReturnMove(Movement move = Movement.No_movement)
 {
     return(Movement.Down); //not finished
 }
Ejemplo n.º 45
0
    static void MovePiece(Movement direction)
    {
        HashSet <Point> toUpdate = new HashSet <Point>();

        for (int x = 0; x < Width; x++)
        {
            for (int y = 0; y < Height; y++)
            {
                if (World[x, y] == CellStates.Alive)
                {
                    if (y == Height - 1 || World[x, y + 1] == CellStates.Dead)
                    {
                        KillAll();
                        toUpdate = new HashSet <Point>();
                        break;
                    }
                    else
                    {
                        toUpdate.Add(new Point(x, y));
                    }
                }
            }
        }

        int xOff = 0;
        int yOff = 0;

        switch (direction)
        {
        case Movement.Left:
            xOff = -1;
            break;

        case Movement.Down:
            yOff = 1;
            break;

        case Movement.Right:
            xOff = 1;
            break;
        }

        bool valid = true;

        foreach (Point point in toUpdate)
        {
            valid = point.x + xOff >= 0 && point.x + xOff < Width && point.y + yOff >= 0 && point.y + yOff < Height;
            if (!valid)
            {
                break;
            }
        }

        if (valid)
        {
            foreach (Point point in toUpdate)
            {
                World[point.x, point.y] = CellStates.Empty;
            }
            foreach (Point point in toUpdate)
            {
                World[point.x + xOff, point.y + yOff] = CellStates.Alive;
            }

            Draw();
        }
    }
Ejemplo n.º 46
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "PlayerProjectile")
        {
            Projectile missile = collision.gameObject.GetComponent <Projectile>();
            Movement   player  = GameObject.FindGameObjectWithTag("Player").GetComponent <Movement>();
            ReceiveDamage(player.damage);
            missile.Hit();
        }
        else if (collision.gameObject.tag == "PlasmaBull")
        {
            PlasmaBull missile = collision.gameObject.GetComponent <PlasmaBull>();
            Movement   player  = GameObject.FindGameObjectWithTag("Player").GetComponent <Movement>();
            ReceiveDamage(player.damage);
            missile.Hit();
        }
        else if (collision.gameObject.tag == "FlatBull")
        {
            FlatBull missile = collision.gameObject.GetComponent <FlatBull>();
            Movement player  = GameObject.FindGameObjectWithTag("Player").GetComponent <Movement>();
            ReceiveDamage(player.damage);
            missile.Hit();
        }
        else if (collision.gameObject.tag == "DefensiveBull")
        {
            DefensiveBull missile = collision.gameObject.GetComponent <DefensiveBull>();
            Movement      player  = GameObject.FindGameObjectWithTag("Player").GetComponent <Movement>();
            Destroy();
            missile.Hit();
        }
        else if (collision.gameObject.tag == "RocketBull")
        {
            RocketBull missile = collision.gameObject.GetComponent <RocketBull>();
            Movement   player  = GameObject.FindGameObjectWithTag("Player").GetComponent <Movement>();
            ReceiveDamage(player.damage);
            missile.Hit();
        }
        else if (collision.gameObject.tag == "LaserBull")
        {
            LaserBull missile = collision.gameObject.GetComponent <LaserBull>();
            Movement  player  = GameObject.FindGameObjectWithTag("Player").GetComponent <Movement>();
            Destroy();
        }
        else if (collision.gameObject.tag == "Player")
        {
            ReceiveDamage(health);
        }

        else if (collision.gameObject.tag == "SpecialMove")
        {
            ReceiveDamage(health);
        }
        if (health <= 0)
        {
            FindObjectOfType <Movement>().IncreasePoints(pointsDropped);
            Slider test = GameObject.FindGameObjectWithTag("ChargeBar").GetComponent <Slider>();
            test.value += chargeBarValue;
            explosionPooler.GetPooledObject(transform.position, transform.rotation);
            Destroy();
            if (Random.Range(1f, 100f) <= 15f)
            {
                Vector3 position = transform.position + new Vector3(0f, -0.8f);
                Instantiate(Drop1, position, transform.rotation);
            }
            if (Random.Range(1f, 100f) >= 85f)
            {
                Vector3 position = transform.position + new Vector3(0f, -0.8f);
                Instantiate(Drop2, position, transform.rotation);
            }
        }
    }
    public override void Excute(StateData data)
    {
        time += Time.deltaTime;
        // 感染後の待機時間
        if (time <= waitTime)
        {
            return;
        }

        // 移動コンポーネント
        Movement movement = data.movement;

        movement.SetSpeed(moveSpeed);
        // 拡張範囲の取得
        ExpansionControl expansion = data.virus.GetOriginal().GetComponent <ExpansionControl>();

        // 感染原(プレイヤ)
        Virus target    = data.virus.GetOriginal();
        Virus selfVirus = data.virus;

        //! ゲームの仕様上 ターゲットが見つからないことはない
        if (target.gameObject == null)
        {
            Debug.Break();
        }

        Vector3 playerVec /* = target.transform.position - hogePlayer*/;
        // 感染源の移動量
        float    x    = Input.GetAxisRaw("Horizontal2");
        float    z    = Input.GetAxisRaw("Vertical2");
        Vector3  vec  = new Vector3(x, 0, z);
        Movement move = target.GetComponent <Movement>();

        if (move == null)
        {
            Debug.Break();
        }
        //playerVec = vec.normalized * move.GetSpeed();

        // 拡張範囲を考慮した差
        Vector3 offset = vec;
        //offset.Normalize();
        float factor = 1.2f;

        offset     *= expansion.ExpansionArea * factor;
        followPoint = target.transform.position + offset * 1;

        Vector3 targetPos = new Vector3();

        // ウィルスコントロールをしているなら...
        if (target.GetComponent <PlayerController>().IsAction())
        {
            isUpdateDestination = true;

            //pathToFollowPoint = null;

            // 探索が終わっていない時 
            targetPos = followPoint;
            movement.SetPriority(50);
            movement.SetSpeed(moveSpeed);
            if (AIManager.infectedPathTemp == null)
            {
                movement.CalculatePath(targetPos, out AIManager.infectedPathTemp);
            }
        }
        else
        {
            followPoint = new Vector3();
            // 集合範囲内にいるか
            if ((target.transform.position - selfVirus.gameObject.transform.position).sqrMagnitude < expansion.ExpansionArea * expansion.ExpansionArea)
            {
                isUpdateDestination = false;
            }
            else
            {
                isUpdateDestination = true;
            }

            targetPos = target.gameObject.transform.position;
        }

        // 目的地の更新
        if (isUpdateDestination)
        {
            if (AIManager.infectedPathTemp != null)
            {
                movement.SetPath(AIManager.infectedPathTemp);
            }
            else
            {
                movement.SetDestination(targetPos);
            }
            //movement.SetIsStopped(false);
        }
        else
        {
            //movement.SetIsStopped(true);
            movement.ResetPath();
        }
    }
Ejemplo n.º 48
0
        /// <summary>
        /// Setup tournament
        /// </summary>
        /// <param name="data">KOPS inf file</param>
        private void SetTournamentData(List <string> data)
        {
            int tournamentBase = int.Parse(data[0]);

            if (tournamentBase > 10000)
            {
                tournamentBase -= 10000;
                scoringMethod   = new ScoringCSR();
                scoring         = 1;
            }
            else
            {
                scoringMethod = new ScoringMP();
                scoring       = 0;
            }

            int rounds = int.Parse(data[1]);

            dealsPerRound = int.Parse(data[2]);
            int mitchellSections      = int.Parse(data[3]);
            int numerationJump        = int.Parse(data[4]);
            int roundUntilLineChanged = int.Parse(data[5]);
            int dealingRound          = int.Parse(data[6]);

            pairsNumber = int.Parse(data[7]);
            records     = int.Parse(data[8]);
            //int.Parse(data[9]); //read AverageRecord
            //int.Parse(data[10]); //read MaxRecord
            //int.Parse(data[13]); // read Deals Number
            int appendix = int.Parse(data[14]);

            List <int> pairNumbers = new List <int>(pairsNumber);

            if (numerationJump == 0)
            {
                numerationJump = tournamentBase;
            }

            for (int i = 0; i < numerationJump * 2 * (mitchellSections + 2); i++)
            //for (int i = 0; i < 16; i++)
            {
                pairNumbers.Add(0);
            }

            for (int i = 0; i < pairsNumber; i++)
            {
                pairNumbers[int.Parse(data[15 + i]) - 1] = i + 1;
            }

            Pairs.SetNumbers(pairNumbers);

            movement = new Movement(tournamentBase, mitchellSections);

            movement.Generate(rounds, dealingRound, roundUntilLineChanged,
                              appendix > 0 ? data.GetRange(15 + pairsNumber, (appendix + 1) * 2 * tournamentBase) : null,
                              pairsNumber, appendix);

            boards = new List <Board>();

            Nullable <int> index = ReadINR();

            for (int i = 0; i < tournamentBase * dealsPerRound; i++)
            {
                //TODO: add processing of INR files
                boards.Add(new Board(i + (index.HasValue ? index.Value : 0)));
            }
        }
Ejemplo n.º 49
0
 void Start()
 {
     projMovement                = projectile.GetComponent <Movement>();
     projectileSpaceObject       = projectile.GetComponent <Projectile>();
     projectileSpaceObject.owner = gameObject;
 }
Ejemplo n.º 50
0
 public void OnWaitForJumpEnded()
 {
     Movement.Jump();
 }
        /// <summary>
        /// Calculates the interpolated path for a linear movement.
        /// </summary>
        /// <param name="movement"> The movement as a linear movement type. </param>
        private void LinearMovementFromRobotTarget(Movement movement)
        {
            // Set the correct tool for this movement
            SetRobotTool(movement);

            // Points for path
            List <Point3d> points = new List <Point3d>();

            // Get the final joint positions of this movement
            _robot.InverseKinematics.Movement = movement;
            _robot.InverseKinematics.CalculateExternalJointPosition();

            // Get the External Joint Positions
            ExternalJointPosition towardsExternalJointPosition = _robot.InverseKinematics.ExternalJointPosition.Duplicate();

            // External Joint Position change
            ExternalJointPosition externalJointPositionChange = (towardsExternalJointPosition - _lastExternalJointPosition) / _interpolations;

            // TODO: Check with last movement to speed up the process? As in old path generator?

            // First target plane in WORLD coordinate space
            _robot.ForwardKinematics.Calculate(_lastRobotJointPosition, _lastExternalJointPosition);
            Plane plane1 = _robot.ForwardKinematics.TCPPlane;

            // Second target plane in WORK OBJECT coordinate space
            RobotTarget robotTarget = movement.Target as RobotTarget;
            Plane       plane2      = robotTarget.Plane;

            // Correction for rotation of the target plane on a movable work object
            if (movement.WorkObject.ExternalAxis != null)
            {
                ExternalAxis externalAxis = movement.WorkObject.ExternalAxis;
                Transform    trans        = externalAxis.CalculateTransformationMatrix(_lastExternalJointPosition * -1, out _);
                plane1.Transform(trans);
            }

            // Re-orient the starting plane to the work object coordinate space of the second target plane
            Plane     globalWorkObjectPlane = new Plane(movement.WorkObject.GlobalWorkObjectPlane);
            Transform orient = Transform.ChangeBasis(Plane.WorldXY, globalWorkObjectPlane);

            plane1.Transform(orient);

            // Target plane position and orientation change per interpolation step
            Vector3d posChange   = (plane2.Origin - plane1.Origin) / _interpolations;
            Vector3d xAxisChange = (plane2.XAxis - plane1.XAxis) / _interpolations;
            Vector3d yAxisChange = (plane2.YAxis - plane1.YAxis) / _interpolations;

            // Correct axis configuration, tool and work object
            RobotTarget subTarget   = new RobotTarget(robotTarget.Name, Plane.WorldXY, robotTarget.AxisConfig);
            Movement    subMovement = new Movement(subTarget);

            subMovement.RobotTool  = movement.RobotTool;
            subMovement.WorkObject = movement.WorkObject;

            // New external joint position
            ExternalJointPosition newExternalJointPosition = _lastExternalJointPosition;

            // Create the sub target planes, robot joint positions and external joint positions for every interpolation step
            for (int i = 0; i < _interpolations; i++)
            {
                // Create new plane: the local target plane (in work object coordinate space)
                Plane plane = new Plane(plane1.Origin + posChange * i, plane1.XAxis + xAxisChange * i, plane1.YAxis + yAxisChange * i);

                // Update the target and movement
                subTarget.Plane = plane;
                subTarget.ExternalJointPosition = newExternalJointPosition;
                subMovement.Target = subTarget;

                // Calculate joint positions
                _robot.InverseKinematics.Movement = subMovement;
                _robot.InverseKinematics.Calculate();

                // Auto Axis Config
                if (_linearConfigurationControl == false)
                {
                    if (i == 0)
                    {
                        _robot.InverseKinematics.CalculateClosestRobotJointPosition(_lastRobotJointPosition);
                    }
                    else
                    {
                        _robot.InverseKinematics.CalculateClosestRobotJointPosition(_robotJointPositions.Last());
                    }
                }

                // Add te calculated joint positions and plane to the class property
                _robotJointPositions.Add(_robot.InverseKinematics.RobotJointPosition.Duplicate());
                _externalJointPositions.Add(_robot.InverseKinematics.ExternalJointPosition.Duplicate());

                // Add error messages (check axis limits)
                _errorText.AddRange(_robot.InverseKinematics.ErrorText.ConvertAll(item => string.Copy(item)));

                // Add the plane
                Plane globalPlane = subMovement.GetPosedGlobalTargetPlane();
                _planes.Add(globalPlane);

                // Always add the first point to list with paths
                if (i == 0)
                {
                    points.Add(new Point3d(globalPlane.Origin));
                }

                // Only add the other point if this point is different
                else if (points[points.Count - 1] != globalPlane.Origin)
                {
                    points.Add(new Point3d(globalPlane.Origin));
                }

                // Update the external joint position
                newExternalJointPosition += externalJointPositionChange;
            }

            // Add last point
            Point3d lastPoint = movement.GetPosedGlobalTargetPlane().Origin;

            if (points[points.Count - 1] != lastPoint)
            {
                points.Add(lastPoint);
            }

            // Generate path curve
            if (points.Count > 1)
            {
                _paths.Add(Curve.CreateInterpolatedCurve(points, 3));
            }
            else
            {
                _paths.Add(null);
            }

            // Get the final joint positions of this movement
            _robot.InverseKinematics.Movement = movement;
            _robot.InverseKinematics.Calculate();

            // Auto Axis Config
            if (_linearConfigurationControl == false)
            {
                _robot.InverseKinematics.CalculateClosestRobotJointPosition(_robotJointPositions.Last());
            }

            // Add error messages (check axis limits)
            _errorText.AddRange(_robot.InverseKinematics.ErrorText.ConvertAll(item => string.Copy(item)));

            // Add last Joint Poistions
            _lastRobotJointPosition    = _robot.InverseKinematics.RobotJointPosition.Duplicate();
            _lastExternalJointPosition = _robot.InverseKinematics.ExternalJointPosition.Duplicate();
        }
Ejemplo n.º 52
0
        public override Movement ReturnMove(Movement move = 0)
        {
            Movement selectedMove = getRandomMove();
            int      x, y;

            x = 0;
            y = 0;
            switch (selectedMove)
            {
            case Movement.NoMovement:
                selectedMove = Movement.NoMovement;
                break;

            case Movement.Up:
                x = 0;
                y = 1;
                break;

            case Movement.Down:
                x = 0;
                y = -1;
                break;

            case Movement.Left:
                x = -1;
                y = 0;
                break;

            case Movement.Right:
                x = 1;
                y = 0;
                break;

            default:
                selectedMove = Movement.NoMovement;
                break;
            }

            while (base.characterVision[x, y] != null)
            {
                selectedMove = getRandomMove();
                switch (selectedMove)
                {
                case Movement.NoMovement:
                    selectedMove = Movement.NoMovement;
                    break;

                case Movement.Up:
                    x = 0;
                    y = 1;
                    break;

                case Movement.Down:
                    x = 0;
                    y = -1;
                    break;

                case Movement.Left:
                    x = -1;
                    y = 0;
                    break;

                case Movement.Right:
                    x = 1;
                    y = 0;
                    break;

                default:
                    selectedMove = Movement.NoMovement;
                    break;
                }
            }

            return(selectedMove);
        }
Ejemplo n.º 53
0
 void Start()
 {
     _movement = gameObject.GetComponent <Movement>();
     _postProcessing.depthOfField.settings = CalculateDof();
 }
Ejemplo n.º 54
0
 /// <summary>
 ///     The <see cref="Collision"/> caused by moving a given
 ///     <see cref="Body"/> with a given <see cref="Movement"/>.
 /// </summary>
 /// <param name="movement">
 ///     The <see cref="Movement"/> to move the <see cref="Body"/>
 ///     with.
 /// </param>
 /// <param name="body">
 ///     The <see cref="Body"/> to move with the <see cref="Movement"/>.
 /// </param>
 /// <returns>
 ///     Never returns.
 /// </returns>
 /// <exception cref="NotImplementedException">
 ///     Always thrown.
 /// </exception>
 public Collision CollisionCausedByMovingBody(
     Movement movement,
     Body body)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 55
0
 public void FindTurtle()
 {
     Turtle = GameObject.FindObjectOfType <Movement>();
     Turtle.Turn(0);
     Turtle.Move(0);
 }
Ejemplo n.º 56
0
 private void Awake()
 {
     motor = GetComponent <Movement>();
     anim  = GetComponent <Animator>();
 }
Ejemplo n.º 57
0
    public override void Update()
    {
        this.dec = Entity.decoration;
        if (!isMoving)
        {
            next = RoutePlanifier.next(this.Entity);
            if (next != null)
            {
                //Evento de perder energia
                if (decreaseEnergy != 0)
                {
                    GameEvent ge = ScriptableObject.CreateInstance <GameEvent>();
                    ge.setParameter("entity", this.Entity);
                    ge.setParameter("energia", decreaseEnergy);
                    ge.Name = "modify energia";

                    Game.main.enqueueEvent(ge);
                }

                Vector3 myPosition    = ((Cell)this.Entity.Position).transform.localPosition,
                        otherPosition = next.transform.localPosition;

                MovementType type = MovementType.Lineal;
                if (((Cell)this.Entity.Position).WalkingHeight != next.WalkingHeight)
                {
                    type       = MovementType.Parabolic;
                    dec.IsoDec = jumpingSprite;
                }
                dec.updateTextures();
                int row = 0;
                if (myPosition.z < otherPosition.z)
                {
                    row = 0;
                }
                else if (myPosition.z > otherPosition.z)
                {
                    row = 2;
                }
                else if (myPosition.x < otherPosition.x)
                {
                    row = 1;
                }
                else if (myPosition.x > otherPosition.x)
                {
                    row = 3;
                }
                dec.Tile = tile = row * dec.IsoDec.nCols;

                this.movement         = Movement.createMovement(type, transform.position, next.transform.position + new Vector3(0, next.WalkingHeight + transform.localScale.y / 2, 0));
                this.movementProgress = 0;
                this.movementDuration = 0.3f;
                isMoving = true;
            }
            else if (movementEvent != null)
            {
                movementFinished = true;
            }
        }

        if (isMoving)
        {
            this.movementProgress += Time.deltaTime;
            transform.position     = this.movement.getPositionAt(this.movementProgress / this.movementDuration);


            if (dec.IsoDec.nCols > 1)
            {
                if (this.movementProgress / this.movementDuration < 0.15)
                {
                    dec.Tile = tile;
                }
                else if (this.movementProgress / this.movementDuration < 0.85)
                {
                    dec.Tile = tile + ((paso) ? 1 : 2);
                }
                else if (this.movementProgress / this.movementDuration < 1)
                {
                    dec.Tile = tile;
                }
            }


            if (this.movementProgress >= this.movementDuration)
            {
                this.isMoving        = false;
                this.Entity.Position = next;
                int lastRow = Mathf.FloorToInt(tile / dec.IsoDec.nCols);
                dec.IsoDec = normalSprite;
                dec.updateTextures();
                dec.Tile = lastRow * dec.IsoDec.nCols;
                paso     = !paso;
            }
        }
    }
 private void Awake()
 {
     movement = GetComponent <Movement>();
     player   = GetComponent <Player>();
 }
Ejemplo n.º 59
0
    public void boom(Movement m)
    {
        float force = m.getYSpeed() * speedtoForce;

        rb.AddForce(transform.right * -force / 10);
    }
Ejemplo n.º 60
0
        public void charSetup(string id, string name, string email, string password, string gender, string race, string selectedClass, int strength, int dexterity, int constitution, int wisdom, int intelligence, int charisma)
        {
            //Creates and saves player
            PlayerData = new Player
            {
                HubGuid              = id,
                Name                 = name,
                Email                = email,
                Password             = password,
                Gender               = gender,
                Race                 = race,
                SelectedClass        = selectedClass,
                Strength             = strength,
                Constitution         = constitution,
                Dexterity            = dexterity,
                Wisdom               = wisdom,
                Intelligence         = intelligence,
                Charisma             = charisma,
                MaxStrength          = strength,
                MaxConstitution      = constitution,
                MaxDexterity         = dexterity,
                MaxWisdom            = wisdom,
                MaxIntelligence      = intelligence,
                MaxCharisma          = charisma,
                intoxicationMaxLevel = constitution,
                Type                 = Player.PlayerTypes.Player,
                JoinedDate           = DateTime.UtcNow,
                LastCommandTime      = DateTime.UtcNow
            };


            //add skills to player
            var classSelected = Core.Player.Classes.PlayerClass.ClassList()
                                .FirstOrDefault(x => x.Value.Name
                                                .Equals(selectedClass, StringComparison.CurrentCultureIgnoreCase));

            if (classSelected.Value != null)
            {
                foreach (var classSkill in classSelected.Value.Skills.Where(x => x.LevelObtained.Equals(1)))
                {
                    PlayerData.Skills.Add(classSkill);
                }
            }
            else
            {
                //well, you get no skills bro
            }

            _PlayerCache.TryAdd(id, PlayerData);

            loadRoom(PlayerData, id);
            //add player to room
            Room roomData = null;

            var getPlayerRoom = new Tuple <string, string, int>(PlayerData.Region, PlayerData.Area, PlayerData.AreaId);

            _AreaCache.TryGetValue(getPlayerRoom, out roomData);

            MIMWebClient.Core.Room.PlayerManager.AddPlayerToRoom(roomData, PlayerData);
            Movement.EnterRoom(PlayerData, roomData);

            Save.SavePlayer(PlayerData);

            // addToRoom(PlayerData.AreaId, roomData, PlayerData, "player");
            Score.ReturnScoreUI(PlayerData);
            Score.UpdateUiPrompt(PlayerData);
            Score.UpdateUiInventory(PlayerData);
        }