protected MoveEntity AddMoveEntity()
    {
        MoveEntity moveEntity = GetMoveEntity();

        moveEntityList.Add(moveEntity);
        return(moveEntity);
    }
Esempio n. 2
0
        private MoveDto fromMoveEntityToMoveDTO(MoveEntity move)
        {
            var config = new MapperConfiguration(c => c.CreateMap <MoveEntity, MoveDto>());
            var mapper = config.CreateMapper();

            return(mapper.Map <MoveDto>(move));
        }
Esempio n. 3
0
    // Spawns the item...
    public void Spawn(Transform spawnLocation)
    {
        GameObject item = Instantiate(
            emptyGameObject,
            spawnLocation.position + RelativeSpawnPosition,
            Quaternion.identity
            );

        // item.transform.position = spawnTransform.position;
        item.transform.localScale = Size;

        SpriteRenderer spriteRenderer = item.AddComponent <SpriteRenderer>();

        spriteRenderer.sprite = Sprite;

        GetPickedUpByPlayerComponent mainComponent = item.AddComponent <GetPickedUpByPlayerComponent>();

        mainComponent.Item = this;

        MoveEntity moveEntityBehaviour = item.AddComponent <MoveEntity>();

        moveEntityBehaviour.MoveEntityDelegate = ItemMovementDelegate;


        InterpolatedTransform it = item.AddComponent <InterpolatedTransform>();

        it.interpolationFactor = interpolationFactor;

        item.AddComponent <InterpolatedTransformUpdater>();
    }
Esempio n. 4
0
        private MoveEntity getMoveFromIA(MoveEntity move)
        {
            var iaMove = getIaMove(move);

            move.computerMove = iaMove;
            move.playerWins   = GameAppHelpers.getPlayerWins(iaMove, move.humanMove, move.gameType);
            return(move);
        }
Esempio n. 5
0
        protected virtual bool OnRaiseMoveEntity(MoveEntityEventArgs e)
        {
            bool?result = MoveEntity?.Invoke(this, e);

            if (result == true)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
    protected MoveEntity GetMoveEntity()
    {
        MoveEntity moveEntity = null;

        if (moveEntityPrepareList.Count > 0)
        {
            int i = Random.Range(0, moveEntityPrepareList.Count);
            moveEntity = moveEntityPrepareList[i];
            moveEntityPrepareList.RemoveAt(i);
        }
        else
        {
            moveEntity = CreateMoveEntity();
        }

        return(moveEntity);
    }
    void Update()
    {
        player = WorldManager.instance.player;
        //Debug.Log ("player reference in update: " + player);

        if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            //Attempt move up
            Debug.Log("up key pressed");
            if (MoveEntity.MoveSuccessful(player, new Vector3(player.currentPosition.x, player.currentPosition.y + 1, 0)))
            {
                //Pass turn or consume action points, unknown presently
                Debug.Log("move successful");
            }
        }
        else if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
            //Attempt move left
            if (MoveEntity.MoveSuccessful(player, new Vector3(player.currentPosition.x - 1, player.currentPosition.y, 0)))
            {
                //Pass turn or consume action points, unknown presently
                Debug.Log("move successful");
            }
        }
        else if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            //Attempt move down
            if (MoveEntity.MoveSuccessful(player, new Vector3(player.currentPosition.x, player.currentPosition.y - 1, 0)))
            {
                //Pass turn or consume action points, unknown presently
                Debug.Log("move successful");
            }
        }
        else if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            //Attempt move right
            if (MoveEntity.MoveSuccessful(player, new Vector3(player.currentPosition.x + 1, player.currentPosition.y, 0)))
            {
                //Pass turn or consume action points, unknown presently
                Debug.Log("move successful");
            }
        }
    }
Esempio n. 8
0
        private int getIaMove(MoveEntity move)
        {
            if (move.difficultyType <= 1) //User always wins (0,1)
            {
                return(GameAppHelpers.getMove(move.humanMove, move.gameType, 0));
            }

            if (move.difficultyType <= 5) //We use the random factor (2,5)
            {
                int gameMod = (int)GameModes.ClassicGameMove;
                if (move.gameType == 1)
                {
                    gameMod = (int)GameModes.SpockGameMove;
                }
                return(_random.Next(0, gameMod - 1));
            }

            if (move.difficultyType > 9) //User ALWAYS looses (10)
            {
                return(GameAppHelpers.getMove(move.humanMove, move.gameType, 1));
            }

            return(GameAppHelpers.getMove(move.humanMove, move.gameType, _random.Next(0, 2)));
        }
Esempio n. 9
0
        protected override void OnUpdate()
        {
            translationComponent = new NativeArray <Translation>(1, Allocator.TempJob);
            float speed = speedMultiplier;

            moveEntityDone = new NativeArray <bool>(1, Allocator.TempJob);
            entityQuery    = EntityManager.CreateEntityQuery(typeof(Translation), typeof(GeometryDataModels.Target));
            var entities = entityQuery.ToEntityArray(Allocator.TempJob);

            if (EntityManager.Exists(entityToMove[0]) && EntityManager.HasComponent <Translation>(entityToMove[0]))
            {
                translationComponent[0] = EntityManager.GetComponentData <Translation>(entityToMove[0]);
                var job2 = new MoveEntity()
                {
                    entityToMove = new NativeArray <Entity>(entityToMove, Allocator.TempJob),
                    translation  = new NativeArray <Translation>(this.translationComponent, Allocator.TempJob),

                    target      = target,
                    moveSpeed   = speed,
                    newPosition = this.newPosition
                };

                Dependency = job2.Schedule(Dependency);
                //Wait for job completion
                Dependency.Complete();
                this.translationComponent[0] = job2.translation[0];
                job2.entityToMove.Dispose();
                job2.translation.Dispose();
                target[0] = job2.target[0];
                EntityManager.SetComponentData(entityToMove[0], translationComponent[0]);
            }

            translationComponent.Dispose();
            entities.Dispose();
            moveEntityDone.Dispose();
        }
 public void saveMove(MoveEntity moveEntity)
 {
     throw new NotImplementedException();
 }
 void Recycle(MoveEntity moveEntity)
 {
     moveEntityPrepareList.Add(moveEntity);
 }