private void OnUserDeath(IKillable kUser)
    {
        Debug.Assert(kUser is IMWRUser);
        IMWRUser user = (IMWRUser)kUser;

        Vector2Int cords = user.CurrentCoordintates;

        CurrentMWR.worldRepresentation[cords.x, cords.y] = true;

        user.KillableEntity.OnDeath -= OnUserDeath;
    }
 private void OnUserSpawn(IMWRUser user)
 {
     if (CurrentMWR.TryAssignUser(user))
     {
     }
     else
     {
         Debug.Log($"initial positioning failed for: {user}");
     }
     user.KillableEntity.OnDeath += OnUserDeath;
 }
Esempio n. 3
0
    public bool MoveToCell(IMWRUser user, Vector2Int endCell)
    {
        if (worldRepresentation[endCell.x, endCell.y])
        {
            worldRepresentation[user.CurrentCoordintates.x, user.CurrentCoordintates.y] = true;
            worldRepresentation[endCell.x, endCell.y] = false;

            user.CurrentCoordintates = endCell;
            return(true);
        }
        else
        {
            return(false);
        }
    }
Esempio n. 4
0
    public bool TryAssignUser(IMWRUser user)
    {
        user.MWR = this;
        //revisa si es que la coordenada a la que se quiere asignar esta ocupada.
        // si es que lo esta busca la coordenada vacia más cercana. ----acá hay una pequeña posibiladad de que no haya ninguna casilla libre---ahí seria retornar false
        //si no esta ocupada, la ocupa y asigna el valor al user.
        Vector2Int bestCell = GetCell(user.GameObject.transform.position);

        if (worldRepresentation[bestCell.x, bestCell.y])
        {
            user.CurrentCoordintates = bestCell;
            worldRepresentation[bestCell.x, bestCell.y] = false;

            return(true);
        }
        else
        {
            return(false);
        }
    }